Package: rocket-fft
Rocket-FFTRocket-FFT makesNumbaaware ofnumpy.fftandscipy.fft. It takes its name from thePocketFFTFast Fourier Transformation library that powers it, and Numba's goal of making your scientific Python code blazingly fast - like a rocket.Getting StartedThe easiest way to get Rocket-FFT is to:$ pip install rocket-fftAlternatively, you can build it from source:$ git clone https://github.com/styfenschaer/rocket-fft.git
$ cd rocket-fft
$ python setup.py installThe latter requires a C++ compiler compatible with your Python installation.Once installed successfully, the following will work (no import required):importnumbaasnbimportnumpyasnp@nb.njitdefjit_fft(x):returnnp.fft.fft(x)a=np.array([1,6,1,8,0,3,3,9])jit_fft(a)Performance TipRocket-FFT makes extensive use of Numba's polymorphic dispatching to achieve both flexible function signatures similar to SciPy and NumPy, and low compilation times. Compilation takes only a few hundred milliseconds in most cases. Calls with default arguments follow a fast path and compile fastest.NumPy-like and SciPy-like interfacesNumPy and SciPy show subtle differences in how they convert types1and handle theaxesargument in some functions2. Rocket-FFT implements both ways and lets its users choose between them.You can set the interface by using thescipy_likeornumpy_likefunction from therocket_fftnamespace:fromrocket_fftimportnumpy_like,scipy_likenumpy_like()Both functions can be used regardless of whether SciPy is installed3. By default, Rocket-FFT uses the SciPy-like interface if SciPy is installed, and the NumPy-like interface otherwise. Note that the interface cannot be changed after the compilation of Rocket-FFT's internals.1NumPy converts all types to eitherfloat64orcomplex128whereas SciPy takes a more fine-grained approach2NumPy allows duplicate axes infft2,ifft2,fftnandifftn, whereas SciPy doesn't3SciPy is an optional runtime dependencyLow-Level InterfaceRocket-FFT also provides a low-level interface to the PocketFFT library. Using the low-level interface can significantly reduce compile time, minimize overhead and give more flexibility to the user. It also provides some functions that are not available through the SciPy-like and NumPy-like interfaces. You can import its functions from therocket_fftnamespace:fromrocket_fftimportc2c,dct,...The low-level interface includes the following functions:defc2c(ain:NDArray[c8]|NDArray[c16],aout:NDArray[c8]|NDArray[c16],axes:NDArray[i8],forward:b1,fct:f4|f8,nthreads:i8)->None:...defr2c(ain:NDArray[f4]|NDArray[f8],aout:NDArray[c8]|NDArray[c16],axes:NDArray[i8],forward:b1,fct:f4|f8,nthreads:i8)->None:...defc2r(ain:NDArray[c8]|NDArray[c16],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],forward:b1,fct:f4|f8,nthreads:i8)->None:...defc2c_sym(ain:NDArray[f4]|NDArray[f8],aout:NDArray[c8]|NDArray[c16],axes:NDArray[i8],forward:b1,fct:f4|f8,nthreads:i8)->None:...defdst(ain:NDArray[f4]|NDArray[f8],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],type:i8,fct:f4|f8,ortho:b1,nthreads:i8)->None:...defdct(ain:NDArray[f4]|NDArray[f8],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],type:i8,fct:f4|f8,ortho:b1,nthreads:i8)->None:...defr2r_separable_hartley(ain:NDArray[f4]|NDArray[f8],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],fct:f4|f8,nthreads:i8)->None:...defr2r_genuine_hartley(ain:NDArray[f4]|NDArray[f8],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],fct:f4|f8,nthreads:i8)->None:...defr2r_fftpack(ain:NDArray[f4]|NDArray[f8],aout:NDArray[f4]|NDArray[f8],axes:NDArray[i8],real2hermitian:b1,forward:b1,fct:f4|f8,nthreads:i8)->None:...defgood_size(target:i8,real:b1)->i8:...Note that the low-level interface provides a lower level of safety and convenience compared to the SciPy-like and NumPy-like interfaces.
There is almost no safety net, and it is up to the user to ensure proper usage. You may want to consult the originalPocketFFTC++ implementation before using it.