# Library and table for Section 3. A symmetric (v,k,l) design with incidence matrix M and order n = k-l gives 2 orthogonal matrices # U = aJ + bM, with J the all-one matrix, b = 1/sqrt(n) and a = (-k -+ sqrt(n))/(v sqrt(n)), which share the same sign matrix S = 2M - J. # One of them is the polar part of S, the other one is its twisted polar part. With X = S^t U we check the eigenvalues, the 1-norms, # and the local maximality, by random rotations. Usage: python3 designs.py import numpy as np SETS = {"Fano plane (7,3,1)": (7, [1, 2, 4]), "Paley biplane (11,5,2)": (11, [1, 3, 4, 5, 9]), "plane of order 3 (13,4,1)": (13, [0, 1, 3, 9]), "PG(3,2) (15,7,3)": (15, [0, 1, 2, 4, 5, 8, 10]), "Paley (19,9,4)": (19, [1, 4, 5, 6, 7, 9, 11, 16, 17]), "plane of order 4 (21,5,1)": (21, [3, 6, 7, 12, 14]), "Paley (23,11,5)": (23, [1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18]), "plane of order 5 (31,6,1)": (31, [1, 5, 11, 24, 25, 27])} def incidence(v, D): M = np.zeros((v, v)) for i in range(v): for d in D: M[i, (i + d) % v] = 1 return M def parameters(v, D): M = incidence(v, D); k = len(D); G = M @ M.T; l = int(round(G[0, 1])) assert np.allclose(G, (k - l)*np.eye(v) + l*np.ones((v, v))), "not a difference set" return M, k, l def matrices(v, D): # returns the 2 orthogonal matrices of the design, the first one being the polar part of S (the plain one) M, k, l = parameters(v, D); n = k - l; b = 1/np.sqrt(n); J = np.ones((v, v)) U = [(-k - e*np.sqrt(n))/(v*np.sqrt(n))*J + b*M for e in (1, -1)] if v < 2*k: U = U[::-1] for W in U: assert np.allclose(W @ W.T, np.eye(v)) return U def spectrum(U): S = np.sign(U); X = S.T @ U; assert np.allclose(X, X.T); return np.linalg.eigvalsh(X) def localmax(U, trials=3000, seed=1): # largest gain of the 1-norm under random small rotations, and under the softest one, in the plane of the 2 lowest eigenvectors of X rng = np.random.default_rng(seed); v = len(U); f = np.abs(U).sum(); worst = -np.inf e, w = np.linalg.eigh(np.sign(U).T @ U); soft = np.outer(w[:, 0], w[:, 1]) - np.outer(w[:, 1], w[:, 0]) def gain(A): return np.abs(U @ np.linalg.solve(np.eye(v) - A/2, np.eye(v) + A/2)).sum() - f for eps in (1e-2, 1e-3, 1e-4): worst = max(worst, gain(eps*soft)) for _ in range(trials//3): A = rng.normal(size=(v, v)); A = A - A.T; worst = max(worst, gain(A*eps/np.linalg.norm(A))) return worst if __name__ == "__main__": for name, (v, D) in SETS.items(): M, k, l = parameters(v, D); n = k - l; P, T = matrices(v, D) print("%s, order n=%d, |v-2k|=%d, 2 sqrt(n)=%.4f" % (name, n, abs(v - 2*k), 2*np.sqrt(n))) for label, U, sign in (("plain ", P, 1), ("twisted", T, -1)): e = spectrum(U); formula = sign*abs(v - 2*k) + 2*(v - 1)*np.sqrt(n) assert np.isclose(np.abs(U).sum(), formula) and np.isclose(e.sum(), formula) sums = np.sort(e)[0] + np.sort(e)[1] print(" %s entries %.5f (on the blocks), %.5f (off); eigenvalues of X: %.4f (once), %.4f; norm/v^1.5 = %.6f; 4-norm^4 = %.5f; smallest sum of 2 eigenvalues %.4f; gain under rotations %.1e" % (label, U[0, D[0]], U[0, [j for j in range(v) if j not in D][0]], sign*abs(v - 2*k), 2*np.sqrt(n), formula/v**1.5, (U**4).sum(), sums, localmax(U)))