# ali.py -- the circulant complex Hadamard matrices of prime order p with few values, of multiplier type: the first row h # is constant on the cosets of the subgroup U of index d in the group of units of Z_p, for d=2,...,6, so that h takes # at most d+1 values, these being the cyclic p-roots of simple index of Bjorck, at the primes 5 <= p <= 127. The orthogonality # equations are solved by Gauss-Newton from random starting points, and the solutions are sorted into classes by the # multiset of the numbers |S|, computed with the translation invariance S(a,b,c,d) = S(0,b-a,c-a,d-a). For each class # the program records the values of h with 15 digits, the zeros of the profile S on the quadruples of distinct indices, # dim P_2 and the gap below the eigenvalue 1 of T_2, the defect, computed as the multiplicity of the eigenvalue 1 of the # Berezin matrix minus 2p-1, both matrices being decomposed into p blocks of size p by the cyclic shift, and the norm of # the Jones-Wenzl piece Phi_k^(0) of T_k in the shift-invariant block, which decides wildness, up to level 8, 7, 6, 5, # 4 or 3, depending on p. A class found for several indices d is treated once, at the smallest one. Stops after 1h50m. # Output: ali_output/ali.log, ali_output/ali.json # Usage: /usr/bin/python3 ali.py import numpy as np, time, json, os, math OUT="ali_output"; os.makedirs(OUT,exist_ok=True) LOG=open(os.path.join(OUT,"ali.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 ch1-1e-9)) return k, float(1-ev[k]) def defect(h): # Berezin matrix in the coordinates (i, u=j-i), blocks B^(c)_{u,v} = sum_m w^{cm} h(u) conj h(u-m) h(v) conj h(v+m) / N N=len(h); x=np.arange(N); tot=0 for c in range(N): w=np.exp(2j*np.pi*c*x/N) L=np.conj(h[(x[:,None]-x[None,:])%N])*w[None,:] # L[u,m] = conj h(u-m) w^m R=np.conj(h[(x[:,None]+x[None,:])%N]) # R[v,m] = conj h(v+m) B=(h[:,None]*h[None,:])*(L@R.T)/N tot+=int(np.sum(abs(np.linalg.eigvals(B)-1)<1e-7)) return tot-(2*N-1) def level(p): return 8 if p<=7 else 7 if p<=11 else 6 if p<=13 else 5 if p<=19 else 4 if p<=47 else 3 if __name__=="__main__": say("ali: circulant complex Hadamard matrices of prime order p and index d = 2,...,6, for 5 <= p <= 127") db={} try: db=json.load(open(os.path.join(OUT,"ali.json"))) except Exception: pass rng=np.random.default_rng(13) primes=[p for p in range(5,128) if all(p%q for q in range(2,p))] for p in primes: seen=[] for d in (2,3,4,5,6): if (p-1)%d: continue tag="%d,%d"%(p,d) if tag in db and db[tag].get("done"): continue if time.time()-T0>LIMIT: break U,orb=cosets(p,d); DM=distinct0(p); classes=[]; old=0 for x in solve(p,orb,rng,tries=150): S=S0(x); key=np.round(np.sort(abs(S).ravel()),6) if any(np.allclose(k,key,atol=2e-6) for k in seen): old+=1; continue for cl in classes: if np.allclose(cl["key"],key,atol=2e-6): cl["hits"]+=1; break else: classes.append({"key":key,"h":x,"S":S,"hits":1}) seen+=[cl["key"] for cl in classes] say("%s p=%d, index %d, %d orbits: %d new classes, %d solutions in classes of smaller index"%(el(),p,d,d+1,len(classes),old)) out=[] for ci,cl in enumerate(classes): h=cl["h"]; S=cl["S"]; c2,gap=p2_and_gap(S); df=defect(h) vals=sorted({complex(round(v.real,12),round(v.imag,12)) for v in h},key=lambda z:(z.real,z.imag)) rec={"U":U,"row":[[float(z.real),float(z.imag)] for z in h],"hits":cl["hits"],"zeros_S":int(np.sum((abs(S)<1e-9)&DM))*p, "min_abs_S_distinct":float(abs(S)[DM].min()),"dim_P2":c2,"gap_T2":gap,"defect":df,"norms_block0":{}} say(" %s p=%d class %d/%d: hits %d, zeros of S %d, min|S| %.6f, dim P_2 %d, gap %.6f, defect %d, values %s"%(el(),p,ci+1,len(classes), cl["hits"],rec["zeros_S"],rec["min_abs_S_distinct"],c2,gap,df," ".join("%.15f%+.15fi"%(z.real,z.imag) for z in vals))) if c2==2: for k in range(2,level(p)+1): if time.time()-T0>LIMIT: break big=p**k>=4*10**7 n=lanczos(Block(h,k,0,np.complex64 if big else np.complex128),40 if p**(k-1)>=200 else 30,3e-6 if big else 1e-11,seed=k*100,tag="",verbose=False)[0] rec["norms_block0"][str(k)]=n say(" %s p=%d class %d level %d: norm of Phi_k^(0) %.6f, 4/p %.6f"%(el(),p,ci+1,k,n,4/p)) out.append(rec) db[tag]={"p":p,"index":d,"classes":out,"done":False} json.dump(db,open(os.path.join(OUT,"ali.json"),"w"),indent=1) db[tag]={"p":p,"index":d,"classes":out,"done":time.time()-T0<=LIMIT} json.dump(db,open(os.path.join(OUT,"ali.json"),"w"),indent=1) if time.time()-T0>LIMIT: say("%s time limit reached"%el()); break say("%s finished"%el())