# FFTLog
A Python implementation of FFTLog for fast logarithmic FFT transforms, developed for [PyBird](https://github.com/pierrexyz/pybird).
## Installation
### Basic installation (recommended)
```bash
pip install fftlog-lss
```
### With JAX acceleration
```bash
pip install "fftlog-lss[jax]"
```
### From source
```bash
git clone https://github.com/pierrexyz/fftlog.git
cd fftlog
pip install --editable .
```
### From source with JAX
```bash
git clone https://github.com/pierrexyz/fftlog.git
cd fftlog
pip install --editable ".[jax]"
```
## Dependencies
### Required
- Python >= 3.8
- numpy >= 1.20.0
- scipy >= 1.7.0
### Optional (for JAX acceleration)
- jax >= 0.4.0
- jaxlib >= 0.4.0
- interpax >= 0.3.0
## Quickstart
### Basic Usage (without JAX)
```python
import numpy as np
from scipy.stats import lognorm
from fftlog import FFTLog
# Create test function (power spectrum)
k = np.logspace(-4, 0, 200)
pk = lognorm.pdf(k, 2.1)
# Initialize FFTLog
fft = FFTLog(
Nmax=512, # Number of points
xmin=1e-5, # Minimum k value
xmax=1e3, # Maximum k value
bias=-0.1, # Bias parameter
complex=False, # Use real FFT
window=0.1 # Anti-aliasing window
)
# FFTLog decomposition and reconstruction
pk_reconstructed = fft.rec(k, pk, k)
# Spherical Bessel Transform
s = np.arange(1., 1e3, 5.)
xi = fft.sbt(k, pk, s) # Fast O(N log N) transform
```
### With JAX Acceleration
```python
import numpy as np
from scipy.stats import lognorm
from fftlog import FFTLog
from fftlog.config import set_jax_enabled
from jax import jit
import jax.numpy as jnp
# Enable JAX mode
set_jax_enabled(True)
# Create test function
k = np.logspace(-4, 0, 200)
pk = lognorm.pdf(k, 2.1)
# Initialize FFTLog (same as above)
fft = FFTLog(
Nmax=512, xmin=1e-5, xmax=1e3,
bias=-0.1, complex=False, window=0.1
)
# Convert to JAX arrays and JIT compile
k_jax, pk_jax = jnp.array(k), jnp.array(pk)
get_coef_jit = jit(fft.Coef)
# Now much faster for repeated calls
coefficients = get_coef_jit(k_jax, pk_jax)
```
## Features
- Fast logarithmic FFT transforms
- Support for both real and complex transforms
- Spherical Bessel transforms
- Anti-aliasing windows
- Optional JAX acceleration for GPU/TPU support
## Documentation
For more detailed examples and documentation, see the notebooks in the `notebooks/` directory.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Raw data
{
"_id": null,
"home_page": null,
"name": "fftlog-lss",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Pierre Zhang <pierre.zhang@example.com>",
"keywords": "fft, logarithmic, transform, scientific, numerical, jax, gpu, acceleration",
"author": "Pierre Zhang",
"author_email": "Pierre Zhang <pierre.zhang@example.com>",
"download_url": "https://files.pythonhosted.org/packages/08/2a/398eaa7e8469dcc0c8f8f56715d66a092670ae66a911a7920605775cb1d3/fftlog_lss-0.1.2.tar.gz",
"platform": null,
"description": "# FFTLog\n\nA Python implementation of FFTLog for fast logarithmic FFT transforms, developed for [PyBird](https://github.com/pierrexyz/pybird).\n\n## Installation\n\n### Basic installation (recommended)\n```bash\npip install fftlog-lss\n```\n\n### With JAX acceleration\n```bash\npip install \"fftlog-lss[jax]\"\n```\n\n### From source\n```bash\ngit clone https://github.com/pierrexyz/fftlog.git\ncd fftlog\npip install --editable .\n```\n\n### From source with JAX\n```bash\ngit clone https://github.com/pierrexyz/fftlog.git\ncd fftlog\npip install --editable \".[jax]\"\n```\n\n## Dependencies\n\n### Required\n- Python >= 3.8\n- numpy >= 1.20.0\n- scipy >= 1.7.0\n\n### Optional (for JAX acceleration)\n- jax >= 0.4.0\n- jaxlib >= 0.4.0\n- interpax >= 0.3.0\n\n## Quickstart\n\n### Basic Usage (without JAX)\n\n```python\nimport numpy as np\nfrom scipy.stats import lognorm\nfrom fftlog import FFTLog\n\n# Create test function (power spectrum)\nk = np.logspace(-4, 0, 200)\npk = lognorm.pdf(k, 2.1)\n\n# Initialize FFTLog\nfft = FFTLog(\n Nmax=512, # Number of points\n xmin=1e-5, # Minimum k value\n xmax=1e3, # Maximum k value\n bias=-0.1, # Bias parameter\n complex=False, # Use real FFT\n window=0.1 # Anti-aliasing window\n)\n\n# FFTLog decomposition and reconstruction\npk_reconstructed = fft.rec(k, pk, k)\n\n# Spherical Bessel Transform\ns = np.arange(1., 1e3, 5.)\nxi = fft.sbt(k, pk, s) # Fast O(N log N) transform\n```\n\n### With JAX Acceleration\n\n```python\nimport numpy as np\nfrom scipy.stats import lognorm\nfrom fftlog import FFTLog\nfrom fftlog.config import set_jax_enabled\nfrom jax import jit\nimport jax.numpy as jnp\n\n# Enable JAX mode\nset_jax_enabled(True)\n\n# Create test function\nk = np.logspace(-4, 0, 200)\npk = lognorm.pdf(k, 2.1)\n\n# Initialize FFTLog (same as above)\nfft = FFTLog(\n Nmax=512, xmin=1e-5, xmax=1e3, \n bias=-0.1, complex=False, window=0.1\n)\n\n# Convert to JAX arrays and JIT compile\nk_jax, pk_jax = jnp.array(k), jnp.array(pk)\nget_coef_jit = jit(fft.Coef)\n\n# Now much faster for repeated calls\ncoefficients = get_coef_jit(k_jax, pk_jax)\n```\n\n## Features\n\n- Fast logarithmic FFT transforms\n- Support for both real and complex transforms\n- Spherical Bessel transforms\n- Anti-aliasing windows\n- Optional JAX acceleration for GPU/TPU support\n\n## Documentation\n\nFor more detailed examples and documentation, see the notebooks in the `notebooks/` directory.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "JAX-accelerated FFTLog implementation for Large Scale Structure cosmology",
"version": "0.1.2",
"project_urls": {
"Bug Tracker": "https://github.com/pierrexyz/fftlog/issues",
"Documentation": "https://github.com/pierrexyz/fftlog#readme",
"Homepage": "https://github.com/pierrexyz/fftlog",
"Repository": "https://github.com/pierrexyz/fftlog"
},
"split_keywords": [
"fft",
" logarithmic",
" transform",
" scientific",
" numerical",
" jax",
" gpu",
" acceleration"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "190f6335fea715b5f18d01f22e440814ecfc16dcd07a965f52bb87208c8893dc",
"md5": "2c04a59bb0e71ac5db40b69445de523f",
"sha256": "7e8e67ba421133e4eb252e903034a129cc5ff56279f5a10dcf956eae9a6c4b4f"
},
"downloads": -1,
"filename": "fftlog_lss-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c04a59bb0e71ac5db40b69445de523f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9703,
"upload_time": "2025-07-30T10:22:31",
"upload_time_iso_8601": "2025-07-30T10:22:31.221115Z",
"url": "https://files.pythonhosted.org/packages/19/0f/6335fea715b5f18d01f22e440814ecfc16dcd07a965f52bb87208c8893dc/fftlog_lss-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "082a398eaa7e8469dcc0c8f8f56715d66a092670ae66a911a7920605775cb1d3",
"md5": "d846c67e2cd98bb1bee26b1ef6a10e17",
"sha256": "1dbfcc12c8733f3dd7c53752487e7342ec2d60bff8f9dfd0128c11dfa5456284"
},
"downloads": -1,
"filename": "fftlog_lss-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d846c67e2cd98bb1bee26b1ef6a10e17",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 10481,
"upload_time": "2025-07-30T10:22:32",
"upload_time_iso_8601": "2025-07-30T10:22:32.468316Z",
"url": "https://files.pythonhosted.org/packages/08/2a/398eaa7e8469dcc0c8f8f56715d66a092670ae66a911a7920605775cb1d3/fftlog_lss-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 10:22:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pierrexyz",
"github_project": "fftlog",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fftlog-lss"
}