Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

""" 

Linear Groups 

 

EXAMPLES:: 

 

sage: GL(4,QQ) 

General Linear Group of degree 4 over Rational Field 

sage: GL(1,ZZ) 

General Linear Group of degree 1 over Integer Ring 

sage: GL(100,RR) 

General Linear Group of degree 100 over Real Field with 53 bits of precision 

sage: GL(3,GF(49,'a')) 

General Linear Group of degree 3 over Finite Field in a of size 7^2 

 

sage: SL(2, ZZ) 

Special Linear Group of degree 2 over Integer Ring 

sage: G = SL(2,GF(3)); G 

Special Linear Group of degree 2 over Finite Field of size 3 

sage: G.is_finite() 

True 

sage: G.conjugacy_classes_representatives() 

( 

[1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] 

[0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] 

) 

sage: G = SL(6,GF(5)) 

sage: G.gens() 

( 

[2 0 0 0 0 0] [4 0 0 0 0 1] 

[0 3 0 0 0 0] [4 0 0 0 0 0] 

[0 0 1 0 0 0] [0 4 0 0 0 0] 

[0 0 0 1 0 0] [0 0 4 0 0 0] 

[0 0 0 0 1 0] [0 0 0 4 0 0] 

[0 0 0 0 0 1], [0 0 0 0 4 0] 

) 

 

AUTHORS: 

 

- William Stein: initial version 

 

- David Joyner: degree, base_ring, random, order methods; examples 

 

- David Joyner (2006-05): added center, more examples, renamed random 

attributes, bug fixes. 

 

- William Stein (2006-12): total rewrite 

 

- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring. 

 

REFERENCES: See [KL1990]_ and [Car1972]_. 

""" 

 

#***************************************************************************** 

# Copyright (C) 2006 David Joyner and William Stein <wstein@gmail.com> 

# Copyright (C) 2013 Volker Braun <vbraun.name@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

from sage.misc.latex import latex 

from sage.groups.matrix_gps.named_group import ( 

normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap ) 

from sage.categories.groups import Groups 

 

 

############################################################################### 

# General Linear Group 

############################################################################### 

 

def GL(n, R, var='a'): 

""" 

Return the general linear group. 

 

The general linear group `GL( d, R )` consists of all `d \times d` 

matrices that are invertible over the ring `R`. 

 

.. NOTE:: 

 

This group is also available via ``groups.matrix.GL()``. 

 

INPUT: 

 

- ``n`` -- a positive integer. 

 

- ``R`` -- ring or an integer. If an integer is specified, the 

corresponding finite field is used. 

 

- ``var`` -- variable used to represent generator of the finite 

field, if needed. 

 

EXAMPLES:: 

 

sage: G = GL(6,GF(5)) 

sage: G.order() 

11064475422000000000000000 

sage: G.base_ring() 

Finite Field of size 5 

sage: G.category() 

Category of finite groups 

sage: TestSuite(G).run() 

 

sage: G = GL(6, QQ) 

sage: G.category() 

Category of infinite groups 

sage: TestSuite(G).run() 

 

Here is the Cayley graph of (relatively small) finite General Linear Group:: 

 

sage: g = GL(2,3) 

sage: d = g.cayley_graph(); d 

Digraph on 48 vertices 

sage: d.plot(color_by_label=True, vertex_size=0.03, vertex_labels=False) # long time 

Graphics object consisting of 144 graphics primitives 

sage: d.plot3d(color_by_label=True) # long time 

Graphics3d Object 

 

:: 

 

sage: F = GF(3); MS = MatrixSpace(F,2,2) 

sage: gens = [MS([[2,0],[0,1]]), MS([[2,1],[2,0]])] 

sage: G = MatrixGroup(gens) 

sage: G.order() 

48 

sage: G.cardinality() 

48 

sage: H = GL(2,F) 

sage: H.order() 

48 

sage: H == G 

True 

sage: H.gens() == G.gens() 

True 

sage: H.as_matrix_group() == H 

True 

sage: H.gens() 

( 

[2 0] [2 1] 

[0 1], [2 0] 

) 

 

TESTS:: 

 

sage: groups.matrix.GL(2, 3) 

General Linear Group of degree 2 over Finite Field of size 3 

""" 

