sparsax.lu_logdet

sparsax.lu_logdet(Ai, Aj, Ax, n)[source]

Log-determinant of a general (non-symmetric) sparse matrix via KLU.

The non-symmetric counterpart of logdet(): computes log|det(A)| from the KLU factor’s U diagonal (plus the row-scale correction), an O(n) C-side sum. 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; shares the per-pattern LRU factor cache with lu_solve(), so a lu_solve and a lu_logdet with identical values factorize only once.

Not differentiable (the non-symmetric logdet gradient is the full selected inverse, which KLU does not expose). Use logdet() for symmetric A when a gradient is needed.

Parameters:
Ai

[n_nz] int32 — COO row/column indices (full matrix, no upper-triangle folding, unlike logdet()).

Aj

[n_nz] int32 — COO row/column indices (full matrix, no upper-triangle folding, unlike logdet()).

Ax

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

n

matrix dimension (static Python int).

Returns:

Scalar float64 log(abs(det(A))).

Raises:

Exception – if A is singular or holds a non-finite value. set_options(on_failure="nan") returns NaN instead.