mat: allow nil destination for Cholesky extraction
MODIFY
mat/cholesky_test.go
mat/cholesky_test.go
@@ -53,18 +53,16 @@ func TestCholesky(t *testing.T) {
if math.Abs(test.cond-chol.cond) > 1e-13 {
t.Errorf("Condition number mismatch: Want %v, got %v", test.cond, chol.cond)
}
- var U TriDense
- chol.UTo(&U)
+ U := chol.UTo(nil)
aCopy := DenseCopyOf(test.a)
var a Dense
- a.Mul(U.TTri(), &U)
+ a.Mul(U.TTri(), U)
if !EqualApprox(&a, aCopy, 1e-14) {
t.Error("unexpected Cholesky factor product")
}
- var L TriDense
- chol.LTo(&L)
- a.Mul(&L, L.TTri())
+ L := chol.LTo(nil)
+ a.Mul(L, L.TTri())
if !EqualApprox(&a, aCopy, 1e-14) {
t.Error("unexpected Cholesky factor product")
}
@@ -234,11 +232,10 @@ func TestCholeskyTo(t *testing.T) {
if !ok {
t.Fatal("unexpected Cholesky factorization failure: not positive definite")
}
- var s SymDense
- chol.To(&s)
+ s := chol.To(nil)
- if !EqualApprox(&s, test, 1e-12) {
- t.Errorf("Cholesky reconstruction not equal to original matrix.\nWant:\n% v\nGot:\n% v\n", Formatted(test), Formatted(&s))
+ if !EqualApprox(s, test, 1e-12) {
+ t.Errorf("Cholesky reconstruction not equal to original matrix.\nWant:\n% v\nGot:\n% v\n", Formatted(test), Formatted(s))
}
}
}

mat: allow nil destination for Cholesky extraction