koblas

CholeskyPolicy

sealed interface CholeskyPolicy(source)

What Lapack.cholesky does when the matrix turns out not to be positive-definite.

A named policy rather than a boolean flag, and Strict rather than Regularize by default. Both parts are deliberate corrections.

koblas used to regularize by default: a non-positive pivot was quietly replaced and factorization continued, so a.cholesky() returned a factor of a matrix that was not the one you passed. That is genuinely useful for the workload it was written for — online statistics on a drifting precision matrix, where the alternative is an exception every few updates — but it is a surprising default for a general linear algebra library, and it is not what dpotrf does. LAPACK reports the failing leading minor. Silently returning something plausible is the worse failure: the caller gets numbers, not a signal.

The type also gives the fudge factor a name. It used to be a bare 1e-5 in the middle of the elimination loop, with no way to see it, change it, or find out that it existed.

Inheritors

Types

Link copied to clipboard
data class Regularize(val minimumPivot: Double = 1.0E-10) : CholeskyPolicy

Continue past a non-positive pivot, treating it as minimumPivot instead.

Link copied to clipboard
data object Strict : CholeskyPolicy

Throw at the first non-positive pivot, naming the position and the value. The default, and what dpotrf effectively does.