fix(linalg): refuse non-finite input in dense Cholesky, Eigen and rank-one updates
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -706,6 +706,18 @@ func Eigen(a *core.Array) (values, vectors *core.Array, err error) {
|
||||
}
|
||||
n := a.Shape()[0]
|
||||
mat := denseFloats(a, n, n)
|
||||
// A non-finite entry slips through the symmetry test below: the
|
||||
// difference of two NaNs never exceeds the tolerance, so a poisoned
|
||||
// matrix reads as symmetric and the sweep hands back a NaN spectrum
|
||||
// with a nil error. The sparse twin refuses the same input, and so
|
||||
// does this one.
|
||||
for i := range n {
|
||||
for j := range n {
|
||||
if math.IsNaN(mat[i*n+j]) || math.IsInf(mat[i*n+j], 0) {
|
||||
return nil, nil, base.Errf("Eigen: entry [%d,%d] is not finite", i, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
// A matrix outside the safe window would drive the reflector norms
|
||||
// and the sweep's squared accumulation past the representable range;
|
||||
// the tridiagonalisation and the QR sweep run on it scaled into the
|
||||
|
||||
Reference in New Issue
Block a user