sparsax.lu_solve

sparsax.lu_solve(Ai, Aj, Ax, b)[source]

Solve A x = b for a general (non-symmetric) sparse A via KLU.

The LU analogue of solve(): use it when A is not symmetric positive definite — e.g. A = I - rho W for a row-standardised spatial weights matrix W. Works inside @jax.jit / lax.scan; the sparsity pattern’s fill-reducing analysis is computed once and cached, and under jax.vmap the whole batch is solved in a single native FFI call.

Parameters:
Ai

[n_nz] int32 — COO row indices.

Aj

[n_nz] int32 — COO column indices. Unlike solve(), the full matrix is used (no upper-triangle folding).

Ax

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

b

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

Returns:

x with the same shape as b.

Raises:

Exception – if A is singular or holds a non-finite value (raised by the XLA runtime with the KLU failure status in the message). set_options(on_failure="nan") returns NaN instead.