sparsax.lu_factor

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

Factor general (non-symmetric) A once via KLU, return a token.

The non-symmetric counterpart of factor(). The token is an opaque int64[2] array carrying a strong reference to a KLU numeric factor held in the extension’s token table. Pass it to lu_solve_factor() and lu_logdet_factor() to issue an unbounded sequence of solves and a logdet against the same factor — no refactoring and no per-call re-hash of Ax. The per-pattern LRU cannot evict the factor while the token is live.

This is the recurrence primitive that lu_solve() cannot express: V_{j+1} = A^{-1}(G V_j) (a shift-invert Krylov basis for a non-symmetric A) needs the previous solve’s output as the next solve’s input, which a single fused call cannot represent.

Not differentiable. Use lu_solve() when gradients are needed.

Parameters:
Ai

[n_nz] int32 — COO row/column indices (full matrix).

Aj

[n_nz] int32 — COO row/column indices (full matrix).

Ax

[n_nz] float64 — COO values.

n

matrix dimension (static Python int).

Returns:

Factor — an opaque int64[2] token. Not meant to be inspected; pass to lu_solve_factor() / lu_logdet_factor().