Question

I am using the CAS SAGE. I have a vector v belonging GF(2). How I will be able to find the integer representation of this vector? Any example please?

 aux = random_matrix(GF(2), n,2*n)
 for i in range(2*n):
     x = ZZ(list(aux[:,i]), base=2)
Was it helpful?

Solution

Assuming I understand you, you have a vector living in a space over GF(2):

sage: V = VectorSpace(GF(2), 5)
sage: V
Vector space of dimension 5 over Finite Field of size 2
sage: v = V.random_element()
sage: v
(0, 1, 0, 1, 1)

There are lots of ways to convert this to an Integer, and lots of equally valid representations. One natural one would be:

sage: i = ZZ(list(v), base=2)
sage: i
26
sage: parent(i)
Integer Ring
sage: i.digits(2)
[0, 1, 0, 1, 1]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top