Skip to main content

Solving tridiagonal systems.

Project description

Tests

tridiax

tridiax implements solvers for tridiagonal systems in jax. All solvers support CPU and GPU, are compatible with jit compilation and can be differentiated with grad.

Implemented solvers

Generally, Thomas algorithm will be faster on CPU whereas the divide and conquer algorithm and Stone's algorithm will be faster on GPU.

Known limitations

Currently, the divide_conquer solver only supports systems whose dimensionality is a power of 2.

Usage

from tridiax import thomas_solve, divide_conquer_solve, stone_solve

dim = 1024
diag = jnp.asarray(np.random.randn(dim))
upper = jnp.asarray(np.random.randn(dim - 1))
lower = jnp.asarray(np.random.randn(dim - 1))
solve = jnp.asarray(np.random.randn(dim))
solution = thomas_solve(lower, diag, upper, solve)

If many systems of the same size are solved and the divide and conquer algorithm is used, it helps to precompute the reordering indizes:

from tridiax import divide_conquer_solve, divide_conquer_index

dim = 1024
diag = jnp.asarray(np.random.randn(dim))
upper = jnp.asarray(np.random.randn(dim - 1))
lower = jnp.asarray(np.random.randn(dim - 1))
solve = jnp.asarray(np.random.randn(dim))

indexing = divide_conquer_index(dim)
solution = divide_conquer_solve(lower, diag, upper, solve, indexing=indexing)

Installation

tridiax is available on pypi:

pip install tridiax

This will install tridiax with CPU support. If you want GPU support, follow the instructions on the JAX github repository to install JAX with GPU support (in addition to installing tridiax). For example, for NVIDIA GPUs, run

pip install -U "jax[cuda12]"

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

tridiax-0.2.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

tridiax-0.2.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file tridiax-0.2.1.tar.gz.

File metadata

  • Download URL: tridiax-0.2.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tridiax-0.2.1.tar.gz
Algorithm Hash digest
SHA256 95a8c6d003cdd694487c99e5ba2c43d4fb4dfbe3a3df96e9ac2c80c1c4aaecd1
MD5 e6766c0167a3ce5780be6222e4e76c96
BLAKE2b-256 5d8d55d41b1de379faf0518b8e110c656bef40e73059df4cfff51c0b72cb4928

See more details on using hashes here.

File details

Details for the file tridiax-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tridiax-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tridiax-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 311b0ed41671303197e219019fb9d22d6b31c841ddf5fdd1ec2601e09ed4e750
MD5 a7bde90843e9a656b11d87da677781a8
BLAKE2b-256 15fdf69ff723a4e6534fce070acc5c50b80e739b2efb4c49ec580a629c6a3898

See more details on using hashes here.

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