\\% Here is the file http://www.jjj.de/pari/conference-mat-ff.inc.gp \\% Create a conference matrix, of order N=1+q^n where \\% q is an odd prime. Need the prime p and an irreducible \\% polynomial fp over GF(q). \\% The matrix C is such that is has zeros on the diagonal and \\% +-1 else, and C*C^T==(N-1)*id \\ Author: Joerg Arndt \\ online at http://www.jjj.de/pari/ \\ version: 2008-March-14 (08:46) num2pol(n,q)= \\ Return polynomial for number n. { local(p, mq, k); p = Pol(0,'x); k = 0; while ( 0!=n, mq = n % q; p += mq * ('x)^k; n -= mq; n \= q; k++; ); return( p ); } /* ---- */ pol2num(p,q)= \\ Return number for polynomial p. { local(t, n); n=0; for (k=0, poldegree(p), t = polcoeff(p, k); t *= Mod(1,q); t = component(t, 2); t *= q^k; n += t; ); return( n ); \\ return( sum(k=0,poldegree(p), q^k*component(Mod(1,q)*polcoeff(p, k),2)) ); } /* ---- */ quadcharvec(fp, q)= \\ Return a table of quadratic characters in GF(q^n) \\ fp is the field polynomial. { local(n, qn, sv, pl); n=poldegree(fp); qn=q^n-1; sv=vector(qn+1, j, -1); sv[1] = 0; for (k=1, qn, pl = num2pol(k,q); pl = Mod(Mod(1,q)*pl, fp); sq = pl * pl; sq = component(sq, 2); i = pol2num( sq, q ); sv[i+1] = +1; ); return( sv ); } /* ----- */ getquadchar_n(n1, n2, q, fp, n)= \\ Return the quadratic character of (n2-n1) in GF(q^n) \\ Powering method { local(p1, p2, d, nd, sc); if ( n1==n2, return(0) ); p1 = num2pol(n1, q); p2 = num2pol(n2, q); d = Mod(1,q)* (p2-p1); d = Mod(d,fp)^((q^n-1)/2); d = component(d, 2); if ( Mod(1,q)==d, sc=+1, sc=-1 ); return( sc ); } /* ---- */ getquadchar_v(n1, n2, q, fp, sv)= \\ Return the quadratic character of (n2-n1) in GF(q^n) \\ Table lookup method { local(p1, p2, d, nd, sc); if ( n1==n2, return(0) ); p1 = num2pol(n1, q); p2 = num2pol(n2, q); d = (p2-p1) % fp; nd = pol2num(d, q); sc = sv[nd+1]; return( sc ); } /* ---- */ printmat01(C)= { local(nr, nc, t); t = matsize(C); nr = t[1]; nc=t[2]; for (r=1, nr, for (c=1, nc, print1(" "); t = C[r,c]; if ( 0==t, print1("0") ); if ( +1==t, print1("+") ); if ( -1==t, print1("-") ); ); print(); ); } /* ---- */ matconference(q, fp, sv)= \\ Return a QxQ conference matrix. \\ q an odd prime. \\ fp an irreducible polynomial modulo q. \\ sv table of quadratic characters in GF(q^n) \\ where n is the degree of fp. { local(y, Q, C, n); n = poldegree(fp); Q=q^n+1; \\ if ( sv[2]==sv[Q-1], y=+1, y=-1 ); \\ symmetry \\ scp = getquadchar(0,1,q,n,fp); \\ scm = getquadchar(1,0,q,n,fp); \\ if ( scp==scm, y=+1, y=-1 ); \\ symmetry C = matrix(Q,Q); for (k=2, Q, C[1,k]=+1); \\ first row \\ for (k=2, Q, C[k,1]=y); \\ first column for (k=2, Q, C[k,1]=+1); \\ first column for (r=2, Q, for (c=2, Q, sc = getquadchar_n(r-2, c-2, q, fp, n); \\ sc = getquadchar_v(r-2, c-2, q, fp, sv); \\ same result C[r,c] = sc; ); ); return( C ); } /* ---- */ ----------------------------------------------------------------------------- \r conference-mat-ff.inc.gp \\ --- q an odd prime and fp a field polynomial: \\q = 13; fp = x-1; \\ simple case: GF(q) \\q = 5; fp = x^2-2; \\ GF(q^2) \\q = 3; fp = x^2+1; \\ GF(q^2) \\ symm \\q = 3; fp = x^3-x+1; \\ GF(q^3) \\ antisymm q = 53; fp = x-1; \\ simple case: GF(q) \\default(echo, 1); print("q = ", q); print("fp = ", fp); n = poldegree(fp); print(" GF(", q, "^", n,")"); fp *= Mod(1,q); if ( !polisirreducible(fp), error("fp reducible over GF(q)")); \\ check sv = quadcharvec(fp, q); \\ quadratic character print("Table of quadratic characters:"); print1(" "); printmat01(Mat(sv)); if ( 0!=sum(j=1,length(sv), sv[j]), quit() ); \\ check C=matconference(q, fp, sv); N=q^n+1; \\print("",N ,"x",N ," conference matrix C:"); printmat01(C); matsize(C) if ( C*C~ != (N-1)*matid(N), error("not a conference matrix!") ); \\C*C~ quit /* ++++++++++++++++++++++ */