degree, ring = normalize_args_vectorspace(n, R, var='a') 

try: 

if ring.is_finite(): 

cat = Groups().Finite() 

else: 

cat = Groups().Infinite() 

except AttributeError: 

cat = Groups() 

name = 'General Linear Group of degree {0} over {1}'.format(degree, ring) 

ltx = 'GL({0}, {1})'.format(degree, latex(ring)) 

try: 

cmd = 'GL({0}, {1})'.format(degree, ring._gap_init_()) 

return LinearMatrixGroup_gap(degree, ring, False, name, ltx, cmd, 

category=cat) 

except ValueError: 

return LinearMatrixGroup_generic(degree, ring, False, name, ltx, 

category=cat) 

 

 

 

############################################################################### 

# Special Linear Group 

############################################################################### 

 

def SL(n, R, var='a'): 

r""" 

Return the special linear group. 

 

The special linear group `SL( d, R )` consists of all `d \times d` 

matrices that are invertible over the ring `R` with determinant 

one. 

 

.. note:: 

 

This group is also available via ``groups.matrix.SL()``. 

 

INPUT: 

 

- ``n`` -- a positive integer. 

 

- ``R`` -- ring or an integer. If an integer is specified, the 

corresponding finite field is used. 

 

- ``var`` -- variable used to represent generator of the finite 

field, if needed. 

 

EXAMPLES:: 

 

sage: SL(3, GF(2)) 

Special Linear Group of degree 3 over Finite Field of size 2 

sage: G = SL(15, GF(7)); G 

Special Linear Group of degree 15 over Finite Field of size 7 

sage: G.category() 

Category of finite groups 

sage: G.order() 

1956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000 

sage: len(G.gens()) 

2 

sage: G = SL(2, ZZ); G 

Special Linear Group of degree 2 over Integer Ring 

sage: G.category() 

Category of infinite groups 

sage: G.gens() 

( 

[ 0 1] [1 1] 

[-1 0], [0 1] 

) 

 

Next we compute generators for `\mathrm{SL}_3(\ZZ)` :: 

 

sage: G = SL(3,ZZ); G 

Special Linear Group of degree 3 over Integer Ring 

sage: G.gens() 

( 

[0 1 0] [ 0 1 0] [1 1 0] 

[0 0 1] [-1 0 0] [0 1 0] 

[1 0 0], [ 0 0 1], [0 0 1] 

) 

sage: TestSuite(G).run() 

 

TESTS:: 

 

sage: groups.matrix.SL(2, 3) 

Special Linear Group of degree 2 over Finite Field of size 3 

""" 

degree, ring = normalize_args_vectorspace(n, R, var='a') 

try: 

if ring.is_finite() or n == 1: 

cat = Groups().Finite() 

else: 

cat = Groups().Infinite() 

except AttributeError: 

cat = Groups() 

name = 'Special Linear Group of degree {0} over {1}'.format(degree, ring) 

ltx = 'SL({0}, {1})'.format(degree, latex(ring)) 

from sage.libs.gap.libgap import libgap 

try: 

cmd = 'SL({0}, {1})'.format(degree, ring._gap_init_()) 

return LinearMatrixGroup_gap(degree, ring, True, name, ltx, cmd, 

category=cat) 

except ValueError: 

return LinearMatrixGroup_generic(degree, ring, True, name, ltx, 

category=cat) 

 

 

 

######################################################################## 

# Linear Matrix Group class 

######################################################################## 

 

class LinearMatrixGroup_generic(NamedMatrixGroup_generic): 

 

def _check_matrix(self, x, *args): 

"""a 

Check whether the matrix ``x`` is special linear. 

 

See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix` 

for details. 

 

EXAMPLES:: 

 

sage: G = SL(2,GF(5)) 

sage: G._check_matrix(G.an_element().matrix()) 

""" 

if self._special: 

if x.determinant() != 1: 

raise TypeError('matrix must have determinant one') 

else: 

if x.determinant() == 0: 

raise TypeError('matrix must non-zero determinant') 

 

 

class LinearMatrixGroup_gap(NamedMatrixGroup_gap, LinearMatrixGroup_generic): 

pass