# fury.py -- a zoo of circulant complex Hadamard matrices H_{ix}=h(x-i), of orders N=6 to 13. The vectors h with |h|=1 and # |FFT(h)|^2=N are searched by the alternating projections of Gerchberg-Saxton from random starts, then polished by # Gauss-Newton to machine precision, and sorted into classes by the spectrum of T_2, which is invariant under equivalence, # transposition and conjugation. For each class with c_2=2, which are the candidates for wildness, the program records # the local dimension of the circulant solutions, the zeros of the profile S on the quadruples of distinct indices, the # number of values of h up to the characters, the phases of the eigenvalues, and the norms of the Jones-Wenzl pieces # Phi_k^(c) of T_k in the character blocks c of the cyclic shift, up to the level 7, 6 or 5, depending on N. A circulant # matrix is wild if and only if the blocks c=0 have norm < 1 at all levels. Stops after 7.5 hours. # Output: fury_output/fury.log, fury_output/fury.json # Usage: /usr/bin/python3 fury.py import numpy as np, time, json, os, itertools OUT="fury_output"; os.makedirs(OUT,exist_ok=True) LOG=open(os.path.join(OUT,"fury.log"),"a") def say(s): print(s,flush=True); LOG.write(s+"\n"); LOG.flush() T0=time.time() 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 T2spec(H): N=len(H); S=profile(H); T=(abs(S)**2).transpose(0,2,1,3).reshape(N*N,N*N)/N**3 return np.sort(np.linalg.eigvalsh(T))[::-1] 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 values_up_to_characters(h): N=len(h); w=np.exp(2j*np.pi/N); best=N for c in range(N): g=h*w**(-c*np.arange(N)); g=g/g[0]; vals=[] for x in g: if not any(abs(x-v)<1e-8 for v in vals): vals.append(x) best=min(best,len(vals)) return best if __name__=="__main__": plan={6:(300,5),7:(500,5),8:(1500,7),9:(1500,7),10:(2000,6),11:(2500,5),12:(2500,5),13:(2500,5)} say("fury: circulant complex Hadamard matrices of orders 6 to 13") db={} try: db=json.load(open(os.path.join(OUT,"fury.json"))) except Exception: pass for N,(R,K) in plan.items(): if str(N) in db and db[str(N)].get("done"): continue rng=np.random.default_rng(1000+N); classes=[]; ok=0 for r in range(R): h,res,J=polish(gs(N,rng)) if res>1e-10: continue ok+=1; sp=T2spec(circ(h)) for cl in classes: if np.allclose(cl["spec"],sp,atol=1e-7): cl["hits"]+=1; break else: classes.append({"spec":sp,"h":h,"hits":1,"localdim":int((N-1)-np.linalg.matrix_rank(J,tol=1e-8)),"c2":int(np.sum(sp>1-1e-8))}) if (r+1)%500==0: say(" %s N=%d: %d/%d starts, %d solutions, %d classes"%(el(),N,r+1,R,ok,len(classes))) c2hist={} for cl in classes: c2hist[cl["c2"]]=c2hist.get(cl["c2"],0)+1 say("%s N=%d: %d solutions, %d classes, by c_2: %s"%(el(),N,ok,len(classes),dict(sorted(c2hist.items())))) cands=sorted([cl for cl in classes if cl["c2"]==2],key=lambda cl:(cl["localdim"],-cl["hits"]))[:40] out=[]; DM=distinct_mask(N) for ci,cl in enumerate(cands): h=cl["h"]; H=circ(h); S=profile(H); St=profile(H.T.copy()) w=np.exp(2j*np.pi/N); lam=np.array([sum(h[t]*w**(k*t) for t in range(N)) for k in range(N)]) rec={"row":[[float(z.real),float(z.imag)] for z in h],"hits":cl["hits"],"localdim":cl["localdim"], "zeros_S":int(np.sum((abs(S)<1e-9)&DM)),"zeros_S_transpose":int(np.sum((abs(St)<1e-9)&DM)), "min_abs_S_distinct":float(abs(S)[DM].min()),"distinct_abs_S":len(set(np.round(abs(S).ravel(),7))), "values_up_to_characters":values_up_to_characters(h), "eigenvalue_phases_over_pi":[float(x) for x in np.angle(lam)/np.pi],"norms":{}} say("%s N=%d class %d/%d: hits %d, local dimension %d, zeros of S %d (transpose %d), min|S| %.4f, values of h %d"%( el(),N,ci+1,len(cands),rec["hits"],rec["localdim"],rec["zeros_S"],rec["zeros_S_transpose"],rec["min_abs_S_distinct"],rec["values_up_to_characters"])) for k in range(2,K+1): if time.time()-T0>7.5*3600: break row=[] for c in range(N): big=N**k>=4*10**7; dt=np.complex64 if big else np.complex128 steps=40 if N**(k-1)>=200 else 30 ev=lanczos(Block(h,k,c,dt),steps,3e-6 if big else 1e-11,seed=k*100+c,tag="N=%d class %d k=%d c=%d"%(N,ci+1,k,c),verbose=False) row.append(ev[0]) rec["norms"][str(k)]=row say(" %s N=%d class %d level %d: block norms %s, max %.6f"%(el(),N,ci+1,k," ".join("%.6f"%x for x in row),max(row))) out.append(rec) db[str(N)]={"classes_total":len(classes),"by_c2":{str(a):b for a,b in c2hist.items()},"candidates":out,"done":False} json.dump(db,open(os.path.join(OUT,"fury.json"),"w"),indent=1) if time.time()-T0>7.5*3600: break db[str(N)]={"classes_total":len(classes),"by_c2":{str(a):b for a,b in c2hist.items()},"candidates":out,"done":True} json.dump(db,open(os.path.join(OUT,"fury.json"),"w"),indent=1) if time.time()-T0>7.5*3600: say("%s time limit reached"%el()); break say("%s finished"%el())