Skip to main content

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:

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

klujax-0.2.8-cp312-cp312-win_amd64.whl (109.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

klujax-0.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

klujax-0.2.8-cp312-cp312-macosx_11_0_arm64.whl (166.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

klujax-0.2.8-cp312-cp312-macosx_10_9_x86_64.whl (214.0 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

klujax-0.2.8-cp311-cp311-win_amd64.whl (109.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

klujax-0.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

klujax-0.2.8-cp311-cp311-macosx_11_0_arm64.whl (167.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

klujax-0.2.8-cp311-cp311-macosx_10_9_x86_64.whl (215.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

klujax-0.2.8-cp310-cp310-win_amd64.whl (107.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

klujax-0.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

klujax-0.2.8-cp310-cp310-macosx_11_0_arm64.whl (165.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

klujax-0.2.8-cp310-cp310-macosx_10_9_x86_64.whl (213.4 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

klujax-0.2.8-cp39-cp39-win_amd64.whl (107.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

klujax-0.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

klujax-0.2.8-cp39-cp39-macosx_11_0_arm64.whl (166.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

klujax-0.2.8-cp39-cp39-macosx_10_9_x86_64.whl (213.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

klujax-0.2.8-cp38-cp38-win_amd64.whl (107.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

klujax-0.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

klujax-0.2.8-cp38-cp38-macosx_11_0_arm64.whl (165.9 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

klujax-0.2.8-cp38-cp38-macosx_10_9_x86_64.whl (213.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file klujax-0.2.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 109.1 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

Hashes for klujax-0.2.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2fab6f5bdfb0a9e645fee31fc64f8c0c927986b93bab1f240c1a872a1161374b
MD5 f02189350f90df728c8a6a3c3778643b
BLAKE2b-256 f0bbc231aa99bf0914b3a3eaab3291340d7440a870bfa4b0ac87bed9aa95e388

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c8907be26b272446b888677eb5cb6d8402b89ca2f82ba80623d1be9bcac68f9
MD5 d4ab1647c609d7672d17f51ca2cb64ad
BLAKE2b-256 1953439df331957573882030b69418fabe715962c7541503879ebfa405d83293

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1de2458f1f7036803013c782aae590465c42a7f3e49f62b5a287fd8592477df2
MD5 3e9aebdb4f4238fb7f5a1970e947c220
BLAKE2b-256 5f6054da5d4b14a9667562ef0b50177ce2e6c6e2d780960025d0038933419e7d

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a86655887a85eca3a474b0fbceb0d1b42394cb7bbe9a9c51083aaf57a0d59a3f
MD5 bfc859a12ace1839588de2f9a32e089f
BLAKE2b-256 1402e5f942fabbd576a850d9dd0fb50489589cf42ce1e316ae3a64cd5bee61c5

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.8-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

Hashes for klujax-0.2.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 088d3a0620f0e2d78d2a0d31c13e39f6bf521285224e2f1c303c4a9e5480a23e
MD5 341a2bdac902848e9d47ebdad128bcc3
BLAKE2b-256 4e6e0f8766f1abf1fb02669a9ad85f7cc2abd9efdb564c98cc2408503f78d128

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8f6f4e689241539c31ca8ec77172eb593d3c834d1483f285dc8a6f45b508f9bc
MD5 4f026af8a4be3028feb55504c23ca923
BLAKE2b-256 71a90fac53e675b8e5d51394a7efb6ef0fc9536e722d03831b5fb57b006bd4ec

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e4b1036834cdb49a085e7d8f3bf494cae20d458931d2224fca6707a5ad11db5
MD5 191f7d6c534696026e2d39a679f4c257
BLAKE2b-256 12807e529feef48493221b765716ab0983e0d99e6bc0b6248d4d9a9d5da03fea

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d0ecf15155d6bf56ae1bce213add1f5dce32f8605b4b4083d6e84eb165a84389
MD5 16cc4be26df6cdf6050cc05379a2cf60
BLAKE2b-256 fd5bfeb03a9907016db26a3c528baf6ebbda9a31e7a8cda98b1959c8e0046fc5

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.8-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

Hashes for klujax-0.2.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e7d816f01f8cbc063d3569e1293123955d64ae76ebfbb9b1b8c165b9aa711591
MD5 348922073fdec112764224bbd8b53699
BLAKE2b-256 d69b7d3b3f55ffb8762bb6e18f618e5a410a32ba3170b3157471c2f137256d2a

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f9bfc281de46ed856ae37a65b0ffc57a86200ff6acc0c4b4e15d147e12996946
MD5 441c46ff5819ff42a13b486bc12820d8
BLAKE2b-256 609e1fc31d2d48dce4744dd82554d6a5bbfa662f71e1a05cae3f8ecc7a10cc26

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03138599f3327377c790f6658407d35cf6317560518f2e1c4adfb056f3d7ab18
MD5 639fa75935057a92219dc907084171c3
BLAKE2b-256 df244c4244af023de934168ef8214fb6ccbda6690d1f72cbc94617381f92154a

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 11715ed6e45b9b28286efa07f54edc4b0d676816aaffadbb87fcfd8144d641f0
MD5 7eab7751d9028ecfc994dc9d00885de0
BLAKE2b-256 cfc4224cc814fcf09214483e1d507cfb8340585c71a49700e0437eacfab73620

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.8-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

Hashes for klujax-0.2.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1575e44e9f60969620057dc18462e2b5e6b80bc691ca873734d556d98888b22b
MD5 652330ea011ed25fc0e6377ef186c41d
BLAKE2b-256 f044d21bebe0c5c63169cea6b9dafdeccedb13e9028982eb5529ff26d74a93aa

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf5f6ba8a681257ebff0de1a3cb34dcf993da96fe40af84236d54786cd4be14b
MD5 5c4704de807282fc48d5ef4361df9944
BLAKE2b-256 b648611168b9c07c5ccd06d401fea927f93e7494015d7827e5e8a274e78d3b95

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 828e1966c20565dd24f82340603755a5dce78632f9dca292b5aa153fc97fd32b
MD5 bb71cb6276b2851174171e96c82b9ef3
BLAKE2b-256 8bae587d79c3df350ca143d3c4f3b10050f9f446dfab512aa9466a9220d68b94

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3cd1e6b60d0471a167bd433784da9fa1ff5ceccab8d8dd4563293ce93f1cacfb
MD5 c2054d921d93a101a408c05034f39d4e
BLAKE2b-256 b4c5213bd2502c2649b843785fe464092440088ee830f8b1ebb9268e20015253

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.8-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

Hashes for klujax-0.2.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3450e192f51a42f1a13ea66c32ce8c4e584194bf241b5c87eb1e724051d2eb35
MD5 cc7b9a809f6e4bf6f7d5f352b6e774b0
BLAKE2b-256 e24a7ddec272e2fca80af4a4a4031b2a98ae54be75f350407fcf45f5d871e867

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e998b6da135469e8de82f91581f4a770e2e110495314679ceca938a7b7f1d342
MD5 ee24e2e6823457d371c260b7c8e55482
BLAKE2b-256 5b876f18a55974151a944ab7dd3f02b9b693db20d271d297d081157a5415fee7

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49bc56640792db788a6d76f5036d0cd401496d4ab4ab59963cb9e250d4611baf
MD5 eb1f02da0403320a88690d4dc5b76b5a
BLAKE2b-256 bf2bc800d4d3b142c50889d3104cb0ddcd546db372080b6441bf2dfa62b7b672

See more details on using hashes here.

File details

Details for the file klujax-0.2.8-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5a70cd43dd41b94da0df02f3480f51675ea4327c3805487e767214c96760d25d
MD5 cd480110db23bca1509c931f4042895f
BLAKE2b-256 7a462bc9ef00d04aca9cb01afd59ecd48750929e9cc923541424de99c698c3e9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page