I want to extract the polynomial over GF(2), whose coefficients correspond to a certain vector over GF(2). However, I get an error:
TypeError: unable to convert (0, 0, 1, 1, 1) to a rational
when doing so. Here's the relevant section of code:
R.<x> = PolynomialRing(GF(2))
print(A)
v = vector(A.basis()[i]);
print(v.category())
print(v)
print(R(v))
I get the following:
Vector space of degree 5 and dimension 2 over Finite Field of size 2
Basis matrix:
[1 0 0 0 0]
[0 0 1 1 1]
raise TypeError("error coercing to finite field")
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.IntegerMod (build/cythonized/sage/rings/finite_rings/integer_mod.c:4878)() 200 return a 201 t = modulus.element_class() --> 202 return t(parent, value) 203 204
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.IntegerMod_abstract.__init__ (build/cythonized/sage/rings/finite_rings/integer_mod.c:6408)() 387 value = py_scalar_to_element(value) 388 if isinstance(value, Element) and value.parent().is_exact(): --> 389 value = sage.rings.rational_field.QQ(value) 390 z = value % self.__modulus.sageInteger 391 else:
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9450)() 895 if mor is not None: 896 if no_extra_args: --> 897 return mor._call_(x) 898 else: 899 return mor._call_with_args(x, args, kwds)
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4734)() 159 print(type(C), C) 160 print(type(C._element_constructor), C._element_constructor) --> 161 raise 162 163 cpdef Element _call_with_args(self, x, args=(), kwds={}):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4626)() 154 cdef Parent C = self._codomain 155 try: --> 156 return C._element_constructor(x) 157 except Exception: 158 if print_warnings:
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/rings/rational.pyx in sage.rings.rational.Rational.__init__ (build/cythonized/sage/rings/rational.cpp:6531)() 536 """ 537 if x is not None: --> 538 self.__set_value(x, base) 539 540 def __reduce__(self):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/rings/rational.pyx in sage.rings.rational.Rational.__set_value (build/cythonized/sage/rings/rational.cpp:8675)() 689 690 else: --> 691 raise TypeError("unable to convert {!r} to a rational".format(x)) 692 693 cdef void set_from_mpq(Rational self, mpq_t value):
TypeError: unable to convert (0, 0, 1, 1, 1) to a rational