def find_cartan_type_from_matrix(CM): """ Find a Cartan type by direct comparison of matrices given from the generalized Cartan matrix ``CM`` and return ``None`` if not found. INPUT: - ``CM`` -- A generalized Cartan matrix EXAMPLES:: sage: from sage.combinat.root_system.cartan_matrix import find_cartan_type_from_matrix sage: M = matrix([[2,-1,-1], [-1,2,-1], [-1,-1,2]]) sage: find_cartan_type_from_matrix(M) ['A', 2, 1] sage: M = matrix([[2,-1,0], [-1,2,-2], [0,-1,2]]) sage: find_cartan_type_from_matrix(M) ['C', 3] sage: M = matrix([[2,-1,-2], [-1,2,-1], [-2,-1,2]]) sage: find_cartan_type_from_matrix(M) """ n = CM.ncols() # Build the list to test based upon rank if n == 1: return CartanType(['A', 1]) test = [['A', n]] if n >= 2: if n == 2: test += [['G',2], ['A',2,2]] test += [['B',n], ['A',n-1,1]] if n >= 3: if n == 3: test += [['G',2,1], ['D',4,3]] test += [['C',n], ['BC',n-1,2], ['C',n-1,1]] if n >= 4: if n == 4: test += [['F',4], ['G',2,1], ['D',4,3]] test += [['D',n], ['B',n-1,1]] if n == 5: test += [['F',4,1], ['D',n-1,1]] elif n == 6: test.append(['E',6]) elif n == 7: test += [['E',7], ['E',6,1]] elif n == 8: test += [['E',8], ['E',7,1]] elif n == 9: test.append(['E',8,1]) # Test every possible Cartan type and its dual for x in test: ct = CartanType(x) if ct.cartan_matrix() == CM: return ct if ct == ct.dual(): continue ct = ct.dual() if ct.cartan_matrix() == CM: return ct return None
def cartan_type(self): r""" Returns the Cartan type of the Cartan companion of self.b_matrix() Only crystallographic types are implemented Warning: this function is redundant but the corresonding method in CartanType does not recognize all the types """ A = self.cartan_companion() n = self.rk degrees_dict = dict(zip(range(n),map(sum,2-A))) degrees_set = Set(degrees_dict.values()) types_to_check = [ ["A",n] ] if n > 1: types_to_check.append(["B",n]) if n > 2: types_to_check.append(["C",n]) if n > 3: types_to_check.append(["D",n]) if n >=6 and n <= 8: types_to_check.append(["E",n]) if n == 4: types_to_check.append(["F",n]) if n == 2: types_to_check.append(["G",n]) if n >1: types_to_check.append(["A", n-1,1]) types_to_check.append(["B", n-1,1]) types_to_check.append(["BC",n-1,2]) types_to_check.append(["A", 2*n-2,2]) types_to_check.append(["A", 2*n-3,2]) if n>2: types_to_check.append(["C", n-1,1]) types_to_check.append(["D", n,2]) if n>3: types_to_check.append(["D", n-1,1]) if n >=7 and n <= 9: types_to_check.append(["E",n-1,1]) if n == 5: types_to_check.append(["F",4,1]) if n == 3: types_to_check.append(["G",n-1,1]) types_to_check.append(["D",4,3]) if n == 5: types_to_check.append(["E",6,2]) for ct_name in types_to_check: ct = CartanType(ct_name) if 0 not in ct.index_set(): ct = ct.relabel(dict(zip(range(1,n+1),range(n)))) ct_matrix = ct.cartan_matrix() ct_degrees_dict = dict(zip(range(n),map(sum,2-ct_matrix))) if Set(ct_degrees_dict.values()) != degrees_set: continue for p in Permutations(range(n)): relabeling = dict(zip(range(n),p)) ct_new = ct.relabel(relabeling) if ct_new.cartan_matrix() == A: return copy(ct_new) raise ValueError("Type not recognized")
def find_cartan_type_from_matrix(CM): """ Find a Cartan type by direct comparison of matrices given from the generalized Cartan matrix ``CM`` and return ``None`` if not found. INPUT: - ``CM`` -- A generalized Cartan matrix EXAMPLES:: sage: from sage.combinat.root_system.cartan_matrix import find_cartan_type_from_matrix sage: M = matrix([[2,-1,-1], [-1,2,-1], [-1,-1,2]]) sage: find_cartan_type_from_matrix(M) ['A', 2, 1] sage: M = matrix([[2,-1,0], [-1,2,-2], [0,-1,2]]) sage: find_cartan_type_from_matrix(M) ['C', 3] sage: M = matrix([[2,-1,-2], [-1,2,-1], [-2,-1,2]]) sage: find_cartan_type_from_matrix(M) """ n = CM.ncols() # Build the list to test based upon rank if n == 1: return CartanType(['A', 1]) test = [['A', n]] if n >= 2: if n == 2: test += [['G',2], ['A',2,2]] test += [['B',n], ['A',n-1,1]] if n >= 3: if n == 3: test += [['G',2,1], ['D',4,3]] test += [['C',n], ['BC',n-1,2], ['C',n-1,1]] if n >= 4: if n == 4: test += [['F',4], ['G',2,1], ['D',4,3]] test += [['D',n], ['B',n-1,1]] if n == 5: test += [['F',4,1], ['D',n-1,1]] elif n == 6: test.append(['E',6]) elif n == 7: test += [['E',7], ['E',6,1]] elif n == 8: test += [['E',8], ['E',7,1]] elif n == 9: test.append(['E',8,1]) # Test every possible Cartan type and its dual for x in test: ct = CartanType(x) if ct.cartan_matrix() == CM: return ct if ct == ct.dual(): continue ct = ct.dual() if ct.cartan_matrix() == CM: return ct return None
def cartan_type(self): r""" Returns the Cartan type of the Cartan companion of self.b_matrix() Only crystallographic types are implemented Warning: this function is redundant but the corresonding method in CartanType does not recognize all the types """ A = self.cartan_companion() n = self.rk degrees_dict = dict(zip(range(n), map(sum, 2 - A))) degrees_set = Set(degrees_dict.values()) types_to_check = [["A", n]] if n > 1: types_to_check.append(["B", n]) if n > 2: types_to_check.append(["C", n]) if n > 3: types_to_check.append(["D", n]) if n >= 6 and n <= 8: types_to_check.append(["E", n]) if n == 4: types_to_check.append(["F", n]) if n == 2: types_to_check.append(["G", n]) if n > 1: types_to_check.append(["A", n - 1, 1]) types_to_check.append(["B", n - 1, 1]) types_to_check.append(["BC", n - 1, 2]) types_to_check.append(["A", 2 * n - 2, 2]) types_to_check.append(["A", 2 * n - 3, 2]) if n > 2: types_to_check.append(["C", n - 1, 1]) types_to_check.append(["D", n, 2]) if n > 3: types_to_check.append(["D", n - 1, 1]) if n >= 7 and n <= 9: types_to_check.append(["E", n - 1, 1]) if n == 5: types_to_check.append(["F", 4, 1]) if n == 3: types_to_check.append(["G", n - 1, 1]) types_to_check.append(["D", 4, 3]) if n == 5: types_to_check.append(["E", 6, 2]) for ct_name in types_to_check: ct = CartanType(ct_name) if 0 not in ct.index_set(): ct = ct.relabel(dict(zip(range(1, n + 1), range(n)))) ct_matrix = ct.cartan_matrix() ct_degrees_dict = dict(zip(range(n), map(sum, 2 - ct_matrix))) if Set(ct_degrees_dict.values()) != degrees_set: continue for p in Permutations(range(n)): relabeling = dict(zip(range(n), p)) ct_new = ct.relabel(relabeling) if ct_new.cartan_matrix() == A: return copy(ct_new) raise ValueError("Type not recognized")