Skip to main content

Very minimal and straightforward cubic interpolation on splines in JAX. Pure differentiable JAX.

Project description

cinx

tests PyPI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cinx-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cinx-0.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for cinx-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c52b9a3c4543ef073daf85946fd83a14d5ff4c82745cdbdb93fa7426dd51c0fd
MD5 ff748fbbb639c0f0763572baa8d56e58
BLAKE2b-256 7d2d0e7d4d61f1682ef0f3f94e92598ae3a83a2909426c34c5db23476034728e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cinx-0.0.1.tar.gz:

Publisher: publish.yml on alonfnt/cinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for cinx-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 389f541a298787b4cde2255a09069db703d8b99ba2e59039a3996c91abdc0d47
MD5 3e4503803fc70c326b6e6298b9827116
BLAKE2b-256 a4904ae8ec784151dee06b86c674b9b89de58ce9beaf8777b46db1edd1114978

See more details on using hashes here.

Provenance

The following attestation bundles were made for cinx-0.0.1-py3-none-any.whl:

Publisher: publish.yml on alonfnt/cinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page