Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/groups/matrix_gps/unitary.py
8815 views
1
r"""
2
Unitary Groups `GU(n,q)` and `SU(n,q)`
3
4
These are `n \times n` unitary matrices with entries in
5
`GF(q^2)`.
6
7
EXAMPLES::
8
9
sage: G = SU(3,5)
10
sage: G.order()
11
378000
12
sage: G
13
Special Unitary Group of degree 3 over Finite Field in a of size 5^2
14
sage: G.gens()
15
(
16
[ a 0 0] [4*a 4 1]
17
[ 0 2*a + 2 0] [ 4 4 0]
18
[ 0 0 3*a], [ 1 0 0]
19
)
20
sage: G.base_ring()
21
Finite Field in a of size 5^2
22
23
AUTHORS:
24
25
- David Joyner (2006-03): initial version, modified from
26
special_linear (by W. Stein)
27
28
- David Joyner (2006-05): minor additions (examples, _latex_, __str__,
29
gens)
30
31
- William Stein (2006-12): rewrite
32
33
- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.
34
"""
35
36
#*********************************************************************************
37
# Copyright (C) 2006 David Joyner and William Stein
38
# Copyright (C) 2013 Volker Braun <[email protected]>
39
#
40
# Distributed under the terms of the GNU General Public License (GPL)
41
# http://www.gnu.org/licenses/
42
#*********************************************************************************
43
44
from sage.rings.all import ZZ, is_FiniteField, GF
45
from sage.misc.latex import latex
46
from sage.groups.matrix_gps.named_group import (
47
normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )
48
49
50
def finite_field_sqrt(ring):
51
"""
52
Helper function.
53
54
INPUT:
55
56
A ring.
57
58
OUTPUT:
59
60
Integer q such that ``ring`` is the finite field with `q^2` elements.
61
62
EXAMPLES::
63
64
sage: from sage.groups.matrix_gps.unitary import finite_field_sqrt
65
sage: finite_field_sqrt(GF(4, 'a'))
66
2
67
"""
68
if not is_FiniteField(ring):
69
raise ValueError('not a finite field')
70
q, rem = ring.cardinality().sqrtrem()
71
if rem != 0:
72
raise ValueError('cardinatity not a square')
73
return q
74
75
76
###############################################################################
77
# General Unitary Group
78
###############################################################################
79
80
def GU(n, R, var='a'):
81
r"""
82
Return the general unitary group.
83
84
The general unitary group `GU( d, R )` consists of all `d \times
85
d` matrices that preserve a nondegenerate sequilinear form over
86
the ring `R`.
87
88
.. note::
89
90
For a finite field the matrices that preserve a sesquilinear
91
form over `F_q` live over `F_{q^2}`. So ``GU(n,q)`` for
92
integer ``q`` constructs the matrix group over the base ring
93
``GF(q^2)``.
94
95
.. note::
96
97
This group is also available via ``groups.matrix.GU()``.
98
99
INPUT:
100
101
- ``n`` -- a positive integer.
102
103
- ``R`` -- ring or an integer. If an integer is specified, the
104
corresponding finite field is used.
105
106
- ``var`` -- variable used to represent generator of the finite
107
field, if needed.
108
109
OUTPUT:
110
111
Return the general unitary group.
112
113
EXAMPLES::
114
115
sage: G = GU(3, 7); G
116
General Unitary Group of degree 3 over Finite Field in a of size 7^2
117
sage: G.gens()
118
(
119
[ a 0 0] [6*a 6 1]
120
[ 0 1 0] [ 6 6 0]
121
[ 0 0 5*a], [ 1 0 0]
122
)
123
sage: GU(2,QQ)
124
General Unitary Group of degree 2 over Rational Field
125
126
sage: G = GU(3, 5, var='beta')
127
sage: G.base_ring()
128
Finite Field in beta of size 5^2
129
sage: G.gens()
130
(
131
[ beta 0 0] [4*beta 4 1]
132
[ 0 1 0] [ 4 4 0]
133
[ 0 0 3*beta], [ 1 0 0]
134
)
135
136
TESTS::
137
138
sage: groups.matrix.GU(2, 3)
139
General Unitary Group of degree 2 over Finite Field in a of size 3^2
140
"""
141
degree, ring = normalize_args_vectorspace(n, R, var=var)
142
if is_FiniteField(ring):
143
q = ring.cardinality()
144
ring = GF(q ** 2, name=var)
145
name = 'General Unitary Group of degree {0} over {1}'.format(degree, ring)
146
ltx = r'\text{{GU}}_{{{0}}}({1})'.format(degree, latex(ring))
147
if is_FiniteField(ring):
148
cmd = 'GU({0}, {1})'.format(degree, q)
149
return UnitaryMatrixGroup_gap(degree, ring, False, name, ltx, cmd)
150
else:
151
return UnitaryMatrixGroup_generic(degree, ring, False, name, ltx)
152
153
154
155
###############################################################################
156
# Special Unitary Group
157
###############################################################################
158
159
def SU(n, R, var='a'):
160
"""
161
The special unitary group `SU( d, R )` consists of all `d \times d`
162
matrices that preserve a nondegenerate sequilinear form over the
163
ring `R` and have determinant one.
164
165
.. note::
166
167
For a finite field the matrices that preserve a sesquilinear
168
form over `F_q` live over `F_{q^2}`. So ``SU(n,q)`` for
169
integer ``q`` constructs the matrix group over the base ring
170
``GF(q^2)``.
171
172
.. note::
173
174
This group is also available via ``groups.matrix.SU()``.
175
176
INPUT:
177
178
- ``n`` -- a positive integer.
179
180
- ``R`` -- ring or an integer. If an integer is specified, the
181
corresponding finite field is used.
182
183
- ``var`` -- variable used to represent generator of the finite
184
field, if needed.
185
186
OUTPUT:
187
188
Return the special unitary group.
189
190
EXAMPLES::
191
192
sage: SU(3,5)
193
Special Unitary Group of degree 3 over Finite Field in a of size 5^2
194
sage: SU(3, GF(5))
195
Special Unitary Group of degree 3 over Finite Field in a of size 5^2
196
sage: SU(3,QQ)
197
Special Unitary Group of degree 3 over Rational Field
198
199
TESTS::
200
201
sage: groups.matrix.SU(2, 3)
202
Special Unitary Group of degree 2 over Finite Field in a of size 3^2
203
"""
204
degree, ring = normalize_args_vectorspace(n, R, var=var)
205
if is_FiniteField(ring):
206
q = ring.cardinality()
207
ring = GF(q ** 2, name=var)
208
name = 'Special Unitary Group of degree {0} over {1}'.format(degree, ring)
209
ltx = r'\text{{SU}}_{{{0}}}({1})'.format(degree, latex(ring))
210
if is_FiniteField(ring):
211
cmd = 'SU({0}, {1})'.format(degree, q)
212
return UnitaryMatrixGroup_gap(degree, ring, True, name, ltx, cmd)
213
else:
214
return UnitaryMatrixGroup_generic(degree, ring, True, name, ltx)
215
216
217
########################################################################
218
# Unitary Group class
219
########################################################################
220
221
class UnitaryMatrixGroup_generic(NamedMatrixGroup_generic):
222
r"""
223
General Unitary Group over arbitrary rings.
224
225
EXAMPLES::
226
227
sage: G = GU(3, GF(7)); G
228
General Unitary Group of degree 3 over Finite Field in a of size 7^2
229
sage: latex(G)
230
\text{GU}_{3}(\Bold{F}_{7^{2}})
231
232
sage: G = SU(3, GF(5)); G
233
Special Unitary Group of degree 3 over Finite Field in a of size 5^2
234
sage: latex(G)
235
\text{SU}_{3}(\Bold{F}_{5^{2}})
236
"""
237
238
def _check_matrix(self, x, *args):
239
"""a
240
Check whether the matrix ``x`` is unitary.
241
242
See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`
243
for details.
244
245
EXAMPLES::
246
247
sage: G = GU(2, GF(5))
248
sage: G._check_matrix(G.an_element().matrix())
249
sage: G = SU(2, GF(5))
250
sage: G._check_matrix(G.an_element().matrix())
251
"""
252
if self._special and x.determinant() != 1:
253
raise TypeError('matrix must have determinant one')
254
if not x.is_unitary():
255
raise TypeError('matrix must be unitary')
256
257
258
class UnitaryMatrixGroup_gap(UnitaryMatrixGroup_generic, NamedMatrixGroup_gap):
259
pass
260
261
262
263
264