# How to index all elements of a finite field?

I would like to assign an integer corresponding to element of a finite field $GF(p^m)$, where $p^m\in[ {13^2,3^5, 131,137,139,251}]$
MWE:

 F.<x> = GF(3^5, impl='givaro')


THe elements of GF(3^5) are 0,1,2,x,x^2 etc, we would like to indexing each element such as $0-->0, 1-->1,2-->2,x-->3, x^2--4$ etc. Not only that, if I call any element for example if I call x^2 it should rerun 4 and conversely.

This process should work for the field order prime $p^m, m=1$ also. How can I do this?

edit retag close merge delete

What is the logic behind this indexing? The more usual way is to associate $f(x)$ to $f(p) \in \mathbb{N}$, so $x^2$ corresponds to $9$ and $x+1$ corresponds to $4$.

( 2021-01-20 13:32:46 +0200 )edit

Sort by ยป oldest newest most voted

If you don't have any privileged choice for the ordering of the elements, simply use list(F) to generate a list containing all elements of the finite field. For instance:

sage: F.<x> = GF(3^5, impl='givaro')
sage: LF = list(F)


The first 10 elements of the list LF are

sage: LF[:10]
[0,
x,
x^2,
x^3,
x^4,
x + 2,
x^2 + 2*x,
x^3 + 2*x^2,
x^4 + 2*x^3,
2*x^4 + x + 2]


Accessing to element of index 5:

sage: LF[5]
x + 2


The reverse operation:

sage: LF.index(x + 2)
5

more

Using the more standard indexing:

sage: F.<x> = GF(3^5, impl='givaro')
sage: F.fetch_int(4)
x + 1
sage: (x+1).integer_representation()
4

more