William, Thanks for the reply. I hadn't dug deep enough to find the "with_basis" variant of the submodule constructor, so I like the suggested approach. Barring anymore significant conversation here, I'll take on submitting this with a ticket and a patch. It'll be a learning experience for me (and make more work for Michael to guide me through the contribution process). ;-)
Rob On Jan 28, 3:34 pm, William Stein <wst...@gmail.com> wrote: > On Wed, Jan 28, 2009 at 3:07 PM, Rob Beezer <goo...@beezer.cotse.net> wrote: > > > A question about computing bases for kernels or null spaces of > > matrices. > > > When working with students studying linear algebra for the first time, > > I like to construct basis vectors for the (right) kernel by working > > through the indices of the non-pivot columns of the reduced row > > echelon form of the matrix, setting these entries to zero, with the > > exception of one entry that is set to 1. Then the other entries are > > just negatives of certain entries of the echelon form matrix. > > > This very approach is used (on the transpose) to compute the (left) > > kernel. But then it gets used in the constructor of a subspace, which > > calls a submodule constructor, which "echelonizes" the basis > > (presumably to achieve some canonical representation). This means the > > kernel produces a vector space with a very nice basis, but my students > > won't recognize it. I'd like to get the pivot/non-pivot basis back. > > > Could the construction of the pivot/non-pivot basis be isolated from > > the kernel() code in matrix2.pyx? And maybe called nullspace_basis > > () or something similar? Then kernel() could call this method on the > > transpose, and use the result to construct the subspace. > > That's a great idea. > > I just looked at the kernel code in matrix2.pyx. Currently there is > only left_kernel and right_kernel. I notice with bemusement that > *both* functions transpose their input then do something! Pretty > stupid. > > I think the right change for your application would be to change this > line in left_kernel: > > W = V.submodule(basis) > > to > > if echelonize: > W = V.submodule(basis) > else: > W = V.submodule_with_basis(basis) > > then put an echelonize=True option in the left_kernel function header. > > William > > -- William --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---