Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

How to access serial number corresponding to each element in GF(23)?

asked 6 years ago

I would like to access serial number corresponding to each element in GF(23)? Corresponding to each serial number, I can access the element in G(23) 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 (23), 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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 6 years ago

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,x2,

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
Preview: (hide)
link
0

answered 6 years ago

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
Preview: (hide)
link

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: 6 years ago

Seen: 269 times

Last updated: Apr 10 '19