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.3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 397185b792bbfd74607e9a89ade22a8676230ed0ab93da182c77b6b951112b9e |
|
MD5 | ecd5337385f018e60e3f3fe31ac20678 |
|
BLAKE2b-256 | a6d102708d384319c3753322f77324ab52c350dd55cd7caeb459ef910bd89300 |
Hashes for rocket_fft-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69d59e28601ce5f731bbd2ee642e7a2888be94dd37e092bf0ecae4d51527e9a0 |
|
MD5 | 05750f0c6a98a921b8bccc6f7d82b0d1 |
|
BLAKE2b-256 | db4c2de51efa5f9fe798e28efd75707a22566ad2d81e2bcae4dd245a6c21614f |
Hashes for rocket_fft-0.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 612b64cde744537cd713532e6df86553de7c3ddd8281ed9980cf8cdfbd55e807 |
|
MD5 | 979500da4b9c3a94841bb3b7ccb5c0e9 |
|
BLAKE2b-256 | 9db6028fbc83fdbeee653f2b9e0e685468f393f863c9c5cc7fb331cd8906b4cc |
Hashes for rocket_fft-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b1d93b3f9916bbc1628c42f5270401b5e4afd9c27015fd535006377ca327faf |
|
MD5 | 968e9d423e70af66b772e34b1c01cd33 |
|
BLAKE2b-256 | 52ec2d07940964c0d728ecb73095db0dc84d0b89f6a68d185859a7e294162aae |
Hashes for rocket_fft-0.2.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0003bd80537a4df2d9ecb1b20931998ea33ae0c852710868a23b089f00e50d9 |
|
MD5 | 9b5409341f0cd0adec790dcd94bcb084 |
|
BLAKE2b-256 | acb676c457fddcd9f4cc90102f6b827779c8d90defa1a3136edfd035ed79a04f |
Hashes for rocket_fft-0.2.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb4c577a514e1062e042ac09c9979fa2454263363825c59ef0422089657babea |
|
MD5 | 829d93713fa2d59a7835de582daf8bf0 |
|
BLAKE2b-256 | c38c1a7baaa6d82f6f35e564b09de2bc7ac6aba465f68d112f2a091b7398cd12 |
Hashes for rocket_fft-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49ac09d4bdf26b3b99ad1d51d8dba1dfd1b1b99fd7c332a312b9a36216382ce9 |
|
MD5 | e40372cb2eef3acbec69058342840dd4 |
|
BLAKE2b-256 | 6a8c8230502c7c19ea9f0fa87b0b1d3cd63b2995971ca858ef2160822293718c |
Hashes for rocket_fft-0.2.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b91baba82007e97e9f2abb7ad3e84c62708863a6f9bf6365e67ae1f51dc24ed |
|
MD5 | 32200953291218c517c998decd0c6fe9 |
|
BLAKE2b-256 | ebfc727dce496acfe44d9a30a27c0857bfe725cc05c6a5649fb6c5aee8d5deaf |
Hashes for rocket_fft-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cadaf209277dc3e2aaa9eed2b6104ee32da34940d9e3147ee2962719bd555738 |
|
MD5 | 9a305776b4abc49d5702a53b5d2c037c |
|
BLAKE2b-256 | 238e15f6ca769112f2e487c20ce03eb170120b05405acc42d6fc8fb8c3ffcaf3 |
Hashes for rocket_fft-0.2.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7d8e4af0a5dd5d5e11a44e70e16aa5b50631737a80441b1df581ea646eabfb7 |
|
MD5 | 2e9ce80d03d806359964141b83c0f38b |
|
BLAKE2b-256 | bfa758f188b396a4ccbe97b1baaf2cd0bb9c7e1c1e551b7722b705745fb0845a |
Hashes for rocket_fft-0.2.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3db0c22bf119acee3061ef197ecf4fe1c89a51de8b51f87bd1adc18792faa035 |
|
MD5 | 625cdaf77cc01d7bcc1cb6c09f6072c3 |
|
BLAKE2b-256 | 332dd37771d53dfdb63929b4f32e7b10cc5e2e67b994e9193b9fffd3fa0834f9 |
Hashes for rocket_fft-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9abd05583aa4d9d56090663807efd2ed7ac2b11b8b0c135e62962bc626b4090 |
|
MD5 | 856df4993b76e4c7aba9b42b839a5aae |
|
BLAKE2b-256 | 810c569eae01dabcf9e892d7ff7a99600a45337e83393572f5e4c09d826bb289 |
Hashes for rocket_fft-0.2.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a17c1d95aa02df224bcd7f845272c27d3500600c80cdd195dedeb7ebe476ad69 |
|
MD5 | b36095514f6cf07034f400c2b3d36423 |
|
BLAKE2b-256 | f960de7e1e5ab619010c1c6a2fe9db5cdb869d38a0a0781fc7d599c02f716dc8 |
Hashes for rocket_fft-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45a6a11fd50f30acac525adb76e804be215b1b8505e5927844a31e23c6e277f7 |
|
MD5 | 5371839053243b6a7d81e995c17a73bf |
|
BLAKE2b-256 | 044e04579e85c6feab81f37145b3719742d5f32b10c211f39e80d0aea6446b24 |
Hashes for rocket_fft-0.2.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d81d6c9e411b65338f343b9dfc4a9c2ac7887876bb13bcc2c4e6c9bd9c16e9f |
|
MD5 | 7cef25304e5fd40d06fecf20cb350e01 |
|
BLAKE2b-256 | 150cb43a8dab1942d47d544509fe505c92a35fcc50c97c363abe8e77a78cd92f |
Hashes for rocket_fft-0.2.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e17d38e7aef41575c3b5ef9a12ab1641e6693aa04fb3ab4ed78a77c76443aa74 |
|
MD5 | d48413dc358cbf5a19547f6d53a58091 |
|
BLAKE2b-256 | 94aabed995adf30352b34910920d5f9159db1885f5bd48b1d7c8493fbab7f278 |
Hashes for rocket_fft-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a20d85161381306c9190d9d3e9be697b3a4e1c624b3f3895c46874031a8f783b |
|
MD5 | f8f6d2088adb4ea0ffed279be69cfdee |
|
BLAKE2b-256 | 262671cb3a9d699d7c7c52fe11f1aff53aa7097142ccb9770ebf7fd8d06fdc89 |
Hashes for rocket_fft-0.2.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd259d99d49fdc0cefbcc3ead05b6144f97fc82262ba00215171efb23fc3bf1d |
|
MD5 | 3ed946f6d484173f3e0e1614c7ac47e1 |
|
BLAKE2b-256 | 11e964b28325c6661b3277f8df592e1a1ea8461db240d55c2bd4224b4f096d94 |
Hashes for rocket_fft-0.2.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6e9115aac74924ccc32c65517dfbc2dca7160d9a474b10b6e6d3dc7024e5bd0 |
|
MD5 | f3c2d52b8393f28f6fb92e16724b353b |
|
BLAKE2b-256 | 2374213018878d57b62adcf4161c3a1f24712da29e65ca73e709030cb11e22ae |
Hashes for rocket_fft-0.2.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e2a8b11bbe04b8fc0a953c0a48422fe0e839f620e83a433063d79acce727796 |
|
MD5 | b60b8e570686410ad5e2aa02a91c602c |
|
BLAKE2b-256 | 4621db15e810a7c7fabc8f346bbf642bee4919a76fb6017ada4e9534956fcf61 |