# charles.py -- circulant Hadamard matrices: norms of the Jones-Wenzl pieces Phi_k^(c) of the transfer matrices T_k, # restricted to the character blocks c=0,...,N-1 of the cyclic shift. A circulant matrix is wild if and only if the # blocks c=0 have norm < 1 at all levels. Matrices: the Bjorck-Froberg matrix BF_6 (levels 2 to 10), the 2-valued # Bjorck circulant B_7 of order 7, whose subfactor is known to be Temperley-Lieb (control case), and the 4-valued # circulant Q_7 of order 7 (levels 2 to 9). Vectors of the block c are stored by their values on the words starting # with 0 (dimension N^(k-1)), T_k is applied by contracting the cycle i_1,x_1,...,i_k,x_k, and the norm is computed by # Lanczos on the range of the Jones-Wenzl projection (leg sums zero, vanishing on words with 2 equal adjacent letters), # which commutes with T_k. The largest levels run in single precision, to fit in 4GB. Stops after 7.5 hours. # Output: charles_output/charles.log, charles_output/charles.json # Usage: /usr/bin/python3 charles.py import numpy as np, time, json, os, sys OUT="charles_output"; os.makedirs(OUT,exist_ok=True) LOG=open(os.path.join(OUT,"charles.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) def bf6(): s3=np.sqrt(3); a=(1-s3+1j*np.sqrt(2*s3))/2 return np.array([1,1j*a,-a,-1j,-np.conj(a),1j*np.conj(a)]) def b7(): z=(-3-1j*np.sqrt(7))/4 return np.array([1,1,z,z,z,1,z]) def polish(h,it=50): N=len(h); th=np.angle(h/h[0])[1:] W=np.exp(-2j*np.pi*np.outer(np.arange(N),np.arange(N))/N) for _ in range(it): hh=np.exp(1j*np.concatenate([[0],th])); f=np.fft.fft(hh); r=abs(f)**2-N if abs(r).max()<1e-14: break J=2*np.real(np.conj(f)[:,None]*1j*hh[None,:]*W)[:,1:] th=th+np.linalg.lstsq(J,-r,rcond=None)[0] return np.exp(1j*np.concatenate([[0],th])) def q7(): u=-0.993359903237228+0.115048262222964j; v=0.212925716127215-0.977068390345175j; x=-0.38900382697617-0.921236138347759j return polish(np.array([1,1,u,v,x,v,u])) 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 ch7.5*3600: say("%s time limit reached"%el()); break key="%s,%d,%d"%(name,k,c) if key in res: continue h=mats[name]; N=len(h) big=N**k>=4*10**7 dt=np.complex64 if big else np.complex128 tol=3e-6 if big else 1e-11 steps=40 if k>=7 else 60 if N**(k-1)<200: steps=min(steps,30) t=time.time(); B=Block(h,k,c,dt) ev=lanczos(B,steps,tol,seed=k*10+c,tag="%s k=%d c=%d"%(name,k,c)) res[key]={"top":ev,"minutes":(time.time()-t)/60} json.dump(res,open(os.path.join(OUT,"charles.json"),"w"),indent=1) say("%s %s level %d block %d: norm %.8f, %.1f minutes"%(el(),name,k,c,ev[0],(time.time()-t)/60)) say("%s finished"%el())