koblas

LuDecomposition

class LuDecomposition(val n: Int, val lu: DoubleArray, val piv: IntArray, failedAt: Int = NOT_SINGULAR)(source)

A general LU factorization with partial pivoting: P·A = L·U, the unit-lower L and upper U packed into one flat column-major lu buffer (L below the diagonal, U on and above) and the row permutation in piv (piv[k] is the original row now at position k). Produced by LinearAlgebra.factor.

The constructor and the factor buffers are public so that out-of-repo LinearAlgebra backends can produce and consume factorizations in the shared format; every backend packs identically, so a decomposition from one backend solves correctly on another. lu and piv are live buffers, not copies: treat them as read-only, and note that LinearAlgebra.factorInto rewrites them in place so a periodic refactorization need not allocate new ones.

Parameters

failedAt

the position of the zero pivot, or NOT_SINGULAR; readable afterwards through failedAt.

Constructors

LuDecomposition

constructor(n: Int, lu: DoubleArray, piv: IntArray, failedAt: Int = NOT_SINGULAR)(source)

Parameters

failedAt

the position of the zero pivot, or NOT_SINGULAR; readable afterwards through failedAt.

Properties

failedAt

Where the factorization broke down: the position k whose pivot U[k][k] was exactly zero, or NOT_SINGULAR when it did not. LAPACK reports the same number as dgetrf's positive info, one lower for being 0-based, and the reference loop knows it just as directly.

Refactorizing in place via LinearAlgebra.factorInto updates it along with the buffers.

lu

n

val n: Int(source)

piv

singular

Whether a zero pivot was encountered; LinearAlgebra.solve on a singular factorization is not meaningful.

Derived from failedAt rather than stored, so the two cannot contradict each other. It used to be the stored flag and every backend set it separately, which left the position — the more useful half, and the one a caller can act on — computed and then discarded.