ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 03 Mar 2022 19:24:52 +0100Declare diagonal matrix with unknown variables in GF(2).https://ask.sagemath.org/question/61381/declare-diagonal-matrix-with-unknown-variables-in-gf2/I have an equation of the form $AXB = V$, that I am trying to solve using Sage. All matrixes are in $GF(2)$, $A$ and $X$ are of size 32x32, and $B$ and $V$ column vectors of size 32.
My unknown matrix $X$ consists in zeros, except on the diagonal where I'd like to have 32 unknowns (representing each bit of a unknown 32-bits integer). I first tried to declare an array of variables like this:
```
vars_list = list(var("x_%d" % i) for i in range(32))
```
which throws me a "TypeError: x_0 is not a variable of Univariate Polynomial Ring in X over Finite Field of size 2 (using GF2X)". Looking at Sage documentation, I didn't find a way to declare them in $GF(2)$.
[Using this link](https://groups.google.com/g/sage-support/c/eRdR8xtEvtA), I tried to declare my variables like this:
```
x_1 = SR(GF(2)(1)) * var("x1")
```
which gave me this time a "TypeError: positive characteristic not allowed in symbolic computations".
How should I setup $X$ so I can solve my equation?KatoptrissThu, 03 Mar 2022 19:24:52 +0100https://ask.sagemath.org/question/61381/Generate a Matrix over a Finite Field with symbolic variableshttps://ask.sagemath.org/question/36148/generate-a-matrix-over-a-finite-field-with-symbolic-variables/ Hi everyone,
I am currently trying to generate a matrix over a finite field of 2 using symbolic variables a,b,c,and d instead of integers. The current problem I am having is that sage tries to convert these variables into integers and do not allow me to generate the matrix.
Inputting:
var('a, b, c, d')
m = matrix(GF(2), [[a,b], [e,f]])
gives me the error:
TypeError: unable to convert a to an integer
Please help, Thank you!!!benliuTue, 03 Jan 2017 16:47:45 +0100https://ask.sagemath.org/question/36148/