Esempio n. 1
0
    def __init__(self, generator_orders, names, values, values_group):
        """
        The Python constructor

        TESTS::

            sage: G = AbelianGroupWithValues([2,-1], [0,4]); G
            Multiplicative Abelian group isomorphic to Z x C4

            sage: cm = sage.structure.element.get_coercion_model()
            sage: cm.explain(G, ZZ, operator.add)
            Coercion on left operand via
                Generic morphism:
                  From: Multiplicative Abelian group isomorphic to Z x C4
                  To:   Integer Ring
            Arithmetic performed after coercions.
            Result lives in Integer Ring
            Integer Ring
        """
        self._values = values
        self._values_group = values_group
        AbelianGroup_class.__init__(self, generator_orders, names)
        self._populate_coercion_lists_(embedding=self.values_embedding())
        if self.ngens() != len(self._values):
            raise ValueError('need one value per generator')
Esempio n. 2
0
    def __init__(self, generator_orders, names, values, values_group):
        """
        The Python constructor

        TESTS::

            sage: G = AbelianGroupWithValues([2,-1], [0,4]); G
            Multiplicative Abelian group isomorphic to Z x C4

            sage: cm = sage.structure.element.get_coercion_model()
            sage: cm.explain(G, ZZ, operator.add)
            Coercion on left operand via
                Generic morphism:
                  From: Multiplicative Abelian group isomorphic to Z x C4
                  To:   Integer Ring
            Arithmetic performed after coercions.
            Result lives in Integer Ring
            Integer Ring
        """
        self._values = values
        self._values_group = values_group
        AbelianGroup_class.__init__(self, generator_orders, names)
        self._populate_coercion_lists_(embedding=self.values_embedding())
        if self.ngens() != len(self._values):
            raise ValueError('need one value per generator')
Esempio n. 3
0
    def __init__(self, invariants, names, number_field, gens, proof=True):
        r"""
        Create a class group.

        Note that the error in the test suite below is caused by the fact that
        there is no category of additive abelian groups.

        EXAMPLES::

            sage: K.<a> = NumberField(x^2 + 23)
            sage: G = K.class_group(); G
            Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23

            sage: G.category()
            Category of groups
            sage: TestSuite(G).run() # see #7945
              Failure in _test_category:
            ...
            The following tests failed: _test_elements
        """
        AbelianGroup_class.__init__(self, len(invariants), invariants, names)
        self._proof_flag = proof
        self.__number_field = number_field
        self.__gens = Sequence([FractionalIdealClass(self, x) for x in gens],
                               immutable=True,
                               universe=self,
                               check=False)
Esempio n. 4
0
    def __init__(self, invariants, names, number_field, gens, proof=True):
        r"""
        Create a class group.

        Note that the error in the test suite below is caused by the fact that
        there is no category of additive abelian groups.

        EXAMPLES::

            sage: K.<a> = NumberField(x^2 + 23)
            sage: G = K.class_group(); G
            Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23

            sage: G.category()
            Category of groups
            sage: TestSuite(G).run() # see #7945
              Failure in _test_category:
            ...
            The following tests failed: _test_elements
        """
        AbelianGroup_class.__init__(self, len(invariants), invariants, names)
        self._proof_flag = proof
        self.__number_field = number_field
        self.__gens = Sequence([FractionalIdealClass(self, x) for x in gens], immutable=True,
                               universe=self, check=False)
Esempio n. 5
0
    def __init__(self, number_field, proof=True):
        """
        Create a unit group of a number field.

        INPUT:

        - ``number_field`` - a number field
        - ``proof`` - boolean (default True): proof flag

        The proof flag is passed to pari via the ``pari_bnf()`` function
        which computes the unit group.  See the documentation for the
        number_field module.

        EXAMPLES::

            sage: x = polygen(QQ)
            sage: K.<a> = NumberField(x^2-38)
            sage: UK = K.unit_group(); UK
            Unit group with structure C2 x Z of Number Field in a with defining polynomial x^2 - 38
            sage: UK.gens()
            [-1, 6*a - 37]

            sage: K.<a> = QuadraticField(-3)
            sage: UK = K.unit_group(); UK
            Unit group with structure C6 of Number Field in a with defining polynomial x^2 + 3
            sage: UK.gens()
            [-1/2*a + 1/2]

            sage: K.<z> = CyclotomicField(13)
            sage: UK = K.unit_group(); UK
            Unit group with structure C26 x Z x Z x Z x Z x Z of Cyclotomic Field of order 13 and degree 12
            sage: UK.gens() # random
            [-z^11, z^5 + z^3, z^6 + z^5, z^9 + z^7 + z^5, z^9 + z^5 + z^4 + 1, z^5 + z]
            """
        proof = get_flag(proof, "number_field")
        K = number_field
        pK = K.pari_bnf(proof)
        self.__number_field = K

        # compute the units via pari:
        fu = [K(u) for u in pK.bnfunit()]

        # compute a torsion generator and pick the 'simplest' one:
        n, z = pK.nfrootsof1()
        n = ZZ(n)
        self.__ntu = n
        z = K(z)

        # If we replaced z by another torsion generator we would need
        # to allow for this in the dlog function!  So we do not.

        # Store the actual generators (torsion first):
        gens = [z] + fu
        self.__nfu = len(fu)
        self.__gens = Sequence(gens, immutable=True, universe=self, check=False)
        # Construct the abtract group:
        AbelianGroup_class.__init__(self, 1 + len(fu), [n] + [0] * len(fu), "u")
