コード例 #1
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
    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
0
ファイル: class_group.py プロジェクト: dagss/sage
    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)
コード例 #3
0
ファイル: values.py プロジェクト: biasse/sage
    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)
コード例 #4
0
    def __init__(self, parent, exponents, 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, parent, exponents)
コード例 #5
0
    def _mul_(self, other):
        r"""
        Multiplication of two (S-)ideal classes.

        EXAMPLES::

            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
コード例 #6
0
ファイル: class_group.py プロジェクト: BlairArchibald/sage
    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
コード例 #7
0
ファイル: class_group.py プロジェクト: dagss/sage
 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())
コード例 #8
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
 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())
コード例 #9
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
    def __init__(self, parent, ideal, element=None):
        r"""
        Returns the S-ideal class of this fractional ideal.

        EXAMPLES::
        
            sage: K.<a> = QuadraticField(-14)
            sage: I = K.ideal(2,a)                  
            sage: S = (I,)
            sage: CS = K.S_class_group(S)
            sage: J = K.ideal(7,a)
            sage: G = K.ideal(3,a+1)
            sage: CS(I)
            Trivial S-ideal class
            sage: CS(J)
            Trivial S-ideal class
            sage: CS(G)
            Fractional S-ideal class (3, a + 1)
        """
        self.__ideal = ideal
        if element is None:
            element = ideal.S_ideal_class_log(parent.S())
        AbelianGroupElement.__init__(self, parent, element)
コード例 #10
0
ファイル: class_group.py プロジェクト: dagss/sage
    def __init__(self, parent, ideal, element=None):
        r"""
        Returns the S-ideal class of this fractional ideal.

        EXAMPLES::
        
            sage: K.<a> = QuadraticField(-14)
            sage: I = K.ideal(2,a)                  
            sage: S = (I,)
            sage: CS = K.S_class_group(S)
            sage: J = K.ideal(7,a)
            sage: G = K.ideal(3,a+1)
            sage: CS(I)
            Trivial S-ideal class
            sage: CS(J)
            Trivial S-ideal class
            sage: CS(G)
            Fractional S-ideal class (3, a + 1)
        """
        self.__ideal = ideal
        if element is None:
            element = ideal.S_ideal_class_log(parent.S())
        AbelianGroupElement.__init__(self, parent, element)
コード例 #11
0
ファイル: class_group.py プロジェクト: BlairArchibald/sage
    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
コード例 #12
0
    def inverse(self):
        r"""
        Return the multiplicative inverse of this ideal class.

        EXAMPLES::

            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
コード例 #13
0
ファイル: unit_group.py プロジェクト: thalespaiva/sagelib
    def __call__(self, u):
        """
        Returns the abstract group element corresponding to the unit u.

        INPUT:

        - ``u`` -- Any object from which an element of the unit group's number
          field `K` may be constructed; an error is raised if an element of `K`
          cannot be constructed from u, or if the element constructed is not a
          unit.

        EXAMPLES::

            sage: x = polygen(QQ)
            sage: K.<a> = NumberField(x^2-38)
            sage: UK = UnitGroup(K)
            sage: UK(1)
            1
            sage: UK(-1)
            u0
            sage: UK.gens()
            [-1, 6*a - 37]
            sage: UK.ngens()
            2
            sage: [UK(u) for u in UK.gens()]
            [u0, u1]
            sage: [UK(u).list() for u in UK.gens()]
            [[1, 0], [0, 1]]
            sage: UK(a)
            Traceback (most recent call last):
            ...
            ValueError: a is not a unit
        """
        K = self.__number_field

        try:
            u = K(u)
        except TypeError:
            raise ValueError, "%s is not an element of %s"%(u,K)
        if not u.is_integral() or u.norm().abs() != 1:
            raise ValueError, "%s is not a unit"%u
        m = K.pari_bnf().bnfisunit(pari(u)).mattranspose()
        # convert column matrix to a list:
        m = [ZZ(m[0,i].python()) for i in range(m.ncols())]
        # NB pari puts the torsion at the end!
        m.insert(0,m.pop())
        return AbelianGroupElement(self, m)
コード例 #14
0
    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
コード例 #15
0
ファイル: class_group.py プロジェクト: dagss/sage
 def inverse(self):
     r"""
     Finds the inverse of the given S-ideal class.
     
     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).inverse()
         Fractional S-ideal class (3, a + 2)
     """
     m = AbelianGroupElement.inverse(self)
     inv_ideal = self.parent().number_field().class_group()(self.ideal()).inverse().ideal()
     return SFractionalIdealClass(self.parent(), inv_ideal , m.list())
コード例 #16
0
ファイル: class_group.py プロジェクト: dagss/sage
    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())
コード例 #17
0
ファイル: class_group.py プロジェクト: dagss/sage
    def _mul_(self, other):
        r"""
        Multiplication 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._mul_(self, other)
        return FractionalIdealClass(self.parent(), (self.__ideal * other.__ideal).reduce_equiv(), m.list())
コード例 #18
0
    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
コード例 #19
0
ファイル: values.py プロジェクト: biasse/sage
    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
コード例 #20
0
ファイル: values.py プロジェクト: biasse/sage
    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
コード例 #21
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
 def inverse(self):
     r"""
     Finds the inverse of the given S-ideal class.
     
     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).inverse()
         Fractional S-ideal class (3, a + 2)
     """
     m = AbelianGroupElement.inverse(self)
     inv_ideal = self.parent().number_field().class_group()(
         self.ideal()).inverse().ideal()
     return SFractionalIdealClass(self.parent(), inv_ideal, m.list())
コード例 #22
0
    def _div_(self, other):
        r"""
        Division of two ideal classes.

        EXAMPLES::

            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
コード例 #23
0
ファイル: class_group.py プロジェクト: BlairArchibald/sage
    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
コード例 #24
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
    def _mul_(self, other):
        r"""
        Multiplication 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._mul_(self, other)
        return FractionalIdealClass(
            self.parent(), (self.__ideal * other.__ideal).reduce_equiv(),
            m.list())
コード例 #25
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
    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())
コード例 #26
0
ファイル: class_group.py プロジェクト: dagss/sage
    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)
コード例 #27
0
ファイル: class_group.py プロジェクト: thalespaiva/sagelib
    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)
コード例 #28
0
ファイル: values.py プロジェクト: biasse/sage
    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
コード例 #29
0
ファイル: values.py プロジェクト: sagemathinc/smc-sage
    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
コード例 #30
0
    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
コード例 #31
0
ファイル: values.py プロジェクト: biasse/sage
    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
コード例 #32
0
 def _element_constructor_(self, *args, **kwargs):
     try:
         return AbelianGroupElement(args[0], self)
     except:
         I = self.__number_field.ideal(*args, **kwargs)
         return AbelianGroupElement(self, self.log(I))