Ask Your Question

Revision history [back]

Convert the vector to a tuple.

Here is an example.

Define the polynomial ring:

sage: R.<x> = PolynomialRing(GF(2))

Using a tuple works:

sage: u = (0, 0, 1, 1, 1)
sage: R(u)
x^4 + x^3 + x^2

Using a vector does not work:

sage: v = vector((0, 0, 1, 1, 1))
sage: R(v)
Traceback (most recent call last):
...
TypeError: unable to convert (0, 0, 1, 1, 1) to a rational

Turning the vector into a tuple does the trick:

sage: R(tuple(v))
x^4 + x^3 + x^2