diff --git a/mat/cholesky.go b/mat/cholesky.go index fa4e91c6..f02ece38 100644 --- a/mat/cholesky.go +++ b/mat/cholesky.go @@ -268,10 +268,10 @@ func (c *Cholesky) LTo(dst *TriDense) *TriDense { return dst } -// To reconstructs the original positive definite matrix given its +// ToSym reconstructs the original positive definite matrix given its // Cholesky decomposition into dst and returns the result. If dst is nil // a new SymDense is allocated. -func (c *Cholesky) To(dst *SymDense) *SymDense { +func (c *Cholesky) ToSym(dst *SymDense) *SymDense { if !c.valid() { panic(badCholesky) } diff --git a/mat/cholesky_example_test.go b/mat/cholesky_example_test.go index 8f75d79b..85e1891d 100644 --- a/mat/cholesky_example_test.go +++ b/mat/cholesky_example_test.go @@ -91,7 +91,7 @@ func ExampleCholesky_SymRankOne() { // Rank-1 update the matrix a. a.SymRankOne(a, 1, x) - au := chol.To(nil) + au := chol.ToSym(nil) // Print the matrix that was updated directly. fmt.Printf("\nA' = %0.4v\n", mat.Formatted(a, mat.Prefix(" "))) diff --git a/mat/cholesky_test.go b/mat/cholesky_test.go index 6a5c853d..b009123c 100644 --- a/mat/cholesky_test.go +++ b/mat/cholesky_test.go @@ -219,7 +219,7 @@ func TestCholeskySolveVec(t *testing.T) { } } -func TestCholeskyTo(t *testing.T) { +func TestCholeskyToSym(t *testing.T) { for _, test := range []*SymDense{ NewSymDense(3, []float64{ 53, 59, 37, @@ -232,7 +232,7 @@ func TestCholeskyTo(t *testing.T) { if !ok { t.Fatal("unexpected Cholesky factorization failure: not positive definite") } - s := chol.To(nil) + s := chol.ToSym(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)) @@ -338,7 +338,7 @@ func TestCholeskySymRankOne(t *testing.T) { a.SymRankOne(&a, alpha, x) var achol SymDense - chol.To(&achol) + chol.ToSym(&achol) if !EqualApprox(&achol, &a, 1e-13) { t.Errorf("n=%v, alpha=%v: mismatch between updated matrix and from Cholesky:\nupdated:\n%v\nfrom Cholesky:\n%v", n, alpha, Formatted(&a), Formatted(&achol)) @@ -413,7 +413,7 @@ func TestCholeskySymRankOne(t *testing.T) { a.SymRankOne(a, test.alpha, x) var achol SymDense - chol.To(&achol) + chol.ToSym(&achol) if !EqualApprox(&achol, a, 1e-13) { t.Errorf("Case %v: mismatch between updated matrix and from Cholesky:\nupdated:\n%v\nfrom Cholesky:\n%v", i, Formatted(a), Formatted(&achol)) diff --git a/stat/distmat/wishart.go b/stat/distmat/wishart.go index 97992ce0..2ea919d3 100644 --- a/stat/distmat/wishart.go +++ b/stat/distmat/wishart.go @@ -151,7 +151,7 @@ func (w *Wishart) RandSym(x *mat.SymDense) *mat.SymDense { } var c mat.Cholesky w.RandChol(&c) - c.To(x) + c.ToSym(x) return x } @@ -204,6 +204,6 @@ func (w *Wishart) RandChol(c *mat.Cholesky) *mat.Cholesky { func (w *Wishart) setV() { w.once.Do(func() { w.v = mat.NewSymDense(w.dim, nil) - w.cholv.To(w.v) + w.cholv.ToSym(w.v) }) } diff --git a/stat/distmv/normal_test.go b/stat/distmv/normal_test.go index 88ac12b9..2d4e3ecd 100644 --- a/stat/distmv/normal_test.go +++ b/stat/distmv/normal_test.go @@ -242,7 +242,7 @@ func TestConditionNormal(t *testing.T) { } var sigma mat.SymDense - newNormal.chol.To(&sigma) + newNormal.chol.ToSym(&sigma) if !mat.EqualApprox(test.newSigma, &sigma, 1e-12) { t.Errorf("Updated sigma mismatch\n.Want:\n% v\nGot:\n% v\n", test.newSigma, sigma) } @@ -280,7 +280,7 @@ func TestConditionNormal(t *testing.T) { t.Fatalf("Bad test, update failed") } var newSigma mat.SymDense - newNormal.chol.To(&newSigma) + newNormal.chol.ToSym(&newSigma) trueMean := test.mu[0] + rho*(std[0]/std[1])*(test.value-test.mu[1]) if math.Abs(trueMean-newNormal.mu[0]) > 1e-14 { t.Errorf("Mean mismatch. Want %v, got %v", trueMean, newNormal.mu[0]) @@ -377,7 +377,7 @@ func TestConditionNormal(t *testing.T) { } } var sigma mat.SymDense - newNormal.chol.To(&sigma) + newNormal.chol.ToSym(&sigma) if !mat.EqualApprox(&sigma, subEstCov, 1e-1) { t.Errorf("Covariance mismatch. Want:\n%0.8v\nGot:\n%0.8v\n", subEstCov, sigma) }