On Jan 16, 9:42 pm, William Stein <wst...@gmail.com> wrote:
> 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.

Okay, I'll take a look.  The next thing I need to figure out is if I
have free modules and morphisms

          f             g
M_1 ----> M_2 ----> M_3

with image(f) in kernel(g), how do I compute kernel(g) / image(f)?  I
suppose linear algebra to change the matrix for f so it is with
respect to a basis for ker(g) instead of w.r.t. M_2...

> > 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.

Okay.

> Thanks for trying this stuff out and reporting the above issues!  And
> I hope you're computing homology groups :-)

Of course that's what I'm doing ;)  I hope to be able to post some
files soon.

  John

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to