Esempio n. 6
0
    def __init__(self, number_field, proof=True):
        """
        Create a unit group of a number field.

        INPUT:

        - ``number_field`` - a number field
        - ``proof`` - boolean (default True): proof flag

        The proof flag is passed to pari via the ``pari_bnf()`` function
        which computes the unit group.  See the documentation for the
        number_field module.

        EXAMPLES::

            sage: x = polygen(QQ)
            sage: K.<a> = NumberField(x^2-38)
            sage: UK = K.unit_group(); UK
            Unit group with structure C2 x Z of Number Field in a with defining polynomial x^2 - 38
            sage: UK.gens()
            [-1, 6*a - 37]

            sage: K.<a> = QuadraticField(-3)
            sage: UK = K.unit_group(); UK
            Unit group with structure C6 of Number Field in a with defining polynomial x^2 + 3
            sage: UK.gens()
            [-1/2*a + 1/2]

            sage: K.<z> = CyclotomicField(13)
            sage: UK = K.unit_group(); UK
            Unit group with structure C26 x Z x Z x Z x Z x Z of Cyclotomic Field of order 13 and degree 12
            sage: UK.gens() # random
            [-z^11, z^5 + z^3, z^6 + z^5, z^9 + z^7 + z^5, z^9 + z^5 + z^4 + 1, z^5 + z]
            """
        proof = get_flag(proof, "number_field")
        K = number_field
        pK = K.pari_bnf(proof)
        self.__number_field = K

        # compute the units via pari:
        fu = [K(u) for u in pK.bnfunit()]

        # compute a torsion generator and pick the 'simplest' one:
        n, z = pK.nfrootsof1()
        n = ZZ(n)
        self.__ntu = n
        z = K(z)

        # If we replaced z by another torsion generator we would need
        # to allow for this in the dlog function!  So we do not.

        # Store the actual generators (torsion first):
        gens = [z] + fu
        self.__nfu = len(fu)
        self.__gens = Sequence(gens, immutable=True, universe=self, check=False)
        # Construct the abtract group:        
        AbelianGroup_class.__init__(self, 1+len(fu), [n]+[0]*len(fu), 'u')
Esempio n. 7
0
    def __init__(self,
                 field,
                 generator_orders,
                 algorithm=None,
                 gen_names='sigma'):
        r"""
        Initialize this Galois group.

        TESTS::

            sage: TestSuite(GF(9).galois_group()).run()
        """
        self._field = field
        self._default_algorithm = algorithm
        AbelianGroup_class.__init__(self, generator_orders, gen_names)
Esempio n. 8
0
    def gen(self, i=0):
        """
        The `i`-th generator of the abelian group.

        INPUT:

        - ``i`` -- integer (default: 0). The index of the generator.

        OUTPUT:

        A group element.

        EXAMPLES::

            sage: F = AbelianGroupWithValues([1,2,3,4,5], 5,[],names='a')
            sage: F.0
            a0
            sage: F.0.value()
            1
            sage: F.2
            a2
            sage: F.2.value()
            3

            sage: G = AbelianGroupWithValues([-1,0,1], [2,1,3])
            sage: G.gens()
            (f0, 1, f2)
        """
        g = AbelianGroup_class.gen(self, i)
        g._value = self._values[i]
        return g
