Path: blob/master/sage/groups/matrix_gps/special_linear.py
4057 views
"""1Special Linear Groups23AUTHORS:45- William Stein: initial version67- David Joyner (2006-05): added examples, _latex_, __str__, gens,8as_matrix_group910- William Stein (2006-12-09): rewrite1112EXAMPLES::1314sage: SL(2, ZZ)15Special Linear Group of degree 2 over Integer Ring16sage: G = SL(2,GF(3)); G17Special Linear Group of degree 2 over Finite Field of size 318sage: G.is_finite()19True20sage: G.conjugacy_class_representatives()21[22[1 0]23[0 1],24[0 2]25[1 1],26[0 1]27[2 1],28[2 0]29[0 2],30[0 2]31[1 2],32[0 1]33[2 2],34[0 2]35[1 0]36]37sage: G = SL(6,GF(5))38sage: G.gens()39[40[2 0 0 0 0 0]41[0 3 0 0 0 0]42[0 0 1 0 0 0]43[0 0 0 1 0 0]44[0 0 0 0 1 0]45[0 0 0 0 0 1],46[4 0 0 0 0 1]47[4 0 0 0 0 0]48[0 4 0 0 0 0]49[0 0 4 0 0 0]50[0 0 0 4 0 0]51[0 0 0 0 4 0]52]53"""5455#*****************************************************************************56# Copyright (C) 2006 William Stein <[email protected]>57#58# Distributed under the terms of the GNU General Public License (GPL)59# http://www.gnu.org/licenses/60#*****************************************************************************6162from sage.structure.unique_representation import UniqueRepresentation63from sage.rings.all import is_FiniteField, Integer, FiniteField64from matrix_group import MatrixGroup_gap, MatrixGroup_gap_finite_field6566def SL(n, R, var='a'):67r"""68Return the special linear group of degree `n` over the ring69`R`.7071EXAMPLES::7273sage: SL(3,GF(2))74Special Linear Group of degree 3 over Finite Field of size 275sage: G = SL(15,GF(7)); G76Special Linear Group of degree 15 over Finite Field of size 777sage: G.category()78Category of finite groups79sage: G.order()80195671259569814696201521906242958634112401800718204947891606736963871306673788236339351996634365767743090701127020626583481909204625023204918796771814955813422677465084565879186574540800000081sage: len(G.gens())82283sage: G = SL(2,ZZ); G84Special Linear Group of degree 2 over Integer Ring85sage: G.gens()86[87[ 0 1]88[-1 0],89[1 1]90[0 1]91]9293Next we compute generators for `\mathrm{SL}_3(\ZZ)`.9495::9697sage: G = SL(3,ZZ); G98Special Linear Group of degree 3 over Integer Ring99sage: G.gens()100[101[0 1 0]102[0 0 1]103[1 0 0],104[ 0 1 0]105[-1 0 0]106[ 0 0 1],107[1 1 0]108[0 1 0]109[0 0 1]110]111112sage: TestSuite(G).run()113"""114if isinstance(R, (int, long, Integer)):115R = FiniteField(R, var)116if is_FiniteField(R):117return SpecialLinearGroup_finite_field(n, R)118else:119return SpecialLinearGroup_generic(n, R)120121class SpecialLinearGroup_generic(UniqueRepresentation, MatrixGroup_gap):122def _gap_init_(self):123"""124String to create this group in GAP.125126EXAMPLES::127128sage: G = SL(6,GF(5)); G129Special Linear Group of degree 6 over Finite Field of size 5130sage: G._gap_init_()131'SL(6, GF(5))'132"""133return "SL(%s, %s)"%(self.degree(), self.base_ring()._gap_init_())134135def _latex_(self):136r"""137EXAMPLES::138139sage: G = SL(6,GF(5))140sage: latex(G)141\text{SL}_{6}(\Bold{F}_{5})142"""143return "\\text{SL}_{%s}(%s)"%(self.degree(), self.field_of_definition()._latex_())144145def _repr_(self):146"""147Text representation of self.148149EXAMPLES::150151sage: SL(6,GF(5))152Special Linear Group of degree 6 over Finite Field of size 5153"""154return "Special Linear Group of degree %s over %s"%(self.degree(), self.base_ring())155156def __call__(self, x):157"""158Construct a new element in this group, i.e. try to coerce x into159self if at all possible.160161EXAMPLES::162163sage: G = SL(3, ZZ)164sage: x = [[1,0,1], [0,1,0], [0,0,1]]165sage: G(x)166[1 0 1]167[0 1 0]168[0 0 1]169"""170if isinstance(x, self.element_class) and x.parent() is self:171return x172try:173m = self.matrix_space()(x)174except TypeError:175raise TypeError, "Cannot coerce %s to a %s-by-%s matrix over %s"%(x,self.degree(),self.degree(),self.base_ring())176if m.determinant() == self.base_ring()(1):177return self.element_class(m, self)178else:179raise TypeError, "%s does not have determinant 1"%(x)180181def __contains__(self, x):182"""183Return True if x is an element of self, False otherwise.184185EXAMPLES::186187sage: G = SL(2, GF(101))188sage: x = [[1,1], [0,1]]189sage: x in G190True191192::193194sage: G = SL(3, ZZ)195sage: x = [[1,0,1], [0,-1,0], [0,0,1]]196sage: x in G197False198"""199try:200x = self(x)201except TypeError:202return False203return True204205206207class SpecialLinearGroup_finite_field(SpecialLinearGroup_generic, MatrixGroup_gap_finite_field):208pass209210211212