mat: rename Cloner=>ClonerFrom and Clone=>CloneFrom
MODIFY
mat/dense.go
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,

MODIFY
mat/dense_test.go
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) {

MODIFY
mat/eigen.go
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

MODIFY
mat/hogsvd.go
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)

MODIFY
mat/list_test.go
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)

MODIFY
mat/lq.go
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)

MODIFY
mat/lq_test.go
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)

MODIFY
mat/lu_test.go
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)

MODIFY
mat/matrix.go
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

MODIFY
mat/product_test.go
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{}

MODIFY
mat/qr.go
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)

MODIFY
mat/qr_test.go
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)

MODIFY
optimize/convex/lp/simplex_test.go
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)

MODIFY
stat/cca_example_test.go
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)

MODIFY
stat/statmat.go
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)

mat: rename Cloner=>ClonerFrom and Clone=>CloneFrom