Solving tridiagonal systems.
Project description
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
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 tridiax-0.2.0.tar.gz.
File metadata
- Download URL: tridiax-0.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2fad526e982b2acfa5b7ce7d4014b1918aeb171315994f13571c7443d10a461
|
|
| MD5 |
29844c3a8635fe59b9965e5711b098c8
|
|
| BLAKE2b-256 |
6e5ee35a7255b5fd5bf465a205eaa10126aa3b0ab634873d1cf4675f7e57ffee
|
File details
Details for the file tridiax-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tridiax-0.2.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f5209b27fc90317df0df96c3ee8ca3b7c86cf6dd957b21605411cb5bd8faba
|
|
| MD5 |
56f05abaca370acf37f8696e06d85452
|
|
| BLAKE2b-256 |
1afa7f6c2fcc31aca498c08b63ce1b5ed3c354643ee1429dd3460dfc9abbc992
|