Skip to main content

splineax

Sparse linear operators and direct solvers for Lineax.

splineax lets you keep a linear system in its native sparse storage (jax.experimental.sparse.BCOO / BCSR) and solve it with a sparse direct solver that plugs straight into lineax.linear_solve. It also interfaces with asdex for calculating sparse Jacobians and using them as operators.

  • Operators: BCOOLinearOperator, BCSRLinearOperator, SparseJacobianLinearOperator.
  • Solvers: Spsolve (any backend), KLU (CPU-only, SuiteSparse, factorization reuse), and AutoSparseLinearSolver (picks one based on the platform).
  • A SparseLinearSolver protocol for separating factorization from solving.

Installation

pip install splineax

Example

Solve a 10000 x 10000 system. As a dense matrix it would need 10^8 entries, but kept sparse it has only ~3 x 10^4 nonzeros, and the solver never materialises the dense form.

import jax.numpy as jnp
import lineax as lx
import numpy as np
from jax.experimental.sparse import BCOO

import splineax as splx

n = 10000
np.random.seed(0)

# A large, randomly sparse matrix with a heavy diagonal (so it is invertible).
diagonal_indices = np.stack([np.arange(n), np.arange(n)], axis=1)
off_diagonal_indices = np.unique(np.random.randint(0, n, size=(2 * n, 2)), axis=0)
indices = jnp.concatenate([diagonal_indices, off_diagonal_indices])
values = jnp.concatenate(
    [
        np.full(n, float(n)),
        np.random.uniform(low=-1, high=1, size=off_diagonal_indices.shape[0]),
    ]
)
matrix = BCOO((values, indices), shape=(n, n)).sum_duplicates()

operator = splx.BCOOLinearOperator(matrix)
vectors = [jnp.ones(n), jnp.arange(n) % 2]
solver = splx.AutoSparseLinearSolver()

# Calculate factorization once...
with solver.factorize(operator) as factorized_state:
    # ...and reuse for multiple solves.
    solution = lx.linear_solve(
        operator, vectors[0], solver=solver, state=factorized_state
    )
    assert jnp.allclose(matrix @ solution.value, vectors[0], atol=1e-4)

    solution = lx.linear_solve(
        operator, vectors[1], solver=solver, state=factorized_state
    )
    assert jnp.allclose(matrix @ solution.value, vectors[1], atol=1e-4)

Documentation

Build the docs locally with uv run mkdocs serve, or view the user guide and API reference here.

Download files

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

Source Distribution

splineax-0.2.3.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

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

splineax-0.2.3-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file splineax-0.2.3.tar.gz.

File metadata

  • Download URL: splineax-0.2.3.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for splineax-0.2.3.tar.gz
Algorithm Hash digest
SHA256 fd20ad402dcfa2ade3d74e0df9de9f608b05140900fba3db7f47a3613223066b
MD5 a1b0ef88e6a0e592a92061269b8a0ff0
BLAKE2b-256 2884a7323066c6ece7e48877af3709c51f61c57fc82ff8dde62f6653604fe5d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for splineax-0.2.3.tar.gz:

Publisher: release.yml on nardi/splineax

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

File details

Details for the file splineax-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: splineax-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for splineax-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ea98528a54c07f28db8942cfb04b6220a531112372d086d78dce864bd74970cf
MD5 5c7e38ba69e3f0f2fc51f68ad55e6a86
BLAKE2b-256 62a53e9ae281f6e425b15fad25cc06394291973e961b542f56f745a06ac9d232

See more details on using hashes here.

Provenance

The following attestation bundles were made for splineax-0.2.3-py3-none-any.whl:

Publisher: release.yml on nardi/splineax

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

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.3 This release

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page