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.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e58719b00035d5ee2fe080d1cc6dfe98fddf9e63d37a858e858a6ea14023ae5 |
|
MD5 | d16fc2190da5edabc7940991fa77f8aa |
|
BLAKE2b-256 | 39596c6c70be00f9263aabd2d612a0e0dd45379c1be8a76b2068124c3837b1b6 |
Hashes for rocket_fft-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaf51d97f66343aeaa359c41547a8c9fbebfbbfb57ee767de6f63d50b56a3d84 |
|
MD5 | 92f1e404f649edafb0f0ad6b8fdb1e36 |
|
BLAKE2b-256 | a3c543cb3bd8901434bd0694d7d10d1b5e8564db4ef2a97746849b9cd1a040c3 |
Hashes for rocket_fft-0.2.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be616716dfca7e40772ce7afddf42b54e73a8f700ff569342cc62ce21ed35d2d |
|
MD5 | e156fce3bd990743023511faeb03cb61 |
|
BLAKE2b-256 | 0f8f665bdc41768dfff918c1bee39dfed5b5b04798fb760e16483f2e40bf840b |
Hashes for rocket_fft-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b459d5196477c6f5e19fa47afcc25a3a1a6ab0040be3cfb87ba45ad72a42c4dd |
|
MD5 | 00f2f84a715552f9bddcd9f8a9bb12ad |
|
BLAKE2b-256 | 6f5ed9073d7166f5e7a74686fd5a92af11a2ef91408457fd7b710a2fcb83a9db |
Hashes for rocket_fft-0.2.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0471a1514fbfddd2191b1a48de6857df19f82835552dfd67786431acb2fad9b5 |
|
MD5 | bd41affba5228e1c6fbd995f0ffea28a |
|
BLAKE2b-256 | d9f1d0213c119a7fd130c1a4eb95846af9d578c656b74c67cc560a07d0e8fe1e |
Hashes for rocket_fft-0.2.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f3200b135b758684da128ebb6b3ca4ff805336bb7d28d9d76adca92ef48e0f7 |
|
MD5 | fbdeb82ec54a6c9604f5a9d1dd6882db |
|
BLAKE2b-256 | 5129b6e06109370fb11d32088044afb1d04b4abf6afeed159d95b3c963166598 |
Hashes for rocket_fft-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e63f40cdc0275e8e25a66ae8364ec56c7be917b9d2809a58400c30d1148d3a44 |
|
MD5 | 06e47175c3a9a320491ac4f71d357683 |
|
BLAKE2b-256 | 76d53d36f521f4515daf92be88d925b541739fc0f2228ff0ecfca316f8d57190 |
Hashes for rocket_fft-0.2.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c90d0fa8b39dbf1117ddafda406d1f9df9e510d7e1aa75c177da4afab0200f5c |
|
MD5 | 57ca521f6e615136717a0d86f544a350 |
|
BLAKE2b-256 | 7ced44255b9e40095f3a279013d6c074ca4480e3430d4502d5547d6a4d1178f9 |
Hashes for rocket_fft-0.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a634a93f7e7d503faf5886c46efe10360f563b6f051d31b587020240d340d2d9 |
|
MD5 | 91ab88e0fa3bee2d455a0fa2ed789a0d |
|
BLAKE2b-256 | b4db908022ce5054b937cb0afa95e15f7f45d968549b507fe1920c9434ccb7e0 |
Hashes for rocket_fft-0.2.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33f9b2b6369bf0e38513507435a29837a8719b51785216769dbed9cec1e3d659 |
|
MD5 | 5f6bbc9a24cd5d78454bff2a418119be |
|
BLAKE2b-256 | 35c5119ce697fb004f211b13baa5206b31282562a362a2f71f264ece4eef3624 |
Hashes for rocket_fft-0.2.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d8a199701df56b3be484cef9ee9bd601861be7ffbc80770e42562232202e353 |
|
MD5 | 6bb39da262ea6a449cc8abf997ed474c |
|
BLAKE2b-256 | 029880ed637e75a10914c360039108abfc974672766ebd6b5c380f4a548c71af |
Hashes for rocket_fft-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6268296245e7f4720c041070b8cd5b85c8f38ecc3b989a836a8bfd6c1346e5 |
|
MD5 | 49c2e1a11df5cd7e75e893a0c642de6f |
|
BLAKE2b-256 | 1ec2232c967bbea80268aca578386d33f0ceeed3591ea6f657c821cb6c95778d |
Hashes for rocket_fft-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 720881343defaf8412d8a22a78b3e666b4d721e360d1e57f0280d90482775256 |
|
MD5 | aaa742240bc6167cfed6df8de233358b |
|
BLAKE2b-256 | 66e767b97437d712ea76c7bcd00a1fcb7fca856a91303e280845e7455d1fe3da |
Hashes for rocket_fft-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92edd96e9b1c39e445418ee28c0849536fcc7ffee6913974c7481c5bf0ee1695 |
|
MD5 | 25c4352227f6bdf2ff78cbf3caf630f4 |
|
BLAKE2b-256 | 141e935e1be53909555dd88c2d2320f1dc32ef6b48362410f2927827d677d98c |
Hashes for rocket_fft-0.2.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 014b2f11cf51588246e84ee3f897622ad7be1ad2d7834b276597640a24119686 |
|
MD5 | eb72d725a8b0e4f3da4314d82998a4cd |
|
BLAKE2b-256 | 4866fdd65d1463ce2b7d787081bf93131712082c46d980bff947fadfe6ccfc3c |
Hashes for rocket_fft-0.2.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75c02e36ad897889e69728d2bff1eb4fd0a727517bab163fc8a311cfe2bf9698 |
|
MD5 | f053d1cd82fd9eebe19e7ad6535f532e |
|
BLAKE2b-256 | dec4b2857bbbd3e8e55bc2ac7c742571c58cb268f134f701015b93a9303974a7 |
Hashes for rocket_fft-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2765b9829a487c2c98fba5ebb40948e5016a439c5e5e596bf14e85458b97407 |
|
MD5 | b4772968031086bef89e5c6aa0ab45aa |
|
BLAKE2b-256 | 6eb8bc711a182194dc0b62aa7d60f252eac492533e7dc3aff0ba0e5affe71047 |
Hashes for rocket_fft-0.2.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 001b1bb604817f080e1292a0b0f5802e4e33597fa25cb6334ad0d6fa3df453c2 |
|
MD5 | 23c9947b75fa41a6610ce7f78bf48769 |
|
BLAKE2b-256 | 5b9ce5e28c3962f770c37ded76a7fc91b334fdc40e4ede1623ae62a6add7beb1 |
Hashes for rocket_fft-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c9a42bdbc75b2b93b1fd9263308627d599b84e766cab4682df5375a6cc85501 |
|
MD5 | 9420996912ab0915427156aeaa4fffd1 |
|
BLAKE2b-256 | 8c3dfc961de653e7e938f9c395c03c289645e2417d071515ac4052267c714166 |
Hashes for rocket_fft-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aaf4030ba689feaa7aba761872bec1f2573d5cad3d41793a3fe65ba09a6e416 |
|
MD5 | 333cdb684568a799545411509376a80b |
|
BLAKE2b-256 | 84237cf9aeb1e5afbfd9ec51728bf48124fb0ab6c4bab289435a006b7b440e08 |
Hashes for rocket_fft-0.2.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173df6e82af3b06b9cd1100968c614579ffc220b5defe6cce857d2ecaea67225 |
|
MD5 | 94b56d8dde9f3692c6f58eb6c7bd7501 |
|
BLAKE2b-256 | d66cb495866043b393336e90305eee46323bc150fd158afa4dd8966b180a2419 |
Hashes for rocket_fft-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef6fb231582af4c6d816d61b2eace7c89eab92829cf75785fb4426e9418de384 |
|
MD5 | 235b14f6479acd17c75d90e56fc0fdae |
|
BLAKE2b-256 | 9e381afd8d82b3c731452c26ca889b038f29ccccef56429702fed772a2a6d4c8 |
Hashes for rocket_fft-0.2.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93564afb172e09913af978e03586c3e16235861e8ce049466bd00de16ebf1d3a |
|
MD5 | 5691392649db5e3ea6467a29f9614c8c |
|
BLAKE2b-256 | 940c379f35667526916424f036f5d1021b04918729d714a54eba1a49289a59d7 |
Hashes for rocket_fft-0.2.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d771fcbf09cd958dcfa16edc1b8932f8a40eadbace5f41e50f564944c75a2629 |
|
MD5 | 02cabeb0d55edba5624b589239c3459d |
|
BLAKE2b-256 | 40da1f30f498c0cba4ec229688f4dca88d25a73ad6456dc463d18fa29dfcd418 |
Hashes for rocket_fft-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d038be60f6c7bfee38fd0ad5e641f65d9068f6410653ca55b0284b6f19f2feb |
|
MD5 | f7ab7aedd9e61ca45a525b769d7cf8d8 |
|
BLAKE2b-256 | 4a1717f02464c51da200882010239ebff98adcd66d159c2e4aa261ab2ac71efb |