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.5-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8a6b6b0ad5b7769aab9b37cad2f17f14f778bff205ba46aee6e71ca1f273662 |
|
MD5 | 8f472751b4d045bd6aba4abe6ec15677 |
|
BLAKE2b-256 | 4c83b18b211ec172bb20dd5dcf77aee7a2517edf5db795be893a2545e8d73ab8 |
Hashes for rocket_fft-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beaf5a064af017f940d24a0b9a94cb4696c8722fda9c1726fea645a41344ea6e |
|
MD5 | 3a18e9dea8ef5319eb2f46b189fe16d0 |
|
BLAKE2b-256 | 6a7b33383d05947c8d2ff0464a38d56222539e56c6c5d2495cbc4dde7c52b724 |
Hashes for rocket_fft-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b38877592f7704fc328d47103e7cf4fdca24f59e2b1c97b3e773c6e60580af4a |
|
MD5 | b07a8994749f51e7a06ff567050d69d5 |
|
BLAKE2b-256 | 902eab61028c898c9de1addb1a3bb7ca685ba4c49e8f280e8d16cbb57d71f529 |
Hashes for rocket_fft-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b63e6e8e7b925e9a8cce75bf30559c6507fe7ce92156acbe42d5481ada81d1c |
|
MD5 | 23d6c3c893aff317850b34e32c611ade |
|
BLAKE2b-256 | df5ca7799631012d51c8d63ff391e922f7214300c41c70eda01aa0c1e553c092 |
Hashes for rocket_fft-0.2.5-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c76f189535e2cda8970a4679966ac320f7486071f0a59a8f13b48884c44325a0 |
|
MD5 | 678a8bb80f36ae2916d3093e05422d04 |
|
BLAKE2b-256 | abd07b18c050d772e599158158447dcbf3d32c9fb6e6a431222430c403656f6a |
Hashes for rocket_fft-0.2.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c2300964ab8aa69a77c42a2495d26c2e19b0a601a26c5565e4cbaeda980625c |
|
MD5 | acc9dd9d44c1e68188643abcdafea728 |
|
BLAKE2b-256 | 7178e676232bd61624ef9c63ef337e132982f6136a13e96e6cc455c1b9435fca |
Hashes for rocket_fft-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c343b9cd17ce9da60022256aabfb39588628de150210250e3f7c75adca369dd |
|
MD5 | 6cd8c4e4dc70445d262ac0e01eb61aa6 |
|
BLAKE2b-256 | 2235636fead6e189dfac59296dc1cbd08d991813819d5fd6b0b73cb9857f6c9e |
Hashes for rocket_fft-0.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db08c74814462c50375dc890ad884ad97100ccc243da02f45b1ea9592b3fa11 |
|
MD5 | 8832fe462d336b6bb66dcd60907a5563 |
|
BLAKE2b-256 | 701d3ff2f912d5b132aa2acb6e48077cc27026bcde01b4705502800e000a487e |
Hashes for rocket_fft-0.2.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e28a8a381c785b528ef23d96139aeefffc9f549d5edb13a9fbddd7a62c636f8a |
|
MD5 | f6610581fe07589285cc713a2980053c |
|
BLAKE2b-256 | 5faa8e2403114bf03bba8dd7513ff9419c822fc9193e846e98b756a5c95c8538 |
Hashes for rocket_fft-0.2.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f3e0ab86409638348cdcb0c7ec3c81d6c1358c67ee5ff34959accad38289f7 |
|
MD5 | 573132fc71a765e7ddd511804da0063b |
|
BLAKE2b-256 | ec8c44b8afb623c7055aedd0ef4f4b8af5f6b19d07cce8b307639b3b596cdcb8 |
Hashes for rocket_fft-0.2.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dada3fab0ef686a31ff627f2e28635feb8d2ccc198dc14259673e413a6d0d2da |
|
MD5 | 92f8c332d388e456c4d7c1e91fcb2e67 |
|
BLAKE2b-256 | 5f7e53c88cf0a8ae4eade287fad38efedb120318db1245873625e10f228cd118 |
Hashes for rocket_fft-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c2c90a47ead16a00751d232aacf0ddcb66e37222770aab9e90b5551d6c3a39e |
|
MD5 | 6770e7ae46b98c7b946abcd17e4c2cdd |
|
BLAKE2b-256 | 5374bbdc3260a60a52c8485f1c178a32af2b64faa66d0b2626ca943c5ef8d98c |
Hashes for rocket_fft-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfdb1abd653e2ef831fec8d73fc4996b9ae8a22f2ef9054a100814ad4fe08462 |
|
MD5 | df8662d0d269a0cce78f660e2e47c110 |
|
BLAKE2b-256 | 561bff754484e83be4f4e720828f5b47f3ba7026dc092a30d61c54bbec200177 |
Hashes for rocket_fft-0.2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee839203b95010bf62f09d77cd722025a16596de5da4d87b44f650238d5ab0d2 |
|
MD5 | d91251aaa5422b068db6d175e63cbaa0 |
|
BLAKE2b-256 | a93d10b2061d7d07b5965251503d85144b5a6307e6a99d3fea945b18ba40e43d |
Hashes for rocket_fft-0.2.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b752e2b0337afe138f1bf0cd46c4d391964c480aeaf42ddf97366d68b8e5e412 |
|
MD5 | 2b2420db95f2e8f6769255c492722ea6 |
|
BLAKE2b-256 | 212838a38940b97d2ecb47dda2d46f3df72d546086ecada8523634d4dc4d24f4 |
Hashes for rocket_fft-0.2.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9a674a7434cbb2d11691d1ad9cbae24ff8d7db10a70cc60004efc5308410360 |
|
MD5 | 8b0851bab697416c67d18a4029dfc933 |
|
BLAKE2b-256 | 234f79abd9f7467b79120411b9c764d142260297bbc58e994e521486bc2472b0 |
Hashes for rocket_fft-0.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 989739a8bb4432b7f4059c19bdede7fde98c76cb70fa62d7a299a8606be5619c |
|
MD5 | dddb77020d90a92587604ef527a7e713 |
|
BLAKE2b-256 | 2480fb502b216489d993c14bfd8431a99e5f70ce6062db502b3af4a83a37fcad |
Hashes for rocket_fft-0.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27848e7e74c84dd9eae3a683260dbf060fde56714a1112438f84cbd310847444 |
|
MD5 | 229318946e36eb33010000462f93e160 |
|
BLAKE2b-256 | 66cb7ff8393ea3bbe80ea1c34dc92250e5a4f2b7d84a349b09101f7f76a438b7 |
Hashes for rocket_fft-0.2.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c51219c3cb38fa7c9ff8641642ac8a5de22f9fa033252bbc2ea557bf34e9637 |
|
MD5 | e88d525f50510760ed4945737fb1f543 |
|
BLAKE2b-256 | ab5e6f7b4e6f32133c7654fd4a415bff251932b87938c9fc04a62d0ff8f0f033 |
Hashes for rocket_fft-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae4ed289f68fb9d30386b427d0d886b6bcacd6831340b693e72ee098b72864c6 |
|
MD5 | 9edf1687e5f33901146f96968fa345c5 |
|
BLAKE2b-256 | 538b9019b669fdf3229ce3ac63aad1b599014f89b3f9997a8b6adbdb3a644a1b |
Hashes for rocket_fft-0.2.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dd1f1a04b56f258d7f34d6d1bb9815be5c563400a81609c997e10ea77e466a1 |
|
MD5 | bfbec5a0a6f59123a196567c4e6fd60b |
|
BLAKE2b-256 | feb7e2020f135c3511b98a20fe754db24e9c91af08a38c53c87f69ba81b3a8a1 |
Hashes for rocket_fft-0.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc2c62bc5943795cae010d61efe7b2383c00814e7f0f8e0678ffb515756bbb4b |
|
MD5 | 7cdce7e17062f9771f252bf2091af3ff |
|
BLAKE2b-256 | 0419c70c17de2e1c0c4d86594b9dab318edc6d019ab8c630f16dd5533ad6247c |
Hashes for rocket_fft-0.2.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63a19be485d95d3497c32913d87328d5427ffdb78f871398bb060f632346548c |
|
MD5 | d9ef781ecddf12698fe42f9dd66e45ac |
|
BLAKE2b-256 | 4d47a3fb7878ccefbabcd1d49cf4cee0d6a4a03b888d4577fae7b7999ad4f6b1 |
Hashes for rocket_fft-0.2.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19c4f11f3fa3f0acb2f81d7c5f16c1077998ce04ad1c9a069e0b6877906cd8d6 |
|
MD5 | cca64c56d6b30e67b1485b3573b0c737 |
|
BLAKE2b-256 | 324b9d4f5a02f24b36bcc529abc6d01d579ec3a939831024e541d91234603df0 |
Hashes for rocket_fft-0.2.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9eddb716b8601d6728c621c94b1a5f1ab8053763e9010e684320d3bef9361b4 |
|
MD5 | a4d536e5bc1da50a7b34241b258a3f63 |
|
BLAKE2b-256 | 162a1e042302d199f6634b3e31721aea4cc6db5064faa4166d043880426a7646 |