# Does H (real, N=16) have a bistochastic form over mu_{2^a} for SOME a? <=> exact cover of # 16 columns + 16 rows by the sets cols(x) U rows(Hx), x in X\{0}, X = {x ternary : Hx in {0,+-4}^16}. import sys, numpy as np, itertools, time sys.path.insert(0,'..'); sys.path.insert(0,'.') import matrices as m k=int(sys.argv[1]) H=np.real(m.from_hex(m.HAD16[k])).astype(np.int16); N=16 half=np.array(list(itertools.product([-1,0,1],repeat=8)),dtype=np.int16) SL=half@H[:,:8].T; SR=half@H[:,8:].T X=[] for a in range(len(half)): s=SL[a][None,:]+SR good=np.all((s==0)|(s==4)|(s==-4),axis=1) for b in np.nonzero(good)[0]: X.append(np.r_[half[a],half[b]]) X=np.array(X,dtype=np.int16); HX=X.astype(int)@H.T.astype(int) w=1<>i &1] for i in range(32)] count=0; first=None; parts_hist={} sys.setrecursionlimit(10000) STOP="--first" in sys.argv def search(covered,chosen): global count,first if covered==FULL: count+=1; parts_hist[len(chosen)]=parts_hist.get(len(chosen),0)+1 if first is None: first=list(chosen) if STOP: raise StopIteration return # choose uncovered item with fewest candidate sets best=None; bestc=None for i in range(32): if not covered>>i&1: c=[s for s in by_item[i] if s&covered==0] if best is None or len(c)>16)) for s in first])