mirror of
https://github.com/gonum/gonum.git
synced 2025-10-13 02:43:59 +08:00
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:
@@ -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{
|
||||
|
Reference in New Issue
Block a user