def Dih(n): 'Dihedral group of order n' if n == 1: return simple.z(2) elif n == 2: c = numpy.array([[0, 1, 2, 3], [1, 0, 3, 2], [2, 3, 0, 1], [3, 2, 1, 0]]) return algebra.algebra(c) elif n == 3: c = numpy.array([[0, 1, 2, 3, 4, 5], [1, 2, 0, 4, 5, 3], [2, 0, 1, 5, 3, 4], [3, 5, 4, 0, 2, 1], [4, 3, 5, 1, 0, 2], [5, 4, 3, 2, 1, 0]]) return algebra.algebra(c) else: raise Exception("Dihedral groups so far only defined for n<4")
def randomGroup(n): '''Randomly generate a group of order n. It does that by putting in random values and then checking group axioms. This is about as inefficient as an algorithm can possibly get!!! ''' count = 0 # We need some exit mechanism in case it's impossible while True: c = numpy.empty((n, n), dtype=numpy.uint32) for i, j in itertools.product(range(n), range(n)): if i == 0: c[i, j] = j elif j == 0: c[i, j] = i else: c[i, j] = random.randint(0, n-1) is_good = True # Check invertibility for i in range(n): has_inverse = False for j in range(n): if c[i, j] == 0 and c[j, i] == 0: has_inverse = True break if not has_inverse: is_good = False break # Check associativity if is_good: for i, j, k in itertools.product(range(n), range(n), range(n)): if c[c[i, j], k] != c[i, c[j, k]]: is_good = False break if is_good: return algebra(c) # If not good, go around and try another one... count += 1 if count > 1000000: raise Exception("Didn't find a group of order {0}!".format(n))
def Steinberg(family, n, q): order = 0 if family == '2A': # Classic Steinberg group if n <= 1: raise Exception x = 1 for i in range(1, n + 1): x *= (q**(i + 1) - (-1)**(i + 1)) x *= q**(n * (n + 1) // 2) x /= math.gcd(n + 1, q + 1) name = f"^(2)A_{n}({q}^2)" order = x elif family == '2D': # Classic Steinberg group if n <= 3: raise Exception x = 1 for i in range(1, n + 1): x *= (q**(2 * i) - 1) x *= (q**2 + 1) x *= q**(n * (n - 1)) x /= math.gcd(4, q**n + 1) name = f"^(2)D_{n}({q}^2)" order = x elif family == '2E': # Exceptional Steinberg group if n != 6: raise Exception x = 1 for i in [2, 5, 6, 8, 9, 12]: x *= (q**i - (-1)**i) x *= q**36 x /= math.gcd(3, q + 1) name = f"^(2)E_{n}({q}^2)" order = x elif family == '3E': # Exceptional Steinberg group if n != 4: raise Exception x = 1 x *= q**12 x *= (q**8 + q**4 + 1) x *= (q**6 - 1) x *= (q**2 - 1) name = f"^(3)E_{n}({q}^3)" order = x c = algebra(None) c.setName(name) c.setOrder(order) return c
def Suzuki(q): n = 0.5 * (math.log(q, 2) - 1) if abs( n - round(n) ) > 1.E-7: # This "epsilon" value is only suitable for quite small values of q. Revisit... raise Exception("q must be of form 2^(2n+1). q={0}, n={1}".format( q, n)) name = f"^(2)B_2({q})" order = q**2 * (q**2 + 1) * (q - 1) c = algebra(None) c.setName(name) c.setOrder(order) return c
def z(n): ''' Cyclic group of order n. ''' if n <= 0: raise Exception("Need a positive order") c = numpy.empty((n, n), dtype=numpy.uint32) for i in range(n): x = i for j in range(n): c[i, j] = x x += 1 if x >= n: x -= n return algebra(c)
def Chevalley(family, n, q): order = 0 if family == 'A': # Classic Chevalley group x = 1 for i in range(1, n + 1): x *= (q**(i + 1) - 1) x *= q**(n * (n + 1) // 2) x /= math.gcd(n + 1, q - 1) name = f"A_{n}({q})" order = x elif family == 'B': # Classic Chevalley group if n < 1: raise Exception x = 1 for i in range(1, n + 1): x *= (q**(2 * i) - 1) x *= q**(n * n) x /= math.gcd(2, q - 1) name = f"B_{n}({q})" order = x elif family == 'C': # Classic Chevalley group if n < 2: raise Exception x = 1 for i in range(1, n + 1): x *= (q**(2 * i) - 1) x *= q**(n * n) x /= math.gcd(2, q - 1) name = f"C_{n}({q})" order = x elif family == 'D': # Classic Chevalley group if n < 2: raise Exception x = 1 for i in range(1, n + 1): x *= (q**(2 * i) - 1) x *= q**(n * (n - 1)) * (q**n - 1) x /= math.gcd(4, q**n - 1) name = f"D_{n}({q})" order = x elif family == 'E': # Exceptional Chevalley group x = 1 if n == 6: for i in [2, 5, 6, 8, 9, 12]: x *= (q**i - 1) x *= q**36 x /= math.gcd(3, q - 1) elif n == 7: for i in [2, 6, 8, 10, 12, 14, 18]: x *= (q**i - 1) x *= q**63 x /= math.gcd(2, q - 1) elif n == 8: for i in [2, 8, 12, 14, 18, 20, 24, 30]: x *= (q**i - 1) x *= q**120 else: raise Exception("Impossible value for n") name = f"E_{n}({q})" order = x elif family == 'F': # Exceptional Chevalley group x = 1 if n == 4: for i in [2, 6, 8, 12]: x *= (q**i - 1) x *= q**24 else: raise Exception("Impossible value for n") name = f"F_{n}({q})" order = x elif family == 'G': # Exceptional Chevalley group x = 1 if n == 2: for i in [2, 6]: x *= (q**i - 1) x *= q**6 else: raise Exception("Impossible value for n") name = f"G_{n}({q})" order = x c = algebra(None) c.setName(name) c.setOrder(order) return c