def build_B(cls, n, k=1, **kw): roots = [] lookup = {} # long roots for i in range(n): for j in range(i + 1, n): for a in [-1, 1]: for b in [-1, 1]: root = [0] * n root[i] = a root[j] = b root = tuple(root) lookup[root] = len(roots) roots.append(root) # short roots for i in range(n): for a in [-1, 1]: root = [0] * n root[i] = a * k root = tuple(root) lookup[root] = len(roots) roots.append(root) assert len(lookup) == len(roots) assert len(roots) == 2 * n**2 gen = [] for i in range(n - 1): perm = [] for idx, root in enumerate(roots): _root = list(root) _root[i], _root[i + 1] = _root[i + 1], _root[i] # swap i, i+1 coords jdx = lookup[tuple(_root)] perm.append(jdx) perm = Perm(perm, roots) gen.append(perm) perm = [] for idx, root in enumerate(roots): _root = list(root) _root[n - 1] = -_root[n - 1] jdx = lookup[tuple(_root)] perm.append(jdx) perm = Perm(perm, roots) gen.append(perm) return Weyl_B(roots, gen, name="B_%d" % n, **kw)
def build_D(cls, n, **kw): assert n >= 2 roots = [] lookup = {} for i in range(n): for j in range(i + 1, n): for a in [-1, 1]: for b in [-1, 1]: root = [0] * n root[i] = a root[j] = b root = tuple(root) lookup[root] = len(roots) roots.append(root) assert len(lookup) == len(roots) assert len(roots) == 2 * n * (n - 1) gen = [] for i in range(n - 1): perm = [] for idx, root in enumerate(roots): _root = list(root) _root[i], _root[i + 1] = _root[i + 1], _root[i] # swap i, i+1 coords jdx = lookup[tuple(_root)] perm.append(jdx) perm = Perm(perm, roots) gen.append(perm) perm = [] for idx, root in enumerate(roots): _root = list(root) _root[n - 1], _root[n - 2] = -_root[n - 2], -_root[ n - 1] # swap & negate last two coords jdx = lookup[tuple(_root)] perm.append(jdx) perm = Perm(perm, roots) gen.append(perm) return Weyl_D(roots, gen, name="D_%d" % n, **kw)