Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/groups/matrix_gps/symplectic.py
4072 views
1
"""
2
Symplectic Linear Groups
3
4
AUTHORS:
5
6
- David Joyner (2006-03): initial version, modified from
7
special_linear (by W. Stein)
8
9
EXAMPLES::
10
11
sage: G = Sp(4,GF(7))
12
sage: G._gap_init_()
13
'Sp(4, 7)'
14
sage: G
15
Symplectic Group of rank 2 over Finite Field of size 7
16
sage: G.random_element()
17
[1 6 5 5]
18
[2 1 4 5]
19
[1 2 4 5]
20
[4 0 2 2]
21
sage: G.order()
22
276595200
23
"""
24
25
#*****************************************************************************
26
# Copyright (C) 2006 David Joyner and William Stein
27
#
28
# Distributed under the terms of the GNU General Public License (GPL)
29
# http://www.gnu.org/licenses/
30
#*****************************************************************************
31
32
from sage.rings.all import is_FiniteField, Integer, FiniteField
33
from matrix_group import MatrixGroup_gap, MatrixGroup_gap_finite_field
34
35
def Sp(n, R, var='a'):
36
"""
37
Return the symplectic group of degree n over R.
38
39
EXAMPLES::
40
41
sage: Sp(4,5)
42
Symplectic Group of rank 2 over Finite Field of size 5
43
sage: Sp(3,GF(7))
44
Traceback (most recent call last):
45
...
46
ValueError: the degree n (=3) must be even
47
"""
48
if n%2!=0:
49
raise ValueError, "the degree n (=%s) must be even"%n
50
if isinstance(R, (int, long, Integer)):
51
R = FiniteField(R, var)
52
if is_FiniteField(R):
53
return SymplecticGroup_finite_field(n, R)
54
else:
55
return SymplecticGroup_generic(n, R)
56
57
class SymplecticGroup_generic(MatrixGroup_gap):
58
def _gap_init_(self):
59
raise TypeError, 'no analogue of this symplectic group in GAP'
60
61
def _latex_(self):
62
r"""
63
Return LaTeX representation of this group.
64
65
EXAMPLES::
66
67
sage: latex(Sp(4,5))
68
\text{Sp}_{4}(\Bold{F}_{5})
69
"""
70
return "\\text{Sp}_{%s}(%s)"%(self.degree(), self.field_of_definition()._latex_())
71
72
def _repr_(self):
73
"""
74
Return print representation of this group.
75
76
EXAMPLES::
77
78
sage: Sp(2,4)
79
Symplectic Group of rank 1 over Finite Field in a of size 2^2
80
"""
81
return "Symplectic Group of rank %s over %s"%(self.degree()/2, self.base_ring())
82
83
class SymplecticGroup_finite_field(SymplecticGroup_generic, MatrixGroup_gap_finite_field):
84
def _gap_init_(self):
85
"""
86
Return GAP string that evaluates to this group.
87
88
EXAMPLES::
89
90
sage: Sp(2,4)._gap_init_()
91
'Sp(2, 4)'
92
"""
93
return "Sp(%s, %s)"%(self.degree(), self.base_ring().order())
94
95
96
97
98