Arithmetic operation is not working in finite field GF(4091^2)?

I am facing problem during arithmetic operation in $GF(4091^2)$. But everything working fine in $GF(13^2)$ as

Var('x')
F.<x> = GF(13^2)
a=F.fetch_int(150)+F.fetch_int(97)
print a


How can I fix this?

edit retag close merge delete

Sort by ยป oldest newest most voted

The difference comes from different methods being available depending on the underlying finite field implementation.

The givaro implementation, available only for prime powers less than 2^16, provides a fetch_int method.

Below we illustrate this and propose a fetch_int function to provide the functionality in other cases.

Illustration

sage: p = 13
sage: F.<a> = GF(p^2)
sage: b = F.fetch_int(150)
sage: c = F.fetch_int(97)
sage: b, c, b + c
(11*a + 7, 7*a + 6, 5*a)

sage: pp = 4091
sage: FF.<aa> = GF(pp^2)
sage: FF.fetch_int(150)

sage: type(F)
<class 'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>
sage: type(FF)
<class 'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>

sage: FF.<aa> = GF(pp^2, impl='givaro')
Traceback (most recent call last)
...
ValueError: q must be < 2^16

sage: F.fetch_int??
...
Given an integer n return a finite field element in self
which equals n under the condition that :meth:gen() is set to
:meth:characteristic().
...


Define fetch_int as a function:

def fetch_int(F, n):
return FF(n.digits(base=F.characteristic()))


Then use it as follows:

sage: fetch_int(FF, 12275)
3*a + 2
sage: 3*pp + 2
sage: n
12275


Making all finite fields provide fetch_int regardless of the implementation is the object of

more

the following answer explains how to set the givaro implementation to benefit from the fetch_int method. Unfortunately, in this case, the number 4091^2 is too large for givaro implementation, so that the default implementation (pari) can not be replaced with givaro, which can only handle fields of size less than 2^16:

sage: type(GF(4091^2))
<class 'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>

sage: GF(4091^2, impl='givaro')
ValueError: q must be < 2^16

more

1

@ tmonteil What is the solution then?

( 2021-01-25 18:04:36 +0200 )edit