Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/groups/matrix_gps/linear.py
8815 views
1
"""
2
Linear Groups
3
4
EXAMPLES::
5
6
sage: GL(4,QQ)
7
General Linear Group of degree 4 over Rational Field
8
sage: GL(1,ZZ)
9
General Linear Group of degree 1 over Integer Ring
10
sage: GL(100,RR)
11
General Linear Group of degree 100 over Real Field with 53 bits of precision
12
sage: GL(3,GF(49,'a'))
13
General Linear Group of degree 3 over Finite Field in a of size 7^2
14
15
sage: SL(2, ZZ)
16
Special Linear Group of degree 2 over Integer Ring
17
sage: G = SL(2,GF(3)); G
18
Special Linear Group of degree 2 over Finite Field of size 3
19
sage: G.is_finite()
20
True
21
sage: G.conjugacy_class_representatives()
22
(
23
[1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2]
24
[0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0]
25
)
26
sage: G = SL(6,GF(5))
27
sage: G.gens()
28
(
29
[2 0 0 0 0 0] [4 0 0 0 0 1]
30
[0 3 0 0 0 0] [4 0 0 0 0 0]
31
[0 0 1 0 0 0] [0 4 0 0 0 0]
32
[0 0 0 1 0 0] [0 0 4 0 0 0]
33
[0 0 0 0 1 0] [0 0 0 4 0 0]
34
[0 0 0 0 0 1], [0 0 0 0 4 0]
35
)
36
37
AUTHORS:
38
39
- William Stein: initial version
40
41
- David Joyner: degree, base_ring, random, order methods; examples
42
43
- David Joyner (2006-05): added center, more examples, renamed random
44
attributes, bug fixes.
45
46
- William Stein (2006-12): total rewrite
47
48
- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.
49
50
REFERENCES:
51
52
- [KL] Peter Kleidman and Martin Liebeck. The subgroup structure of
53
the finite classical groups. Cambridge University Press, 1990.
54
55
- [C] R. W. Carter. Simple groups of Lie type, volume 28 of Pure and
56
Applied Mathematics. John Wiley and Sons, 1972.
57
"""
58
59
#*****************************************************************************
60
# Copyright (C) 2006 David Joyner and William Stein <[email protected]>
61
# Copyright (C) 2013 Volker Braun <[email protected]>
62
#
63
# Distributed under the terms of the GNU General Public License (GPL)
64
#
65
# http://www.gnu.org/licenses/
66
#*****************************************************************************
67
68
from sage.misc.latex import latex
69
from sage.groups.matrix_gps.named_group import (
70
normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )
71
72
73
74
###############################################################################
75
# General Linear Group
76
###############################################################################
77
78
def GL(n, R, var='a'):
79
"""
80
Return the general linear group.
81
82
The general linear group `GL( d, R )` consists of all `d \times d`
83
matrices that are invertible over the ring `R`.
84
85
.. note::
86
87
This group is also available via ``groups.matrix.GL()``.
88
89
INPUT:
90
91
- ``n`` -- a positive integer.
92
93
- ``R`` -- ring or an integer. If an integer is specified, the
94
corresponding finite field is used.
95
96
- ``var`` -- variable used to represent generator of the finite
97
field, if needed.
98
99
EXAMPLES::
100
101
sage: G = GL(6,GF(5))
102
sage: G.order()
103
11064475422000000000000000
104
sage: G.base_ring()
105
Finite Field of size 5
106
sage: G.category()
107
Category of finite groups
108
sage: TestSuite(G).run()
109
110
sage: G = GL(6, QQ)
111
sage: G.category()
112
Category of groups
113
sage: TestSuite(G).run()
114
115
Here is the Cayley graph of (relatively small) finite General Linear Group::
116
117
sage: g = GL(2,3)
118
sage: d = g.cayley_graph(); d
119
Digraph on 48 vertices
120
sage: d.show(color_by_label=True, vertex_size=0.03, vertex_labels=False)
121
sage: d.show3d(color_by_label=True)
122
123
::
124
125
sage: F = GF(3); MS = MatrixSpace(F,2,2)
126
sage: gens = [MS([[2,0],[0,1]]), MS([[2,1],[2,0]])]
127
sage: G = MatrixGroup(gens)
128
sage: G.order()
129
48
130
sage: G.cardinality()
131
48
132
sage: H = GL(2,F)
133
sage: H.order()
134
48
135
sage: H == G
136
True
137
sage: H.gens() == G.gens()
138
True
139
sage: H.as_matrix_group() == H
140
True
141
sage: H.gens()
142
(
143
[2 0] [2 1]
144
[0 1], [2 0]
145
)
146
147
TESTS::
148
149
sage: groups.matrix.GL(2, 3)
150
General Linear Group of degree 2 over Finite Field of size 3
151
"""
152
degree, ring = normalize_args_vectorspace(n, R, var='a')
153
name = 'General Linear Group of degree {0} over {1}'.format(degree, ring)
154
ltx = 'GL({0}, {1})'.format(degree, latex(ring))
155
try:
156
cmd = 'GL({0}, {1})'.format(degree, ring._gap_init_())
157
return LinearMatrixGroup_gap(degree, ring, False, name, ltx, cmd)
158
except ValueError:
159
return LinearMatrixGroup_generic(degree, ring, False, name, ltx)
160
161
162
163
###############################################################################
164
# Special Linear Group
165
###############################################################################
166
167
def SL(n, R, var='a'):
168
r"""
169
Return the special linear group.
170
171
The special linear group `GL( d, R )` consists of all `d \times d`
172
matrices that are invertible over the ring `R` with determinant
173
one.
174
175
.. note::
176
177
This group is also available via ``groups.matrix.SL()``.
178
179
INPUT:
180
181
- ``n`` -- a positive integer.
182
183
- ``R`` -- ring or an integer. If an integer is specified, the
184
corresponding finite field is used.
185
186
- ``var`` -- variable used to represent generator of the finite
187
field, if needed.
188
189
EXAMPLES::
190
191
sage: SL(3, GF(2))
192
Special Linear Group of degree 3 over Finite Field of size 2
193
sage: G = SL(15, GF(7)); G
194
Special Linear Group of degree 15 over Finite Field of size 7
195
sage: G.category()
196
Category of finite groups
197
sage: G.order()
198
1956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000
199
sage: len(G.gens())
200
2
201
sage: G = SL(2, ZZ); G
202
Special Linear Group of degree 2 over Integer Ring
203
sage: G.gens()
204
(
205
[ 0 1] [1 1]
206
[-1 0], [0 1]
207
)
208
209
Next we compute generators for `\mathrm{SL}_3(\ZZ)` ::
210
211
sage: G = SL(3,ZZ); G
212
Special Linear Group of degree 3 over Integer Ring
213
sage: G.gens()
214
(
215
[0 1 0] [ 0 1 0] [1 1 0]
216
[0 0 1] [-1 0 0] [0 1 0]
217
[1 0 0], [ 0 0 1], [0 0 1]
218
)
219
sage: TestSuite(G).run()
220
221
TESTS::
222
223
sage: groups.matrix.SL(2, 3)
224
Special Linear Group of degree 2 over Finite Field of size 3
225
"""
226
degree, ring = normalize_args_vectorspace(n, R, var='a')
227
name = 'Special Linear Group of degree {0} over {1}'.format(degree, ring)
228
ltx = 'SL({0}, {1})'.format(degree, latex(ring))
229
from sage.libs.gap.libgap import libgap
230
try:
231
cmd = 'SL({0}, {1})'.format(degree, ring._gap_init_())
232
return LinearMatrixGroup_gap(degree, ring, True, name, ltx, cmd)
233
except ValueError:
234
return LinearMatrixGroup_generic(degree, ring, True, name, ltx)
235
236
237
238
########################################################################
239
# Linear Matrix Group class
240
########################################################################
241
242
class LinearMatrixGroup_generic(NamedMatrixGroup_generic):
243
244
def _check_matrix(self, x, *args):
245
"""a
246
Check whether the matrix ``x`` is special linear.
247
248
See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`
249
for details.
250
251
EXAMPLES::
252
253
sage: G = SL(2,GF(5))
254
sage: G._check_matrix(G.an_element().matrix())
255
"""
256
if self._special:
257
if x.determinant() != 1:
258
raise TypeError('matrix must have determinant one')
259
else:
260
if x.determinant() == 0:
261
raise TypeError('matrix must non-zero determinant')
262
263
264
class LinearMatrixGroup_gap(NamedMatrixGroup_gap, LinearMatrixGroup_generic):
265
pass
266
267