Rocket-FFT extends Numba by scipy.fft and numpy.fft
Project description
Rocket-FFT
Rocket-FFT makes Numba aware of numpy.fft
and scipy.fft
. It takes its name from the PocketFFT Fast Fourier Transformation library that powers it, and Numba's goal of making your scientific Python code blazingly fast - like a rocket.
Getting Started
The easiest way to get Rocket-FFT is to:
$ pip install rocket-fft
Alternatively, you can build it from source:
$ git clone https://github.com/styfenschaer/rocket-fft.git
$ cd rocket-fft
$ python setup.py install
The latter requires a C++ compiler compatible with your Python installation.
Once installed successfully, the following will work (no import required):
import numba as nb
import numpy as np
@nb.njit
def jit_fft(x):
return np.fft.fft(x)
a = np.array([1, 6, 1, 8, 0, 3, 3, 9])
jit_fft(a)
Performance Tip
Rocket-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 interfaces
NumPy and SciPy show subtle differences in how they convert types1 and handle the axes
argument in some functions2. Rocket-FFT implements both ways and lets its users choose between them.
You can set the interface by using the scipy_like
or numpy_like
function from the rocket_fft
namespace:
from rocket_fft import numpy_like, scipy_like
numpy_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 either float64
or complex128
whereas SciPy takes a more fine-grained approach
2NumPy allows duplicate axes in fft2
, ifft2
, fftn
and ifftn
, whereas SciPy doesn't
3SciPy is an optional runtime dependency
Low-Level Interface
Rocket-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 the rocket_fft
namespace:
from rocket_fft import c2c, dct, ...
The low-level interface includes the following functions:
def c2c(ain: NDArray[c8] | NDArray[c16], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: b1, fct: f4 | f8, nthreads: i8) -> None: ...
def r2c(ain: NDArray[f4] | NDArray[f8], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: b1, fct: f4 | f8, nthreads: i8) -> None: ...
def c2r(ain: NDArray[c8] | NDArray[c16], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], forward: b1, fct: f4 | f8, nthreads: i8) -> None: ...
def c2c_sym(ain: NDArray[f4] | NDArray[f8], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: b1, fct: f4 | f8, nthreads: i8) -> None: ...
def dst(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], type: i8, fct: f4 | f8, ortho: b1, nthreads: i8) -> None: ...
def dct(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], type: i8, fct: f4 | f8, ortho: b1, nthreads: i8) -> None: ...
def r2r_separable_hartley(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], fct: f4 | f8, nthreads: i8) -> None: ...
def r2r_genuine_hartley(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], fct: f4 | f8, nthreads: i8) -> None: ...
def r2r_fftpack(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], real2hermitian: b1, forward: b1, fct: f4 | f8, nthreads: i8) -> None: ...
def good_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 original PocketFFT C++ implementation before using it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for rocket_fft-0.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0646cc49435f552edf3d13bc3abaa93adb3f25289c2318363f3bc9d0d624a66 |
|
MD5 | bd0740d723ea2170097b4a2cea60ea75 |
|
BLAKE2b-256 | a6e10fca93f0d76e90b2c51770ce7006c2b1ed84e23508574ed5e677b91c8874 |
Hashes for rocket_fft-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f426140fb76956f9d6e7699a3b3fe5b19bdca0c4959a9c1c7ae5886288c38568 |
|
MD5 | 1699d60602660bced5288a26ebf95f1a |
|
BLAKE2b-256 | 52fed83a2f10920e89735e365367818769fc7294148b2ac92e36f9212d2e19d1 |
Hashes for rocket_fft-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96db5331ffffb13b557818d0ec3e2881b4a84e7a0e89b3e2bc1499d75fa63630 |
|
MD5 | 2ffdd880feea849652e0ef19b625238a |
|
BLAKE2b-256 | c4376a2f4ecd2f22a27c82df2576c642d48f02a2bf8987f9f72b8c2532eb0754 |
Hashes for rocket_fft-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dac436bb695e3978f9ed4411995387b3cfeab790e15e13d7748636dd9bc6a69e |
|
MD5 | f738b81995af133a45eb75ec1864909b |
|
BLAKE2b-256 | 80d323670d31b897047234acee144be36ed0a4c0d0e7a8fbd4c7acf82c6a1f44 |
Hashes for rocket_fft-0.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cca96983aa8b192b83026bb91471703f4046646dd882e169389974f09e476df |
|
MD5 | 8ce4a7f06054a0e686db9d089dcf90b3 |
|
BLAKE2b-256 | dc5af0f0ad52d8d9d4091109fd422ee48c830b7d2381ec2eb9c6d46d7023bb4c |
Hashes for rocket_fft-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f657190b8860f704a1511db46aeccf74be1bc2e339ee0c6e9243f84827e32d07 |
|
MD5 | eddd6cc723165623c7dd7ff9914fe974 |
|
BLAKE2b-256 | ec0983815f46bf9f346d3cd47dd8ac69f17ad3a555b76bb72b47c21223e1d233 |
Hashes for rocket_fft-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf8493cb41d5ecdf95fcc63d7587f358459a4116dcf7de582c36c4d5562e9cff |
|
MD5 | f10f8a81ad3ebeddc5363f4658e31c7a |
|
BLAKE2b-256 | 8da2e2083f639a09a20afdca7f390030722a4863471190b5b3fdeb0043de56b3 |
Hashes for rocket_fft-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6895805ae19cf543a928c4bd75eeebe126a2429a07650543e7595227b3cb17be |
|
MD5 | efa571256f623087311d588b5090e19f |
|
BLAKE2b-256 | c88672fa5d9bb16c59147be1f33f345f8cb2856bdd42b6766dfbf40c80a0ae50 |
Hashes for rocket_fft-0.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b858e5f75db14efcbb3550977f18fedb4e4e2b90acd1128de65aee573b03dbbe |
|
MD5 | 9eadfd6f70a2e4fb5f75c2f13590e6db |
|
BLAKE2b-256 | 785bc65c7bfdbbd7af3c12d7d08a547baaf9d099b62fac0f57bb5931be8928ae |
Hashes for rocket_fft-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8856e29bd19404f24af1e051b5bc6797bc3b8a533cd9c2cfeaec58e95c0fded7 |
|
MD5 | eab4222122543b0f0f95909816cbd3d2 |
|
BLAKE2b-256 | 6dfc000e0d58eb6c719d28c92453e822c0ebf9ddb25779c4380e5b34842c853d |
Hashes for rocket_fft-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b68f2597e6cc2350804bdf0cad513cb8bebbf6090988e8ec426ab70bb75f75ee |
|
MD5 | 7d747d2a25c6c2e60f1f4c73d519e4d7 |
|
BLAKE2b-256 | 85613516fb81f30f711e7e5572814405357cd10b232460eb968cee36c1f3570f |
Hashes for rocket_fft-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2fe500a6ffbe88f25e91d71059b4b2f4373c76ce8d78c9ff1724f63873aa2a9 |
|
MD5 | 63bc9540d51ac4523d1cebcc0726e1bc |
|
BLAKE2b-256 | 56930eaab694d62d043e8583952375d715b5745db5bba338f303ef308461a592 |