A library to manage and effiently implement all complexities around the complex Fast Fourier Transform.
Project description
Intro | Installation | Documentation | Preprint (arXiv) | Change log
Intro
FFTArray is a Python library that handles multidimensional arrays and their representation in dual spaces (original and frequency domain) and provides the following highlight features:
From formulas to code: The user can directly map analytical equations involving Fourier transforms to code without mixing discretization details with physics. This enables rapid prototyping of diverse physical models and solver strategies.
Seamless multidimensionality: Dimensions are broadcast by name which enables a uniform API to seamlessly transition from single- to multi-dimensional systems.
High performance: Avoidable scale and phase factors in the Fourier transform are automatically skipped. Via the Python Array API Standard, FFTArray supports many different array libraries to enable for example hardware acceleration via GPUs.
Below we give a quick introduction to the basic functionality of the library. For a more thorough description of FFTArray, we recommend reading the preprint and the documentation.
Adding Coordinate Grids to the FFT
The continuous Fourier transform is defined as:
When discretizing it on a finite grid in position and frequency space, one does not only get the Fast Fourier transform (FFT) but some additional phase and scale factors:
\(\mathrm{fft}\) and \(\mathrm{ifft}\) follow here the definition of NumPy’s default behavior in its Discrete Fourier Transform module.
Keeping track of these coordinate-dependent scale and phase factors is tedious and error-prone. Additionally the sample spacing and number of samples in position space define the sample spacing in frequency space and vice versa via \(1 = N \Delta x \Delta f\) which usually needs to be ensured by hand.
FFTArray automatically takes care of these and provides an easy to use general discretized Fourier transform by managing the coordinate grids in multiple dimensions, ensuring those are always correct. Arrays with sampled values are combined with the dimension metadata as well as in which space the values currently are:
import fftarray as fa
dim_x = fa.dim_from_constraints(name="x", n=1024, pos_middle=0., d_pos=0.01, freq_middle=0)
dim_y = fa.dim_from_constraints(name="y", n=2048, pos_min=-5., pos_max=6., freq_middle=0)
arr_x = fa.coords_from_dim(dim_x, "pos")
arr_y = fa.coords_from_dim(dim_y, "pos")
arr_gauss_2d = fa.exp(-(arr_x**2 + arr_y**2)/0.2)
arr_gauss_2d_in_freq_space = arr_gauss_2d.into_space("freq")
For a quick getting started, see First steps.
Built for Implementing Spectral Fourier Solvers
Spectral Fourier solvers like the split-step method require many consecutive (inverse) Fourier transforms. In these cases the additional scale and phase factors can be optimized out. By only applying these phase factors lazily, FFTArray handles this use case with minimal performance impact while still providing the comfort of ensuring the application of all required phase factors. For quantum mechanics, especially for simulating matter waves, the matterwave package provides a collection of helpers built on top of FFTArray.
Installation
The required dependencies of FFTArray are kept minimal to ensure compatibility with different environments. For most use cases we recommend installing the optional constraint solver for easy Dimension definition with the dimsolver option:
pip install fftarray[dimsolver]
Any array library besides NumPy like for example JAX should be installed following their respective documentation.
Citing FFTArray
To cite FFTArray:
@misc{seckmeyer2025,
title={FFTArray: A Python Library for the Implementation of Discretized Multi-Dimensional Fourier Transforms},
author={Stefan J. Seckmeyer and Christian Struckmann and Gabriel Müller and Jan-Niclas Kirsten-Siemß and Naceur Gaaloul},
year={2025},
eprint={2508.03697},
archivePrefix={arXiv},
primaryClass={physics.comp-ph},
url={https://arxiv.org/abs/2508.03697},
}
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fftarray-0.5.2.tar.gz.
File metadata
- Download URL: fftarray-0.5.2.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4327affce6f4a09bf2d125fa55085866338000319f65b4dacedee681d21e72
|
|
| MD5 |
38f972941c5222c28f0e67f615e8285c
|
|
| BLAKE2b-256 |
bc154282f9f220b0b3a2f77ce48f7ce77d905591e35b9dc6e0a4c7d4635ac4d6
|
File details
Details for the file fftarray-0.5.2-py3-none-any.whl.
File metadata
- Download URL: fftarray-0.5.2-py3-none-any.whl
- Upload date:
- Size: 61.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c714cfe1f507c313c4050a4a739a0bcb0bb9b7b6bec34df6bf880e7647e57afc
|
|
| MD5 |
3a2d615f68701f1e4a8f9d14e4dfd3fc
|
|
| BLAKE2b-256 |
309ac76b085808ac2df016087720da1516664216cfcf3b34481f6c0e5fd16fb0
|