Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbarnett committed Dec 13, 2023
2 parents 5b75b84 + 9a1fae7 commit f2facd9
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 43 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/C++.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
container: quay.io/pypa/manylinux2014_x86_64:latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install fftw
run: |
Expand All @@ -34,7 +34,7 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 10.15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install omp and fftw
run: |
Expand All @@ -53,7 +53,7 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 10.15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install gcc and fftw
run: |
Expand All @@ -73,7 +73,7 @@ jobs:
shell: msys2 {0}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: 'Setup MSYS2'
uses: msys2/setup-msys2@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cmake_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: cmake ci linux macos windows
on: [push]

jobs:
Test:
cmake-ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
generator: "Ninja"
build_type: "Release"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Cpp
uses: aminya/setup-cpp@v1
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/python_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
container: quay.io/pypa/manylinux2014_x86_64:latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install fftw
run: |
Expand All @@ -31,7 +31,7 @@ jobs:
tools/finufft/build-wheels-linux.sh
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: linux-wheels
path: python/finufft/wheelhouse/finufft*manylinux*.whl
Expand All @@ -42,7 +42,7 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 10.15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install gcc and fftw
run: |
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 -m pytest test
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: macos-wheels
path: python/finufft/fixed_wheel/*.whl
Expand All @@ -166,13 +166,13 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install GCC and make
run: C:\msys64\usr\bin\bash.exe -lc "pacman -Sy --noconfirm make mingw-w64-x86_64-toolchain mingw-w64-x86_64-fftw"

- name: Build and Test Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
architecture: 'x64'
Expand All @@ -181,7 +181,7 @@ jobs:
.\.github\workflows\python_test_win.ps1
- name: Build and Test Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
Expand All @@ -190,7 +190,7 @@ jobs:
.\.github\workflows\python_test_win.ps1
- name: Build and Test Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
Expand All @@ -199,7 +199,7 @@ jobs:
.\.github\workflows\python_test_win.ps1
- name: Build and Test Python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
Expand All @@ -208,7 +208,7 @@ jobs:
.\.github\workflows\python_test_win.ps1
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: windows-wheels
path: wheelhouse\*.whl
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ option(FINUFFT_STATIC_LINKING "Whether to link the static FINUFFT library (libfi
# sphinx tag (don't remove): @cmake_opts_end

if(FINUFFT_USE_CPU)
# suppress Windows warnings about "unsafe" functions
if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

set(CPM_DOWNLOAD_VERSION 0.38.0)
include(cmake/setupCPM.cmake)

Expand Down
4 changes: 2 additions & 2 deletions include/finufft/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
// (RAND_MAX is in stdlib.h)
#include <stdlib.h>
//#define rand01() (((FLT)(rand()%RAND_MAX))/RAND_MAX)
#define rand01() ((FLT)rand()/RAND_MAX)
#define rand01() ((FLT)rand()/(FLT)RAND_MAX)
// unif[-1,1]:
#define randm11() (2*rand01() - (FLT)1.0)
// complex unif[-1,1] for Re and Im:
#define crandm11() (randm11() + IMA*randm11())

// Thread-safe seed-carrying versions of above (x is ptr to seed)...
#define rand01r(x) ((FLT)rand_r(x)/RAND_MAX)
#define rand01r(x) ((FLT)rand_r(x)/(FLT)RAND_MAX)
// unif[-1,1]:
#define randm11r(x) (2*rand01r(x) - (FLT)1.0)
// complex unif[-1,1] for Re and Im:
Expand Down
56 changes: 33 additions & 23 deletions python/finufft/finufft/_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ class Plan:
# execute the plan
f = plan.execute(c)
Also see ``python/examples/guru1d1.py`` and ``python/examples/guru2d1.py``.
Also see ``python/finufft/examples/guru1d1.py`` and
``python/finufft/examples/guru2d1.py``.
Args:
nufft_type (int): type of NUFFT (1, 2, or 3).
n_modes_or_dim (int or tuple of ints): if ``nufft_type`` is 1 or 2,
this should be a tuple specifying the number of modes
in each dimension (for example, ``(50, 100)``),
otherwise, if ``nufft_type`` is 3, this should be the
n_modes_or_dim (int or tuple of ints): for type 1 and type 2, this
should be a tuple specifying the number of modes in
each dimension (for example, ``(50, 100)``),
otherwise, for type 3, this should be the
number of dimensions (between 1 and 3).
n_trans (int, optional): number of transforms to compute
simultaneously.
Expand All @@ -84,7 +85,7 @@ class Plan:
exponential, otherwise the negative sign exponential;
defaults to +1 for types 1 and 3 and to -1 for type 2.
dtype (string, optional): the precision of the transform,
'complex64' or 'complex128'.
``'complex64'`` or ``'complex128'``.
**kwargs (optional): for more options, see :ref:`opts`.
"""
def __init__(self,nufft_type,n_modes_or_dim,n_trans=1,eps=1e-6,isign=None,dtype='complex128',**kwargs):
Expand Down Expand Up @@ -232,17 +233,17 @@ def execute(self,data,out=None):
Performs the NUFFT specified at plan instantiation with the points set
by ``setpts``. For type-1 and type-3 transforms, the input is a set of
source strengths, while for a type-2 transform, it consists of an
array of size ``n_modes``. If ``n_transf`` is greater than one,
``n_transf`` inputs are expected, stacked along the first axis.
array of size ``n_modes``. If ``n_trans`` is greater than one,
``n_trans`` inputs are expected, stacked along the first axis.
Args:
data (complex[M], complex[n_transf, M], complex[n_modes], or complex[n_transf, n_modes]): The input source strengths
data (complex[M], complex[n_tr, M], complex[n_modes], or complex[n_tr, n_modes]): The input source strengths
(type 1 and 3) or source modes (type 2).
out (complex[n_modes], complex[n_transf, n_modes], complex[M], or complex[n_transf, M], optional): The array where the
out (complex[n_modes], complex[n_tr, n_modes], complex[M], or complex[n_tr, M], optional): The array where the
output is stored. Must be of the right size.
Returns:
complex[n_modes], complex[n_transf, n_modes], complex[M], or complex[n_transf, M]: The output array of the transform(s).
complex[n_modes], complex[n_tr, n_modes], complex[M], or complex[n_tr, M]: The output array of the transform(s).
"""

_data = _ensure_array_type(data, "data", self.dtype)
Expand Down Expand Up @@ -586,7 +587,7 @@ def _wrap_docstring(docstring, tw=80, min_spacing=2):
return docstring


def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
def _set_nufft_doc(f, dim, tp, example='python/finufft/test/accuracy_speed_tests.py'):
doc_nufft1 = \
"""{dim}D type-1 (nonuniform to uniform) complex NUFFT
Expand All @@ -600,12 +601,12 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
Args:
{pts_doc}
c (complex[M] or complex[ntransf, M]): source strengths.
c (complex[M] or complex[n_tr, M]): source strengths.
n_modes (integer or integer tuple of length {dim}, optional): number of
uniform Fourier modes requested {modes_tuple}. May be even or odd; in
either case, modes {pt_idx} are integers satisfying {pt_constraint}.
Must be specified if ``out`` is not given.
out (complex[{modes}] or complex[ntransf, {modes}], optional): output array
out (complex[{modes}] or complex[n_tr, {modes}], optional): output array
for Fourier mode values. If ``n_modes`` is specifed, the shape
must match, otherwise ``n_modes`` is inferred from ``out``.
eps (float, optional): precision requested (>1e-16).
Expand All @@ -618,11 +619,14 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
The output is written into the ``out`` array if supplied.
Returns:
complex[{modes}] or complex[ntransf, {modes}]: The resulting array.
complex[{modes}] or complex[n_tr, {modes}]: The resulting array.
Example:
::
import numpy as np
import finufft
# number of nonuniform points
M = 100
Expand Down Expand Up @@ -654,10 +658,10 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
Args:
{pts_doc}
f (complex[{modes}] or complex[ntransf, {modes}]): Fourier mode
f (complex[{modes}] or complex[n_tr, {modes}]): Fourier mode
coefficients, where {modes} may be even or odd. In either case
the mode indices {pt_idx} satisfy {pt_constraint}.
out (complex[M] or complex[ntransf, M], optional): output array
out (complex[M] or complex[n_tr, M], optional): output array
at targets.
eps (float, optional): precision requested (>1e-16).
isign (int, optional): if non-negative, uses positive sign in
Expand All @@ -669,11 +673,14 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
The output is written into the ``out`` array if supplied.
Returns:
complex[M] or complex[ntransf, M]: The resulting array.
complex[M] or complex[n_tr, M]: The resulting array.
Example:
::
import numpy as np
import finufft
# number of nonuniform points
M = 100
Expand Down Expand Up @@ -707,9 +714,9 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
Args:
{src_pts_doc}
c (complex[M] or complex[ntransf, M]): source strengths.
c (complex[M] or complex[n_tr, M]): source strengths.
{target_pts_doc}
out (complex[N] or complex[ntransf, N]): output values at target frequencies.
out (complex[N] or complex[n_tr, N]): output values at target frequencies.
eps (float, optional): precision requested (>1e-16).
isign (int, optional): if non-negative, uses positive sign in
exponential, otherwise negative sign.
Expand All @@ -720,11 +727,14 @@ def _set_nufft_doc(f, dim, tp, example='python/test/accuracy_speed_tests.py'):
The output is written into the ``out`` array if supplied.
Returns:
complex[M] or complex[ntransf, M]: The resulting array.
complex[M] or complex[n_tr, M]: The resulting array.
Example:
::
import numpy as np
import finufft
# number of source points
M = 100
Expand Down Expand Up @@ -835,10 +845,10 @@ def nufft3d3(x,y,z,c,s,t,u,out=None,eps=1e-6,isign=1,**kwargs):
return invoke_guru(3,3,x,y,z,c,s,t,u,out,isign,eps,None,**kwargs)


_set_nufft_doc(nufft1d1, 1, 1, 'python/examples/simple1d1.py, python/examples/simpleopts1d1.py')
_set_nufft_doc(nufft1d1, 1, 1, 'python/finufft/examples/simple1d1.py, python/finufft/examples/simpleopts1d1.py')
_set_nufft_doc(nufft1d2, 1, 2)
_set_nufft_doc(nufft1d3, 1, 3)
_set_nufft_doc(nufft2d1, 2, 1, 'python/examples/simple2d1.py, python/examples/many2d1.py')
_set_nufft_doc(nufft2d1, 2, 1, 'python/finufft/examples/simple2d1.py, python/finufft/examples/many2d1.py')
_set_nufft_doc(nufft2d2, 2, 2)
_set_nufft_doc(nufft2d3, 2, 3)
_set_nufft_doc(nufft3d1, 3, 1)
Expand Down
4 changes: 2 additions & 2 deletions test/basicpassfail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ int main()
std::vector<FLT> x(M); // NU pts locs
std::vector<CPX> c(M); // strengths
for (BIGINT j=0; j<M; ++j) {
x[j] = M_PI*(2*((FLT)rand()/RAND_MAX)-1); // uniform random in [-pi,pi)
c[j] = 2*((FLT)rand()/RAND_MAX)-1 + I*(2*((FLT)rand()/RAND_MAX)-1);
x[j] = M_PI*(2*((FLT)rand()/(FLT)RAND_MAX)-1); // uniform random in [-pi,pi)
c[j] = 2*((FLT)rand()/(FLT)RAND_MAX)-1 + I*(2*((FLT)rand()/(FLT)RAND_MAX)-1);
}
// Run it (NULL = default opts) .......................................
int ier = FINUFFT1D1(M,&x[0],&c[0],isign,tol,N,&F[0],NULL);
Expand Down

0 comments on commit f2facd9

Please sign in to comment.