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.10-cp313-cp313-win_amd64.whl (109.2 kB view details)

Uploaded CPython 3.13 Windows x86-64

klujax-0.2.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

klujax-0.2.10-cp313-cp313-macosx_11_0_arm64.whl (166.1 kB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

klujax-0.2.10-cp313-cp313-macosx_10_13_x86_64.whl (215.7 kB view details)

Uploaded CPython 3.13 macOS 10.13+ x86-64

klujax-0.2.10-cp312-cp312-win_amd64.whl (109.2 kB view details)

Uploaded CPython 3.12 Windows x86-64

klujax-0.2.10-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.10-cp312-cp312-macosx_11_0_arm64.whl (166.1 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

klujax-0.2.10-cp312-cp312-macosx_10_13_x86_64.whl (215.6 kB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

klujax-0.2.10-cp310-cp310-macosx_10_9_x86_64.whl (213.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

klujax-0.2.10-cp39-cp39-macosx_10_9_x86_64.whl (213.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

klujax-0.2.10-cp38-cp38-win_amd64.whl (107.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 macOS 11.0+ ARM64

klujax-0.2.10-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.10-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: klujax-0.2.10-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 109.2 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

Hashes for klujax-0.2.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a72516a5daea1a920488154c0ae2a32917cc25e1ca205e6a641366a6a34e5b03
MD5 a3b01b0968f5d6a5982a111adafa4797
BLAKE2b-256 5494930e76aada70f2a5a535fd8298ea339accf3130e6f45249d1a0d993ee8e0

See more details on using hashes here.

File details

Details for the file klujax-0.2.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9bf0b2b5c0613db274058456475e7d23793e934a5eb0505b2d43a2ef4b89c1d
MD5 4975713d39d0a8c1935f03e44ba87756
BLAKE2b-256 a47d58a93ae3caa2d440e71eb05c8d1b77d5d50c915212e2df42502dc6430c06

See more details on using hashes here.

File details

Details for the file klujax-0.2.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klujax-0.2.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af237e960e915abd2cabe66d1d2881575f120c8d15e2abaa5c09cdb7743aea36
MD5 10a1aada3d78bd07e955fac7799774f0
BLAKE2b-256 ab778f9a5a10272a2606ca07b0bf9aa3d62d2f8c16a31903e481698146fd3f65

See more details on using hashes here.

File details

Details for the file klujax-0.2.10-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.10-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cd45520f03e9c5b00af287acbea92179f87ce5b1584474161cf5e2411e5672e4
MD5 d4a58c3147b1dc4713fd632849377da0
BLAKE2b-256 fac87f2da07fad559c91fc51bb1213423d9581e4587db275879e5ecd41237c50

See more details on using hashes here.

File details

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

File metadata

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

Hashes for klujax-0.2.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9aab5307dc8fe5b892635bda29171544d3ea59cb8f112f6bf1479a34e5134392
MD5 63299186289f3636e66626b0159cf640
BLAKE2b-256 49835deb13788abd0f51c822ab143b8b37e8569fc3a67dfacb9e4296ffa1bee5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1857480efb01fd3088365080a6328457515d0d8d832bcca968b340036525dff9
MD5 3669a2c9da67414bda82afdf67e1277a
BLAKE2b-256 7ccb01923ba31d236d2df704a0a17e450a11a82b1af44bfada2a91c9d3367115

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 939f13ae0c697437434c7332b4752e7252e9f1bc85df8b6f5b5143be1c54e259
MD5 ad6bde430ec24b01406d87737b2cadb1
BLAKE2b-256 7aeba2aabfc3c14a2aa53104caf45b66e37c59e479d342bae0ad28b0beee9284

See more details on using hashes here.

File details

Details for the file klujax-0.2.10-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for klujax-0.2.10-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e075a6a775a263bc7f3357f35d2d5e2c9b3a889346ce01c7809a882bd8a58c6b
MD5 1929cddbbbedefeee1e5e6b9a9f1869d
BLAKE2b-256 710c30d09807ff5ab60e8b8b9550e6593dad7486feef26e19b7df26f93f63b7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.10-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.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d7cb1e3d15bbd6dfe147ea918bc6010df7fc05dac663c24286d097fa66a9cb8d
MD5 c992a77784dd41bfda4af704a7b3cbfe
BLAKE2b-256 4be0844aa4b4774c7bce9fa8d3ca2b9cff385e2aa8e0bcd9c22e9f472f35b0c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e26316fa44846229882eb3fa28e1aede93f8d561c480a09b5c0932f91e3da92
MD5 9cb0cd1e7453d1bf90859482f18c4f56
BLAKE2b-256 0a85985577022846e34aa9b1b85a8bbb070386bcf2c6c97c9bb5e995d04f5ffe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 078d99982e2777edd98d8f467587593958821880cfbaad28920b81d35a4cc399
MD5 97be283510f76afab94abbe5fd326637
BLAKE2b-256 449ed33bb0ee6db5b577a788b1cce18ca82b7c59171dbe45accbf7b022c8e1bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cbac09971600c87415fb51cc1e209bdb9416ff73b33b6aec17572fd328d08200
MD5 3327f88f3d02b3cd97c8f971af163a26
BLAKE2b-256 69f18e650a11e9eed6112c2e7b3f45f9e15d5cdac6fea43839f60261bca1a9e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.10-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.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5c92f4b55f1a72d4aeb48eab5861f8c1edf951f19ec373d7dfe89cdb1404e127
MD5 05fc1cd547cc8fdca9860a52ed3681cb
BLAKE2b-256 821614a8fc84742458f5adc672993a21206bcba4afb94b3bc14d1fc5e1eb56b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2696a15fe819a83edcd5f3d34380456de5bdf97925a9413a13f87c1dd89f4b2f
MD5 fb77db91a6ba9c288e4a89c11b7fa5e4
BLAKE2b-256 b528f598cba15ca45b775de27ba88b76eecef8a65746a76b06ea4d9380be1c63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 257d48a068144ddf47d1cba1792432360b5c9cd3f2594fffe38dc3c2d56bb12d
MD5 9f99ae119ff857ab5299f42202aa36e1
BLAKE2b-256 7bc135716fbda061b9bc5941f76eeb7909bddc0fc3708f128c1b85df24202e29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8fbbdca92bd18bff4f6cb5e8383e6709cf5f3112db5a9deddfa15cc3011cd3d5
MD5 75d332937e181a2250485e31238c5c99
BLAKE2b-256 a116f36cf065359b48b2efc81e2c3c959e8597579d977091db52c90d6e86a008

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.10-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.10-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 99bb86c08b6c0b87bc6b96a5dc2448b743a671ed2ac9143955a725da0f6abd23
MD5 a6b378df474d5b846b1734bf11967db0
BLAKE2b-256 cfa3d6cbfbdb7f43de5c6ebf2b7a95efbc3ef2176614d7a2d6cf04598cc28b71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c62a56d43bd314bcefa93602fcf1b1095d632fdaffd6a9bc8a5675c19daabd86
MD5 df7a1650d9434ebedc8524b49c3c5639
BLAKE2b-256 0692864f6c5bef5cbc6a6146e443f6541d9bd88063915aa8e8c09b26d38e7b53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5823cc06ace158b405c74589fcd09950f3b5e76edcaba7e4acee26c0a8403d59
MD5 527e362644da797cdad8036ab91cc38f
BLAKE2b-256 e9a3b648095b335ea49c43316c109cb274660248b68bd7b38227e49b879fcfcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d87043cc57113231e04edc78ef93eec42bc0f8249f154ec86d31c748e9de9698
MD5 3bc981a361f68866e726d182e559dac4
BLAKE2b-256 830abcaa3a17e4dec629657ab3b942196d7cb2451d3712e38ba293b6ffffebe9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klujax-0.2.10-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 107.8 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.10-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2a6fa0a795469b63e4a6010561148e015ba9dd3e1e518947f3853bab35eb8330
MD5 a8479f2cfbec325594061c6c76ebde7f
BLAKE2b-256 f53882c8c5b68b67c0d02eb3c94704fc4632283d056fc0900c39fa6dc966f9ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30629851e61f144c4d28ae73328dba8ed9e7e7d65dd5115e252f54aecf4b3877
MD5 d68861f3547af9fb205952c6933d40df
BLAKE2b-256 f73d885f7f06b6690c2af440a0711be52486f205bc21bafcfd181c36389fbd69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3676f01ea94233606ac98b21bd7e0ba53801e71d071ddf9d72a67ed1b520f5b
MD5 e06aa0296a84cbc7b3613cc5a6e4b52d
BLAKE2b-256 a85daa77fab2ebe34867e0c2d6a284997e97dbb02d188cbddfd7ac1f01d9ec02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klujax-0.2.10-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6f688ee08e7f17474c2db30aef94745f195e8e7c29e8eb7ecfbbc42588a5ed72
MD5 103e493a16d4fd2a48686b9a4c63c748
BLAKE2b-256 9167816b41fc0a3bab5b012346de02d488bb20d0685057ee20c75784eaf3fdcd

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