Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/groups/matrix_gps/symplectic.py
8815 views
1
"""
2
Symplectic Linear Groups
3
4
EXAMPLES::
5
6
sage: G = Sp(4,GF(7)); G
7
Symplectic Group of degree 4 over Finite Field of size 7
8
sage: g = prod(G.gens()); g
9
[3 0 3 0]
10
[1 0 0 0]
11
[0 1 0 1]
12
[0 2 0 0]
13
sage: m = g.matrix()
14
sage: m * G.invariant_form() * m.transpose() == G.invariant_form()
15
True
16
sage: G.order()
17
276595200
18
19
AUTHORS:
20
21
- David Joyner (2006-03): initial version, modified from
22
special_linear (by W. Stein)
23
24
- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.
25
"""
26
27
#*****************************************************************************
28
# Copyright (C) 2006 David Joyner and William Stein
29
# Copyright (C) 2013 Volker Braun <[email protected]>
30
#
31
# Distributed under the terms of the GNU General Public License (GPL)
32
# http://www.gnu.org/licenses/
33
#*****************************************************************************
34
35
from sage.misc.latex import latex
36
from sage.misc.cachefunc import cached_method
37
from sage.groups.matrix_gps.named_group import (
38
normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )
39
40
41
42
###############################################################################
43
# Symplectic Group
44
###############################################################################
45
46
def Sp(n, R, var='a'):
47
r"""
48
Return the symplectic group.
49
50
The special linear group `GL( d, R )` consists of all `d \times d`
51
matrices that are invertible over the ring `R` with determinant
52
one.
53
54
.. note::
55
56
This group is also available via ``groups.matrix.Sp()``.
57
58
INPUT:
59
60
- ``n`` -- a positive integer.
61
62
- ``R`` -- ring or an integer. If an integer is specified, the
63
corresponding finite field is used.
64
65
- ``var`` -- variable used to represent generator of the finite
66
field, if needed.
67
68
EXAMPLES::
69
70
sage: Sp(4, 5)
71
Symplectic Group of degree 4 over Finite Field of size 5
72
73
sage: Sp(4, IntegerModRing(15))
74
Symplectic Group of degree 4 over Ring of integers modulo 15
75
76
sage: Sp(3, GF(7))
77
Traceback (most recent call last):
78
...
79
ValueError: the degree must be even
80
81
TESTS::
82
83
sage: groups.matrix.Sp(2, 3)
84
Symplectic Group of degree 2 over Finite Field of size 3
85
86
sage: G = Sp(4,5)
87
sage: TestSuite(G).run()
88
"""
89
degree, ring = normalize_args_vectorspace(n, R, var=var)
90
if degree % 2 != 0:
91
raise ValueError('the degree must be even')
92
name = 'Symplectic Group of degree {0} over {1}'.format(degree, ring)
93
ltx = r'\text{{Sp}}_{{{0}}}({1})'.format(degree, latex(ring))
94
from sage.libs.gap.libgap import libgap
95
try:
96
cmd = 'Sp({0}, {1})'.format(degree, ring._gap_init_())
97
return SymplecticMatrixGroup_gap(degree, ring, True, name, ltx, cmd)
98
except ValueError:
99
return SymplecticMatrixGroup_generic(degree, ring, True, name, ltx)
100
101
102
103
class SymplecticMatrixGroup_generic(NamedMatrixGroup_generic):
104
105
@cached_method
106
def invariant_form(self):
107
"""
108
Return the quadratic form preserved by the orthogonal group.
109
110
OUTPUT:
111
112
A matrix.
113
114
EXAMPLES::
115
116
sage: Sp(4, QQ).invariant_form()
117
[0 0 0 1]
118
[0 0 1 0]
119
[0 1 0 0]
120
[1 0 0 0]
121
"""
122
from sage.matrix.constructor import zero_matrix
123
m = zero_matrix(self.base_ring(), self.degree())
124
for i in range(self.degree()):
125
m[i, self.degree()-i-1] = 1
126
m.set_immutable()
127
return m
128
129
def _check_matrix(self, x, *args):
130
"""
131
Check whether the matrix ``x`` is symplectic.
132
133
See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`
134
for details.
135
136
EXAMPLES::
137
138
sage: G = Sp(4,GF(5))
139
sage: G._check_matrix(G.an_element().matrix())
140
"""
141
F = self.invariant_form()
142
if x * F * x.transpose() != F:
143
raise TypeError('matrix must be symplectic')
144
145
146
class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_gap):
147
r"""
148
Symplectic group in GAP
149
150
EXAMPLES::
151
152
sage: Sp(2,4)
153
Symplectic Group of degree 2 over Finite Field in a of size 2^2
154
155
sage: latex(Sp(4,5))
156
\text{Sp}_{4}(\Bold{F}_{5})
157
"""
158
159
@cached_method
160
def invariant_form(self):
161
"""
162
Return the quadratic form preserved by the orthogonal group.
163
164
OUTPUT:
165
166
A matrix.
167
168
EXAMPLES::
169
170
sage: Sp(4, GF(3)).invariant_form()
171
[0 0 0 1]
172
[0 0 1 0]
173
[0 2 0 0]
174
[2 0 0 0]
175
"""
176
m = self.gap().InvariantBilinearForm()['matrix'].matrix()
177
m.set_immutable()
178
return m
179
180
181
182
183
184
185