Hi All, I have been playing with some code where I want to find a submodule of a module V which is annihilated by a bunch of maps. What I want to do something like the following:
V= some free submodule of rank v inside a space of rank d\ge v. mat=[[0 for col in range(w)] for row in range(v)] # fairly sparse matrix which describes the map f on bases of V and W ...compute non-zero entries of the matrix ``mat`` V = V.intersection( matrix(mat).kernel() ) where v=dim V, w=dim W where f is a map from V to W. Of course, this doesn't quite work because matrix(mat).kernel() returns a submodule of ZZ^v with respect to its standard basis whereas the space V has a very different basis in general. To get around this I found myself writing kernel=V.submodule_with_basis([V.linear_combination_of_basis(b.list()) for b in matrix(pmat).kernel().basis()]) V=V.intersection(kernel) This strikes me as being a very convoluted way of writing something is presumably quite common: writing the standard basis elements as linear combinations of another basis. My question is: is there a better way to do this? For a little while, I tried defining W=FreeModule(ZZ,w) and then constructing the map f explicitly as a homomorphism from V to W. Doing it this way does make f.kernel() into a submodule of V, but this approach just seems to create a lot of extra overhead with very little benefit as I essentially still had to construct the matrix ``mat`` above and used it to define ``f`` with respect to the bases of ``V`` and ``W``. In fact, all this really did was shift my problem above of writing the basis of the kernel in terms of the basis of V to the problem of writing the images of f in terms of the standard basis of W. (Even though I imagine that this second approach is much slower I really should have checked by doing some profiling before rewriting as above, but I didn't...) Any thoughts? Cheers, Andrew -- 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.
