#16617: simple echelon matrix iterator
-------------------------------------+-------------------------------------
       Reporter:  vdelecroix         |        Owner:
           Type:  enhancement        |       Status:  needs_info
       Priority:  major              |    Milestone:  sage-6.3
      Component:  linear algebra     |   Resolution:
       Keywords:  matrix             |    Merged in:
        Authors:  Vincent Delecroix  |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/vdelecroix/16617                 |  f3cc9b7a9979e164565df53fa11dd6f8647a6ee9
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 Replying to [comment:4 ncohen]:
 > Helloooooooooooo !
 >
 > First of all, I don't get why you wrote this in Cython instead of
 changing the old implementation... Does it change much to the performance
 ? I wonder if you wouldn't obtain the same crazy speedups simply caching
 `m0` as you do and using itertools instead of `VectorSpace`.. Or is it
 that you want to aviod the final matrix multiplication ?

 The main speed up is to get rid of VectorSpaces. I do not want to use
 them, so I need a `echelon_matrix_iterator`. Whether it is cython or not
 is a matter of micro seconds, so I do not care that much (except that
 using cython allows to set the cache of matrices with the pivot that can
 be used later).

 > Details:
 >
 > - It seems that what you do is iterate on *reduced* echelon form

 it is!

 > - Could you add a doctest like that ?
 >
 > {{{
 > sage: q=71
 > sage: F = GF(q)
 > sage: len(list(echelon_matrix_iterator(F, 1, 3, copy=False))) ==
 q**2+q+1
 > True
 > sage: len(list(echelon_matrix_iterator(F, 2, 3, copy=False))) ==
 q**2+q+1
 > True
 > }}}

 Of course.

 > - I do not understand why you have to call {{{del}}} `O_o`

 This is a crazy thing in the implementation of itertools. If the only
 reference to the tuple is owned by the iterator then it is reused.
 Otherwise you create a fresh one. What you gain is creation time of a
 tuple...
 {{{
 sage: from itertools import product
 sage: timeit("for p in product([0,1,2,3],[3,4,5,6],[1,2,3,4],[1,2,3,4]):
 pass")
 625 loops, best of 3: 21.9 µs per loop
 sage: timeit("for p in product([0,1,2,3],[3,4,5,6],[1,2,3,4],[1,2,3,4]):
 del p")
 625 loops, best of 3: 7.81 µs per loop
 }}}

 Vincent

--
Ticket URL: <http://trac.sagemath.org/ticket/16617#comment:5>
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