示例#1
0
def finufft3d2(x,
               y,
               z,
               c,
               isign,
               eps,
               f,
               debug=0,
               spread_debug=0,
               spread_sort=1,
               fftw=0,
               modeord=0,
               chkbnds=1):
    """3D type-2 (aka forward) complex nonuniform fast Fourier transform

	c[j] =   SUM   f[k1,k2,k3] exp(+/-i (k1 x[j] + k2 y[j] + k3 z[j])).
	       k1,k2,k3
	                 for j = 1,...,nj,  where sum is over
	-ms/2 <= k1 <= (ms-1)/2, -mt/2 <= k2 <= (mt-1)/2, -mu/2 <= k3 <= (mu-1)/2

	Inputs:
	x     (float[nj]): nonuniform target x-coords, valid only in [-3pi,3pi]
	y     (float[nj]): nonuniform target y-coords, valid only in [-3pi,3pi]
	z     (float[nj]): nonuniform target z-coords, valid only in [-3pi,3pi]
	f     (complex[ms,mt,mu]): Fourier mode coefficients, with x (ms) fastest
	      ms, mt, and mu can be either even or odd; in either case
	      their mode range is integers lying in [-m/2, (m-1)/2], with
	      mode ordering in all dimensions given by modeord.
	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), ...
	modeord (int): 0 (CMCL increasing mode ordering), 1 (FFT ordering)
	chkbnds (int): 0 (don't check NU points valid), 1 (do).
	
	Outputs:
	c     (complex[nj]): values at targets

	Returns:
	error status, 0 : success
	              1 : eps too small
	              2 : size of arrays to malloc exceed MAX_NF
	              4 : if chkbnds, at least one NU point out of range
	Example:
	see python_tests/accuracy_speed_tests.py
	"""
    # c is the output and must have dtype=np.complex128
    x = x.astype(np.float64, copy=False)  #copies only if type changes
    y = y.astype(np.float64, copy=False)  #copies only if type changes
    z = z.astype(np.float64, copy=False)  #copies only if type changes
    f = f.astype(
        np.complex128, copy=False, order='F'
    )  #copies only if type changes: so if f is not F-ordered, it will make a transposed copy
    return finufftpy_cpp.finufft3d2_cpp(x, y, z, c, isign, eps, f, debug,
                                        spread_debug, spread_sort, fftw,
                                        modeord, chkbnds)
def nufft3d2(x,y,z,c,isign,eps,f,debug=0,spread_debug=0,spread_sort=2,fftw=0,modeord=0,chkbnds=1,upsampfac=2.0):
  """3D type-2 (aka forward) complex nonuniform fast Fourier transform

  ::

    c[j] =   SUM   f[k1,k2,k3] exp(+/-i (k1 x[j] + k2 y[j] + k3 z[j])).
	   k1,k2,k3
	             for j = 0,...,nj-1,  where sum is over
    -ms/2 <= k1 <= (ms-1)/2, -mt/2 <= k2 <= (mt-1)/2, -mu/2 <= k3 <= (mu-1)/2

  Args:
    x     (float[nj]): nonuniform target x-coords, valid only in [-3pi,3pi]
    y     (float[nj]): nonuniform target y-coords, valid only in [-3pi,3pi]
    z     (float[nj]): nonuniform target z-coords, valid only in [-3pi,3pi]
    c     (complex[nj]): output values at targets. Should be initialized as a
        numpy array of the correct size
    isign (int): if >=0, uses + sign in exponential, otherwise - sign
    eps   (float): precision requested (>1e-16)
    f     (complex[ms,mt,mu]): Fourier mode coefficients, where ms, mt and mu
          are either even or odd; in either case
	  their mode range is integers lying in [-m/2, (m-1)/2], with
	  mode ordering in all dimensions given by modeord. Ordering is Fortran-style, ie ms fastest.
    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)
    modeord (int, optional): 0 (CMCL increasing mode ordering), 1 (FFT ordering)
    chkbnds (int, optional): 0 (don't check NU points valid), 1 (do)
    upsampfac (float): either 2.0 (default), or 1.25 (low RAM & small FFT size)

  .. note::

    The output is written into the c array.

  Returns:
    int: 0 if success, 1 if eps too small,
       2 if size of arrays to malloc exceed MAX_NF,
       4 at least one NU point out of range (if chkbnds true)

  Example:
    see ``python_tests/accuracy_speed_tests.py``
  """
  # c is the output and must have dtype=np.complex128
  x=x.astype(np.float64,copy=False) #copies only if type changes
  y=y.astype(np.float64,copy=False) #copies only if type changes
  z=z.astype(np.float64,copy=False) #copies only if type changes
  f=f.astype(np.complex128,copy=False,order='F') #copies only if type changes: so if f is not F-ordered, it will make a transposed copy
  return finufftpy_cpp.finufft3d2_cpp(x,y,z,c,isign,eps,f,debug,spread_debug,spread_sort,fftw,modeord,chkbnds,upsampfac)