I have been walking through some of the matrix code before adding some
enhancements.

A right_kernel() will take the transpose of a matrix and call
left_kernel().  left_kernel() (or kernel()) generally takes a
transpose before calling some other code to row-reduce the matrix, and
so on.  It appears that most of the specialized code actually
constructs a right kernel: IML for dense integer/rational matrices,
PARI for those with entries in number fields and original Sage code
for other fields.  The effect is that a matrix is often (always?)
transposed twice if you are really after a right kernel.

I built a 2500 x 2500 matrix and multiplied it by its transpose so I
could work on a symmetric matrix (thus a left or right kernel will be
identical computations).

sage: a=random_matrix(ZZ,2500,x=10)
sage: m=a*a.transpose().change_ring(QQ)

sage: time m.left_kernel()   --> 5.84 seconds
sage: time m.right_kernel()  --> 8.58 seconds

Timings on just a simple transpose of a matrix of this size pretty
much account for all of the difference.  It should therefore be
possible to get a right kernel in this case at around 3 seconds if two
transposes were eliminated.  Furthermore, I've found all the
transposes a bit confusing as I chase my way up and down the class
hierarchy.

Proposal:  Place the guts of kernel computations for each
(specialized) class into a right_kernel() method, where it would seem
to naturally belong.  Mostly these would replace kernel() methods that
are computing left kernels.  A call to kernel() or left_kernel()
should arrive at the top of the hierarchy where it would take a
transpose and call the (specialized) right_kernel().  So there
wouldn't be a change in behavior in routines currently calling kernel
() or left_kernel(), and we would retain Sage's preference for the
left by having the vanilla kernel() give back a left kernel.  The
changes would be more efficient computationally and also make the code
more expressive of what is really happening when and where.

Comments, suggestions, warnings?

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to