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.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d452cd8206c3261603f1b045c0e84a8b07f9a078360e417f660d44989494557 |
|
MD5 | dd34b4b7865c3359dc31d9ecb200fa16 |
|
BLAKE2b-256 | 2f24eb2afe63b5779cdc5e0675064691a1926821930c2ffbc78b4802bfd07197 |
Hashes for rocket_fft-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d3198fc71ff16eaf86ddfc5eb41186b33d03fdb483ef25158ee6c6bbca484ba |
|
MD5 | f3160b47abb3319c67b0c5dcd1c4e769 |
|
BLAKE2b-256 | c5414ef5fda86ed39860985e43b43ea8d46505abad9ec98daeaa4b6f4c13bf3d |
Hashes for rocket_fft-0.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2d5b93d51b5d1796e5e83b1adaeedf64cd40032bf6cefa208ed84dd720454bc |
|
MD5 | ec1f80b956e18a31366877b7b84f41b4 |
|
BLAKE2b-256 | 22add19568b39c8ba6fec235c5caca14aeaa9c9342577be91dc8e60b90398a9d |
Hashes for rocket_fft-0.2.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94fdb3688fa0da632e00ea2c9712f5d4bc728c7bb9c720e339439a41dc0a84e1 |
|
MD5 | 04a8dca8317a87232b819be189189bb1 |
|
BLAKE2b-256 | 4609c717aa0ba34739623fd287f252a29826d1b0a5f2ab4df77148c3afcab644 |
Hashes for rocket_fft-0.2.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c144b0e7c8dbec27f9ae72e89101304caedea28f666050851afa0dcc18884fad |
|
MD5 | 3b4beb20ef67fe377c1de411126098f5 |
|
BLAKE2b-256 | 3bfceb2c1464535919e95b488716ed09baf05cf71f317e888ebec1e4b2234b81 |
Hashes for rocket_fft-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d8fe6d313e98b41e6639a1b94dc4ca9ba5fefa16975ca7b208777a411569ef |
|
MD5 | 87c638fd0946ad42539b34f5e60623de |
|
BLAKE2b-256 | c4b4a03980e9463390d0b65fe019235b5888d5c3912f2cf7df1107882f4fc71a |
Hashes for rocket_fft-0.2.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef653d706e6ec79711e5867fb6b1aee6676c26e045621c17b52dbe93b588f01 |
|
MD5 | ad54f9f7bca33374320cbcef67c62c48 |
|
BLAKE2b-256 | d968fe5ebf43419ef9fc957fca09d6b7b47b6211c0abd69c9ed020f8fd4e9467 |
Hashes for rocket_fft-0.2.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e54070550f6921b1470c82d53f6a23de64aee2178147fa06f803832237a0e7f |
|
MD5 | fda596b1336a1f210f42711614ef2827 |
|
BLAKE2b-256 | a88447ebbc6dbbd9983d9d2c6faa86d3f68a4f3293ffa3fb82ef33634d58107f |
Hashes for rocket_fft-0.2.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 894137af5cce4859c31561926fc8c083d467cecd728ecb68aba8aafd369e63ff |
|
MD5 | e6e9a2cca4b72e34283c50f184101615 |
|
BLAKE2b-256 | 181da97e88efd6256acdd08d8edc444a67f3ba9c24e5c7a2ee0f23eb483943eb |
Hashes for rocket_fft-0.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b4e48dbe0677a84528f549c0fe17661565306e5f4ca57620c373a0114482845 |
|
MD5 | f6adcf5dc6c8d15174879433951c304b |
|
BLAKE2b-256 | 4232b7ad20621fca82ca5cfe0ba8660851e6ad8ec7ef832d63630a2b3ceab316 |
Hashes for rocket_fft-0.2.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa316da2fe40df4d85d53ff784e8d6d3dac8aeae375c5f77d099d035649a685e |
|
MD5 | 1459e6568371c165015101d8f60620a0 |
|
BLAKE2b-256 | a198cb17379fdbec4a151292d7262e5753e7dda392dda0cc4ef5a040823a8a11 |
Hashes for rocket_fft-0.2.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8438583871a03651d6f7887f52c7f4ae445f5e475ede0a1787738ca030e68146 |
|
MD5 | 20534eb22994b68cd9e54d8924eebf40 |
|
BLAKE2b-256 | 40c34226e7b448505d9e4a47cc2f047dcb7909fa9c04ca8fde505ee506bddaab |
Hashes for rocket_fft-0.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 783b63a32cdfc48acb507aa643c044184d7aaa2a33b03510cebe60669b5a149d |
|
MD5 | 905a90a94ba73ec87c76a4ebd38bf6cc |
|
BLAKE2b-256 | 2aea94686ff71378430844505bc87d3dd1f7c385121a9cb65e3e75719ead683c |
Hashes for rocket_fft-0.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fea7cd610ecbaecc4c5da95250254a559fe22956605415c20ff450784329e2f6 |
|
MD5 | aa21c6e5cc1b7a8b0ad0d6f5f0b4098e |
|
BLAKE2b-256 | a4f725ee88a8202d1121251a9db1470a92cf3da7c59e55cc4bfb79dfdba68631 |
Hashes for rocket_fft-0.2.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41616e72752139b608ac7863d41d9267f78202d9e49bb35880ebbcf00cdee1b2 |
|
MD5 | d1ef99b80c83339a439bd770fb775cdc |
|
BLAKE2b-256 | 7f4aea0e00df2800abc269a3edf7e522dcf46152102f5a3b8cc6e44e99bc6cb0 |
Hashes for rocket_fft-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5547082ca17a9558a747d098f8dae87aa9a42d9c559c9a3da47a738b9843c037 |
|
MD5 | d6a338dfaa9dec8fde6f0933ea9a2fa1 |
|
BLAKE2b-256 | 8a579cac2ff11ee2c3dc6e0737358238c9293495d846990b719d18ce50842c09 |