Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
1

Using vector with variables over a finite field

asked 1 year ago

Saar gravatar image

updated 1 year ago

FrédéricC gravatar image

I'm trying to write a code that does some manipulation on a vector of variables and then checks something for each of their assignments. The manipulation includes multiplying the vector by a matrix. Everything is over GF(2) so for n variables there are 2n options which is fine with me.

I've seen that the following code works for declaring a vector with variables

x, y, z = var('x y z')

vector([x, y, z])

My problem is that these variables aren't from GF(2), and so when I try multiplying it by a matrix which is indeed declared over GF(2), it throws an exception.

The specific exception is TypeError: positive characteristic not allowed in symbolic computations.

Is there any workaround for still doing the manipulation?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 1 year ago

rburing gravatar image

Instead of symbolic variables you can use the generators of a polynomial ring:

sage: R.<x,y,z> = PolynomialRing(GF(2))
sage: v = vector([x, y, z])
sage: M = matrix(GF(2), [[0, 1, 0], [0, 0, 1], [1, 0, 0]])
sage: M*v
(y, z, x)

Like symbolic expressions, polynomials allow substitution/evaluation with the subs method.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 1 year ago

Seen: 257 times

Last updated: Aug 11 '23