a KLU solver for JAX
Project description
KLUJAX
A sparse linear solver for JAX based on the efficient KLU algorithm.
CPU & float64
This library is a wrapper around the SuiteSparse KLU algorithms. This means the algorithm is only implemented for C-arrays and hence is only available for CPU arrays with double precision, i.e. float64 or complex128.
Note that this will be enforced at import of klujax
!
Usage
The klujax
library provides a single function solve(A, b)
, which solves for x
in
the linear system Ax=b
A is a sparse tensor in COO-format with shape mxm
and x and b
have shape mxn
. Note that JAX does not have a native sparse matrix representation and
hence A should be represented as a tuple of two index arrays and a value
array: (Ai, Aj, Ax)
.
import jax.numpy as jnp
from klujax import solve
b = jnp.array([8, 45, -3, 3, 19], dtype=jnp.float64)
A_dense = jnp.array([[2, 3, 0, 0, 0],
[3, 0, 4, 0, 6],
[0, -1, -3, 2, 0],
[0, 0, 1, 0, 0],
[0, 4, 2, 0, 1]], dtype=jnp.float64)
Ai, Aj = jnp.where(jnp.abs(A_dense) > 0)
Ax = A_dense[Ai, Aj]
result_ref = jnp.linalg.inv(A_dense)@b
result = solve(Ai, Aj, Ax, b)
print(jnp.abs(result - result_ref) < 1e-12)
print(result)
[ True True True True True]
[1. 2. 3. 4. 5.]
Installation
The library is statically linked to the SuiteSparse C++ library. It can be installed on most platforms as follows:
pip install klujax
There exist pre-built wheels for Linux and Windows (python 3.8+). If no compatible wheel is found, however, pip will attempt to install the library from source... make sure you have the necessary build dependencies installed.
Linux
On linux, you'll need gcc
and g++
. Then just do a normal pip install:
pip install klujax
Windows
On Windows, installing from source is a bit more involved as typically the build dependencies are not installed. To install those, download Visual Studio Community 2017 from here. During installation, go to Workloads and select the following workloads:
- Desktop development with C++
- Python development
Then go to Individual Components and select the following additional items:
- C++/CLI support
- VC++ 2015.3 v14.00 (v140) toolset for desktop
Then, download and install Microsoft Visual C++ Redistributable from here.
After these installation steps, run the following commands inside a x64 Native Tools Command Prompt for VS 2017:
set DISTUTILS_USE_SDK=1
pip install klujax
License & Credits
© Floris Laporte 2022, LGPL-2.1
This library was partly based on:
- torch_sparse_solve, LGPL-2.1
- SuiteSparse, LGPL-2.1
- kagami-c/PyKLU, LGPL-2.1
- scipy.sparse, BSD-3
This library vendors an unmodified version of the SuiteSparse libraries in its source (.tar.gz) distribution to allow for static linking. This is in accordance with their LGPL licence.
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 Distributions
Built Distributions
File details
Details for the file klujax-0.2.9-cp313-cp313-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 109.1 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9361ec3bdcbbf1dd8206bd25b240c4826132f0cb8135a42143c7d28688c1ebff |
|
MD5 | 5cbcbcd4041dc730e22cc71fcb00d6c3 |
|
BLAKE2b-256 | 7fb4e8633f5c4d0559e0dcfb6f20eef993393564967f826555233498fe702956 |
File details
Details for the file klujax-0.2.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bf7ba59ca902581ed9ba853018d18b057260dfa9ee41e287c9e94140132b5dc |
|
MD5 | 5d37657e273886a09ac33f46e34ade8d |
|
BLAKE2b-256 | 79fa9d8719a22706076eaca1593010db5755c147e46219d2968f44adbdb65671 |
File details
Details for the file klujax-0.2.9-cp313-cp313-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 166.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53c4ee4927f98f3913aec2d09e95ed4fc81cba9af4e3b163cc707548e3cf209f |
|
MD5 | c1c7879ce657b1e2398379dae4bbe9ce |
|
BLAKE2b-256 | bfde7f3efe35be332273203dfef494603c5177cc0da76639157f3565ac06fc02 |
File details
Details for the file klujax-0.2.9-cp313-cp313-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp313-cp313-macosx_10_13_x86_64.whl
- Upload date:
- Size: 215.7 kB
- Tags: CPython 3.13, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 190ff143b0819ed61e34eda4e7d52a9362b0a2b9a49abaaa78569837d3e17daf |
|
MD5 | 4558e517ec9347139ce20075ec89fc2e |
|
BLAKE2b-256 | 562b705f938504d92125578ce0fa9882a60ee77df23f380a7d93d2f959475532 |
File details
Details for the file klujax-0.2.9-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 109.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd7de2bd567a9cdaa242868dbecfa9182da523b6d8d267f97e04d4c83e9af6f7 |
|
MD5 | e1ed284c2741e926d399a8ac00106750 |
|
BLAKE2b-256 | c4e7021517e4ef4747ed5d5367e7556c0484ab30256ef2476ac6067459a72f04 |
File details
Details for the file klujax-0.2.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b94a204ffcffe5233ac9c615577da253e7882ff2281c45627a44e069655e0af |
|
MD5 | 0dc142784e4d0d5413280cd65ca7425e |
|
BLAKE2b-256 | 9ba1e32bf69465efd929d2f793f882789a50a1fb24e14f3083570a3346817544 |
File details
Details for the file klujax-0.2.9-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 166.0 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8071edba947e8fb6f3b191f1658c393e62e258581f246184fdbedf26812eb3e |
|
MD5 | 18ce7605691ef6ea4569c87152b04277 |
|
BLAKE2b-256 | d80f5d032d89b815a261edda8f75cdf23ba00fb7db9aa3da0731ffa33a05ced9 |
File details
Details for the file klujax-0.2.9-cp312-cp312-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 215.6 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09cfa7709e72336bd600f7eb9f5a85bdf9cde8af624e5e4361c31be3a6d77953 |
|
MD5 | c831c13ee7a86401cabe8b2d7d55eb0d |
|
BLAKE2b-256 | 981f405209ce3731d3d2a30dd6cc63bc23e20c69ff26ca2626296fce42e44c67 |
File details
Details for the file klujax-0.2.9-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 109.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e10accb3b93172a22d2a304aa1c0e4b122111ea6283c00361d7faed52ab42e42 |
|
MD5 | 754e5889bc72d335ffaba8b2d837e4e9 |
|
BLAKE2b-256 | 2635bad4042b9b190c666edeade5ec590f59147044451bdcfcc6fd9b17797a4d |
File details
Details for the file klujax-0.2.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30a152541bed650c7891ae8abc9778396b5cfe8f2cbbf72bfd5633d69470bf9b |
|
MD5 | 1a95c0e7606653df2832d996c6735968 |
|
BLAKE2b-256 | 7426ab0759128fc84c5fe087457a6549bba9936207cfe73b7629367ead67e6b4 |
File details
Details for the file klujax-0.2.9-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 167.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef88fa23ed3dc407aa6ac683f2935f371f3a7a462b0f941f24c78c16152e985 |
|
MD5 | f951d049c4353c5a8339a5cfdd63a9d3 |
|
BLAKE2b-256 | 36cec7821eca16603ffdccbd57433451d3f1d552d08b2f53b3893ba765fe2e94 |
File details
Details for the file klujax-0.2.9-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 215.0 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11a51c35c9ebd72bcec781388abd7de91ab49ddc85a6ef0606a469cb69a8afb5 |
|
MD5 | f48c5bb72e23ae552ed2c8ce0cf518cd |
|
BLAKE2b-256 | f938f2e62105f3576ccebf6163fe602c5a44b655f0ab415c1c4b92143ae5c0b3 |
File details
Details for the file klujax-0.2.9-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 107.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa2ce6c68eccc463de3a723c80d0caf30e7637a2f312329639e93104135a346a |
|
MD5 | 98fae663391beda8ec82bd2341183908 |
|
BLAKE2b-256 | 8dd73c95c7eca0bdf0ee6546e53c5e0ad32831436fc287cfe16c572b12429b5b |
File details
Details for the file klujax-0.2.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62b223442a8345ed4d6c65d580e9597342ac3942d4fd28aa06fce3db4cc8c80c |
|
MD5 | d09e019b2ff397a8113038cc2a119c7c |
|
BLAKE2b-256 | e61f296aff8a7c30dbbaa32ac9f388612784a401af70d949d0d2968cc30cfbd0 |
File details
Details for the file klujax-0.2.9-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 165.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4539ee4ec3fa6197f632a27485f0d31deec4bad2bda060c3771172e951c6eecb |
|
MD5 | 0676d5a4186e4cf3b0b791e141dcd72d |
|
BLAKE2b-256 | 55da9862660800ae67d910c89ace89b8d8a6c1e553b2b298dfb3fa22b954b7e7 |
File details
Details for the file klujax-0.2.9-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 213.4 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 089aa5e737ba6be456ab2d29c04d07dc779c43503b4c85e006a513665ce4cdb3 |
|
MD5 | b76a108a065df2118fe1b3cdacec158e |
|
BLAKE2b-256 | 01925a2e6a8340f52f28afa218402483cae50aff0ab2c2f3bccb552f349b5b34 |
File details
Details for the file klujax-0.2.9-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 107.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91d907ff65efad5d65bac720f92d5a7a962f09f760a8da0faffd6135f8a7be6e |
|
MD5 | efd00deb33c5b8fad9f377dc97368ae2 |
|
BLAKE2b-256 | ccb04d4e39b35fe823e24b63e0bb70361d5acb3bd23ec6da1997178ab7df1fd9 |
File details
Details for the file klujax-0.2.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b956c11e7d73312998b8293641134a779f9bf4468e56a026622a86bace4bf9 |
|
MD5 | 6180a87c34647bb7cbcd6040325631fa |
|
BLAKE2b-256 | 6c828f315afec7f3719308b6b19a62ebf1caaca802fc5cd3c371a0387a6e48fc |
File details
Details for the file klujax-0.2.9-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 166.0 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcccbd1770401a6186204e57d43575fe4a36905d71fe17913f7df25ec061cac7 |
|
MD5 | 54e7673db696b93ab3f47c6263e19539 |
|
BLAKE2b-256 | e95db07d73b516e56b598e3900c104d17c2bd673206970c569aeba21712bc3ea |
File details
Details for the file klujax-0.2.9-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 213.5 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f7b86ac070c4e92f2ec4c7db3c2b8b64dead47aca3fee4ad0b3d7fa860cdd86 |
|
MD5 | 7426a0f65408a9f563fc85948bfdc2df |
|
BLAKE2b-256 | 240435e39bf93e4507e7857de81d235fdb8a7d591d2a18d45e851171f3df552d |
File details
Details for the file klujax-0.2.9-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 107.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fa9aa1536c35f5915da33119c1b1671cb92147d0e50117ea04d3d587abedb9f |
|
MD5 | f90ea867fbeb0f71efd80d8fb39f6ada |
|
BLAKE2b-256 | 2aa52b1e8faee21126d834451d9adb0eaa042d8d8c151756ddc16910e1f9bf0f |
File details
Details for the file klujax-0.2.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec9c9d2d1d94deed626d9f34f693f4d1454604cbf14e1c9f8674575193c2549a |
|
MD5 | ac6b1821efc26d667b46571ee33b9af0 |
|
BLAKE2b-256 | 1d618435193480ee2fd143a74390a2d1c7715a1601cf3d9bd69480b415571c4b |
File details
Details for the file klujax-0.2.9-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 165.9 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2727b7c5f685faca5452e83a2cd987473ab0d34d59328b5b85fd70e6f18c36d |
|
MD5 | 922ad3b76bd25eadb8181803991285f4 |
|
BLAKE2b-256 | 826c104fcb8dae4eaa0302b6292d50c9f10fa1fa9750fdbdfa1ed82018fb3d59 |
File details
Details for the file klujax-0.2.9-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: klujax-0.2.9-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 213.4 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42566e5ee8ac51af8d363c58676459e3a914b1c0e620a4fa0db18b354b3f30c9 |
|
MD5 | 16a77cc610f2252e09512fede6bb1a5e |
|
BLAKE2b-256 | 5301e68ec200933e60ac9cc8a107b9863fa8c626b7c792d50548be61585305c6 |