mat: rename NewDiagonal to NewDiagDense
MODIFY
mat/diagonal.go
mat/diagonal.go
@@ -73,10 +73,10 @@ type DiagDense struct {
mat blas64.Vector
}
-// NewDiagonal creates a new Diagonal matrix with n rows and n columns.
-// The length of data must be n or data must be nil, otherwise NewDiagonal
-// will panic. NewDiagonal will panic if n is zero.
-func NewDiagonal(n int, data []float64) *DiagDense {
+// NewDiagDense creates a new Diagonal matrix with n rows and n columns.
+// The length of data must be n or data must be nil, otherwise NewDiagDense
+// will panic. NewDiagDense will panic if n is zero.
+func NewDiagDense(n int, data []float64) *DiagDense {
if n <= 0 {
if n == 0 {
panic(ErrZeroLength)

MODIFY
mat/diagonal_test.go
mat/diagonal_test.go
@@ -12,7 +12,7 @@ import (
"gonum.org/v1/gonum/blas/blas64"
)
-func TestNewDiagonal(t *testing.T) {
+func TestNewDiagDense(t *testing.T) {
for i, test := range []struct {
data []float64
n int
@@ -35,7 +35,7 @@ func TestNewDiagonal(t *testing.T) {
}),
},
} {
- band := NewDiagonal(test.n, test.data)
+ band := NewDiagDense(test.n, test.data)
rows, cols := band.Dims()
if rows != test.n {
@@ -128,7 +128,7 @@ func TestDiagFrom(t *testing.T) {
want *Dense
}{
{
- mat: NewDiagonal(6, []float64{1, 2, 3, 4, 5, 6}),
+ mat: NewDiagDense(6, []float64{1, 2, 3, 4, 5, 6}),
want: NewDense(6, 6, []float64{
1, 0, 0, 0, 0, 0,
0, 2, 0, 0, 0, 0,
@@ -395,10 +395,10 @@ func TestDiagonalAtSet(t *testing.T) {
for _, nilstart := range []bool{true, false} {
var diag *DiagDense
if nilstart {
- diag = NewDiagonal(n, nil)
+ diag = NewDiagDense(n, nil)
} else {
data := make([]float64, n)
- diag = NewDiagonal(n, data)
+ diag = NewDiagDense(n, data)
// Test the data is used.
for i := range data {
data[i] = -float64(i) - 1

MODIFY
optimize/cmaes.go
optimize/cmaes.go
@@ -210,7 +210,7 @@ func (cma *CmaEsChol) Init(dim, tasks int) int {
cma.chol.Clone(cma.InitCholesky)
} else {
// Set the initial Cholesky to I.
- b := mat.NewDiagonal(dim, nil)
+ b := mat.NewDiagDense(dim, nil)
for i := 0; i < dim; i++ {
b.SetDiag(i, 1)
}

MODIFY
stat/mds/mds.go
stat/mds/mds.go
@@ -73,7 +73,7 @@ func TorgersonScaling(dst *mat.Dense, eigdst []float64, dis mat.Symmetric) (k in
// TODO(kortschak): Make use of the knowledge
// of k to avoid doing unnecessary work.
- dst.Mul(dst, mat.NewDiagonal(len(vals), vals))
+ dst.Mul(dst, mat.NewDiagDense(len(vals), vals))
return k, dst, eigdst
}

MODIFY
stat/pca_test.go
stat/pca_test.go
@@ -183,7 +183,7 @@ tests:
// Check that the set of principal vectors is
// orthonormal by comparing V^T*V to the identity matrix.
- I := mat.NewDiagonal(c, nil)
+ I := mat.NewDiagDense(c, nil)
for k := 0; k < c; k++ {
I.SetDiag(k, 1)
}

mat: rename NewDiagonal to NewDiagDense