Very minimal and straightforward cubic interpolation on splines in JAX. Pure differentiable JAX.
Project description
cinx
cinx is a minimal, non-nonsense library for differentiable and fast cubic spline interpolation in JAX.
It's designed to be fully JAX-native, supporting GPU/TPU/CPU execution, and allowing you to backpropagate through your interpolation steps for seamless integration into your machine learning workflows.
Usage
cinx provides a straightforward interp function that handles both single-variable and multi-variable interpolation.
Its pure JAX design means you can trivially use JAX transformations like jax.vmap for batch processing and jax.grad for gradient calculations.
Basic 1D Interpolation
import cinx
import jax.numpy as jnp
xp = jnp.linspace(0, 1, 5)
fp = jnp.sin(xp * jnp.pi)
x = jnp.linspace(0, 1, 100)
f = cinx.interp(x, xp, fp)
Multi-variate Interpolation
import jax.numpy as jnp
from cinx import interp
theta = jnp.linspace(0, 2 * jnp.pi, 5)
X_data = jnp.stack((theta, jnp.sin(theta)), axis=-1)
fp = jnp.dot(X_data, rot_matrix(jnp.pi / 4).T)
xp = jnp.linspace(0, 1, len(fp))
x = jnp.linspace(0, 1, 100)
f = interp(x, xp, fp)
Batch Interpolation
import jax
import jax.numpy as jnp
from cinx import interp
theta = jnp.linspace(0, 2 * jnp.pi, 5)
rot_matrix = lambda a: jnp.array([[jnp.cos(a), -jnp.sin(a)],
[jnp.sin(a), jnp.cos(a)]])
X_data = jnp.stack((theta, jnp.sin(theta)), axis=-1)
angles_batch = jnp.linspace(0, 2 * jnp.pi, 10)
fp = jnp.stack([jnp.dot(X_data, rot_matrix(a).T) for a in angles_batch], axis=0)
xp = jnp.linspace(0, 1, len(fp[0]))
x = jnp.linspace(0, 1, 100)
interp_vmap = jax.vmap(interp, in_axes=(None, None, 0))
f = interp_vmap(x, xp, fp)
Installation
cinx can be installed from PyPI via pip:
pip install cinx
Citation
You don't have to, but if you use cinx in your research and need to reference it, please cite it as follows:
@software{alonso_zdyb_cinx,
author = {Alonso, Albert and Zdyb, Frans},
title = {cinx: Minimal Cubic Spline Interpolation in JAX},
url = {https://github.com/alonfnt/cinx},
version = {0.0.1},
year = {2025}
}
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 cinx-0.0.1.tar.gz.
File metadata
- Download URL: cinx-0.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c52b9a3c4543ef073daf85946fd83a14d5ff4c82745cdbdb93fa7426dd51c0fd
|
|
| MD5 |
ff748fbbb639c0f0763572baa8d56e58
|
|
| BLAKE2b-256 |
7d2d0e7d4d61f1682ef0f3f94e92598ae3a83a2909426c34c5db23476034728e
|
Provenance
The following attestation bundles were made for cinx-0.0.1.tar.gz:
Publisher:
publish.yml on alonfnt/cinx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cinx-0.0.1.tar.gz -
Subject digest:
c52b9a3c4543ef073daf85946fd83a14d5ff4c82745cdbdb93fa7426dd51c0fd - Sigstore transparency entry: 263013846
- Sigstore integration time:
-
Permalink:
alonfnt/cinx@c692daf5f5c7d37a55b2283a3cb768131f5f9189 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alonfnt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c692daf5f5c7d37a55b2283a3cb768131f5f9189 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cinx-0.0.1-py3-none-any.whl.
File metadata
- Download URL: cinx-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
389f541a298787b4cde2255a09069db703d8b99ba2e59039a3996c91abdc0d47
|
|
| MD5 |
3e4503803fc70c326b6e6298b9827116
|
|
| BLAKE2b-256 |
a4904ae8ec784151dee06b86c674b9b89de58ce9beaf8777b46db1edd1114978
|
Provenance
The following attestation bundles were made for cinx-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on alonfnt/cinx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cinx-0.0.1-py3-none-any.whl -
Subject digest:
389f541a298787b4cde2255a09069db703d8b99ba2e59039a3996c91abdc0d47 - Sigstore transparency entry: 263013850
- Sigstore integration time:
-
Permalink:
alonfnt/cinx@c692daf5f5c7d37a55b2283a3cb768131f5f9189 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alonfnt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c692daf5f5c7d37a55b2283a3cb768131f5f9189 -
Trigger Event:
workflow_dispatch
-
Statement type: