# Ticket #11589: trac_11589_apply_zero_creation_to_strassen.patch

File trac_11589_apply_zero_creation_to_strassen.patch, 1.8 KB (added by SimonKing, 10 years ago)

Use the mecanisms from the preceding patches in Strassen multiplication

• ## sage/matrix/matrix1.pyx

```# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1311851937 -7200
# Node ID 1f48bd2c336aba49b4daac3486c901fe0a19fcd1
# Parent  9ea016e211d608f991fd4e84ccf1f171651a764b
#11589: Remove hard-coded and potentially slow creation of zero matrix in Strassen multiplication

diff --git a/sage/matrix/matrix1.pyx b/sage/matrix/matrix1.pyx```
 a else: return MS def new_matrix(self, nrows=None, ncols=None, entries=0, def new_matrix(self, nrows=None, ncols=None, entries=None, coerce=True, copy=True, sparse=None): """ Create a matrix in the parent of this matrix with the given number
• ## sage/matrix/matrix2.pyx

`diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx`
 a if cutoff <= 0: raise ValueError, "cutoff must be at least 1" #output = self.new_matrix(self._nrows, right._ncols) # the following is a little faster: if self.is_sparse(): output = self.matrix_space(self._nrows, right._ncols, sparse = True)(0) else: output = self.matrix_space(self._nrows, right._ncols, sparse = False).zero_matrix().__copy__() output = self.new_matrix(self._nrows, right._ncols) # The following used to be a little faster, but meanwhile # the previous line is faster. #if self.is_sparse(): #    output = self.matrix_space(self._nrows, right._ncols, sparse = True)(0) #else: #    output = self.matrix_space(self._nrows, right._ncols, sparse = False).zero_matrix().__copy__() self_window   = self.matrix_window() right_window  = right.matrix_window()