# defect.py -- the defect of Tadej and Zyczkowski. For a complex Hadamard matrix H of order N, the defect is the # dimension of the space of real matrices A with sum_k H_ik conj(H_jk) (A_ik - A_jk) = 0 for all i,j, minus 2N-1. # These are the first order deformations H_ik exp(i t A_ik) preserving the Hadamard condition, modulo the trivial ones # A_ik = alpha_i + beta_k. We compute it for the real matrices in the folder matrices, checking the formula # (N-1)(N-2)/2, and for the complex examples of complexglow.py. import numpy as np, glob def defect(H): H=np.asarray(H,complex); N=len(H); rows=[] for i in range(N): for j in range(i+1,N): v=H[i]*np.conj(H[j]); r=np.zeros((N,N),complex); r[i,:]+=v; r[j,:]-=v; rows.append(r.ravel()) if not rows: return 0 L=np.array(rows); M=np.vstack([L.real,L.imag]); s=np.linalg.svd(M,compute_uv=False) return N*N-int(np.sum(s>1e-8*s[0]))-(2*N-1) def fourier(N): return np.exp(2j*np.pi*np.outer(np.arange(N),np.arange(N))/N) print("(1) real Hadamard matrices") for f in sorted(glob.glob('matrices/*.txt')): H=np.loadtxt(f); N=len(H); print(f" {f.split('/')[-1][:-4]:8s} N={N:2d} defect = {defect(H):4d} (N-1)(N-2)/2 = {(N-1)*(N-2)//2}",flush=True) print("(2) complex examples") i=1j; w=np.exp(2j*np.pi/3) Haag=np.array([[1,1,1,1,1,1],[1,-1,i,i,-i,-i],[1,i,-1,-i,i,-i],[1,i,-i,-1,-i,i],[1,-i,i,-i,-1,i],[1,-i,-i,i,i,-1]]) Tao=np.array([[1,1,1,1,1,1],[1,1,w,w,w**2,w**2],[1,w,1,w**2,w**2,w],[1,w,w**2,1,w,w**2],[1,w**2,w**2,w,1,w],[1,w**2,w,w**2,w,1]]) def F4q(t): q=np.exp(1j*t); return np.array([[1,1,1,1],[1,-1,1,-1],[1,q,-1,-q],[1,-q,-1,q]]) def dita6(t): F2=fourier(2); F3=fourier(3); q=np.exp(1j*t); Q=np.array([[1,1],[1,q],[1,q**2]]); H=np.zeros((6,6),complex) for a in range(3): for b in range(2): for c in range(3): for d in range(2): H[2*a+b,2*c+d]=Q[a,d]*F3[a,c]*F2[b,d] return H ex=[("F_2 (x)_q F_2, q=1",F4q(0)),("F_2 (x)_q F_2, q=e^(0.7i)",F4q(0.7)),("F_2 (x)_q F_2, q=i",F4q(np.pi/2))] ex+=[(f"F_{n}",fourier(n)) for n in range(5,13)]+[("F_3 (x)_Q F_2, t=0.4",dita6(0.4)),("Haagerup",Haag),("Tao",Tao)] for name,H in ex: print(f" {name:26s} N={len(H):2d} defect = {defect(H)}",flush=True)