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 b  
    18261826        else:
    18271827            return MS
    18281828
    1829     def new_matrix(self, nrows=None, ncols=None, entries=0,
     1829    def new_matrix(self, nrows=None, ncols=None, entries=None,
    18301830                   coerce=True, copy=True, sparse=None):
    18311831        """
    18321832        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 b  
    50805080        if cutoff <= 0:
    50815081            raise ValueError, "cutoff must be at least 1"
    50825082
    5083         #output = self.new_matrix(self._nrows, right._ncols)
    5084         # the following is a little faster:
    5085         if self.is_sparse():
    5086             output = self.matrix_space(self._nrows, right._ncols, sparse = True)(0)
    5087         else:
    5088             output = self.matrix_space(self._nrows, right._ncols, sparse = False).zero_matrix().__copy__()
     5083        output = self.new_matrix(self._nrows, right._ncols)
     5084        # The following used to be a little faster, but meanwhile
     5085        # the previous line is faster.
     5086        #if self.is_sparse():
     5087        #    output = self.matrix_space(self._nrows, right._ncols, sparse = True)(0)
     5088        #else:
     5089        #    output = self.matrix_space(self._nrows, right._ncols, sparse = False).zero_matrix().__copy__()
    50895090       
    50905091        self_window   = self.matrix_window()
    50915092        right_window  = right.matrix_window()