def __mul__(self, other): if isinstance(other, Integral): mask = -(other & 1) return Cocode(self.value & mask & 0xfff) elif isinstance(other, AutPL): return Cocode(mat24.op_cocode_perm(self.value, other.perm)) else: return NotImplemented
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 mul_Tp(tag, octad, sub, g): d = m24.octad_to_gcode(octad) c = m24.suboctad_to_cocode(sub, d) eps, pi, rep = g.cocode, g.perm, g.rep d1 = m24.op_ploop_autpl(d, rep) c1 = m24.op_cocode_perm(c, pi) s = d1 >> 12 s ^= (eps >> 11) & 1 & m24.suboctad_weight(sub) octad1 = m24.gcode_to_octad(d1) sub1 = m24.cocode_to_suboctad(c1, d1) return s, tag, octad1, sub1
def test_group_ploop(n_cases): print("") for i, (c, v, g) in enumerate( zip(cocode_testvectors(n_cases), get_testvectors(n_cases), autpl_testwords(n_cases))): cg = c * g vg = v * g if i < 1: print(c, "*", g, "=", cg) print(v, "*", g, "=", vg) cg_ref = Cocode(mat24.op_cocode_perm(c.ord, g.perm)) assert cg == cg_ref assert len(cg) == len(c) vg_ref = GcVector(mat24.op_vect_perm(v.ord, g.perm)) assert vg == vg_ref assert len(vg) == len(v) if len(v) & 1 == 0: assert v / 2 == vg / 2 == Parity(len(v) >> 1) if len(v) & 3 == 0: assert v / 4 == vg / 4 == Parity(len(v) >> 2) assert v % 2 == vg % 2 == Parity(len(v))
def apply_perm(v, src, dest, n, log_list, verbose=0): r"""Apply permutation to vector in Leech lattice mod 2. The function computes a permutation :math:`\pi` that maps the entries of the array ``src`` of length ``n`` to the entries of the array ``dest`` (of the same length) in the given order. Let :math:`v_2` be the vector in the Leech lattice mod 2 given by parameter ``v2``. The function returns :math:`v_2 x_\pi`. Parameter ``v2`` and the return value are given in Leech lattice encoding. Parameter ``p_res`` points to an integer where the function stores the element :math:`x_\pi` as a generator of the monster group as as described in file ``mmgroup_generators.h``. That generator is stored with tag ``MMGROUP_ATOM_TAG_IP`` so that we can compute the inverse of :math:`\pi` very efficiently. We compute the inverse of the lowest permutation (in lexical order) that maps ``dest[:n]`` to ``src[:n]``. """ res, p = mat24.perm_from_map(dest[:n], src[:n]) assert res > 0, (res, dest[:n], src[:n]) p_inv = mat24.inv_perm(p) p_num = mat24.perm_to_m24num(p) log_list.append(0xA0000000 + p_num) xd = (v >> 12) & 0xfff xdelta = (v ^ mat24.ploop_theta(xd)) & 0xfff m = mat24.perm_to_matrix(p_inv) xd = mat24.op_gcode_matrix(xd, m) xdelta = mat24.op_cocode_perm(xdelta, p_inv) v_out = (xd << 12) ^ xdelta ^ mat24.ploop_theta(xd) if verbose: print("Apply permutation (mapping v to gcode %s):\n%s" % (hex(mat24.gcode_to_vect(v_out >> 12)), p_inv)) return v_out