Path: blob/master/src/sage/groups/matrix_gps/unitary.py
8815 views
r"""1Unitary Groups `GU(n,q)` and `SU(n,q)`23These are `n \times n` unitary matrices with entries in4`GF(q^2)`.56EXAMPLES::78sage: G = SU(3,5)9sage: G.order()1037800011sage: G12Special Unitary Group of degree 3 over Finite Field in a of size 5^213sage: G.gens()14(15[ a 0 0] [4*a 4 1]16[ 0 2*a + 2 0] [ 4 4 0]17[ 0 0 3*a], [ 1 0 0]18)19sage: G.base_ring()20Finite Field in a of size 5^22122AUTHORS:2324- David Joyner (2006-03): initial version, modified from25special_linear (by W. Stein)2627- David Joyner (2006-05): minor additions (examples, _latex_, __str__,28gens)2930- William Stein (2006-12): rewrite3132- Volker Braun (2013-1) port to new Parent, libGAP, extreme refactoring.33"""3435#*********************************************************************************36# Copyright (C) 2006 David Joyner and William Stein37# Copyright (C) 2013 Volker Braun <[email protected]>38#39# Distributed under the terms of the GNU General Public License (GPL)40# http://www.gnu.org/licenses/41#*********************************************************************************4243from sage.rings.all import ZZ, is_FiniteField, GF44from sage.misc.latex import latex45from sage.groups.matrix_gps.named_group import (46normalize_args_vectorspace, NamedMatrixGroup_generic, NamedMatrixGroup_gap )474849def finite_field_sqrt(ring):50"""51Helper function.5253INPUT:5455A ring.5657OUTPUT:5859Integer q such that ``ring`` is the finite field with `q^2` elements.6061EXAMPLES::6263sage: from sage.groups.matrix_gps.unitary import finite_field_sqrt64sage: finite_field_sqrt(GF(4, 'a'))65266"""67if not is_FiniteField(ring):68raise ValueError('not a finite field')69q, rem = ring.cardinality().sqrtrem()70if rem != 0:71raise ValueError('cardinatity not a square')72return q737475###############################################################################76# General Unitary Group77###############################################################################7879def GU(n, R, var='a'):80r"""81Return the general unitary group.8283The general unitary group `GU( d, R )` consists of all `d \times84d` matrices that preserve a nondegenerate sequilinear form over85the ring `R`.8687.. note::8889For a finite field the matrices that preserve a sesquilinear90form over `F_q` live over `F_{q^2}`. So ``GU(n,q)`` for91integer ``q`` constructs the matrix group over the base ring92``GF(q^2)``.9394.. note::9596This group is also available via ``groups.matrix.GU()``.9798INPUT:99100- ``n`` -- a positive integer.101102- ``R`` -- ring or an integer. If an integer is specified, the103corresponding finite field is used.104105- ``var`` -- variable used to represent generator of the finite106field, if needed.107108OUTPUT:109110Return the general unitary group.111112EXAMPLES::113114sage: G = GU(3, 7); G115General Unitary Group of degree 3 over Finite Field in a of size 7^2116sage: G.gens()117(118[ a 0 0] [6*a 6 1]119[ 0 1 0] [ 6 6 0]120[ 0 0 5*a], [ 1 0 0]121)122sage: GU(2,QQ)123General Unitary Group of degree 2 over Rational Field124125sage: G = GU(3, 5, var='beta')126sage: G.base_ring()127Finite Field in beta of size 5^2128sage: G.gens()129(130[ beta 0 0] [4*beta 4 1]131[ 0 1 0] [ 4 4 0]132[ 0 0 3*beta], [ 1 0 0]133)134135TESTS::136137sage: groups.matrix.GU(2, 3)138General Unitary Group of degree 2 over Finite Field in a of size 3^2139"""140degree, ring = normalize_args_vectorspace(n, R, var=var)141if is_FiniteField(ring):142q = ring.cardinality()143ring = GF(q ** 2, name=var)144name = 'General Unitary Group of degree {0} over {1}'.format(degree, ring)145ltx = r'\text{{GU}}_{{{0}}}({1})'.format(degree, latex(ring))146if is_FiniteField(ring):147cmd = 'GU({0}, {1})'.format(degree, q)148return UnitaryMatrixGroup_gap(degree, ring, False, name, ltx, cmd)149else:150return UnitaryMatrixGroup_generic(degree, ring, False, name, ltx)151152153154###############################################################################155# Special Unitary Group156###############################################################################157158def SU(n, R, var='a'):159"""160The special unitary group `SU( d, R )` consists of all `d \times d`161matrices that preserve a nondegenerate sequilinear form over the162ring `R` and have determinant one.163164.. note::165166For a finite field the matrices that preserve a sesquilinear167form over `F_q` live over `F_{q^2}`. So ``SU(n,q)`` for168integer ``q`` constructs the matrix group over the base ring169``GF(q^2)``.170171.. note::172173This group is also available via ``groups.matrix.SU()``.174175INPUT:176177- ``n`` -- a positive integer.178179- ``R`` -- ring or an integer. If an integer is specified, the180corresponding finite field is used.181182- ``var`` -- variable used to represent generator of the finite183field, if needed.184185OUTPUT:186187Return the special unitary group.188189EXAMPLES::190191sage: SU(3,5)192Special Unitary Group of degree 3 over Finite Field in a of size 5^2193sage: SU(3, GF(5))194Special Unitary Group of degree 3 over Finite Field in a of size 5^2195sage: SU(3,QQ)196Special Unitary Group of degree 3 over Rational Field197198TESTS::199200sage: groups.matrix.SU(2, 3)201Special Unitary Group of degree 2 over Finite Field in a of size 3^2202"""203degree, ring = normalize_args_vectorspace(n, R, var=var)204if is_FiniteField(ring):205q = ring.cardinality()206ring = GF(q ** 2, name=var)207name = 'Special Unitary Group of degree {0} over {1}'.format(degree, ring)208ltx = r'\text{{SU}}_{{{0}}}({1})'.format(degree, latex(ring))209if is_FiniteField(ring):210cmd = 'SU({0}, {1})'.format(degree, q)211return UnitaryMatrixGroup_gap(degree, ring, True, name, ltx, cmd)212else:213return UnitaryMatrixGroup_generic(degree, ring, True, name, ltx)214215216########################################################################217# Unitary Group class218########################################################################219220class UnitaryMatrixGroup_generic(NamedMatrixGroup_generic):221r"""222General Unitary Group over arbitrary rings.223224EXAMPLES::225226sage: G = GU(3, GF(7)); G227General Unitary Group of degree 3 over Finite Field in a of size 7^2228sage: latex(G)229\text{GU}_{3}(\Bold{F}_{7^{2}})230231sage: G = SU(3, GF(5)); G232Special Unitary Group of degree 3 over Finite Field in a of size 5^2233sage: latex(G)234\text{SU}_{3}(\Bold{F}_{5^{2}})235"""236237def _check_matrix(self, x, *args):238"""a239Check whether the matrix ``x`` is unitary.240241See :meth:`~sage.groups.matrix_gps.matrix_group._check_matrix`242for details.243244EXAMPLES::245246sage: G = GU(2, GF(5))247sage: G._check_matrix(G.an_element().matrix())248sage: G = SU(2, GF(5))249sage: G._check_matrix(G.an_element().matrix())250"""251if self._special and x.determinant() != 1:252raise TypeError('matrix must have determinant one')253if not x.is_unitary():254raise TypeError('matrix must be unitary')255256257class UnitaryMatrixGroup_gap(UnitaryMatrixGroup_generic, NamedMatrixGroup_gap):258pass259260261262263264