# reduce.py -- the reduction to coset sums: for a cocyclic Hadamard matrix H = (psi(g,h)) over G (cocycle.json) and a # normal subgroup G0 of index k on which psi is a coboundary over T, the bistochastic forms with column multipliers # conj(phi) * c, c constant on the cosets of G0, correspond to the vectors c in T^k with U c unimodular, where # U = A/sqrt(N) is the k x k unitary matrix of coset sums. We build U, check that it is unitary, find the vectors c # by the alternating iteration from random starts, and test the resulting forms of H for entries in roots of unity. # Only the first cocyclic structure of each type (group, coboundary or not) in the json file is treated. import numpy as np, json, sys, itertools from collections import Counter H=np.loadtxt(sys.argv[1]); N=len(H); kmax=int(sys.argv[3]) if len(sys.argv)>3 else 4 data=json.load(open(sys.argv[2] if len(sys.argv)>2 else 'cocycle.json')) from groups import name_table rng=np.random.default_rng(1) def rootorder(z,nmax=1000): t=(np.angle(z)/(2*np.pi))%1 for n in range(1,nmax+1): if abs(t*n-round(t*n))<1e-7: return n return 0 seen_types=set() for C in data: if (C.get('group'),C['z_in_commutator']) in seen_types: continue seen_types.add((C.get('group'),C['z_in_commutator'])) rl,cl,mult,psi=C['rows'],C['cols'],np.array(C['mult']),np.array(C['psi'],float) Mx=H[np.ix_(rl,cl)]; cs=Mx[0,:] inv=[int(np.nonzero(mult[a]==0)[0][0]) for a in range(N)] def gen(S): S=set(S)|{0} while True: T=S|{int(mult[a][b]) for a in S for b in S} if T==S: return frozenset(S) S=T subs={gen(c) for r in (1,2) for c in itertools.combinations(range(N),r)} normal=[K for K in subs if 1