Skip to main content

Rocket-FFT extends Numba by scipy.fft and numpy.fft

Project description

Rocket-FFT

PyPI version License python status downloads

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([2, 7, 1, 8, 2, 8, 1, 8])
jit_fft(a)

Supported NumPy Functions

The whole numpy.fft module is supported, which contains all the functions listed below:

  • numpy.fft.fft
  • numpy.fft.ifft
  • numpy.fft.fft2*
  • numpy.fft.ifft2*
  • numpy.fft.fftn*
  • numpy.fft.ifftn*
  • numpy.fft.rfft
  • numpy.fft.irfft
  • numpy.fft.rfft2
  • numpy.fft.irfft2
  • numpy.fft.rfftn
  • numpy.fft.irfftn
  • numpy.fft.hfft
  • numpy.fft.ihfft
  • numpy.fft.fftfreq
  • numpy.fft.rfftfreq
  • numpy.fft.fftshift
  • numpy.fft.ifftshift

*Rocket-FFT follows SciPy's approach of not allowing duplicate axes

Supported SciPy Functions

If you have SciPy installed, you will have support for most of the scipy.fft module, including:

  • scipy.fft.fft
  • scipy.fft.ifft
  • scipy.fft.fft2
  • scipy.fft.ifft2
  • scipy.fft.fftn
  • scipy.fft.ifftn
  • scipy.fft.rfft
  • scipy.fft.irfft
  • scipy.fft.rfft2
  • scipy.fft.irfft2
  • scipy.fft.rfftn
  • scipy.fft.irfftn
  • scipy.fft.hfft
  • scipy.fft.ihfft
  • scipy.fft.hfft2
  • scipy.fft.ihfft2
  • scipy.fft.hfftn
  • scipy.fft.ihfftn
  • scipy.fft.dct
  • scipy.fft.dct2
  • scipy.fft.dctn
  • scipy.fft.idctn
  • scipy.fft.dst
  • scipy.fft.idst
  • scipy.fft.dstn
  • scipy.fft.idstn
  • scipy.fft.fht
  • scipy.fft.ifht
  • scipy.fft.fftshift
  • scipy.fft.ifftshift
  • scipy.fft.fftfreq
  • scipy.fft.ifftfreq
  • scipy.fft.fhtoffset
  • scipy.fft.next_fast_len

Type Conversion

If SciPy is installed, Rocket-FFT follows SciPy's approach to type conversion, otherwise it follows NumPy's approach. You can change the type conversion rule by calling 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 installed. Note that this change is irreversible after the compilation of Rocket-FFT's internal functions.

Performance Tip

Rocket-FFT achieves both, flexibility in function signatures similar to scipy.fft and numpy.fft and low compilation times. Compilation takes a few hundred milliseconds in most cases. Calls with default arguments are treated specially and compile fastest.

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 and NumPy interfaces. You can import the functions of the low-level interface 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 does not provide the same level of safety and convenience as the SciPy and NumPy interfaces. There is no safety net, and it is up to the user to ensure proper usage. You may want to look at the original PocketFFT C++ implementation before using it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rocket-fft-0.1.5.tar.gz (35.9 kB view details)

Uploaded Source

Built Distributions

rocket_fft-0.1.5-cp310-cp310-win_amd64.whl (184.1 kB view details)

Uploaded CPython 3.10Windows x86-64

