# joshua.py -- circulant complex Hadamard matrices H_{ix}=h(x-i) of multiplier type: h is constant on the orbits of a # subgroup U of the group of units of Z_N, acting on Z_N by multiplication, which for N prime are the cyclic N-roots of # simple index of Bjorck, and which include the matrices C_7A, C_7C, C_8, C_10, C_14, C_15 of the paper. For N=6 to 32, and for all # subgroups U with at most 12 orbits, the orthogonality equations, which are constant on the orbits too, are solved by # Gauss-Newton from random starting points. The solutions are sorted into classes by the multiset of the numbers |S|, # which is invariant under equivalence and conjugation, c_2 being the number of components of the support of T_2, and for the # classes with c_2=2 the program records the subgroup, the values of h with 16 digits, the zeros of the profile S on the # quadruples of distinct indices, and the norms of the Jones-Wenzl pieces Phi_k^(c) of T_k in the character blocks of # the cyclic shift, up to level 4 for N<=20 and level 3 beyond. Stops after 1h50m. # Output: joshua_output/joshua.log, joshua_output/joshua.json # Usage: /usr/bin/python3 joshua.py import numpy as np, time, json, os, itertools, math OUT="joshua_output"; os.makedirs(OUT,exist_ok=True) LOG=open(os.path.join(OUT,"joshua.log"),"a") def say(s): print(s,flush=True); LOG.write(s+"\n"); LOG.flush() T0=time.time(); LIMIT=110*60 def el(): return "%7.1fm"%((time.time()-T0)/60) class Block: def __init__(s,h,k,c,dt): s.N=N=len(h); s.k=k; s.c=c; s.dt=dt s.w=np.exp(2j*np.pi*c/N) s.wp=np.array([s.w**t for t in range(N)],dtype=dt) d=(np.arange(N)[:,None]-np.arange(N)[None,:])%N h=np.asarray(h,dtype=complex); hm=h[(-np.arange(N))%N] s.ops=[] for P,Q in ((h,np.conj(h)),(np.conj(hm),hm)): Pm=P[d].astype(dt); Qm=Q[d].astype(dt) K=(Qm[:,None,:]*Pm[None,:,:]) # K[b,y,z] s.ops.append((Pm,Qm,np.ascontiguousarray(K.transpose(0,2,1)))) # Kt[b,z,y] idx=np.indices((N,)*(k-1)); m=(idx[0]!=0) for j in range(k-2): m&=(idx[j]!=idx[j+1]) s.m=m.astype(np.float32 if dt==np.complex64 else np.float64) def contract(s,g,op): N,k=s.N,s.k; Pm,Qm,Kt=op G=Pm[:,0].reshape((N,)+(1,)*(k-1))*g[None] for t in range(2,k+1): a=N**(t-2); r=N**(k-t) X=np.ascontiguousarray(G.reshape(a,N,N,r).transpose(1,0,3,2)).reshape(N,a*r,N); del G Y=np.matmul(X,Kt); del X G=np.ascontiguousarray(Y.reshape(N,a,r,N).transpose(1,0,3,2)); del Y G=G.reshape((N,)*k) out=np.zeros((N,)*(k-1),dtype=s.dt); ax=tuple(range(k-1)) for z1 in range(N): out+=s.wp[z1]*np.roll(G[(-z1)%N],shift=z1,axis=ax)*Qm[:,z1].reshape((1,)*(k-2)+(N,)) return out def T(s,g): y=s.contract(g,s.ops[0]) y=np.ascontiguousarray(y.transpose(tuple(range(s.k-2,-1,-1)))) y=s.contract(y,s.ops[1]) y=np.ascontiguousarray(y.transpose(tuple(range(s.k-2,-1,-1)))) return y/s.N**(s.k+1) def P1(s,g): N,k=s.N,s.k for ax in range(k-1): g=g-g.mean(axis=ax,keepdims=True) av=np.zeros_like(g) for t in range(N): av+=s.wp[t]*np.roll(g,shift=t,axis=tuple(range(k-1))) return g-av/N def proj(s,g,tol,maxit=300): for it in range(maxit): g2=s.P1(g)*s.m ch=np.linalg.norm(g2-g)/max(np.linalg.norm(g2),1e-300); g=g2 if chabcd',H,H.conj(),H.conj(),H) def invariants(H): # the multiset of the numbers |S(a,b,c,d)|, invariant under equivalence and conjugation, and c_2 = number of connected # components of the graph on pairs (i1,i2), (j1,j2) joined when S(i1,j1,i2,j2) is nonzero N=len(H); S=profile(H); A=abs(S) key=np.round(np.sort(A.ravel()),6) adj=(A>1e-9).transpose(0,2,1,3).reshape(N*N,N*N) parent=list(range(N*N)) def find(x): while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x] return x I,J=np.nonzero(np.triu(adj)) for i,j in zip(I.tolist(),J.tolist()): ri,rj=find(i),find(j) if ri!=rj: parent[ri]=rj return key,len({find(x) for x in range(N*N)}) def distinct_mask(N): a,b,c,d=np.indices((N,)*4); return (a!=b)&(a!=c)&(a!=d)&(b!=c)&(b!=d)&(c!=d) def subgroups(N): units=[u for u in range(1,N) if math.gcd(u,N)==1] def gen(S): G={1} while True: new={(g*s)%N for g in G for s in S}|G if new==G: return frozenset(G) G=new subs=set() for a in units: subs.add(gen([a])) for b in units: if b>a: subs.add(gen([a,b])) return sorted(subs,key=lambda G:(-len(G),sorted(G))) def orbits(N,U): seen=set(); orb=[] for t in range(N): if t in seen: continue o=sorted({(u*t)%N for u in U}); orb.append(o); seen|=set(o) return orb def solve(N,orb,rng,tries): m=len(orb); lab=np.zeros(N,dtype=int) for j,o in enumerate(orb): for t in o: lab[t]=j reps=[o[0] for o in orb if o[0]!=0] sols=[] for _ in range(tries): th=2*np.pi*rng.random(m); th[0]=0 for it in range(60): x=np.exp(1j*th[lab]) r=np.array([np.sum(np.roll(x,-s)*np.conj(x)) for s in reps]) res=np.concatenate([r.real,r.imag]) if np.abs(res).max()<1e-13: break J=np.zeros((2*len(reps),m-1)) for j in range(1,m): dx=1j*x*(lab==j) dr=np.array([np.sum(np.roll(dx,-s)*np.conj(x)+np.roll(x,-s)*np.conj(dx)) for s in reps]) J[:,j-1]=np.concatenate([dr.real,dr.imag]) step=np.linalg.lstsq(J,-res,rcond=None)[0]; th[1:]+=step x=np.exp(1j*th[lab]) if abs(np.abs(np.fft.fft(x))**2-N).max()<1e-10: sols.append(x) return sols if __name__=="__main__": say("joshua: circulant complex Hadamard matrices of multiplier type, N=6 to 32") db={} try: db=json.load(open(os.path.join(OUT,"joshua.json"))) except Exception: pass rng=np.random.default_rng(7) for N in range(6,33): if str(N) in db: continue if time.time()-T0>LIMIT: say("%s time limit reached"%el()); break classes=[]; DM=distinct_mask(N) for U in subgroups(N): orb=orbits(N,U) if len(orb)>12 or len(orb)<2: continue for x in solve(N,orb,rng,tries=60): key,c2=invariants(circ(x)) for cl in classes: if len(cl["key"])==len(key) and np.allclose(cl["key"],key,atol=2e-6): if len(orb)LIMIT: break c2h={} for cl in classes: c2h[cl["c2"]]=c2h.get(cl["c2"],0)+1 say("%s N=%d: %d classes, by c_2: %s"%(el(),N,len(classes),dict(sorted(c2h.items())))) out=[] for cl in [c for c in classes if c["c2"]==2]: h=cl["h"]; H=circ(h); S=profile(H) rec={"U":cl["U"],"orbits":cl["orbits"],"row":[[float(z.real),float(z.imag)] for z in h], "zeros_S":int(np.sum((abs(S)<1e-9)&DM)),"min_abs_S_distinct":float(abs(S)[DM].min()),"norms":{}} say(" %s N=%d class: U=%s, %d orbits, zeros of S %d, min|S| %.6f, values %s"%(el(),N,cl["U"],cl["orbits"],rec["zeros_S"],rec["min_abs_S_distinct"], " ".join("%.12f%+.12fi"%(z.real,z.imag) for z in sorted({complex(round(v.real,10),round(v.imag,10)) for v in h},key=lambda z:(z.real,z.imag))))) K=4 if N<=20 else 3 for k in range(2,K+1): if time.time()-T0>LIMIT: break row=[lanczos(Block(h,k,c,np.complex128),40 if N**(k-1)>=200 else 30,1e-11,seed=k*100+c,tag="",verbose=False)[0] for c in range(N)] rec["norms"][str(k)]=row say(" %s level %d: block norms max %.6f, block 0 %.6f, 4/N %.6f"%(el(),k,max(row),row[0],4/N)) out.append(rec) db[str(N)]={"classes":len(classes),"by_c2":{str(a):b for a,b in c2h.items()},"c2_two":out} json.dump(db,open(os.path.join(OUT,"joshua.json"),"w"),indent=1) say("%s finished"%el())