# Ticket #9290: trac-9290-review.patch

File trac-9290-review.patch, 6.4 KB (added by chapoton, 8 years ago)
• ## sage/combinat/root_system/cartan_matrix.py

# HG changeset patch
# User Frederic Chapoton <chapoton at math.univ-lyon1.fr>
# Date 1382300757 -7200
# Node ID b6212ce803a2bf1e73fdac7f33525ba1fc970891
# Parent  f82f4f1be6c3087fe7d660d6eed5f1fd92e439a3
trac #9290 review, minor details

diff --git a/sage/combinat/root_system/cartan_matrix.py b/sage/combinat/root_system/cartan_matrix.py
 a class CartanMatrix(Matrix_integer_sparse EXAMPLES:: sage: C = CartanMatrix(['B',4,1]) sage: cm = CartanMatrix([[2,-5],[-2,2]]) sage: cm.symmetrizer() Finite family {0: 2, 1: 5} class CartanMatrix(Matrix_integer_sparse if not sym: raise ValueError("the Cartan matrix is not symmetrizable") iset = self.index_set() # The result from is_symmetrizable needs to be scaled to integer coefficients # The result from is_symmetrizable needs to be scaled # to integer coefficients from sage.rings.arith import LCM from sage.rings.all import QQ scalar = LCM(map(lambda x: QQ(x).denominator(), sym)) return Family( {iset[i]: ZZ(val*scalar) for i,val in enumerate(sym)} ) return Family( {iset[i]: ZZ(val*scalar) for i, val in enumerate(sym)} ) ########################################################################## # Cartan type methods
• ## sage/combinat/root_system/coxeter_group.py

diff --git a/sage/combinat/root_system/coxeter_group.py b/sage/combinat/root_system/coxeter_group.py
 a def CoxeterGroup(data, implementation=No return WeylGroup(cartan_type) return CoxeterMatrixGroup(cartan_type, base_ring, index_set) raise NotImplementedError("Coxeter group of type %s as %s group not implemented "%(cartan_type, implementation)) raise NotImplementedError("Coxeter group of type %s as %s group not implemented " % (cartan_type, implementation)) @cached_function def is_chevie_available():
• ## sage/combinat/root_system/weyl_group.py

diff --git a/sage/combinat/root_system/weyl_group.py b/sage/combinat/root_system/weyl_group.py
 a def WeylGroup(x, prefix=None): try: ct = CartanType(x) except TypeError: ct = CartanMatrix(x) # See if it's a Cartan matrix ct = CartanMatrix(x)  # See if it is a Cartan matrix if ct.is_finite(): return WeylGroup_gens(ct.root_system().ambient_space(), prefix=prefix) return WeylGroup_gens(ct.root_system().root_space(), prefix=prefix)
• ## sage/groups/matrix_gps/coxeter_group.py

diff --git a/sage/groups/matrix_gps/coxeter_group.py b/sage/groups/matrix_gps/coxeter_group.py
 a from sage.rings.all import ZZ from sage.rings.infinity import infinity from sage.rings.universal_cyclotomic_field.universal_cyclotomic_field import UniversalCyclotomicField class CoxeterMatrixGroup(FinitelyGeneratedMatrixGroup_generic, UniqueRepresentation): r""" A Coxeter group represented as a matrix group. class CoxeterMatrixGroup(FinitelyGenerat @staticmethod def __classcall_private__(cls, data, base_ring=None, index_set=None): """ Normalize arguements to ensure a unique representation. Normalize arguments to ensure a unique representation. EXAMPLES:: class CoxeterMatrixGroup(FinitelyGenerat n = G.num_verts() # Setup the basis matrix as all 2 except 1 on the diagonal data = matrix(ZZ, [[2]*n for i in range(n)]) data = matrix(ZZ, [[2]*n]*n) for i in range(n): data[i,i] = ZZ.one() data[i, i] = ZZ.one() verts = G.vertices() for e in G.edges(): m = e[2] if m is None: m = 3 elif m == infinity or m == -1: # FIXME: Hack because there is no ZZ\cup\{\infty\} elif m == infinity or m == -1:  # FIXME: Hack because there is no ZZ\cup\{\infty\} m = -1 elif m <= 1: raise ValueError("invalid Coxeter graph label") i = verts.index(e[0]) j = verts.index(e[1]) data[j,i] = data[i,j] = m data[j, i] = data[i, j] = m if index_set is None: index_set = G.vertices() class CoxeterMatrixGroup(FinitelyGenerat raise ValueError("the Coxeter matrix is not symmetric") if any(d != 1 for d in data.diagonal()): raise ValueError("the Coxeter matrix diagonal is not all 1") if any(val <= 1 and val != -1 for i,row in enumerate(data.rows()) for val in row[i+1:]): if any(val <= 1 and val != -1 for i, row in enumerate(data.rows()) for val in row[i+1:]): raise ValueError("invalid Coxeter label") if index_set is None: class CoxeterMatrixGroup(FinitelyGenerat from sage.functions.trig import cos from sage.symbolic.constants import pi val = lambda x: base_ring(2*cos(pi / x)) if x != -1 else base_ring(2) gens = [MS.one() + MS({(i, j): val(coxeter_matrix[i,j]) for j in range(n)}) gens = [MS.one() + MS({(i, j): val(coxeter_matrix[i, j]) for j in range(n)}) for i in range(n)] FinitelyGeneratedMatrixGroup_generic.__init__(self, n, base_ring, gens, category=CoxeterGroups()) FinitelyGeneratedMatrixGroup_generic.__init__(self, n, base_ring, gens, category=CoxeterGroups()) def _repr_(self): """ class CoxeterMatrixGroup(FinitelyGenerat [ 0  1 -1] """ if not i in self._index_set: raise ValueError("%s is not in the index set %s"%(i, self.index_set())) raise ValueError("%s is not in the index set %s" % (i, self.index_set())) return self.gen(self._index_set.index(i)) class Element(MatrixGroupElement_generic):