Heya!
I want to do something relatively easy in Sage but can't figure out how. Hopefully you can help me. I want to do some symbolic operations (matrix/vector) in the GF(2). Let's start out with real numbers first:
(m1, m2, m3, m4) = (var("m1"), var("m2"), var("m3"), var("m4"))
q = Matrix([
[m1, m2],
[m3, m4],
])
print(q)
print(q * q)
Works pefectly:
[m1 m2]
[m3 m4]
[ m1^2 + m2*m3 m1*m2 + m2*m4]
[m1*m3 + m3*m4 m2*m3 + m4^2]
But when I try the same thing in GF(2) by definiing
q = Matrix(GF(2), [
[m1, m2],
[m3, m4],
])
I get:
[...]
File "parent.pyx", line 1069, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:8546)
File "coerce_maps.pyx", line 156, in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:4930)
File "expression.pyx", line 857, in sage.symbolic.expression.Expression._integer_ (sage/symbolic/expression.cpp:5877)
TypeError: unable to convert x (=m1) to an integer
However, the matrix definition seems to be okay, when I do
q = Matrix(GF(2), [
[1, 1 ],
[1, 0],
])
print(q * q)
I get
[0 1]
[1 1]
which is what I'd expect. Why does it not work with variables when working in GF(2) and how can I get this to work the way I want it to?
Thank you so much,
Regards,
Kim