change mat64.Vec to []float64

This commit is contained in:
Jonathan J Lawlor
2014-12-02 20:47:56 -05:00
parent 2121128140
commit 0d3fcca1eb
2 changed files with 4 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ import (
// data matrix x. cov should be a square matrix with the same number of // data matrix x. cov should be a square matrix with the same number of
// columns as the input data matrix x, or if it is nil then a new Dense // columns as the input data matrix x, or if it is nil then a new Dense
// matrix will be constructed. // matrix will be constructed.
func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts mat64.Vec) *mat64.Dense { func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts []float64) *mat64.Dense {
// matrix version of the two pass algorithm. This doesn't use // matrix version of the two pass algorithm. This doesn't use
// the correction found in the Covariance and Variance functions. // the correction found in the Covariance and Variance functions.
@@ -50,7 +50,7 @@ func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts mat64.Vec) *mat64.De
// normalization factor, typical n-1 // normalization factor, typical n-1
var N float64 var N float64
if wts != nil { if wts != nil {
if wr, _ := wts.Dims(); wr != r { if wr := len(wts); wr != r {
panic("weight vector length mismatch") panic("weight vector length mismatch")
} }

View File

@@ -47,13 +47,13 @@ func TestCovarianceMatrix(t *testing.T) {
1, -2, 1, -2,
2, 4, 2, 4,
}), }),
weights: mat64.Vec([]float64{ weights: []float64{
1.5, 1.5,
.5, .5,
1.5, 1.5,
.5, .5,
1, 1,
}), },
r: 2, r: 2,
c: 2, c: 2,
x: []float64{ x: []float64{