Ask Your Question
1

How to access serial number corresponding to each element in $GF(2^3)$?

asked 2019-04-10 07:33:28 +0100

I would like to access serial number corresponding to each element in $GF(2^3)$? Corresponding to each serial number, I can access the element in $G(2^3)$ as follows:

F.<x> = GF(2^3, name='x', modulus=x^3 + x^2 + 1)
for i in range(2^3):
    print i,'=>',F.fetch_int(i)

This provides :

0 => 0
1 => 1
2 => x
3 => x + 1
4 => x^2
5 => x^2 + 1
6 => x^2 + x
7 => x^2 + x + 1

I would like to get the reverse process which will provide seral number corresponding to each element in $(2^3)$, that is,

0 => 0
1 => 1
x => 2
x + 1 => 3
x^2 => 4
x^2 + 1 => 5
x^2 + x => 6
x^2 + x + 1 => 7

Is there any such way?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-04-10 10:46:21 +0100

rburing gravatar image

Note that the mapping is just taking the binary digits of the integer and using them as coefficients w.r.t. the basis $1,x,x^2,\ldots$

You can use the built-in integer_representation() method, or do the job manually:

sage: a = F.fetch_int(3)
sage: a.integer_representation()
3
sage: ZZ(list(vector(a)), base=2)
3
edit flag offensive delete link more
0

answered 2019-04-10 10:31:26 +0100

tmonteil gravatar image

What you can do is a dictionary:

sage: d = dict()
sage: for i in range(2^3):
....:     d[F.fetch_int(i)] = i

sage: d
{0: 0, 1: 1, x: 2, x + 1: 3, x^2: 4, x^2 + 1: 5, x^2 + x: 6, x^2 + x + 1: 7}
sage: d[x^2]
4
sage: d[x+1]
3
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-04-10 07:33:28 +0100

Seen: 257 times

Last updated: Apr 10 '19