Path: blob/master/sage/groups/matrix_gps/symplectic.py
4072 views
"""1Symplectic Linear Groups23AUTHORS:45- David Joyner (2006-03): initial version, modified from6special_linear (by W. Stein)78EXAMPLES::910sage: G = Sp(4,GF(7))11sage: G._gap_init_()12'Sp(4, 7)'13sage: G14Symplectic Group of rank 2 over Finite Field of size 715sage: G.random_element()16[1 6 5 5]17[2 1 4 5]18[1 2 4 5]19[4 0 2 2]20sage: G.order()2127659520022"""2324#*****************************************************************************25# Copyright (C) 2006 David Joyner and William Stein26#27# Distributed under the terms of the GNU General Public License (GPL)28# http://www.gnu.org/licenses/29#*****************************************************************************3031from sage.rings.all import is_FiniteField, Integer, FiniteField32from matrix_group import MatrixGroup_gap, MatrixGroup_gap_finite_field3334def Sp(n, R, var='a'):35"""36Return the symplectic group of degree n over R.3738EXAMPLES::3940sage: Sp(4,5)41Symplectic Group of rank 2 over Finite Field of size 542sage: Sp(3,GF(7))43Traceback (most recent call last):44...45ValueError: the degree n (=3) must be even46"""47if n%2!=0:48raise ValueError, "the degree n (=%s) must be even"%n49if isinstance(R, (int, long, Integer)):50R = FiniteField(R, var)51if is_FiniteField(R):52return SymplecticGroup_finite_field(n, R)53else:54return SymplecticGroup_generic(n, R)5556class SymplecticGroup_generic(MatrixGroup_gap):57def _gap_init_(self):58raise TypeError, 'no analogue of this symplectic group in GAP'5960def _latex_(self):61r"""62Return LaTeX representation of this group.6364EXAMPLES::6566sage: latex(Sp(4,5))67\text{Sp}_{4}(\Bold{F}_{5})68"""69return "\\text{Sp}_{%s}(%s)"%(self.degree(), self.field_of_definition()._latex_())7071def _repr_(self):72"""73Return print representation of this group.7475EXAMPLES::7677sage: Sp(2,4)78Symplectic Group of rank 1 over Finite Field in a of size 2^279"""80return "Symplectic Group of rank %s over %s"%(self.degree()/2, self.base_ring())8182class SymplecticGroup_finite_field(SymplecticGroup_generic, MatrixGroup_gap_finite_field):83def _gap_init_(self):84"""85Return GAP string that evaluates to this group.8687EXAMPLES::8889sage: Sp(2,4)._gap_init_()90'Sp(2, 4)'91"""92return "Sp(%s, %s)"%(self.degree(), self.base_ring().order())939495969798