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.7-cp312-cp312-win_amd64.whl (109.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

klujax-0.2.7-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.7-cp312-cp312-macosx_11_0_arm64.whl (166.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

klujax-0.2.7-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.7-cp311-cp311-win_amd64.whl (109.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

klujax-0.2.7-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.7-cp311-cp311-macosx_11_0_arm64.whl (167.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

klujax-0.2.7-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.7-cp310-cp310-win_amd64.whl (107.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

klujax-0.2.7-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.7-cp310-cp310-macosx_11_0_arm64.whl (165.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

klujax-0.2.7-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.7-cp39-cp39-win_amd64.whl (107.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

klujax-0.2.7-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.7-cp39-cp39-macosx_11_0_arm64.whl (166.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

klujax-0.2.7-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.7-cp38-cp38-win_amd64.whl (107.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

klujax-0.2.7-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.7-cp38-cp38-macosx_11_0_arm64.whl (165.9 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

klujax-0.2.7-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.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 521c30503fb3a6c3cc5216189b6a5b35ad2dc8a672d8bf6ed6717ab4ccdfd02b
MD5 770e632e8aba033e8f4dfc1722169651
BLAKE2b-256 1822d2176ad233a99a6cb12a54d4d04fad19c7f11cac2d08015ae94ac4637958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d068fec039f298b75547c16eea15be0bb824b5ca091168116b38e1ea6185797f
MD5 33e46d674de6831ea195dacedd0930f0
BLAKE2b-256 14d93909c098ffacfc21f80f7448342502787b8204f81201f0977ab0d9b9d927

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 297fee4ca037cec6fbba672659e9ed406f1fe07ff64c0dc028faf60f5940124c
MD5 6cc674c84deb1829d0b1aaa1754323fb
BLAKE2b-256 2d2f69b0189fecce631cf6d9771ab7f396a91b3b7187ca3c56e9346518f636de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dfa52a5570ec53d53ede30df1566a68b40387aec52a32430d84e6f90a5014440
MD5 e8a9854b4e851af4d99becfebd88c92e
BLAKE2b-256 75c7f24dc02ab040d3e880d0feb48cc59406c5043c42c473731a0c576b6c773d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f648e1ec4cfbe71b3cfa005c399d3c1e312fb52833d3477f27877a4fece66674
MD5 7b5484bb26aa3619c75138a337d06f63
BLAKE2b-256 d38dcceed5c05d465bb2b21e505761508c2e39d41b7bc093ebd5a012b5ec834c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb777dcb3ae9688ffa4ba90d22b5188f570bd848215dff4df471418a3a3d709c
MD5 88747641e0ee4d84ca60cb368d6c24cb
BLAKE2b-256 803d9b418f0a4acc8c7bcb5a0649d5e06201ef23dff5bc9d08776e09f1ea06ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33cd5daa9596bbdee1b1b58e80f86eefbd27fc477af5a739b7ce195ca54285d8
MD5 bb3f3b45e967896b51455477d3f0e978
BLAKE2b-256 8f5e6a0ee737944244aa5d80a33b7463968bab23fb474bd075f76cb819cc8eff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3e3939b34c31854afb57356d5293bf20353e4b87755f616c4d3a1a6f4dcc9b51
MD5 3e1b428d165bf5ec88356e5d766f38c0
BLAKE2b-256 f389d5a4420a80f384262a6c010daa2af2849841f1b81767364b150569ec03af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.7-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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9d77b03ca26dfdd9a1eb9cb2e9f538d26d1798d658641051268f2a9d6802d971
MD5 12f9fa4f6cef20547dc0177f123dd7b8
BLAKE2b-256 098fe8ccec45c4161f975e45c37a1876ae970ff4ce61e2a71bdc447de5ceda1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9de243c6b9b68d6d890257e6f920d77d39d69faea62a6dace62fc07383fddffc
MD5 a2a8ebd87ecec264dcb4e9e03e96a81a
BLAKE2b-256 304a24b39ab800ab4466f9b042410e7e1962f8f3d3d32f2e604120e1b3534858

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 525163574d8628010296493a1670d9469ab618caaae3a1f98a8abe4f2bd0269e
MD5 2555fd0a309ab39febf3742eda2b382b
BLAKE2b-256 3a1afed7ae8c4c7ee29fdabddd978014347165aea0d321b3b01c562685fd91c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 874e24d4c23a303897d964d060a253025ac2fcbb845b9871fd09494f1a5906ce
MD5 07a60ce9d3d3399c229359f31961d432
BLAKE2b-256 23ec731c4ad0b9c650d8878f2d6636dce085a51b6c30c0ea4654e89349a0fb56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.7-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.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 129027c8ed9097dde58513a25a4d4732e0927c05e3c00b5a347760e9a77e9e35
MD5 7fb9264182b66f8efa86e0727e03fdc5
BLAKE2b-256 549d7c321aead8a59cb33c5bc0ff6972ac7c1b8b49c0ada939d225eadc19a1cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e85666e6572b613367804df78f235851577130bf4e2620315f6c774ed1a60e0f
MD5 632ae74f2f44997eab58056472cb86e1
BLAKE2b-256 71b7ec89a499ac7d3e5c209523f615d9a327dcdb4fa7c71e731a98dbddc86ba2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90084fd9f194f1d16b715ee814e852997e255c74f2ee7a800b1508602482f988
MD5 1944c1ca061e728148387b58d56d8d0c
BLAKE2b-256 3c7ba471ab110aa15a2900324f23b4b2f6e64f2478c9fa132c2b5e964a163fe5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53a24e954b7e7c9d5ec754d7dbed203550d58c28465f988e0014f22604252df8
MD5 a1e9759d3713395d956f3e2cd1c835da
BLAKE2b-256 3014426d91da2bf628d44966283d2c217c54316e534ca1a859a294c51529fbc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.7-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.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6aa439179c4fa1af52bdfb140ae0185507c00e7cda69a0c8103ee56fdd164009
MD5 8fef3c06e0f38885fa29aa59612d617c
BLAKE2b-256 f86722793ab7841ea4def69e40b78d3ebf873c3197e30e645ee024aaa5a26dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae4387059c2ab39dd82dd1423954c59e029d9c46676f9db93589c9a29e9e39e3
MD5 f126816a729f7ca148947ae2ca86c991
BLAKE2b-256 67af45f0845f7b9e250277a23e428bfa1a9364e748fca933f94e683940a8821d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 537beaccca976ae775d1fcab423b751daaf87fffaa7c837143a4364466fb9a2c
MD5 2be4edb39aa240e47585e6abce412b41
BLAKE2b-256 1858b25007c5e90d6d313a5bfd0f6db33300ab0b188c0ba6d18e5bf82c119e4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 95775f98ae9c3482b56b4e1d8d0e6886b35d773ac2920b4a722047d956d76f54
MD5 adfe36c9d50ad7cc39e17c48ea8eafb2
BLAKE2b-256 266cb40741a19c76ef2101213c877d519a0980712968d6cc9bde925e3a5e7fdc

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