\\% Printing routines, mostly for abjects over GF(2) \\ Author: Joerg Arndt \\ License: GPL version 3 or later \\ online at http://www.jjj.de/pari/ \\ version: 2011-January-19 (12:49) printbin(x, zc="0", cc=".")= { /* print binary, symbols for zero and one can be supplied */ local(z, t); x = 1.0*x; if ( x<0, print1("-"); x=-x); z = binary(floor(x)); for (i=1,length(z), t=z[i]; print1(if(0==t, zc, t))); x = frac(x); if (0==x, return() ); print1(cc); z = binary(x)[2]; for (i=1,length(z), t=z[i]; print1(if(0==t, zc, t))); } /* ------------ */ ppb(i, n)= { /* binary print an n-bit integer */ \\ for (j=0, n, print1( if( bitand(1<n, for(j=1,d-n,print1(".") ) ); } /* ------------ */ ppp(p, d=0)= { /* print polynomial over GF(2) */ local(n,v); if ( 0==d, d=poldegree(p) ); v = vector(d+1, i, polcoeff(p, d+1-i) ); ppv( v, d+1 ); } /* ------------ */ ppc(p)= { /* print polynomial (powers of x with non-zero coeff.) over GF(2) */ forstep (i=poldegree(p), 0, -1, if (0!=polcoeff(p,i),print1(i,","))); } /* ------------ */ ppfact(n)= { /* print factorization nicely */ local( f, len, e ); if ( 1>=n, print1(n); return() ); f = factor(n); len = length(f~); for (i=1, len, print1(f[i,1]); e = f[i,2]; if ( e>1, print1("^", e) ); if ( i