CudAkima is a Python package that offers a parallel, GPU-accelerated implementation of Akima Splines. The code also provides CPU support. The documentation is available here, while the code is hosted on GitHub.
Akima Splines are spline interpolants that tend to show smoother behaviors with respect to the widely used Cubic Splines. On the other hand, Akima Splines have a discontinuous second derivative.
Both scipy and cupy already offer implementations of Akima Splines. However, in these versions, the NaN values and stacking them into multidimensional arrays.
In this implementation, the coefficients of the polynomials used for the interpolation are not stored in memory. For this reason, the package is particularly suited for applications where the arrays to perform the interpolation on keep changing (e.g., when doing parameter estimation on the location and amplitude of the spline knots). In this specific case, where scipy (cupy) by a factor of
The interpolation scheme needs at least 4 finite points to work successfully. This caveat is due to the current boundary conditions. If this condition is not met (ie, the interpolation grid is made of less than 4 points), linear interpolation is used instead.
Here is a quick example of how to get started with the package:
from cudakima import AkimaInterpolant1D
interpolant = AkimaInterpolant1D()
Check out the examples directory for more info and comparisons.
CudAkima depends only on numba and numpy. It also requires cupy to be used on GPUs.
This project is managed by uv. uv can be installed with:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# or with Homebrew
brew install uv
# or with pipx
pipx install uv
To set up the development environment, first clone the repository:
git clone https://github.com/asantini29/CudAkima.git
cd CudAkima
uv sync
This will create a virtual environment and install all necessary dependencies. Run your commands within this environment using
uv run <YOUR-COMMAND>
We use SemVer for versioning.
Current Version: 0.2.2
- Alesandro Santini
Get in touch if you would like to contribute!
- extend documentation.
- look at different boundary conditions.
- work on a possible 2D interpolation.
This project is licensed under the MIT License - see the LICENSE.md file for details.
If you use CudAkima in your research, you can cite it in the following way:
@software{cudakima_2024_13919394,
author = {Alessandro Santini},
title = {asantini29/CudAkima: First official release},
month = oct,
year = 2024,
publisher = {Zenodo},
version = {v0.2.2},
doi = {10.5281/zenodo.13919394},
url = {https://doi.org/10.5281/zenodo.13919394}
}
We thank Nikolaos Karnesis for discussions.