Exemplo n.º 1
0
def nufft1d3(x,
             c,
             isign,
             eps,
             s,
             f,
             debug=0,
             spread_debug=0,
             spread_sort=2,
             fftw=0,
             upsampfac=2.0):
    """1D type-3 (NU-to-NU) complex nonuniform fast Fourier transform

  ::

	     nj-1
    f[k]  =  SUM   c[j] exp(+-i s[k] x[j]),      for k = 0, ..., nk-1
	     j=0
  
  Args:
    x     (float[nj]): nonuniform source points, in R
    c     (complex[nj]): source strengths
    isign (int): if >=0, uses + sign in exponential, otherwise - sign
    eps   (float): precision requested (>1e-16)
    s     (float[nk]): nonuniform target frequency points, in R
    f     (complex[nk]): output values at target frequencies.
       Should be initialized as a numpy array of the correct size
    debug (int, optional): 0 (silent), 1 (print timing breakdown)
    spread_debug (int, optional): 0 (silent), 1, 2... (print spreader info)
    spread_sort (int, optional): 0 (don't sort NU pts in spreader), 1 (sort),
       2 (heuristic decision to sort)
    fftw (int, optional): 0 (use FFTW_ESTIMATE), 1 (use FFTW_MEASURE)
    upsampfac (float): either 2.0 (default), or 1.25 (low RAM & small FFT size)

  .. note::

    The output is written into the f array.

  Returns:
    int: 0 if success, 1 if eps too small,
       2 if size of arrays to malloc exceed MAX_NF

  Example:
    see ``python_tests/accuracy_speed_tests.py``
  """
    # f is the output and must have dtype=np.complex128
    x = x.astype(np.float64, copy=False)  #copies only if type changes
    c = c.astype(np.complex128, copy=False)  #copies only if type changes
    s = s.astype(np.float64, copy=False)  #copies only if type changes
    return finufftpy_cpp.finufft1d3_cpp(x, c, isign, eps, s, f, debug,
                                        spread_debug, spread_sort, fftw,
                                        upsampfac)
Exemplo n.º 2
0
def finufft1d3(x,
               c,
               isign,
               eps,
               s,
               f,
               debug=0,
               spread_debug=0,
               spread_sort=1,
               fftw=0):
    """1D type-3 (NU-to-NU) complex nonuniform fast Fourier transform

	          nj
	f[k]  =  SUM   c[j] exp(+-i s[k] x[j]),      for k = 1, ..., nk
	         j=1

	Inputs:
	x     (float[nj]): nonuniform source points, in R
	c     (complex[nj]): source strengths
	s     (float[nk]): nonuniform target frequency points, in R
	isign (int): if >=0, uses + sign in exponential, otherwise - sign.
	eps   (float): precision requested (>1e-16)
	
	Optional inputs:
	debug (int): 0 (silent), 1 (print timing breakdown).
	spread_debug (int): 0 (spreader silent), 1, 2... (print spreader info)
	spread_sort (int): 0 (don't sort NU pts in spreader), 1 (sort)
	fftw (int): 0 (use FFTW_ESTIMATE), 1 (use FFTW_MEASURE), ...

	Outputs:
	f     (complex[nk]): values at target frequencies

	Returns:
	error status, 0 : success
	              1 : eps too small
	              2 : size of arrays to malloc exceed MAX_NF

	Example:
	see python_tests/accuracy_speed_tests.py
	"""
    # f is the output and must have dtype=np.complex128
    x = x.astype(np.float64, copy=False)  #copies only if type changes
    c = c.astype(np.complex128, copy=False)  #copies only if type changes
    s = s.astype(np.float64, copy=False)  #copies only if type changes
    return finufftpy_cpp.finufft1d3_cpp(x, c, isign, eps, s, f, debug,
                                        spread_debug, spread_sort, fftw)