This class is intended as a template for anything in Sage that needs the functionality of abelian groups. One can create an AdditiveAbelianGroupWrapper object from any given set of elements in some given parent, as long as an _add_ method has been defined.
We create a toy example based on the Mordell-Weil group of an elliptic curve over \(\QQ\):
sage: E = EllipticCurve('30a2') sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] sage: M = AdditiveAbelianGroupWrapper(pts.parent(), pts, [3, 2, 2]) sage: M Additive abelian group isomorphic to Z/3 + Z/2 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - 19*x + 26 over Rational Field sage: M.gens() ((4 : -7 : 1), (7/4 : -11/8 : 1), (3 : -2 : 1)) sage: 3*M.0 (0 : 1 : 0) sage: 3000000000000001 * M.0 (4 : -7 : 1) sage: M == loads(dumps(M)) # known bug, see http://trac.sagemath.org/sage_trac/ticket/11599#comment:7 True
We check that ridiculous operations are being avoided:
sage: set_verbose(2, 'additive_abelian_wrapper.py') sage: 300001 * M.0 verbose 1 (...: additive_abelian_wrapper.py, _discrete_exp) Calling discrete exp on (1, 0, 0) (4 : -7 : 1) sage: set_verbose(0, 'additive_abelian_wrapper.py')
The parent of AdditiveAbelianGroupWrapperElement
The orders of the generators with which this group was initialised. (Note that these are not necessarily a minimal set of generators.) Generators of infinite order are returned as 0. Compare self.invariants(), which returns the orders of a minimal set of generators.
sage: V = Zmod(6)**2 sage: G = AdditiveAbelianGroupWrapper(V, [2*V.0, 3*V.1], [3, 2]) sage: G.generator_orders() (3, 2) sage: G.invariants() (6,)
The ambient group in which this abelian group lives.
sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) sage: G.universe() Algebraic Field
An element of an AdditiveAbelianGroupWrapper.
Return the underlying object that this element wraps.
sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) sage: T; type(T) (0 : 0 : 1) <class 'sage.groups.additive_abelian.additive_abelian_wrapper.EllipticCurveTorsionSubgroup_with_category.element_class'> sage: T.element(); type(T.element()) (0 : 0 : 1) <class 'sage.schemes.elliptic_curves.ell_point.EllipticCurvePoint_number_field'>