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:
@@ -691,3 +691,18 @@ func TestCholeskyBlockedReconstruction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestCholeskyRefusesNonFinite pins the refusal of a poisoned matrix:
|
||||
// the pivot test cannot see a NaN (it fails every comparison), so
|
||||
// without the gate the sweep would answer an all-NaN factor with a nil
|
||||
// error, where the sparse sibling refuses the same input.
|
||||
func TestCholeskyRefusesNonFinite(t *testing.T) {
|
||||
nan := mustFromFloats(t, []float64{math.NaN(), 0, 0, 1}, 2, 2)
|
||||
if _, err := Cholesky(nan); err == nil || !strings.Contains(err.Error(), "not finite") {
|
||||
t.Fatalf("Cholesky(NaN): %v", err)
|
||||
}
|
||||
inf := mustFromFloats(t, []float64{0, 0, 0, math.Inf(1)}, 2, 2)
|
||||
if _, err := Cholesky(inf); err == nil || !strings.Contains(err.Error(), "not finite") {
|
||||
t.Fatalf("Cholesky(Inf): %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user