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]"
Metadata
Release files for tridiax 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tridiax-0.2.1.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tridiax-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / tridiax-0.2.1.tar.gz
| Download URL | tridiax-0.2.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95a8c6d003cdd694487c99e5ba2c43d4fb4dfbe3a3df96e9ac2c80c1c4aaecd1
|
|
BLAKE2b-256 checksum How to use checksums |
5d8d55d41b1de379faf0518b8e110c656bef40e73059df4cfff51c0b72cb4928
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / tridiax-0.2.1-py3-none-any.whl
| Download URL | tridiax-0.2.1-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
311b0ed41671303197e219019fb9d22d6b31c841ddf5fdd1ec2601e09ed4e750
|
|
BLAKE2b-256 checksum How to use checksums |
15fdf69ff723a4e6534fce070acc5c50b80e739b2efb4c49ec580a629c6a3898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|