Esempio n. 9
0
    def gen(self, i=0):
        """
        The `i`-th generator of the abelian group.

        INPUT:

        - ``i`` -- integer (default: 0). The index of the generator.

        OUTPUT:

        A group element.

        EXAMPLES::

            sage: F = AbelianGroupWithValues([1,2,3,4,5], 5,[],names='a')
            sage: F.0
            a0
            sage: F.0.value()
            1
            sage: F.2
            a2
            sage: F.2.value()
            3

            sage: G = AbelianGroupWithValues([-1,0,1], [2,1,3])
            sage: G.gens()
            (f0, 1, f2)
        """
        g = AbelianGroup_class.gen(self, i)
        g._value = self._values[i]
        return g
Esempio n. 10
0
    def __init__(self, number_field, mod_ideal=1, mod_archimedean=None):
        if mod_archimedean is None:
            mod_archimedean = [0] * len(number_field.real_places())
        mod_ideal = number_field.ideal(mod_ideal)

        bnf = gp(number_field.pari_bnf())
        # Use PARI to compute ray class group
        bnr = bnf.bnrinit([mod_ideal, mod_archimedean], 1)
        invariants = bnr[5][2]  # bnr.clgp.cyc
        invariants = tuple([Integer(x) for x in invariants])
        names = tuple(["I%i" % i for i in range(len(invariants))])
        generators = bnr[5][3]  # bnr.gen = bnr.clgp[3]
        generators = [number_field.ideal(pari(x)) for x in generators]

        AbelianGroup_class.__init__(self, invariants, names)
        self.__number_field = number_field
        self.__bnr = bnr
        self.__pari_mod = bnr[2][1]
        self.__mod_ideal = mod_ideal
        self.__mod_arch = mod_archimedean
        self.__generators = generators
Esempio n. 11
0
    def __init__(self, number_field, mod_ideal = 1, mod_archimedean = None):
        if mod_archimedean == None:
            mod_archimedean = [0] * len(number_field.real_places())
        mod_ideal = number_field.ideal( mod_ideal )

        bnf = gp(number_field.pari_bnf())
        # Use PARI to compute ray class group
        bnr = bnf.bnrinit([mod_ideal, mod_archimedean],1)
        invariants = bnr[5][2]         # bnr.clgp.cyc
        invariants = tuple([ Integer(x) for x in invariants ])
        names = tuple([ "I%i"%i for i in range(len(invariants)) ])
        generators = bnr[5][3]         # bnr.gen = bnr.clgp[3]
        generators = [ number_field.ideal(pari(x)) for x in generators ]

        AbelianGroup_class.__init__(self, invariants, names)
        self.__number_field = number_field
        self.__bnr = bnr
        self.__pari_mod = bnr[2][1]
        self.__mod_ideal = mod_ideal
        self.__mod_arch = mod_archimedean
        self.__generators = generators
Esempio n. 12
0
    def __init__(self, invariants, names, number_field, gens, S, proof=True):
        r"""
        Create an S-class group.

        EXAMPLES::
        
            sage: K.<a> = QuadraticField(-14)
            sage: I = K.ideal(2,a)                  
            sage: S = (I,)
            sage: K.S_class_group(S)
            S-class group of order 2 with structure C2 of Number Field in a with defining polynomial x^2 + 14
            sage: K.<a> = QuadraticField(-105)
            sage: K.S_class_group([K.ideal(13, a + 8)])
            S-class group of order 4 with structure C2 x C2 of Number Field in a with defining polynomial x^2 + 105
        """
        AbelianGroup_class.__init__(self, len(invariants), invariants, names)
        self._proof_flag = proof
        self.__number_field = number_field
        self.__S = S
        self.__gens = Sequence([SFractionalIdealClass(self, x) for x in gens], immutable=True,
                               universe=self, check=False)
Esempio n. 13
0
    def __init__(self, invariants, names, number_field, gens, S, proof=True):
        r"""
        Create an S-class group.

        EXAMPLES::
        
            sage: K.<a> = QuadraticField(-14)
            sage: I = K.ideal(2,a)                  
            sage: S = (I,)
            sage: K.S_class_group(S)
            S-class group of order 2 with structure C2 of Number Field in a with defining polynomial x^2 + 14
            sage: K.<a> = QuadraticField(-105)
            sage: K.S_class_group([K.ideal(13, a + 8)])
            S-class group of order 4 with structure C2 x C2 of Number Field in a with defining polynomial x^2 + 105
        """
        AbelianGroup_class.__init__(self, len(invariants), invariants, names)
        self._proof_flag = proof
        self.__number_field = number_field
        self.__S = S
        self.__gens = Sequence([SFractionalIdealClass(self, x) for x in gens],
                               immutable=True,
                               universe=self,
                               check=False)