diff --git a/mat/dense.go b/mat/dense.go index 87b1105c..f0bcd2a9 100644 --- a/mat/dense.go +++ b/mat/dense.go @@ -15,7 +15,7 @@ var ( _ Matrix = dense _ Mutable = dense - _ Cloner = dense + _ ClonerFrom = dense _ RowViewer = dense _ ColViewer = dense _ RawRowViewer = dense @@ -186,7 +186,7 @@ func (m *Dense) asTriDense(n int, diag blas.Diag, uplo blas.Uplo) *TriDense { // DenseCopyOf returns a newly allocated copy of the elements of a. func DenseCopyOf(a Matrix) *Dense { d := &Dense{} - d.Clone(a) + d.CloneFrom(a) return d } @@ -375,12 +375,12 @@ func (m *Dense) Grow(r, c int) Matrix { return &t } -// Clone makes a copy of a into the receiver, overwriting the previous value of -// the receiver. The clone operation does not make any restriction on shape and +// CloneFrom makes a copy of a into the receiver, overwriting the previous value of +// the receiver. The clone from operation does not make any restriction on shape and // will not cause shadowing. // -// See the Cloner interface for more information. -func (m *Dense) Clone(a Matrix) { +// See the ClonerFrom interface for more information. +func (m *Dense) CloneFrom(a Matrix) { r, c := a.Dims() mat := blas64.General{ Rows: r, diff --git a/mat/dense_test.go b/mat/dense_test.go index e1cf5a88..b886722d 100644 --- a/mat/dense_test.go +++ b/mat/dense_test.go @@ -229,7 +229,7 @@ func TestDenseSetRowColumn(t *testing.T) { for ri, row := range as { a := NewDense(flatten(as)) m := &Dense{} - m.Clone(a) + m.CloneFrom(a) a.SetRow(ri, make([]float64, a.mat.Cols)) m.Sub(m, a) nt := Norm(m, 2) @@ -242,7 +242,7 @@ func TestDenseSetRowColumn(t *testing.T) { for ci := range as[0] { a := NewDense(flatten(as)) m := &Dense{} - m.Clone(a) + m.CloneFrom(a) a.SetCol(ci, make([]float64, a.mat.Rows)) col := make([]float64, a.mat.Rows) for j := range col { @@ -1137,7 +1137,7 @@ func TestDensePowN(t *testing.T) { } func (m *Dense) iterativePow(a Matrix, n int) { - m.Clone(a) + m.CloneFrom(a) for i := 1; i < n; i++ { m.Mul(m, a) } @@ -1174,12 +1174,12 @@ func TestDenseCloneT(t *testing.T) { var got, gotT Dense for j := 0; j < 2; j++ { - got.Clone(a.T()) + got.CloneFrom(a.T()) if !Equal(&got, want) { t.Errorf("expected transpose for test %d iteration %d: %v transpose = %v", i, j, test.a, test.want) } - gotT.Clone(got.T()) + gotT.CloneFrom(got.T()) if !Equal(&gotT, a) { t.Errorf("expected transpose for test %d iteration %d: %v transpose = %v", i, j, test.a, test.want) @@ -1438,7 +1438,7 @@ func TestDenseClone(t *testing.T) { } { a := NewDense(flatten(test.a)) b := *a - a.Clone(a) + a.CloneFrom(a) a.Set(test.i, test.j, test.v) if Equal(&b, a) { @@ -1925,7 +1925,7 @@ func TestDenseInverse(t *testing.T) { } var tmp Dense - tmp.Clone(test.a) + tmp.CloneFrom(test.a) aU, transposed := untranspose(test.a) if transposed { switch aU := aU.(type) { diff --git a/mat/eigen.go b/mat/eigen.go index ee971e4a..aaf7fa53 100644 --- a/mat/eigen.go +++ b/mat/eigen.go @@ -176,7 +176,7 @@ func (e *Eigen) Factorize(a Matrix, kind EigenKind) (ok bool) { panic(ErrShape) } var sd Dense - sd.Clone(a) + sd.CloneFrom(a) left := kind&EigenLeft != 0 right := kind&EigenRight != 0 diff --git a/mat/hogsvd.go b/mat/hogsvd.go index bd843e6b..61bd94ad 100644 --- a/mat/hogsvd.go +++ b/mat/hogsvd.go @@ -136,7 +136,7 @@ func (gsvd *HOGSVD) Factorize(m ...Matrix) (ok bool) { if gsvd.err != nil { return false } - b[i].Clone(biT.T()) + b[i].CloneFrom(biT.T()) } gsvd.n = len(m) diff --git a/mat/list_test.go b/mat/list_test.go index ac9be943..1936f084 100644 --- a/mat/list_test.go +++ b/mat/list_test.go @@ -547,7 +547,7 @@ func makeCopyOf(a Matrix) Matrix { return retranspose(a, makeCopyOf(t.Untranspose())) case *Dense, *basicMatrix: var m Dense - m.Clone(a) + m.CloneFrom(a) return returnAs(&m, t) case *SymDense, *basicSymmetric: n := t.(Symmetric).Symmetric() @@ -925,7 +925,7 @@ func testOneInputFunc(t *testing.T, var want interface{} if dimsOK { var aDense Dense - aDense.Clone(a) + aDense.CloneFrom(a) want = denseComparison(&aDense) } aCopy := makeCopyOf(a) @@ -1095,8 +1095,8 @@ func testTwoInputFunc(t *testing.T, var want interface{} if dimsOK { var aDense, bDense Dense - aDense.Clone(a) - bDense.Clone(b) + aDense.CloneFrom(a) + bDense.CloneFrom(b) want = denseComparison(&aDense, &bDense) } aCopy := makeCopyOf(a) @@ -1175,7 +1175,7 @@ func testOneInput(t *testing.T, var want Dense if dimsOK { var aDense Dense - aDense.Clone(a) + aDense.CloneFrom(a) denseComparison(&want, &aDense) } aCopy := makeCopyOf(a) @@ -1327,8 +1327,8 @@ func testTwoInput(t *testing.T, var want Dense if dimsOK { var aDense, bDense Dense - aDense.Clone(a) - bDense.Clone(b) + aDense.CloneFrom(a) + bDense.CloneFrom(b) denseComparison(&want, &aDense, &bDense) } aCopy := makeCopyOf(a) diff --git a/mat/lq.go b/mat/lq.go index d788457d..5a22bd1f 100644 --- a/mat/lq.go +++ b/mat/lq.go @@ -59,7 +59,7 @@ func (lq *LQ) factorize(a Matrix, norm lapack.MatrixNorm) { if lq.lq == nil { lq.lq = &Dense{} } - lq.lq.Clone(a) + lq.lq.CloneFrom(a) work := []float64{0} lq.tau = make([]float64, k) lapack64.Gelqf(lq.lq.mat, lq.tau, work, -1) diff --git a/mat/lq_test.go b/mat/lq_test.go index 2b353b69..c5cc1120 100644 --- a/mat/lq_test.go +++ b/mat/lq_test.go @@ -26,7 +26,7 @@ func TestLQ(t *testing.T) { } } var want Dense - want.Clone(a) + want.CloneFrom(a) var lq LQ lq.Factorize(a) diff --git a/mat/lu_test.go b/mat/lu_test.go index a68ba059..5cf53fb2 100644 --- a/mat/lu_test.go +++ b/mat/lu_test.go @@ -19,7 +19,7 @@ func TestLUD(t *testing.T) { } } var want Dense - want.Clone(a) + want.CloneFrom(a) var lu LU lu.Factorize(a) diff --git a/mat/matrix.go b/mat/matrix.go index 259739e9..456e78d8 100644 --- a/mat/matrix.go +++ b/mat/matrix.go @@ -129,11 +129,11 @@ type RawColViewer interface { RawColView(j int) []float64 } -// A Cloner can make a copy of a into the receiver, overwriting the previous value of the +// A ClonerFrom can make a copy of a into the receiver, overwriting the previous value of the // receiver. The clone operation does not make any restriction on shape and will not cause // shadowing. -type Cloner interface { - Clone(a Matrix) +type ClonerFrom interface { + CloneFrom(a Matrix) } // A Reseter can reset the matrix so that it can be reused as the receiver of a dimensionally diff --git a/mat/product_test.go b/mat/product_test.go index 8585855b..31b18d1b 100644 --- a/mat/product_test.go +++ b/mat/product_test.go @@ -118,7 +118,7 @@ func TestProduct(t *testing.T) { var a *Dense for i, b := range factors { if i == 0 { - want.Clone(b) + want.CloneFrom(b) continue } a, want = want, &Dense{} diff --git a/mat/qr.go b/mat/qr.go index bf38ee4d..70c489a2 100644 --- a/mat/qr.go +++ b/mat/qr.go @@ -59,7 +59,7 @@ func (qr *QR) factorize(a Matrix, norm lapack.MatrixNorm) { if qr.qr == nil { qr.qr = &Dense{} } - qr.qr.Clone(a) + qr.qr.CloneFrom(a) work := []float64{0} qr.tau = make([]float64, k) lapack64.Geqrf(qr.qr.mat, qr.tau, work, -1) diff --git a/mat/qr_test.go b/mat/qr_test.go index 36dbe6c5..7e591040 100644 --- a/mat/qr_test.go +++ b/mat/qr_test.go @@ -29,7 +29,7 @@ func TestQR(t *testing.T) { } } var want Dense - want.Clone(a) + want.CloneFrom(a) var qr QR qr.Factorize(a) diff --git a/optimize/convex/lp/simplex_test.go b/optimize/convex/lp/simplex_test.go index 8be0c673..42516f0f 100644 --- a/optimize/convex/lp/simplex_test.go +++ b/optimize/convex/lp/simplex_test.go @@ -217,7 +217,7 @@ func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b // subject to -A^T * nu <= c negAT := &mat.Dense{} - negAT.Clone(a.T()) + negAT.CloneFrom(a.T()) negAT.Scale(-1, negAT) cNew, aNew, bNew := Convert(b, negAT, c, nil, nil) diff --git a/stat/cca_example_test.go b/stat/cca_example_test.go index def77317..44ef9cba 100644 --- a/stat/cca_example_test.go +++ b/stat/cca_example_test.go @@ -94,7 +94,7 @@ func ExampleCC() { // Canonical Correlation Matrix, or the correlations between the sphered // data. var corSph mat.Dense - corSph.Clone(pVecs) + corSph.CloneFrom(pVecs) col := make([]float64, xd) for j := 0; j < yd; j++ { mat.Col(col, j, &corSph) diff --git a/stat/statmat.go b/stat/statmat.go index d584b680..285623e2 100644 --- a/stat/statmat.go +++ b/stat/statmat.go @@ -34,7 +34,7 @@ func CovarianceMatrix(dst *mat.SymDense, x mat.Matrix, weights []float64) { } var xt mat.Dense - xt.Clone(x.T()) + xt.CloneFrom(x.T()) // Subtract the mean of each of the columns. for i := 0; i < c; i++ { v := xt.RawRowView(i)