rocket_fft-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rocket_fft-0.1.5-cp310-cp310-macosx_11_0_arm64.whl (243.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rocket_fft-0.1.5-cp310-cp310-macosx_10_9_x86_64.whl (283.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

rocket_fft-0.1.5-cp39-cp39-win_amd64.whl (184.1 kB view details)

Uploaded CPython 3.9Windows x86-64

rocket_fft-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

rocket_fft-0.1.5-cp39-cp39-macosx_11_0_arm64.whl (243.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

rocket_fft-0.1.5-cp39-cp39-macosx_10_9_x86_64.whl (283.4 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rocket_fft-0.1.5-cp38-cp38-win_amd64.whl (184.1 kB view details)

Uploaded CPython 3.8Windows x86-64

rocket_fft-0.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

rocket_fft-0.1.5-cp38-cp38-macosx_11_0_arm64.whl (243.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

rocket_fft-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl (283.4 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file rocket-fft-0.1.5.tar.gz.

File metadata

  • Download URL: rocket-fft-0.1.5.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for rocket-fft-0.1.5.tar.gz
Algorithm Hash digest
SHA256 448b0bfbebfa4f656d8a5c79a818530bf4687153f73622acf7d7ac2908e84877
MD5 789c008056ac1c418fe0365f629e8e3f
BLAKE2b-256 f16b6dbfbf2f732b82e119561dafc6171419bbcc196bea832961db4949d8dea0

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rocket_fft-0.1.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 184.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for rocket_fft-0.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b9301952216882f72443d08b5bc6c6bbd6530291a0243007f36b17acbd340f85
MD5 9da55e781460c9b61c89fd13c7698806
BLAKE2b-256 6806dbdfebde07d6a50afb8001ad9a591d97b06ba1e5659ec0731f44480ea7e5

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7f97081eb702149a8a70bd9d90d2ee2753b3318a79f3b34b207ba963bdf51a5
MD5 18dd87dd1fddd417c3c65c809c852d4e
BLAKE2b-256 8363ef23d2e32278114d69b50c43ed7d1beadefaf806bdfc6ce3d18587c3b447

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7767b2ea1bb752e6a5cd0f13b51cd59aa603c2a0d03a0058d2d5232c4b24785b
MD5 919f45bedd086c28950e463d6520c014
BLAKE2b-256 5cedd200cd6b312d94e03c93933b5982460849cd6d1531e2e5cc463f4b4e61b9

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c5ce0691b55b557a04198103b1a083439fe2f3fafc5d08e4df44335f62076502
MD5 1cabf48571069cff2de8557809b9213f
BLAKE2b-256 570c08c8ebf60e0ba888041da4ed5cc58ac547aceb1663ede9ece28ba06ac67e

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rocket_fft-0.1.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 184.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for rocket_fft-0.1.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a38039d2856bc70f1339efaf915eb392a20bdc672da674db33140590bb4760aa
MD5 f0252e107c19ffb9d39eb765b71906d7
BLAKE2b-256 e164fc4a9f8f1883d281967f57368f8caa968e4cb83e9bfa43e02eb8c92bc9be

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b2b24bb1886235ec654d4e8983afb7a32d15462325045fde8e737510747ea4f3
MD5 cfb311fed4c736694f4643e22c335628
BLAKE2b-256 f62e9701eaf96ea599fd993ff98587d2c8a867da1a1e4a82f7d811253dccd9e6

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3e0d981b2cb28c24c362cf8e4c6ae3dd895ca57dd0b1bc2c0eac89900e5584c
MD5 18e3d0170000852296d216552e33c286
BLAKE2b-256 8461f66e27cf95894d0c1863de1304641967dd97179c5dec171698588b96e595

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a324b2c150069a265c71fe4b237dc8a5b33c37cf5e000c73eac837b5258f8284
MD5 9782904bed67e1c8afa5394c751820ed
BLAKE2b-256 7621af08f09d5b59fa86f832f5f7331095a7a58b92a60478d98772e55739e1f1

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rocket_fft-0.1.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 184.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for rocket_fft-0.1.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8a47c942bb3a902a2974f3f14cc2fb37e9b67f77058ed6306f9c7601d50f8e1d
MD5 dc5922aa45814c3f9189d6d468bb5bc4
BLAKE2b-256 1c2c6ace0dca8a10d0f41d54c36c2aff43c8e62569500a2044757b8be3470086

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a55bd5f8c68c492570f888d8cb9c51bf9917015db77073524d6f92e50f133d1
MD5 c86c01a32cec70e8ed7d953b86f888e8
BLAKE2b-256 22b3f92ecacf15766862e0f140f78021ec3ec637003f44cbc8f96679ce3b9685

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 544ba57dc414edd6754902e43279835cf9e810f9d6cb86faafb7d24e7f5256fb
MD5 3602e0b0b89c7432a0e23c006bfeadf8
BLAKE2b-256 2bd95274149264e366d2f984ea38c0a0114af850ac8613bd70849c6e6062edba

See more details on using hashes here.

File details

Details for the file rocket_fft-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rocket_fft-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aae5bc2a406b2a61d72a0ae02ad69c17ae52a9e510c91b38eecb6291a3baf670
MD5 d4352c49e272e1aca5a162361e5be6de
BLAKE2b-256 d4e421fb16e79a6b85ba6072da7fa98850d0349bbcadc261804b2e9ab4fb013e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page