1 | initial version |
Another approach would be to build a 2-dimensional vector space.
First build the base field:
sage: FFq.<a> = GF(2^3)
sage: FFq
Finite Field in a of size 2^3
We could make a list from this:
sage: list(FFq)
[0, a, a^2, a + 1, a^2 + a, a^2 + a + 1, a^2 + 1, 1]
And we can square the field to get a vector space:
sage: FFq^2
Vector space of dimension 2 over Finite Field in a of size 2^3
This can be listed too:
sage: list(FFq^2)
[(0, 0), (a, 0), (a^2, 0), (a + 1, 0), (a^2 + a, 0), (a^2 + a + 1, 0), (a^2 + 1, 0), (1, 0), (0, a), (a, a), (a^2, a), (a + 1, a), (a^2 + a, a), (a^2 + a + 1, a), (a^2 + 1, a), (1, a), (0, a^2), (a, a^2), (a^2, a^2), (a + 1, a^2), (a^2 + a, a^2), (a^2 + a + 1, a^2), (a^2 + 1, a^2), (1, a^2), (0, a + 1), (a, a + 1), (a^2, a + 1), (a + 1, a + 1), (a^2 + a, a + 1), (a^2 + a + 1, a + 1), (a^2 + 1, a + 1), (1, a + 1), (0, a^2 + a), (a, a^2 + a), (a^2, a^2 + a), (a + 1, a^2 + a), (a^2 + a, a^2 + a), (a^2 + a + 1, a^2 + a), (a^2 + 1, a^2 + a), (1, a^2 + a), (0, a^2 + a + 1), (a, a^2 + a + 1), (a^2, a^2 + a + 1), (a + 1, a^2 + a + 1), (a^2 + a, a^2 + a + 1), (a^2 + a + 1, a^2 + a + 1), (a^2 + 1, a^2 + a + 1), (1, a^2 + a + 1), (0, a^2 + 1), (a, a^2 + 1), (a^2, a^2 + 1), (a + 1, a^2 + 1), (a^2 + a, a^2 + 1), (a^2 + a + 1, a^2 + 1), (a^2 + 1, a^2 + 1), (1, a^2 + 1), (0, 1), (a, 1), (a^2, 1), (a + 1, 1), (a^2 + a, 1), (a^2 + a + 1, 1), (a^2 + 1, 1), (1, 1)]
So now we can define the function:
sage: def f(x,y):
....: return x*y+x^2+y^3
....:
And then apply it to each coordinate pair:
sage: [f(*coords) for coords in FFq^2]
[0, a^2, a^2 + a, a^2 + 1, a, a + 1, a^2 + a + 1, 1, a + 1, a + 1, a^2 + a, 0, a^2 + a, a^2 + 1, a^2 + 1, 0, a^2 + 1, a, a^2 + 1, a^2 + a + 1, a, a^2 + a + 1, 0, 0, a^2, a^2 + a, a^2 + 1, a^2, a^2 + a + 1, a^2 + 1, a^2 + a + 1, a^2 + a, a^2 + a + 1, a^2, a^2, a + 1, a^2 + a + 1, 0, a + 1, 0, a, a + 1, a^2 + 1, a^2 + 1, a^2, a, a + 1, a^2, a^2 + a, a + 1, a, a^2 + a + 1, a^2 + a + 1, a + 1, a^2 + a, a, 1, a^2 + a + 1, a + 1, a^2 + a + 1, a^2 + 1, a^2 + 1, a + 1, 1]
Note that the *
syntax here is called argument unpacking. Basically, f(*(2,3,4)) = f(2,3,4).
To summarize, an alternative approach would be:
FFq.<a> = GF(2^3)
def f(x,y):
return x*y+x^2+y^3
[f(*coords) for coords in FFq^2]