Flexible-grid approximations to continuous Fourier transforms
Project description
FlexFT
FlexFT evaluates finite-sum approximations to continuous Fourier transforms (CFTs) on uniform input and output grids whose spacings can be chosen independently. It uses the Bailey-Swarztrauber fractional DFT/Bluestein convolution, implemented with JAX FFTs.
For samples f(x) on
x[n] = x0 + (n - floor(N / 2)) * dx
the forward transform flexft(f, dx=dx, dk=dk, x0=x0, k0=k0) returns
approximations on
k[m] = k0 + (m - floor(N / 2)) * dk.
Computational cost
flexft uses Bluestein's algorithm to rewrite the discretised CFT
approximation as a linear convolution, then evaluates that convolution with
FFTs. A one-shot transform currently needs two forward FFTs and one inverse FFT,
each of length 2N, where N is the number of samples.
The asymptotic complexity is therefore the same as an FFT, but with a larger
constant prefactor. When the convolution kernel is precomputed by reusing a
FlexFT plan, each subsequent transform needs only one forward FFT and one
inverse FFT of length 2N.
Installation
pip install flexft
The quick-start plot below also uses Matplotlib.
Quick start
import jax.numpy as jnp
import matplotlib.pyplot as plt
from flexft import flexft
N = 512
dx = 0.04
dk = 0.01
x = (jnp.arange(N) - N // 2) * dx
k = (jnp.arange(N) - N // 2) * dk
# With the convention F(k) = integral f(x) exp(-i 2 pi k x) dx,
# exp(-pi x^2) is its own continuous Fourier transform.
f = jnp.exp(-jnp.pi * x**2)
F_flexft = flexft(f, dx=dx, dk=dk)
F_exact = jnp.exp(-jnp.pi * k**2)
fig, ax = plt.subplots(figsize=(6, 3.5))
ax.plot(k, F_exact, label="exact", linewidth=2)
ax.plot(k, F_flexft.real, "--", label="flexft", linewidth=2)
ax.set(xlabel="k", ylabel="F(k)")
ax.legend()
fig.tight_layout()
fig.savefig("docs/assets/readme-quick-start.png", dpi=200)
Omit dk in the forward transform to use the FFT-compatible spacing
1 / (N * dx). Conversely, omit dx in the inverse transform to use
1 / (N * dk).
For repeated transforms with unchanged grids, construct and reuse FlexFT or
IFlexFT; this reuses the precomputed convolution kernel.
Documentation
Read the full documentation for the derivation, shifted grids, 2D transforms, API reference, and more examples.
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 flexft-0.1.1.tar.gz.
File metadata
- Download URL: flexft-0.1.1.tar.gz
- Upload date:
- Size: 229.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69514cfb7c4f65c8355fbe21791cb58f48a1afb4b8bda4154e99fa30165b9e7d
|
|
| MD5 |
1b10d60c81e9acf338486e854196538f
|
|
| BLAKE2b-256 |
3330b5a305d606334ee1a22a0c6765b7a6679f94a460a07e4a304fd6e146a1f0
|
Provenance
The following attestation bundles were made for flexft-0.1.1.tar.gz:
Publisher:
publish.yml on tomsturges/FlexFT
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flexft-0.1.1.tar.gz -
Subject digest:
69514cfb7c4f65c8355fbe21791cb58f48a1afb4b8bda4154e99fa30165b9e7d - Sigstore transparency entry: 2137271056
- Sigstore integration time:
-
Permalink:
tomsturges/FlexFT@10c69ec96db136db54602cc5f22eaefc57dcd8d9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tomsturges
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10c69ec96db136db54602cc5f22eaefc57dcd8d9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file flexft-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flexft-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7421f7f06be11c45f372c9573a8f45603c8cb6f3e4d89e5dab00150b7b8f0361
|
|
| MD5 |
25d66120db12fa7bd8e13eee6fb0fb41
|
|
| BLAKE2b-256 |
9591fdd4a783a892f8445fe2e55c4b4afaa6be0da6cb7a20710ecffa94bc3c43
|
Provenance
The following attestation bundles were made for flexft-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on tomsturges/FlexFT
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flexft-0.1.1-py3-none-any.whl -
Subject digest:
7421f7f06be11c45f372c9573a8f45603c8cb6f3e4d89e5dab00150b7b8f0361 - Sigstore transparency entry: 2137271195
- Sigstore integration time:
-
Permalink:
tomsturges/FlexFT@10c69ec96db136db54602cc5f22eaefc57dcd8d9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tomsturges
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10c69ec96db136db54602cc5f22eaefc57dcd8d9 -
Trigger Event:
release
-
Statement type: