On Fri, Jan 16, 2009 at 9:22 PM, John H Palmieri <jhpalmier...@gmail.com> wrote: > > 1. How can I compute the cokernel of a matrix? For example: > > sage: mat = matrix(ZZ, 2, 2, [[1, 0], [0, 2]]) > sage: M = FreeModule(ZZ, rank=2) > > Then I would like to use M / mat.image() or M / mat.column_module(), > but those give errors. (It works if M and mat are defined over QQ, and > perhaps over any field?) > > Is there an easy way to do this? If not, are quotients of free modules > (e.g., over PIDs) defined in Sage, and if so, how do I get at them?
This is not implemented in sage. At least you can compute the Smith form which will give the *structure* of the cokernel; it also gives the transformation matrices, which also gives an explicit isomorphism to the cokernel. sage: A = matrix(ZZ, 2, [1,0,0,2]) sage: A.smith_form? sage: A.smith_form() ([1 0] [0 2], [1 0] [0 1], [1 0] [0 1]) sage: A.elementary_divisors() [1, 2] If you want to have a fancy cokernel object you'll have to implement it -- but the work of implementing smith form is at least already in sage. > 2. Another question about free modules: what does == mean, > mathematically, for them? That they are equal as submodules of their ambient tuple-space. All sage free modules are embedded in R^n for some ring R, and A = B if and only if A = B as subsets of the ambient tuple module. > For example: > > sage: id = matrix(ZZ, 2, 2, [[1, 0], [0, 1]]) > sage: id.right_kernel() == FreeModule(ZZ, rank=0) > False The right kernel is the 0 submodule of ZZ^2. You're comparing that to the 0 submodule of ZZ^0. > > I guess if I want to test isomorphism, I should just check that the > ranks are equal? Yes. > > Oh, wait, I just found the method nonembedded_free_module, which looks > like what I want: > > sage: id.right_kernel().nonembedded_free_module() == FreeModule(ZZ, 0) > True > 3. One more thing: is the following a bug? > > sage: id = matrix(ZZ, 2, 2, [[1, 0], [0, 1]]) > > Then id.right_kernel() works, as does id.kernel() (which gives the > left kernel), but id.left_kernel() gives an error: "TypeError: > Argument K (= Integer Ring) must be a field." Yes, that is a bug. Please make a trac ticket. Thanks for trying this stuff out and reporting the above issues! And I hope you're computing homology groups :-) -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---