On Tuesday, December 4, 2012 3:14:27 AM UTC-8, Andrew Mathas wrote: > > Thanks Nils. I this is similar to, but more elegant than, what I tried > earlier. I went back to the solution above, however, I thought that there > was probably a lot of overhead in creating the space ZZ^3 and the > homomorphism. Indeed, > > %timeit V.hom([(ZZ^3)(v) for v in [[1,2,3],[2,1,4],[3,3,7]]]).kernel() > 125 loops, best of 3: 2.15 ms per loop > > sage: %timeit > V.submodule_with_basis([V.linear_combination_of_basis(b.list()) for b in > mat.kernel().basis()]) > 625 loops, best of 3: 1.39 ms per loop > > so it does seem to be slower, although one example is hardly definitive. >
I wouldn't draw any conclusions from that. In one timeit you are still constructing the matrix/hom whereas in the other you already have it. Anyway, indeed, the whole module (homomorphism) code is incredibly inefficient because special cases such a ZZ-modules haven't been special-cased at all yet (except for computing the kernel code). If you want speed, write it out in matrices: sage: %timeit matrix([[1,2,3],[2,1,4],[3,3,7]]).transpose().right_kernel_matrix()*matrix([[0,1,2,3],[2,3,1,4],[1,3,2,1]]) 625 loops, best of 3: 668 µs per loop As long as you only need submodules it's not so bad. Once you really need quotients (especially non-free ones) you probably are better off using modules. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en.
