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,
Anything symbolic is in the symbolic ring SR, finite field elements are in
GF(2). You can wrap finite field elements in the symbolic ring if you want
to do symbolic computations with finite field coefficients:
sage: SR(GF(5)(3)) * x
3*x
sage: _ * 2
x
though the symbolic elemnts still don't
I'm not sure I understand fully what you're saying. I did
m1 = SR(GF(2)(1)) * var(m1)
m2 = SR(GF(2)(1)) * var(m2)
m3 = SR(GF(2)(1)) * var(m3)
m4 = SR(GF(2)(1)) * var(m4)
but the Matrix definition
q = Matrix(GF(2), [
[m1, m2],
[m3, m4],
])
still results in the same error: unable to
Your matrix is over GF(2) not over the symbolic ring SR:
sage: m1 = SR(GF(2)(1)) * var(m1)
sage: m2 = SR(GF(2)(1)) * var(m2)
sage: m3 = SR(GF(2)(1)) * var(m3)
sage: m4 = SR(GF(2)(1)) * var(m4)
sage: q = Matrix(SR, [
[m1, m2],
[m3, m4],
])
sage: q^2
[ m1^2 + m2*m3 m1*m2 + m2*m4]
[m1*m3 +
Hello,
I want to do some symbolic operations (matrix/vector) in the GF(2).
Here is an alternative approach (assuming all your expressions are
polynomials in m1, m2, m3 and m4):
sage: R.m1,m2,m3,m4 = PolynomialRing(GF(2))
sage: q = Matrix(R, [[m1, m2], [m3, m4]])
sage: q
[m1 m2]
[m3 m4]
sage: