Add Reset method

Reset allows reuse of used matrices, a use that would otherwise be
blocked by dim checking for many operations.
This commit is contained in:
kortschak
2014-01-22 09:34:49 +10:30
parent 1a85feca5c
commit 85652f6bd8
2 changed files with 12 additions and 0 deletions

View File

@@ -187,6 +187,11 @@ func (m *Dense) Submatrix(a Matrix, i, j, r, c int) {
m.Clone(m)
}
func (m *Dense) Reset() {
m.mat.Rows, m.mat.Cols = 0, 0
m.mat.Data = m.mat.Data[:0]
}
func (m *Dense) Clone(a Matrix) {
r, c := a.Dims()
m.mat = RawMatrix{