示例#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 _subgroup_constructor(self, libgap_subgroup):
        """
        Return a finitely generated subgroup.

        See
        :meth:`sage.groups.libgap_wrapper.ParentLibGAP._subgroup_constructor`
        for details.

        TESTS::

            sage: SL2Z = SL(2,ZZ)
            sage: S, T = SL2Z.gens()
            sage: G = SL2Z.subgroup([T^2]); G   # indirect doctest
            Subgroup with 1 generators (
            [1 2]
            [0 1]
            ) of Special Linear Group of degree 2 over Integer Ring
            sage: G.ambient() is SL2Z
            True
        """
        cat = Groups()
        if self in Groups().Finite():
            cat = cat.Finite()
        from sage.groups.matrix_gps.finitely_generated import FinitelyGeneratedMatrixGroup_gap
        return FinitelyGeneratedMatrixGroup_gap(self.degree(),
                                                self.base_ring(),
                                                libgap_subgroup,
                                                ambient=self,
                                                category=cat)
示例#3
0
    def __init__(self, degree, base_ring, category=None):
        """
        Base class for matrix groups over generic base rings

        You should not use this class directly. Instead, use one of
        the more specialized derived classes.

        INPUT:

        - ``degree`` -- integer. The degree (matrix size) of the
          matrix group.

        - ``base_ring`` -- ring. The base ring of the matrices.

        TESTS::

            sage: G = GL(2, QQ)
            sage: from sage.groups.matrix_gps.matrix_group import MatrixGroup_generic
            sage: isinstance(G, MatrixGroup_generic)
            True
        """
        assert base_ring in Rings
        assert is_Integer(degree)

        self._deg = degree
        if self._deg <= 0:
            raise ValueError('the degree must be at least 1')

        cat = Groups() if category is None else category
        if base_ring in Rings().Finite():
            cat = cat.Finite()
        super(MatrixGroup_generic, self).__init__(base=base_ring, category=cat)
示例#4
0
    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 = 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
        """
        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()

        FinitelyGeneratedMatrixGroup_gap.__init__(self,
                                                  ZZ(dim),
                                                  self._ring,
                                                  gap_group,
                                                  category=cat)
示例#5
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)
示例#6
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)