sparsax.selinv

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

Selected inverse: entries of A^{-1} at A’s sparsity pattern.

Returns z with z[k] == (A^{-1})[Ai[k], Aj[k]], computed by Takahashi’s recurrence on the Cholesky factor without ever forming the dense inverse: one dense block at a time on a supernodal factor, one column at a time on a simplicial one. Shares the factorization cache with solve() / logdet().

This is the quantity logdet()’s reverse-mode rule uses (d log|A| / dA = A^{-1}), exposed directly because the selected inverse is useful on its own — e.g. posterior marginal variances diag(A^{-1}) of a Gaussian with precision A, read off the Ai == Aj entries.

Parameters:
Ai

COO matrix as in solve().

Aj

COO matrix as in solve().

Ax

COO matrix as in solve().

n

matrix dimension (static Python int).

Returns:

A^{-1} at each COO position. Off-diagonal values are symmetric ((A^{-1})[i, j] == (A^{-1})[j, i]), so entries below the diagonal carry the same value as their transpose.

Return type:

[n_nz] float64, aligned with Ax