On Aug 28, 2008, at 6:20 AM, John Cremona wrote:

>
> Thanks for your comments, David.  I am having some success:
>
> sage: A = AbelianGroup([2,3])
> sage: A.list()
> [1, f1, f1^2, f0, f0*f1, f0*f1^2]
> sage: A = AbelianGroup([2,3],operation='+')
> sage: A.list()
> [0, f1, 2*f1, f0, f0+f1, f0+2*f1]
>
> sage: A = AbelianGroup([2,3], names='ab')
> sage: A.list()
> [1, b, b^2, a, a*b, a*b^2]
> sage: A = AbelianGroup([2,3],names='ab',operation='+')
> sage: A.list()
> [0, b, 2*b, a, a+b, a+2*b]
>
> The one thing I cannot get to work in the additive case is  (for
> example) 2*g where g is a group element.  I have tried all possible
> combinations of __lmul__, _lmul_, __rmul__, _rmul_, but although I
> have this ok:
>
> sage: a,b=A.gens()
> sage: b._lmul_(20)
> 2*b
> sage: 2*b
>
> inputting 20*b gives an error:
> TypeError                                 Traceback (most recent  
> call last)
>
> /home/john/sage-3.1.final/<ipython console> in <module>()
>
> /home/john/sage-3.1.final/element.pyx in
> sage.structure.element.RingElement.__mul__
> (sage/structure/element.c:9190)()
>
> /home/john/sage-3.1.final/coerce.pyx in
> sage.structure.coerce.CoercionModel_cache_maps.bin_op
> (sage/structure/coerce.c:6288)()
>
> TypeError: unsupported operand parent(s) for '*': 'Integer Ring' and
> 'Additive Abelian Group isomorphic to C2 x C3'
>
> Maybe someone who understands coercion can tell me how to get  
> around this?

You need to implement _lmul_ and make sure the basering is Z.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to