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.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad1d1158e9799c585f063ea0d20aba7af518828a2b1124edddd91e1ab2e1c928 |
|
MD5 | 7bc57b0b1128d1f60c1ddac812d3c8fe |
|
BLAKE2b-256 | 2115ae0402babdd345c39eaaabd8e018d2c2319b34019e2ec3336be46f8f7651 |
Hashes for rocket_fft-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c4f42194cd4adddcfe365fe9d6bab193787b2b74a837062be9bb6d668ecb96 |
|
MD5 | 3277d9652c33c8e283f5eeac83f67a53 |
|
BLAKE2b-256 | 28e6c52e99a8f93ea4fbf033552a354e06c640e842011e522f771b28bc28db02 |
Hashes for rocket_fft-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4736842b4cb7d2dd4095a5b8c3b82529107aaef56024b8e9749103fb86212520 |
|
MD5 | b8b43eb013d393da9f7ed60664aea836 |
|
BLAKE2b-256 | 3703ac96d5243b3a75fc9f49a37ddfe46da321836e49d47896ddfbf25d8aebf5 |
Hashes for rocket_fft-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef98b1e93353f33b16c9ecbfb45189894c0d282eb7e20916697e53a20f38b5de |
|
MD5 | d2958c4ce25513854d15cda39ea19309 |
|
BLAKE2b-256 | 941a43690f9bdbb8c8ab95352d98230b3b7edec218fb290e268c3b6640e684d0 |
Hashes for rocket_fft-0.2.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a73d69c29a9d78b8b14e40bd46f930331963cada7cfffc655ac24b1c22b6349 |
|
MD5 | 5b4ce25df3b9b820de62a499b46bf30e |
|
BLAKE2b-256 | a845a904183d4baa5e781dcaa285ea9a0de35644ab3d9854cf9be4c43cf2048f |
Hashes for rocket_fft-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 483d95967506d2f729a96f82126ccb046f520bbd8a59410f244ff06985a35cde |
|
MD5 | 5b59ea1263bf0aa8312b5e44971ee760 |
|
BLAKE2b-256 | 06601f50ae64f84ea6d96b7ee8e5bdfe16220885d8ff875bae4ff017c93b0694 |
Hashes for rocket_fft-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0024184a5ae8f477b75c00a52478b0e6efb1f980d2d4d31d5e0d2058281a1eea |
|
MD5 | 17febae009eb971bdf645140507a9ca8 |
|
BLAKE2b-256 | ac96c29cc114ca562422381ed8e6715f95b2467797f79b98d3823e9d403236a5 |
Hashes for rocket_fft-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f01c100d050355ac19af9d435662a98bfae69a643e9c6dc6d34c0714f1418931 |
|
MD5 | 57ac87d1c51853a1318b05554b874771 |
|
BLAKE2b-256 | 6e14815bd35f2e705e5dfc0ea6c5bd5e7c11793d6209bd2449f36182d22a8c18 |
Hashes for rocket_fft-0.2.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3efef2479f53a1386d3bf202d2ec77f3aa5d331bc9c5ec6f1ac47b3f76e6fd5b |
|
MD5 | 6876275381f419b81abc5283883adb41 |
|
BLAKE2b-256 | 15fb876f81e05931115fd7dfd0731e3aa1aa8da685f51d504f7f36081c0f5f6e |
Hashes for rocket_fft-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de6e047162f79a0a142f93ca5bb0eac1a4833a896d5757a54efd4ec107bf7733 |
|
MD5 | 606f2bcd1594d63d90651bc538a16467 |
|
BLAKE2b-256 | 3738c77fbae2cd7967b2ab015e2c2884847a51f4e032bf8c04d2b13fe6cd1c61 |
Hashes for rocket_fft-0.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02d9ed2ad0d5e54d778d19525e0580779c11826c402d1bade53dc80555d1bf3c |
|
MD5 | fa1f8b8be4ca03a3e828293dbab30a11 |
|
BLAKE2b-256 | 8d26dc4de9897ff0f5c6e4c3f7055a5f5283a54a81f3d701610662f2f891adb8 |
Hashes for rocket_fft-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f6094cc8c4d7dd8f975e9a7493beda0513879de99756b0113e7d394728139e4 |
|
MD5 | d6067b0f58ca66bc1817ac0d4b7893a6 |
|
BLAKE2b-256 | c849f3df5da34551757e2a2188d7c2ad261c945cb1ff80e2491c5a6f90213a93 |
Hashes for rocket_fft-0.2.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a77ec5ea6da81926cd9f87dbc2be41594103ebdaf3ad21cd0044e8efe957232a |
|
MD5 | 47ee31823fef22364d5d339d7e5ae562 |
|
BLAKE2b-256 | 0434193872cd227eb66e4237f96c7eb625e5307a584193cb58c570369e7d6101 |
Hashes for rocket_fft-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 746170d2354df208c9b5493648515b5145bebaf31ec01cd590be534bb925dfa9 |
|
MD5 | 4b195da32d5eb684eb6b270b2f24415a |
|
BLAKE2b-256 | e02d49662ac0f6b3cd9d60efa2b3c8f658b7c842c56fd1c891217ad105760b08 |
Hashes for rocket_fft-0.2.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa44b7050ee18985172e9411df43a4cd783d9d553dc72e2977c260dc9175077 |
|
MD5 | 4e16735c0544d48af03c515f639ccea0 |
|
BLAKE2b-256 | ec522430dab3e953e9d4302ca7af33bb6f9bb7e51b0f0b226060cb9e47b363b5 |
Hashes for rocket_fft-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f56df46f9e6f7e7a9af0e2ccfd1c0cf91b6f8c6ce76493025d7903746046561 |
|
MD5 | 8de8ded5ebfb645bf5b5a75e3e968d04 |
|
BLAKE2b-256 | 26dae4954e08c6fe6c95e7c5e5d8cad0908e09b36e01cba9d8f6f16bbd754ddf |