go-moremath icon indicating copy to clipboard operation
go-moremath copied to clipboard

Please update your use of github.com/gonum/matrix to github.com/gonum/gonum

Open nim-nim opened this issue 7 years ago โ€ข 2 comments

github.com/gonum/matrix is deprecated

nim-nim avatar Mar 19 '18 14:03 nim-nim

diff -uNr go-moremath-033754ab1fee508c9f98f2785eec2365964e0b05.orig/fit/lsquares.go go-moremath-033754ab1fee508c9f98f2785eec2365964e0b05/fit/lsquares.go
--- go-moremath-033754ab1fee508c9f98f2785eec2365964e0b05.orig/fit/lsquares.go   2017-02-10 20:34:28.000000000 +0100
+++ go-moremath-033754ab1fee508c9f98f2785eec2365964e0b05/fit/lsquares.go        2018-03-20 13:07:28.200088026 +0100
@@ -9,7 +9,7 @@
        "math"
        "strings"

-       "github.com/gonum/matrix/mat64"
+       "gonum.org/v1/gonum/mat"
 )

 // LinearLeastSquares computes the least squares fit for the function
@@ -60,36 +60,36 @@
        for i, term := range terms {
                term(xs, xTVals[i*len(xs):i*len(xs)+len(xs)])
        }
-       XT := mat64.NewDense(len(terms), len(xs), xTVals)
+       XT := mat.NewDense(len(terms), len(xs), xTVals)
        X := XT.T()

        // Construct ๐—แต€๐–.
-       var XTW *mat64.Dense
+       var XTW *mat.Dense
        if weights == nil {
                // ๐– is the identity matrix.
                XTW = XT
        } else {
                // Since ๐– is a diagonal matrix, we do this directly.
-               XTW = mat64.DenseCopyOf(XT)
-               WDiag := mat64.NewVector(len(weights), weights)
+               XTW = mat.DenseCopyOf(XT)
+               WDiag := mat.NewVecDense(len(weights), weights)
                for row := 0; row < len(terms); row++ {
-                       rowView := XTW.RowView(row)
+                       rowView := XTW.RowView(row).(*mat.VecDense)
                        rowView.MulElemVec(rowView, WDiag)
                }
        }

        // Construct ๐ฒ.
-       y := mat64.NewVector(len(ys), ys)
+       y := mat.NewVecDense(len(ys), ys)

        // Compute ฮ’ฬ‚.
-       lhs := mat64.NewDense(len(terms), len(terms), nil)
+       lhs := mat.NewDense(len(terms), len(terms), nil)
        lhs.Mul(XTW, X)

-       rhs := mat64.NewVector(len(terms), nil)
+       rhs := mat.NewVecDense(len(terms), nil)
        rhs.MulVec(XTW, y)

        BVals := make([]float64, len(terms))
-       B := mat64.NewVector(len(terms), BVals)
+       B := mat.NewVecDense(len(terms), BVals)
        B.SolveVec(lhs, rhs)
        return BVals
 }

nim-nim avatar Mar 20 '18 12:03 nim-nim

ping @aclements

dgryski avatar Mar 27 '18 21:03 dgryski