Bill Allombert on Fri, 26 Mar 2004 18:58:30 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Magma <-> Pari/GP syntax ???

On Fri, Mar 26, 2004 at 08:23:28AM -0800, Richard Graham wrote:
> Greetings,
> I searched the archives and looked at the documentation,
> however I'm a Pari/GP newbie and not a mathematician.
> Can Pari/GP perform the following Magma code?
> ___________________________________________________________
> F:=GF(2);
> P<x>:=PolynomialRing(F);

First a _very_ important warning:
I have changed to use a and x as variables, in that order, instead of x
and X.  Don't change that.  See below how to use different names.

> g:=x^5+x^2+1;


> IsPrimitive(g);

I am not sure what do IsPrimitive.

> EF<alpha>:=ext<F|g>;


> EP<X>:=PolynomialRing(EF);
> G:=X^2 + alpha^2*X + alpha^16;

G=x^2 + alpha^2*x + alpha^16;

> (X^16 + alpha^2*X^15 + alpha^16*X^14 + X^5 + alpha^2*X^4 + alpha^16*X^3
> + X^2 + alpha^2*X + alpha^16) mod (G);

(x^16 + alpha^2*x^15 + alpha^16*x^14 + x^5 + alpha^2*x^4 + alpha^16*x^3 + x^2 + alpha^2*x + alpha^16) % G

> Is there a primer/tutorial for doing calculations in GF(2^n)
> for Pari/GP?

GP is not well suited for GF(2^n). It can do it
sure, but it is not optimized at all. libpari is slightly better
but far from perfect.

Basically you build a generator alpha of GF(2^n) by using:


and then you can compute with it normally.
==How to use other variable names:===

If you want to use 'foo' for 'a' and 'bar' for 'x' as variable, issue
at the start of your GP session. 'x' is not a valid choice for
'foo' here.
The reason being variables need to be ordered so that GP compute
in GF(2)[bar]/(P(bar))[foo] and not in G(2)(foo)[bar]/(P(bar)).

variable priority is attributed as follow:
1) x has always the lowest priority
2) new variable are affected the lowest priority remaining
in a first-come first-served basis.

so in effect
declare that bar has lower priority than foo.

(the choice of 'a' above was completly arbitrary)