################################################## ## ## ## Assumes f is defined over GF(q) ## and returns f mod an irred poly ## (irreducible in GF(q)[x]), as a element of GF(q^d) ## ## ## ## ## ################################################## HomToFF:=function(f,irred_poly) # assumed f is defined over F=GF(q) # returns f mod irred_poly (irreducible in F[x]) # as a element of F # below FF=F[x]/(f(x)) local FF,as,a,q,p; F:=DefaultField(CoefficientsOfUnivariatePolynomial(f)); FF:=GF(F,irred_poly); as:=RootsOfUPol(FF,irred_poly); a:=Minimum(as); return Value(f,a); end; #################### Examples ##################### x:=X(GF(9),"x"); f:=x^7+x^3+x+1; DefaultField(CoefficientsOfUnivariatePolynomial(f)); as:=RootsOfUPol(GF(3^7),f); a:=Minimum(as); pol:=x^2+x+1; Value(pol,a); HomToFF(pol,f);