How to use finufft - 1 common examples

To help you get started, we’ve selected a few finufft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flatironinstitute / finufft / python / demo.py View on Github external
import time
import finufft
import numpy as np

np.random.seed(42)

acc = 1.e-9
N = int(1e6)
M = int(1e6)
x = np.random.uniform(-np.pi, np.pi, N)
c = np.random.randn(N) + 1.j * np.random.randn(N)

strt = time.time()
F = finufft.nufft1d1(x, c, M, eps=acc, iflag=1)
print("Finished nufft in {0:.2e} seconds. Checking..."
      .format(time.time()-strt))

n = 142519
Ftest = 0.0
for j in range(M):
    Ftest += c[j] * np.exp(n * x[j] * 1.j)
Fmax = np.max(np.abs(F))
err = np.abs((F[n + N // 2] - Ftest) / Fmax)
print("Error relative to max of F: {0}".format(err))

finufft

Python interface to FINUFFT

Apache-2.0
Latest version published 15 days ago

Package Health Score

61 / 100
Full package analysis

Popular finufft functions

Similar packages