#10763: Speedup of  matrix multiplication
------------------------------+---------------------------------------------
   Reporter:  SimonKing       |       Owner:  jason, was           
       Type:  enhancement     |      Status:  needs_review         
   Priority:  major           |   Milestone:  sage-4.6.2           
  Component:  linear algebra  |    Keywords:  matrix multiplication
     Author:  Simon King      |    Upstream:  N/A                  
   Reviewer:                  |      Merged:                       
Work_issues:                  |  
------------------------------+---------------------------------------------
Changes (by SimonKing):

  * status:  needs_work => needs_review


Comment:

 The test failures were caused by a very stupid mistake:
 `self.new_matrix()` by default assumes that the dimension of the new
 matrix is the same as the dimension of the old matrix. In the
 multiplication algorithms, I saw
 `self.new_matrix(nrows=self.nrows(),...)`, was not reading further, and
 thought that we are in the default case, thus, deleted the arguments.

 Of course, it continues "(..., ncols=right.ncols())`.

 What I did now was to avoid calling `self.nrows()` and `right.ncols()` -
 direct access to the attributes `self._nrows` and `right._ncols` is
 faster.

 To my surprise, the timings improved a little more:
 {{{
 sage: def test(M):
 ....:     for i in xrange(10^6):
 ....:         M*=M
 ....:     return M
 ....:
 sage: m = matrix(GF(3),[[1]])
 sage: %time test(m)
 CPU times: user 36.67 s, sys: 0.16 s, total: 36.83 s
 Wall time: 36.95 s
 [1]
 sage: m = matrix(GF(2),[[1]])
 sage: %time test(m)
 CPU times: user 26.29 s, sys: 0.14 s, total: 26.43 s
 Wall time: 26.50 s
 [1]
 }}}

 Is it faster to provide arguments with a default value ''explicitly''?

 The tests for `sage/matrix/` passed. I am now running all doctests (not
 the long ones), but I think I can already revert it to "needs review".

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10763#comment:8>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to