def mul24_perm(v, pi): perm = m24num_to_perm(pi) w = np.zeros(24, dtype=np.int32) for i in range(24): w[perm[i]] = v[i] for i in range(24): v[i] = w[i]
def map_cocode(c, pi): """Map cocode element with permutation pi 'c' is a cocode element in 'cocode' representation. 'pi' is the number of a permutation in the Mathieu group Mat24. The function returns the image of 'c' under the permutation 'pi' in 'cocode' representation. """ perm = mat24.m24num_to_perm(pi) return mat24.op_cocode_perm(c, perm)
def test_mat24lex(ntests=5000, verbose=0): lindex = [] ldata = [] for i, n in enumerate(mat24lex_testcases(ntests)): # Do additional checks for the first few samples test_ref = i < 100 # Compute permutation p with number n using the cython wrapper # mat24.m24num_to_perm() for function mat24_m24num_to_perm() p = mat24.m24num_to_perm(n) # For the first few random test data do: if test_ref: # Check result p against two slow reference implementations p_py_ref = py_mat24_int_to_perm(n) assert p == p_py_ref, (n, p, p_py_ref) p_ref = mat24_int_to_perm(n) assert p == p_ref, (n, p, p_ref) if verbose: print(i, n, p[:10]) # Append pair (n i) to the list 'lindex' and put ldata[i] = p lindex.append((n, i)) ### p[2] = randint(0,23) # This would destroy the order ldata.append(p) # Compute number n1 of permutation p using the cython wrapper # mat24.perm_to_m24num() for function mat24_perm_to_m24num() n1 = mat24.perm_to_m24num(p) # Then n == n1 must hold assert n1 == n, (hex(n), hex(n1), p) # For the first few random test data do: if test_ref: # Check result n1 against a slow reference implementation n1_ref = mat24_perm_to_int(p) assert n1_ref == n, (hex(n), hex(n1_ref), p) # Sort the index list 'lindex' by permutation numbers. lindex.sort() # Let n0 be the first permutation number in 'lindex' and # let p0 be the corresponding permutation. n0, index0 = lindex[0] p0 = ldata[index0] # For all subsequent permutation numbers n1 in the list 'lindex' # let p1 be the corresponding permutation. for n1, index1 in lindex[1:]: p1 = ldata[index1] if n1 > n0: # Check that permutation p1 is greater the the previous # permutation p0 (assuming that n1 is greater than the # previous number n0). assert p1 > p0 elif n1 == n0: # Birthday paradoxon: n1 == n0 may (and will) happen assert p1 == p0 else: raise ValueError("Something is going wrong here") # Update 'previous' number n0 and permutation p0 n0, p0 = n1, p1
def __init__(self, tag, cocode, perm=0): self.tag = tag if isinstance(cocode, Integral): self.cocode = cocode & 0xfff if perm: if isinstance(perm, Integral): self.m24num = perm else: self.m24num = mat24.perm_to_m24num(perm) self.perm = mat24.m24num_to_perm(self.m24num) self.rep = mat24.perm_to_autpl(cocode, self.perm) else: self.m24num = 0 self.perm = mat24.m24num_to_perm(0) self.rep = mat24.cocode_to_autpl(cocode) else: self.rep = cocode self.perm = mat24.autpl_to_perm(self.rep) self.cocode = mat24.autpl_to_cocode(self.rep) self.m24num = mat24.perm_to_m24num(self.perm)
def map_octad(oct, delta, pi): """Map octad through a Parker loop automorphsim to octad. Here 'oct' is an octad given in ocatad representation, interpreted as a (positive) element of the Parker loop. The pair (delta, pi), with delte a cocode element and pi the number of a permutation in Mat24, is an automorphism of the Parker loop. The function returns a pair (sign, img_octad) representing an element of the Parker loop with a given sign. img_octad is the number of the correspondig octad in octad representation. The return value is the image of the octad under the Parker loop automorphism (delta, pi). """ gcode = mat24.octad_to_gcode(oct) perm = mat24.m24num_to_perm(pi) m = mat24.perm_to_autpl(delta, perm) image = mat24.op_ploop_autpl(gcode, m) image_oct = mat24.gcode_to_octad(image) sign = (image >> 12) & 1 return sign, image_oct
def rand_perm(): """Return random permutation in ``Mat24`` as a list""" num = random.randint(0, mat24.MAT24_ORDER - 1) return mat24.m24num_to_perm(num)
def _compute_from_numbers(self): self._perm = mat24.m24num_to_perm(self._perm_num) self.rep = mat24.perm_to_autpl(self._cocode, self._perm)