\\ Compute arithmetic tables in finite field arithmetic with Pari/GP.
\\ Copyright 2018 Ken Takusagawa
\\ This program is free software: you can redistribute it and/or modify
\\ it under the terms of the GNU General Public License as published by
\\ the Free Software Foundation, either version 3 of the License, or (at
\\ your option) any later version.
\\ This program is distributed in the hope that it will be useful, but
\\ WITHOUT ANY WARRANTY; without even the implied warranty of
\\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\\ General Public License for more details.
\\ You should have received a copy of the GNU General Public License
\\ along with this program. If not, see .
\\ Example usage:
\\ go(2,3) prints out tables for F_{2^3}=F_8.
redpoly=ffinit(3,2);
gen=Mod(Mod(1,3)*x,redpoly);
mffdisp(x,digits)=for(j=1,digits,i=digits-j;print1(lift(polcoeff(lift(x),i))));
ppmdisp(x,digits)=for(j=1,digits,i=digits-j;print1(" ",lift(polcoeff(lift(x),i))));print();
allr(p,n)=local(l,val,dig,s);kill(x);l=listcreate();for(i=0,p^n-1,val=i;s=Mod(0,ffinit(p,n));for(j=1,n,dig=val%p;val=(val-dig)/p;s=s+Mod(dig,p)*x^(j-1));listput(l,s));l;
texttable(l,digits)=for(i=1,length(l),for(j=1,length(l),print1(" ");mffdisp(l[i]*l[j],digits));print());
htable(l,digits)=print1("
* | ");for(i=1,length(l),print1("");mffdisp(l[i],digits);print1(" | "));print("
");for(i=1,length(l),print1("");mffdisp(l[i],digits);print1(" | ");for(j=1,length(l),print1("");mffdisp(l[i]*l[j],digits);print1(" | "));print("
"));
\\ handle html formatting later
ltable(l,digits)=print1("* ");for(i=1,length(l),print1(" ");mffdisp(l[i],digits));print();for(i=1,length(l),mffdisp(l[i],digits);for(j=1,length(l),print1(" ");mffdisp(l[i]*l[j],digits));print(" "));
\\ltable(allr(2,2),2)
ppmtable(l)=for(i=1,length(l),for(j=1,length(l),ppmdisp(l[i]*l[j],3)));
powtable(l,digits)=for(i=1,length(l),mffdisp(l[i],digits);for(j=0,length(l),print1(" ");mffdisp(l[i]^j,digits));print());
invtable(l,digits)=for(i=2,length(l),print1(" ");mffdisp(l[i],digits));print();for(i=2,length(l),print1(" ");mffdisp(l[i]^-1,digits));print();
go(p,n)=local(r);r=allr(p,n);print("length ",length(r));print(ffinit(p,n));ltable(r,n);print("pow");powtable(r,n);print("inv");invtable(r,n);