pub enum LdltError {
ZeroPivot(usize),
NearZeroPivot {
column: usize,
pivot: f64,
scale: f64,
suggested_shift: f64,
},
InvalidInput(&'static str),
SizeMismatch {
expected: usize,
got: usize,
},
}Expand description
Failure modes of the factorization and solves.
Eq is deliberately not derived: LdltError::NearZeroPivot carries f64 payloads.
Variants§
ZeroPivot(usize)
A zero pivot (D[k] == 0) was hit at this column: the matrix is singular or the
un-pivoted factorization broke down there.
NearZeroPivot
A pivot that is not exactly zero but has lost every significant digit to
cancellation: |D[k]| < NEAR_ZERO_PIVOT_REL * scale.
This is the honest report of the case that used to be returned silently, and it
matters because the sign pattern of D is the matrix inertia (Sylvester’s law).
A pivot at this magnitude still has a sign, but that sign is rounding noise, so the
inertia read from the factorization would be noise too - and downstream that inertia
is a Sturm eigenvalue count, i.e. an eigenvalue or buckling load. Returning it is
strictly better than returning a number nobody can tell is wrong.
Recover by moving off the near-singular point: either shift the matrix yourself, or
call SparseLdlt::factor_shifted, which does exactly that and reports the shift it
used through SparseLdlt::shift.
Fields
scale: f64The largest absolute diagonal entry of the input matrix - the reference the tolerance is relative to.
suggested_shift: f64A diagonal shift large enough to clear the breakdown: sqrt(
NEAR_ZERO_PIVOT_REL ) * scale, i.e. comfortably outside the tolerance band
rather than on its edge. Factoring A + suggested_shift * I is an exact
factorization of a NEARBY matrix, not of A.
InvalidInput(&'static str)
The CSC arrays were inconsistent (bad length, col_ptr not monotonic, an index
out of range, or a non-finite value).
SizeMismatch
A right-hand side (or multi-RHS row) did not match the factored matrix’s order.