Commit 5081ca7e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

housekeeping

parent 736d7e43
/*
* This file is part of nifty_gridder.
*
* nifty_gridder is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* nifty_gridder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with nifty_fridder; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <iostream>
......@@ -16,7 +34,9 @@ namespace py = pybind11;
namespace {
constexpr double pi = 3.141592653589793238462643383279502884197;
//
// Utilities for converting between Cartesian coordinates and Peano index
//
static const uint16_t utab[] = {
#define Z(a) 0x##a##0, 0x##a##1, 0x##a##4, 0x##a##5
......@@ -109,6 +129,10 @@ void myassert(bool cond, const char *msg)
throw runtime_error(msg);
}
//
// Utilities for indirect sorting (argsort)
//
template<typename It, typename Comp> class IdxComp__
{
private:
......@@ -155,6 +179,10 @@ inline double fmodulo (double v1, double v2)
// return (v1>=0) ? ((v1<v2) ? v1 : fmod(v1,v2)) : (fmod(v1,v2)+v2);
}
//
// Utilities for Gauss-Legendre quadrature
//
static inline double one_minus_x2 (double x)
{ return (fabs(x)>0.1) ? (1.+x)*(1.-x) : 1.-x*x; }
......@@ -212,6 +240,10 @@ void legendre_prep(int n, vector<double> &x, vector<double> &w)
} // end of parallel region
}
//
// Start of real gridder functionality
//
using a_i_c = py::array_t<int, py::array::c_style | py::array::forcecast>;
using a_d_c = py::array_t<double, py::array::c_style | py::array::forcecast>;
using a_c_c = py::array_t<complex<double>,
......@@ -536,8 +568,11 @@ a_c_c from_grid (const a_d_c &uv_, const a_d_c &grid0_, double epsilon)
return res;
}
/* Compute correction factors for the ES gridding kernel
This implementation follows eqs. (3.8) to (3.10) of Barnett et al. 2018 */
a_d_c correction_factors (size_t n, size_t nval, double epsilon)
{
constexpr double pi = 3.141592653589793238462643383279502884197;
auto w = get_w(epsilon);
auto beta = 2.3*w;
auto p = int(1.5*w+2);
......
......@@ -11,10 +11,9 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user)
include_dirs = ['./', _deferred_pybind11_include(True),
_deferred_pybind11_include()]
extra_compile_args = []
include_dirs = ['./', _deferred_pybind11_include(),
_deferred_pybind11_include(True)]
python_module_link_args = []
if sys.platform == 'darwin':
......@@ -27,6 +26,8 @@ else:
extra_compile_args += ['--std=c++14', '-fopenmp', '-march=native', '-O3', '-ffast-math']
python_module_link_args += ['-fopenmp', '-march=native', '-Wl,-rpath,$ORIGIN']
# if you don't want debugging info, add "-s" to python_module_link_args
def get_extension_modules():
return [Extension('nifty_gridder',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment