コード例 #1
0
    def __init__(self, ambient, gens):
        r"""
        Initialize this subgroup.

        TESTS::

            sage: from sage.groups.abelian_gps.abelian_group_gap import AbelianGroupGap, AbelianGroupSubgroup_gap
            sage: G = AbelianGroupGap([])
            sage: gen = G.gens()
            sage: A = AbelianGroupSubgroup_gap(G, gen)
            sage: TestSuite(A).run()

        Check that we are in the correct category::

            sage: G = AbelianGroupGap([2,3,0])      # optional - gap_packages
            sage: g = G.gens()                      # optional - gap_packages
            sage: H1 = G.subgroup([g[0],g[1]])      # optional - gap_packages
            sage: H1 in Groups().Finite()           # optional - gap_packages
            True
            sage: H2 = G.subgroup([g[0],g[2]])      # optional - gap_packages
            sage: H2 in Groups().Infinite()         # optional - gap_packages
            True
        """
        gens_gap = tuple([g.gap() for g in gens])
        G = ambient.gap().Subgroup(gens_gap)
        from sage.rings.infinity import Infinity
        category = Groups().Commutative()
        if G.Size().sage() < Infinity:
            category = category.Finite()
        else:
            category = category.Infinite()
        # FIXME: Tell the category that it is a Subobjects() category
        # category = category.Subobjects()
        AbelianGroup_gap.__init__(self, G, ambient=ambient, category=category)
コード例 #2
0
    def __init__(self, generator_orders):
        r"""
        Constructor.

        TESTS::

            sage: from sage.groups.abelian_gps.abelian_group_gap import AbelianGroupGap
            sage: A = AbelianGroup((2,3,4))
            sage: TestSuite(A).run()
        """
        category = Groups().Commutative()
        if 0 in generator_orders:
            if not libgap.LoadPackage("Polycyclic"):
                raise ImportError("unable to import polycyclic package")
            G = libgap.eval("AbelianPcpGroup(%s)" % list(generator_orders))
            category = category.Infinite()
            self.Element = AbelianGroupElement_polycyclic
        else:
            G = libgap.AbelianGroup(generator_orders)
            category = category.Finite().Enumerated()
        AbelianGroup_gap.__init__(self, G, category=category)
コード例 #3
0
    def __init__(self, degree, ring):
        """
        Initialize ``self``.

        INPUT:

        - ``degree`` -- integer. The degree of the affine group, that
          is, the dimension of the affine space the group is acting on
          naturally.

        - ``ring`` -- a ring. The base ring of the affine space.

        EXAMPLES::

            sage: Aff6 = AffineGroup(6, QQ)
            sage: Aff6 == Aff6
            True
            sage: Aff6 != Aff6
            False

        TESTS::

            sage: G = AffineGroup(2, GF(5)); G
            Affine Group of degree 2 over Finite Field of size 5
            sage: TestSuite(G).run()
            sage: G.category()
            Category of finite groups

            sage: Aff6 = AffineGroup(6, QQ)
            sage: Aff6.category()
            Category of infinite groups
        """
        self._degree = degree
        cat = Groups()
        if degree == 0 or ring in Rings().Finite():
            cat = cat.Finite()
        elif ring in Rings().Infinite():
            cat = cat.Infinite()
        self._GL = GL(degree, ring)
        Group.__init__(self, base=ring, category=cat)
コード例 #4
0
ファイル: heisenberg.py プロジェクト: swewers/mein_sage
    def __init__(self, n=1, R=0):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: H = groups.matrix.Heisenberg(n=2, R=5)
            sage: TestSuite(H).run()  # long time
            sage: H.category()
            Category of finitely generated finite enumerated groups
            sage: H = groups.matrix.Heisenberg(n=2, R=4)
            sage: TestSuite(H).run()  # long time
            sage: H = groups.matrix.Heisenberg(n=3)
            sage: TestSuite(H).run(max_runs=30, skip="_test_elements")  # long time
            sage: H = groups.matrix.Heisenberg(n=2, R=GF(4))
            sage: TestSuite(H).run()  # long time

        TESTS::

            sage: groups.matrix.Heisenberg(n=2, R=ZZ).category()
            Category of finitely generated infinite enumerated groups
        """
        def elementary_matrix(i, j, val, MS):
            elm = copy(MS.one())
            elm[i, j] = val
            elm.set_immutable()
            return elm

        self._n = n
        self._ring = R
        # We need the generators of the ring as a commutative additive group
        if self._ring is ZZ:
            ring_gens = [self._ring.one()]
        else:
            if self._ring.cardinality() == self._ring.characteristic():
                ring_gens = [self._ring.one()]
            else:
                # This is overkill, but is the only way to ensure
                #   we get all of the elements
                ring_gens = list(self._ring)

        dim = ZZ(n + 2)
        MS = MatrixSpace(self._ring, dim)
        gens_x = [
            elementary_matrix(0, j, gen, MS) for j in range(1, dim - 1)
            for gen in ring_gens
        ]
        gens_y = [
            elementary_matrix(i, dim - 1, gen, MS) for i in range(1, dim - 1)
            for gen in ring_gens
        ]
        gen_z = [elementary_matrix(0, dim - 1, gen, MS) for gen in ring_gens]
        gens = gens_x + gens_y + gen_z

        from sage.libs.gap.libgap import libgap
        gap_gens = [libgap(single_gen) for single_gen in gens]
        gap_group = libgap.Group(gap_gens)

        cat = Groups().FinitelyGenerated()
        if self._ring in Rings().Finite():
            cat = cat.Finite()
        else:
            cat = cat.Infinite()

        FinitelyGeneratedMatrixGroup_gap.__init__(self,
                                                  ZZ(dim),
                                                  self._ring,
                                                  gap_group,
                                                  category=cat)