mirror of
https://github.com/gonum/gonum.git
synced 2025-10-29 09:42:38 +08:00
Remove unnecessary intermediate var
This commit is contained in:
@@ -45,7 +45,7 @@ func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts []float64) *mat64.De
|
|||||||
var xc mat64.Dense
|
var xc mat64.Dense
|
||||||
xc.TCopy(&xt)
|
xc.TCopy(&xt)
|
||||||
|
|
||||||
var n, scale float64
|
var n float64
|
||||||
if wts != nil {
|
if wts != nil {
|
||||||
if wr := len(wts); wr != r {
|
if wr := len(wts); wr != r {
|
||||||
panic(mat64.ErrShape)
|
panic(mat64.ErrShape)
|
||||||
@@ -66,8 +66,7 @@ func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts []float64) *mat64.De
|
|||||||
cov.Mul(&xt, &xc)
|
cov.Mul(&xt, &xc)
|
||||||
|
|
||||||
// Scale by the sample size.
|
// Scale by the sample size.
|
||||||
scale = 1 / (n - 1)
|
cov.Scale(1/(n-1), cov)
|
||||||
cov.Scale(scale, cov)
|
|
||||||
|
|
||||||
return cov
|
return cov
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user