Path: blob/master/src/sage/groups/matrix_gps/linear.py
8815 views
"""1Linear Groups23EXAMPLES::45sage: GL(4,QQ)6General Linear Group of degree 4 over Rational Field7sage: GL(1,ZZ)8General Linear Group of degree 1 over Integer Ring9sage: GL(100,RR)10General Linear Group of degree 100 over Real Field with 53 bits of precision11sage: GL(3,GF(49,'a'))12General Linear Group of degree 3 over Finite Field in a of size 7^21314sage: SL(2, ZZ)15Special Linear Group of degree 2 over Integer Ring16sage: G = SL(2,GF(3)); G17Special Linear Group of degree 2 over Finite Field of size 318sage: G.is_finite()19True20sage: G.conjugacy_class_representatives()21(22[1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2]23[0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0]24)25sage: G = SL(6,GF(5))26sage: G.gens()27(28[2 0 0 0 0 0] [4 0 0 0 0 1]29[0 3 0 0 0 0] [4 0 0 0 0 0]30[0 0 1 0 0 0] [0 4 0 0 0 0]31[0 0 0 1 0 0] [0 0 4 0 0 0]32[0 0 0 0 1 0] [0 0 0 4 0 0]33[0 0 0 0 0 1], [0 0 0 0 4 0]34)3536AUTHORS:3738- William Stein: initial version3940- David Joyner: degree, base_ring, random, order methods; examples4142- David Joyner (2006-05): added center, more examples, renamed random43attributes, bug fixes.4445- William Stein (2006-12): total rewrite4647- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.4849REFERENCES:5051- [KL] Peter Kleidman and Martin Liebeck. The subgroup structure of52the finite classical groups. Cambridge University Press, 1990.5354- [C] R. W. Carter. Simple groups of Lie type, volume 28 of Pure and55Applied Mathematics. John Wiley and Sons, 1972.56"""5758#*****************************************************************************59# Copyright (C) 2006 David Joyner and William Stein <[email protected]>60# Copyright (C) 2013 Volker Braun <[email protected]>61#62# Distributed under the terms of the GNU General Public License (GPL)63#64# http://www.gnu.org/licenses/65#*****************************************************************************6667from sage.misc.latex import latex68from sage.groups.matrix_gps.named_group import (69normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )70717273###############################################################################74# General Linear Group75###############################################################################7677def GL(n, R, var='a'):78"""79Return the general linear group.8081The general linear group `GL( d, R )` consists of all `d \times d`82matrices that are invertible over the ring `R`.8384.. note::8586This group is also available via ``groups.matrix.GL()``.8788INPUT:8990- ``n`` -- a positive integer.9192- ``R`` -- ring or an integer. If an integer is specified, the93corresponding finite field is used.9495- ``var`` -- variable used to represent generator of the finite96field, if needed.9798EXAMPLES::99100sage: G = GL(6,GF(5))101sage: G.order()10211064475422000000000000000103sage: G.base_ring()104Finite Field of size 5105sage: G.category()106Category of finite groups107sage: TestSuite(G).run()108109sage: G = GL(6, QQ)110sage: G.category()111Category of groups112sage: TestSuite(G).run()113114Here is the Cayley graph of (relatively small) finite General Linear Group::115116sage: g = GL(2,3)117sage: d = g.cayley_graph(); d118Digraph on 48 vertices119sage: d.show(color_by_label=True, vertex_size=0.03, vertex_labels=False)120sage: d.show3d(color_by_label=True)121122::123124sage: F = GF(3); MS = MatrixSpace(F,2,2)125sage: gens = [MS([[2,0],[0,1]]), MS([[2,1],[2,0]])]126sage: G = MatrixGroup(gens)127sage: G.order()12848129sage: G.cardinality()13048131sage: H = GL(2,F)132sage: H.order()13348134sage: H == G135True136sage: H.gens() == G.gens()137True138sage: H.as_matrix_group() == H139True140sage: H.gens()141(142[2 0] [2 1]143[0 1], [2 0]144)145146TESTS::147148sage: groups.matrix.GL(2, 3)149General Linear Group of degree 2 over Finite Field of size 3150"""151degree, ring = normalize_args_vectorspace(n, R, var='a')152name = 'General Linear Group of degree {0} over {1}'.format(degree, ring)153ltx = 'GL({0}, {1})'.format(degree, latex(ring))154try:155cmd = 'GL({0}, {1})'.format(degree, ring._gap_init_())156return LinearMatrixGroup_gap(degree, ring, False, name, ltx, cmd)157except ValueError:158return LinearMatrixGroup_generic(degree, ring, False, name, ltx)159160161162###############################################################################163# Special Linear Group164###############################################################################165166def SL(n, R, var='a'):167r"""168Return the special linear group.169170The special linear group `GL( d, R )` consists of all `d \times d`171matrices that are invertible over the ring `R` with determinant172one.173174.. note::175176This group is also available via ``groups.matrix.SL()``.177178INPUT:179180- ``n`` -- a positive integer.181182- ``R`` -- ring or an integer. If an integer is specified, the183corresponding finite field is used.184185- ``var`` -- variable used to represent generator of the finite186field, if needed.187188EXAMPLES::189190sage: SL(3, GF(2))191Special Linear Group of degree 3 over Finite Field of size 2192sage: G = SL(15, GF(7)); G193Special Linear Group of degree 15 over Finite Field of size 7194sage: G.category()195Category of finite groups196sage: G.order()1971956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000198sage: len(G.gens())1992200sage: G = SL(2, ZZ); G201Special Linear Group of degree 2 over Integer Ring202sage: G.gens()203(204[ 0 1] [1 1]205[-1 0], [0 1]206)207208Next we compute generators for `\mathrm{SL}_3(\ZZ)` ::209210sage: G = SL(3,ZZ); G211Special Linear Group of degree 3 over Integer Ring212sage: G.gens()213(214[0 1 0] [ 0 1 0] [1 1 0]215[0 0 1] [-1 0 0] [0 1 0]216[1 0 0], [ 0 0 1], [0 0 1]217)218sage: TestSuite(G).run()219220TESTS::221222sage: groups.matrix.SL(2, 3)223Special Linear Group of degree 2 over Finite Field of size 3224"""225degree, ring = normalize_args_vectorspace(n, R, var='a')226name = 'Special Linear Group of degree {0} over {1}'.format(degree, ring)227ltx = 'SL({0}, {1})'.format(degree, latex(ring))228from sage.libs.gap.libgap import libgap229try:230cmd = 'SL({0}, {1})'.format(degree, ring._gap_init_())231return LinearMatrixGroup_gap(degree, ring, True, name, ltx, cmd)232except ValueError:233return LinearMatrixGroup_generic(degree, ring, True, name, ltx)234235236237########################################################################238# Linear Matrix Group class239########################################################################240241class LinearMatrixGroup_generic(NamedMatrixGroup_generic):242243def _check_matrix(self, x, *args):244"""a245Check whether the matrix ``x`` is special linear.246247See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`248for details.249250EXAMPLES::251252sage: G = SL(2,GF(5))253sage: G._check_matrix(G.an_element().matrix())254"""255if self._special:256if x.determinant() != 1:257raise TypeError('matrix must have determinant one')258else:259if x.determinant() == 0:260raise TypeError('matrix must non-zero determinant')261262263class LinearMatrixGroup_gap(NamedMatrixGroup_gap, LinearMatrixGroup_generic):264pass265266267