Für Vorlesungen, bitte die Webseite verwenden. https://flavigny.de/lecture
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

109 řádky
2.8KB

  1. import numpy as np
  2. import itertools
  3. import sys
  4. def s_n(n):
  5. return list(itertools.permutations(range(1,n+1)))
  6. def canon_tab(n):
  7. return list(range(1,n+1))
  8. def split_rows(part, lst):
  9. assert(sorted(part, reverse=True) == part)
  10. n = sum(part)
  11. xs = lst.copy()
  12. split = []
  13. for s in part:
  14. split.append(xs[0:s])
  15. xs = xs[s:]
  16. return split
  17. def is_row_stab(part, perm):
  18. n = sum(part)
  19. assert(len(perm) == n)
  20. return list(map(sorted, split_rows(part, canon_tab(n)))) == list(map(sorted, split_rows(part, list(perm))))
  21. def cycles(perm):
  22. cycles = []
  23. xs = list(range(1, len(perm)+1))
  24. while len(xs) > 0:
  25. c = [xs[0]]
  26. k = xs[0]
  27. while (perm[k-1] not in c):
  28. k = perm[k-1]
  29. c.append(k)
  30. xs = [ x for x in xs if x not in c ]
  31. cycles.append(c)
  32. return cycles
  33. def cycle_type(perm):
  34. cs = cycles(perm)
  35. types = {}
  36. for c in cs:
  37. if len(c) not in types:
  38. types[len(c)] = 1
  39. else:
  40. types[len(c)] += 1
  41. t = []
  42. for i in range(1, max(perm)+1):
  43. t.append(types.get(i, 0))
  44. return tuple(t)
  45. def conjugacy_classes(n):
  46. cs = {}
  47. for perm in s_n(n):
  48. ct = cycle_type(perm)
  49. if ct not in cs:
  50. cs[ct] = [perm]
  51. else:
  52. cs[ct].append(perm)
  53. l = list(cs.items())
  54. return sorted(l, key=lambda x: x[0], reverse=True)
  55. def partitions(n, conj_classes=None):
  56. parts = []
  57. if conj_classes == None:
  58. conj_classes = conjugacy_classes(n)
  59. for cycle_type, conj in conj_classes:
  60. part = []
  61. for i, c in enumerate(cycle_type):
  62. for s in range(0, c):
  63. part.append(i+1)
  64. parts.append(sorted(part, reverse=True))
  65. #parts.append([(i+1) * cycle_type[i] for i in range(0, n)])
  66. return list(sorted(parts, reverse=True))
  67. def psi(n):
  68. cs = conjugacy_classes(n)
  69. ps = partitions(n, cs)
  70. m = np.zeros((len(cs), len(cs)))
  71. for i, part in enumerate(ps):
  72. row_stabs = set(filter(lambda sigma: is_row_stab(part, sigma), s_n(n)))
  73. for j, (cycle_type, conj) in enumerate(cs):
  74. m[i, j] = len(row_stabs & set(conj)) * np.math.factorial(n) / (len(row_stabs) * len(conj))
  75. return m
  76. def sigma(n):
  77. cs = conjugacy_classes(n)
  78. m = np.zeros((len(cs), len(cs)))
  79. for i, (cycle_type, conj) in enumerate(cs):
  80. m[i, i] = len(conj) / np.math.factorial(n)
  81. return m
  82. if __name__ == '__main__':
  83. if len(sys.argv) >= 2:
  84. n = int(sys.argv[1])
  85. else:
  86. n = 3
  87. psi = psi(n)
  88. sigma = sigma(n)
  89. a = np.dot(psi, np.dot(sigma, np.transpose(psi)))
  90. k = np.linalg.cholesky(a)
  91. x = np.dot(np.linalg.inv(k), psi)
  92. print("Character table for S_n where n =", n)
  93. print("Rows are indexed by partitions and columns by conjugacy classes")
  94. print(x.round())