sparsax.solve

sparsax.solve(Ai, Aj, Ax, b, mode=0)[source]

Solve A x = b for symmetric positive definite sparse A.

Works inside @jax.jit; the sparsity pattern’s symbolic analysis is computed once and cached across calls.

Parameters:
Ai

[n_nz] int32 — COO row indices.

Aj

[n_nz] int32 — COO column indices. Entries with Ai > Aj are ignored (the matrix is taken from the upper triangle).

Ax

[n_nz] float64 — COO values. Duplicates are summed.

b

[n] or [n, n_rhs] float64 — right-hand side(s).

mode=0

which system to solve, one of the MODE_* constants. MODE_A (default) solves A x = b; other modes expose the factor parts (e.g. MODE_LT for L^T x = b).

Returns:

x with the same shape as b.

Raises:

Exception – if the matrix is not positive definite (raised by the XLA runtime with the CHOLMOD failure column in the message). set_options(on_failure="nan") returns NaN instead.