diff --git a/mat64/dense.go b/mat64/dense.go index 505bf63..33d46cf 100644 --- a/mat64/dense.go +++ b/mat64/dense.go @@ -199,7 +199,7 @@ func (m *Dense) SetRow(i int, src []float64) { panic(matrix.ErrRowLength) } - copy(m.rowView(i), src) + copy(m.rawRowView(i), src) } // RowView returns row i of the matrix data represented as a column vector, @@ -213,7 +213,7 @@ func (m *Dense) RowView(i int) *Vector { return &Vector{ mat: blas64.Vector{ Inc: 1, - Data: m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+m.mat.Cols], + Data: m.rawRowView(i), }, n: m.mat.Cols, } @@ -225,11 +225,11 @@ func (m *Dense) RawRowView(i int) []float64 { if i >= m.mat.Rows || i < 0 { panic(matrix.ErrRowAccess) } - return m.rowView(i) + return m.rawRowView(i) } -func (m *Dense) rowView(r int) []float64 { - return m.mat.Data[r*m.mat.Stride : r*m.mat.Stride+m.mat.Cols] +func (m *Dense) rawRowView(i int) []float64 { + return m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+m.mat.Cols] } // View returns a new Matrix that shares backing data with the receiver. diff --git a/mat64/matrix.go b/mat64/matrix.go index fe7a1d2..12da4e1 100644 --- a/mat64/matrix.go +++ b/mat64/matrix.go @@ -88,27 +88,27 @@ type Mutable interface { } // A RowViewer can return a Vector reflecting a row that is backed by the matrix -// data. The Vector returned will have Len() == nCols. +// data. The Vector returned will have length equal to the number of columns. type RowViewer interface { - RowView(r int) *Vector + RowView(i int) *Vector } // A RawRowViewer can return a slice of float64 reflecting a row that is backed by the matrix // data. type RawRowViewer interface { - RawRowView(r int) []float64 + RawRowView(i int) []float64 } -// A ColViewer can return a Vector reflecting a row that is backed by the matrix -// data. The Vector returned will have Len() == nRows. +// A ColViewer can return a Vector reflecting a column that is backed by the matrix +// data. The Vector returned will have length equal to the number of rows. type ColViewer interface { - ColView(c int) *Vector + ColView(j int) *Vector } // A RawColViewer can return a slice of float64 reflecting a column that is backed by the matrix // data. type RawColViewer interface { - RawColView(c int) []float64 + RawColView(j int) []float64 } // A Cloner can make a copy of a into the receiver, overwriting the previous value of the