本文整理汇总了Python中sage.groups.abelian_gps.abelian_group_element.AbelianGroupElement类的典型用法代码示例。如果您正苦于以下问题:Python AbelianGroupElement类的具体用法?Python AbelianGroupElement怎么用?Python AbelianGroupElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbelianGroupElement类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent, ideal, element=None):
"""
Returns the ideal class of this fractional ideal.
EXAMPLE::
sage: K.<a> = NumberField(x^2 + 23,'a'); G = K.class_group()
sage: G(K.ideal(13, a + 4))
Fractional ideal class (13, 1/2*a + 17/2)
"""
self.__ideal = ideal
if element is None:
element = map(int, ideal.ideal_class_log(proof=parent._proof_flag))
AbelianGroupElement.__init__(self, parent, element)
示例2: __init__
def __init__(self, exponents, parent, value=None):
"""
Create an element
EXAMPLES::
sage: F = AbelianGroupWithValues([1,-1], [2,4])
sage: a,b = F.gens()
sage: a*b^-1 in F
True
sage: (a*b^-1).value()
-1
"""
self._value = value
AbelianGroupElement.__init__(self, exponents, parent)
示例3: _mul_
def _mul_(self, other):
r"""
Multiplication of two (S-)ideal classes.
EXAMPLE::
sage: G = NumberField(x^2 + 23,'a').class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
sage: I = G.0; I
Fractional ideal class (2, 1/2*a - 1/2)
sage: I*I # indirect doctest
Fractional ideal class (2, 1/2*a + 1/2)
sage: I*I*I # indirect doctest
Trivial principal fractional ideal class
sage: K.<a> = QuadraticField(-14)
sage: I = K.ideal(2,a)
sage: S = (I,)
sage: CS = K.S_class_group(S)
sage: G = K.ideal(3,a+1)
sage: CS(G)*CS(G)
Trivial S-ideal class
"""
m = AbelianGroupElement._mul_(self, other)
m._value = (self.ideal() * other.ideal()).reduce_equiv()
return m
示例4: inverse
def inverse(self):
r"""
Return the multiplicative inverse of this ideal class.
EXAMPLE::
sage: K.<a> = NumberField(x^3 - 3*x + 8); G = K.class_group()
sage: G(2, a).inverse()
Fractional ideal class (2, a^2 + 2*a - 1)
"""
m = AbelianGroupElement.inverse(self)
return FractionalIdealClass(self.parent(), (~self.__ideal).reduce_equiv(), m.list())
示例5: inverse
def inverse(self):
r"""
Return the multiplicative inverse of this ideal class.
EXAMPLE::
sage: K.<a> = NumberField(x^3 - 3*x + 8); G = K.class_group()
sage: G(2, a).inverse()
Fractional ideal class (2, a^2 + 2*a - 1)
sage: ~G(2, a)
Fractional ideal class (2, a^2 + 2*a - 1)
"""
m = AbelianGroupElement.inverse(self)
m._value = (~self.ideal()).reduce_equiv()
return m
示例6: _mul_
def _mul_(left, right):
"""
Multiply ``left`` and ``right``
TESTS::
sage: G.<a,b> = AbelianGroupWithValues([5,2], 2)
sage: a._mul_(b)
a*b
sage: a*b
a*b
sage: (a*b).value()
10
"""
m = AbelianGroupElement._mul_(left, right)
m._value = left.value() * right.value()
return m
示例7: _div_
def _div_(left, right):
"""
Divide ``left`` by ``right``
TESTS::
sage: G.<a,b> = AbelianGroupWithValues([5,2], 2)
sage: a._div_(b)
a*b^-1
sage: a/b
a*b^-1
sage: (a/b).value()
5/2
"""
m = AbelianGroupElement._div_(left, right)
m._value = left.value() / right.value()
return m
示例8: _mul_
def _mul_(self, other):
r"""
Multiplies together two S-ideal classes.
EXAMPLES::
sage: K.<a> = QuadraticField(-14)
sage: I = K.ideal(2,a)
sage: S = (I,)
sage: CS = K.S_class_group(S)
sage: G = K.ideal(3,a+1)
sage: CS(G)*CS(G)
Trivial S-ideal class
"""
m = AbelianGroupElement._mul_(self, other)
return SFractionalIdealClass(self.parent(), (self.ideal() * other.ideal()).reduce_equiv(), m.list())
示例9: _div_
def _div_(self, other):
r"""
Division of two ideal classes.
EXAMPLE::
sage: G = NumberField(x^2 + 23,'a').class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
sage: I = G.0; I
Fractional ideal class (2, 1/2*a - 1/2)
sage: I*I # indirect doctest
Fractional ideal class (2, 1/2*a + 1/2)
sage: I*I*I # indirect doctest
Trivial principal fractional ideal class
"""
m = AbelianGroupElement._div_(self, other)
m._value = (self.ideal() / other.ideal()).reduce_equiv()
return m
示例10: order
def order(self):
r"""
Return the order of this ideal class in the class group.
EXAMPLE::
sage: K.<w>=QuadraticField(-23)
sage: OK=K.ring_of_integers()
sage: C=OK.class_group()
sage: [c.order() for c in C]
[1, 3, 3]
sage: k.<a> = NumberField(x^2 + 20072); G = k.class_group(); G
Class group of order 76 with structure C38 x C2 of Number Field in a with defining polynomial x^2 + 20072
sage: [c.order() for c in G.gens()]
[38, 2]
"""
# an old method with a new docstring
return AbelianGroupElement.order(self)
示例11: __pow__
def __pow__(self, n):
"""
Exponentiate ``self``
INPUT:
- ``n`` -- integer. The exponent.
TESTS::
sage: G.<a,b> = AbelianGroupWithValues([5,2], 2)
sage: a^3
a^3
sage: (a^3).value()
125
"""
m = Integer(n)
if n != m:
raise TypeError('argument n (= '+str(n)+') must be an integer.')
pow_self = AbelianGroupElement.__pow__(self, m)
pow_self._value = pow(self.value(), m)
return pow_self
示例12: inverse
def inverse(self):
"""
Return the inverse element.
EXAMPLE::
sage: G.<a,b> = AbelianGroupWithValues([2,-1], [0,4])
sage: a.inverse()
a^-1
sage: a.inverse().value()
1/2
sage: a.__invert__().value()
1/2
sage: (~a).value()
1/2
sage: (a*b).value()
-2
sage: (a*b).inverse().value()
-1/2
"""
m = AbelianGroupElement.inverse(self)
m._value = ~self.value()
return m