Path: blob/master/src/sage/groups/matrix_gps/symplectic.py
8815 views
"""1Symplectic Linear Groups23EXAMPLES::45sage: G = Sp(4,GF(7)); G6Symplectic Group of degree 4 over Finite Field of size 77sage: g = prod(G.gens()); g8[3 0 3 0]9[1 0 0 0]10[0 1 0 1]11[0 2 0 0]12sage: m = g.matrix()13sage: m * G.invariant_form() * m.transpose() == G.invariant_form()14True15sage: G.order()162765952001718AUTHORS:1920- David Joyner (2006-03): initial version, modified from21special_linear (by W. Stein)2223- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.24"""2526#*****************************************************************************27# Copyright (C) 2006 David Joyner and William Stein28# Copyright (C) 2013 Volker Braun <[email protected]>29#30# Distributed under the terms of the GNU General Public License (GPL)31# http://www.gnu.org/licenses/32#*****************************************************************************3334from sage.misc.latex import latex35from sage.misc.cachefunc import cached_method36from sage.groups.matrix_gps.named_group import (37normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )38394041###############################################################################42# Symplectic Group43###############################################################################4445def Sp(n, R, var='a'):46r"""47Return the symplectic group.4849The special linear group `GL( d, R )` consists of all `d \times d`50matrices that are invertible over the ring `R` with determinant51one.5253.. note::5455This group is also available via ``groups.matrix.Sp()``.5657INPUT:5859- ``n`` -- a positive integer.6061- ``R`` -- ring or an integer. If an integer is specified, the62corresponding finite field is used.6364- ``var`` -- variable used to represent generator of the finite65field, if needed.6667EXAMPLES::6869sage: Sp(4, 5)70Symplectic Group of degree 4 over Finite Field of size 57172sage: Sp(4, IntegerModRing(15))73Symplectic Group of degree 4 over Ring of integers modulo 157475sage: Sp(3, GF(7))76Traceback (most recent call last):77...78ValueError: the degree must be even7980TESTS::8182sage: groups.matrix.Sp(2, 3)83Symplectic Group of degree 2 over Finite Field of size 38485sage: G = Sp(4,5)86sage: TestSuite(G).run()87"""88degree, ring = normalize_args_vectorspace(n, R, var=var)89if degree % 2 != 0:90raise ValueError('the degree must be even')91name = 'Symplectic Group of degree {0} over {1}'.format(degree, ring)92ltx = r'\text{{Sp}}_{{{0}}}({1})'.format(degree, latex(ring))93from sage.libs.gap.libgap import libgap94try:95cmd = 'Sp({0}, {1})'.format(degree, ring._gap_init_())96return SymplecticMatrixGroup_gap(degree, ring, True, name, ltx, cmd)97except ValueError:98return SymplecticMatrixGroup_generic(degree, ring, True, name, ltx)99100101102class SymplecticMatrixGroup_generic(NamedMatrixGroup_generic):103104@cached_method105def invariant_form(self):106"""107Return the quadratic form preserved by the orthogonal group.108109OUTPUT:110111A matrix.112113EXAMPLES::114115sage: Sp(4, QQ).invariant_form()116[0 0 0 1]117[0 0 1 0]118[0 1 0 0]119[1 0 0 0]120"""121from sage.matrix.constructor import zero_matrix122m = zero_matrix(self.base_ring(), self.degree())123for i in range(self.degree()):124m[i, self.degree()-i-1] = 1125m.set_immutable()126return m127128def _check_matrix(self, x, *args):129"""130Check whether the matrix ``x`` is symplectic.131132See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`133for details.134135EXAMPLES::136137sage: G = Sp(4,GF(5))138sage: G._check_matrix(G.an_element().matrix())139"""140F = self.invariant_form()141if x * F * x.transpose() != F:142raise TypeError('matrix must be symplectic')143144145class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_gap):146r"""147Symplectic group in GAP148149EXAMPLES::150151sage: Sp(2,4)152Symplectic Group of degree 2 over Finite Field in a of size 2^2153154sage: latex(Sp(4,5))155\text{Sp}_{4}(\Bold{F}_{5})156"""157158@cached_method159def invariant_form(self):160"""161Return the quadratic form preserved by the orthogonal group.162163OUTPUT:164165A matrix.166167EXAMPLES::168169sage: Sp(4, GF(3)).invariant_form()170[0 0 0 1]171[0 0 1 0]172[0 2 0 0]173[2 0 0 0]174"""175m = self.gap().InvariantBilinearForm()['matrix'].matrix()176m.set_immutable()177return m178179180181182183184185