#17567: Cross product matrix (hat operator)
-------------------------------------+-------------------------------------
       Reporter:  gagern             |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.5
      Component:  linear algebra     |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Martin von Gagern  |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/gagern/ticket/17567              |  57cf33d49d93bb828261ab1a39a1ba3ff82cb256
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by tscrim):

 A few comments. Please remove the `self` as input, it's not considered as
 such. I would also consider using the
 {{{:wikipedia:`Hat_operator#Cross_product`}}} in the documentation.

 A bit more substantial, I would instead check the rank by
 `self.parent().rank()` and define `s` inside of each of the 2 cases. This
 is a slight speed penalty in the general ring case, but for `ZZ`, which
 always copies the list, this could result in a big speedup:
 {{{
 sage: m = (ZZ^4).random_element()
 sage: %timeit len(m.list(copy=False))
 1000000 loops, best of 3: 1.39 µs per loop
 sage: %timeit m.parent().rank()
 1000000 loops, best of 3: 955 ns per loop
 sage: m = (QQ['t']^4).random_element()
 sage: %timeit len(m.list(copy=False))
 1000000 loops, best of 3: 791 ns per loop
 sage: m = (ZZ^20).random_element()
 sage: %timeit len(m.list(copy=False))
 100000 loops, best of 3: 3.03 µs per loop
 }}}
 Plus this is more robust if the behavior is changed to mimic `ZZ` (i.e.,
 it always copies the elements). I might also consider adding the
 definition of `R` and `zero` inside of the 2 cases as well, but that is a
 definite micro-optimization.

 Somewhat of a side note, constructing the basis might be an expensive
 operation. So if you don't really need it, then let's stay away from using
 it.

 Nice little patch; looks good otherwise.

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