Hi Uptal, Yep, you're exactly right about what's causing this issue -- each time you call SL2Z(), it creates a new object. However, there's no need for this -- after all, SL2Z is a real mathematical object, so it should be a distinct object in Sage, just like ZZ or QQ. So I've made this change, and posted a patch at:
http://trac.sagemath.org/sage_trac/ticket/3275 It'll be in the next version of Sage (3.0.2). Note that this means you'll want to use it slightly differently -- so your example would become: sage: S = SL2Z([0,-1,1,0]) sage: T = SL2Z([1,1,0,1]) sage: S*T [ 0 -1] [ 1 1] Or better yet: sage: S = SL2Z.0 ; S [ 0 -1] [ 1 0] Definitely let us know if you run into any more trouble! -cc On Thu, May 22, 2008 at 2:14 PM, Utpal Sarkar <[EMAIL PROTECTED]> wrote: > > Hi, > > There are problems doing arithmetic in SL_2(Z): > S,T = SL2Z().gens() > S*T; # no problem > S^2*T^3; # no problem > S^-2*T^-3; # no problem > but when I multiply two elements with different exponent: > S^-2*T^3; > S^2*T^-3; > T^2*T^-3; > I get a > <type 'exceptions.TypeError'>: Cannot convert > sage.matrix.matrix_integer_2x2.Matrix_integer_2x2 to > sage.matrix.matrix_integer_dense.Matrix_integer_dense > However, T.parent() and (T^-1).parent() return the same thing (both > equal string values "Modular Group SL(2,Z)" and equal when directly > compared with == and even with 'is'). > When I do > sage: S = SL2Z()([0,-1,1,0]) > sage: T = SL2Z()([1,1,0,1]) > sage: S*T > I even get a runtime error: > <type 'exceptions.RuntimeError'>: There is a bug in the coercion code > in SAGE. > In this case in fact the parents are not equal: they are when compared > with ==, but not with 'is'. > (That's fine, that is more something of the implementation) > Finally, if I do > sage: G = SL2Z() > sage: S = G([0,-1,1,0]) > sage: T = G([1,1,0,1]) > then I can work correctly with S and T. > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
