#18979: avoid Maxima on creation of symbolic matrices
-------------------------+-------------------------------------------------
       Reporter:  rws    |        Owner:
           Type:         |       Status:  needs_review
  defect                 |    Milestone:  sage-6.9
       Priority:  major  |   Resolution:
      Component:         |    Merged in:
  linear algebra         |    Reviewers:
       Keywords:         |  Work issues:
        Authors:  Ralf   |       Commit:
  Stephan                |  2c4fa619863baebcfe5239a2b325eabac83ed819
Report Upstream:  N/A    |     Stopgaps:
         Branch:         |
  u/rws/18979            |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by nbruin):

 I think invading a fundamental piece of infrastructure with specific tests
 for a specific ring should not be taken lightly. I think you can avoid
 most of your trouble by delaying the is_zero test to the last possible
 moment:
 {{{
         elif self._nrows == self._ncols:
             self._entries = [entries if i==j else zero for i in
 range(self.nrows) for j in range(self.nrows)]
         elif entries == zero:
             self._entries = [zero]*(self._nrows*self._ncols)
         else:
             raise TypeError("nonzero scalar matrix must be square")
 }}}
 The first list comprehension can be optimized further, if required (I
 suspect that testing whether "entries" is zero to more quickly create a
 square zero matrix is a false optimization: if you need that thing quickly
 often, you should reuse an immutable zero matrix. That will be much
 quicker (and constant in size of the matrix!), so I don't think it's
 necessary).

 If the zero check is expensive, it will almost certainly lead to an error.

--
Ticket URL: <http://trac.sagemath.org/ticket/18979#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to