Bill Allombert on Sun, 11 Mar 2018 21:05:03 +0100


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

Re: Casting t_POL to t_FFELT?


On Sun, Mar 11, 2018 at 12:10:16PM +0200, Aleksandr Lenin wrote:
> Hello
> 
> I noticed that the string repreentation of the t_FFELT (finite field)
> elements is exactly identical to the polynomial.
> 
> Consider a field F_{137^2} defined by polynomial x^2 + x + 1 that is
> irreducible over F_137. Consider an element of F_{137^2} 136x + 136,
> which is a 3-rd order root of unity in this field.
> 
> When I obtain 136x + 136 as the result of FF_sqrtn() call, its type is
> t_FFELT. Then I write it to a string representation as 136x + 136. At
> this point, the information about the finite field is lost. When I try
> to read this value back read it back as gp_read_str("136x + 136"), the
> program does not recognize that this value was once an element of a
> finite field, and gives me a polynomial instead (t_POL).
> 
> I closely inspected the PARI library manual, but could not find any
> meaningful method to convert a t_POL back into t_FFELT. Is there any? I
> ended up with a weird code reconstructing a t_FFELT coefficientwise from
> the coefficients of the corresponding t_POL, but this code looks ugly
> and I think there must be a better way of doing it.

I am a bit confused about what you actually want to achieve.
Why convert t_FFELT to string and read them back ?

Generally you would do
a = ffgen(('x^2 + 'x + 1)*Mod(1,137), 'a);
to create a finite field generator a.
Now you have some element 136*a+136.

If you want to get it back using gp_read_str, you can do
gp_read_str("my(a = ffgen(('x^2 + 'x + 1)*Mod(1,137),'a));136*a+136")

In libpari, there is a function Fq_to_FF that allows to convert t_POL to
t_FFELT, see
<https://pari.math.u-bordeaux.fr/dochtml/html-stable/usersch5.html#Functions-to-handle-t_FFELT>

Cheers,
Bill.