Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unflatten a vector

I have a vector say a $9 \times 9$ vector which looks: \begin{align} \begin{pmatrix} 2x +1 \ x \ 1 \ x \ x^2 + 2x \ 2x \ x\ 2x^2 \ 0 \ \end{matrix} \end{align} These entries in $\mathbb{F}_3[x]$ . There are 9 rows in this matrix and i want to write a function which takes an $n^2 \times 1$ matrix and turns it into a $n \times n$ matrix. So, in this case, we want the function would turn the above vector into

\begin{align} \begin{bmatrix} 2x+1 & x & 1 \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & x^2+2x & 2x \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & 2x^2 & 0 \ \end{bmatrix} \end{align}

In this sage, I tried this: sage: v = Matrix(GF(3)[x], [[2x+1],[x],[1],[x],[x^2+2x],[2x],[x],[2x^2],[0]]) Then, write the following: sage: Matrix(v.base_ring(), 3, 3, v)

This gave an error: inconsistent number of rows: should be 3 but got 1

Unflatten a vector

I have a vector say a $9 \times 9$ vector which looks: \begin{align} \begin{pmatrix} 2x +1 \ x \ 1 \ x \ x^2 + 2x \ 2x \ x\ 2x^2 \ 0 \ \end{matrix} \end{align} These entries in $\mathbb{F}_3[x]$ . There are 9 rows in this matrix and i want to write a function which takes an $n^2 \times 1$ matrix and turns it into a $n \times n$ matrix. So, in this case, we want the function would turn the above vector into

\begin{align} \begin{bmatrix} 2x+1 & x & 1 \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & x^2+2x & 2x \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & 2x^2 & 0 \ \end{bmatrix} \end{align}

In this sage, I tried this: sage: v = Matrix(GF(3)[x], [[2x+1],[x],[1],[x],[x^2+2x],[2x],[x],[2x^2],[0]]) Then, write the following: sage: Matrix(v.base_ring(), 3, 3, v)

This gave an error: inconsistent number of rows: should be 3 but got 1

Unflatten a vector

I have a vector say a $9 \times 9$ vector which looks: \begin{align} \begin{pmatrix} 2x +1 \ x \ 1 \ x \ x^2 + 2x \ 2x \ x\ 2x^2 \ 0 \ \end{matrix} \end{align} These entries in $\mathbb{F}_3[x]$ . There are 9 rows in this matrix and i want to write a function which takes an $n^2 \times 1$ matrix and turns it into a $n \times n$ matrix. So, in this case, we want the function would turn the above vector into

\begin{align} \begin{bmatrix} 2x+1 & x & 1 \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & x^2+2x & 2x \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & 2x^2 & 0 \ \end{bmatrix} \end{align}

In this sage, I tried this: sage: v = Matrix(GF(3)[x], [[2x+1],[x],[1],[x],[x^2+2x],[2x],[x],[2x^2],[0]]) Then, write the following: sage: Matrix(v.base_ring(), 3, 3, v)

This gave an error: inconsistent number of rows: should be 3 but got 1

Unflatten a vector

I have a vector say a $9 \times 9$ 1$ vector which looks: \begin{align} \begin{pmatrix} looks like $$\begin{bmatrix} 2x +1 \ x \ \newline x \newline 1 \ x \ \newline x \newline x^2 + 2x \ 2x \ x\ \newline 2x \newline x \newline 2x^2 \ \newline 0 \ \end{matrix} \end{align} These \newline \end{bmatrix}$$ with entries in $\mathbb{F}_3[x]$ . $\mathbb{F}_3[x]$.

There are 9 rows in this matrix and i want to write a function which which takes an $n^2 \times 1$ matrix and turns it into a $n \times n$ matrix. matrix. So, in this case, we want the function would turn the above vector into

\begin{align} into

$$ \begin{bmatrix} 2x+1 & x & 1 \ \newline x & x^2+2x & 2x \newline x & 2x^2 & 0 \newline \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & x^2+2x & 2x \ \end{bmatrix} \end{align} \begin{align} \begin{bmatrix} x & 2x^2 & 0 \ \end{bmatrix} \end{align}$$

In this sage, Sage, I tried this: this:

sage: v = Matrix(GF(3)[x], [[2x+1],[x],[1],[x],[x^2+2x],[2x],[x],[2x^2],[0]])
[[2*x+1],[x],[1],[x],[x^2+2*x],[2*x],[x],[2*x^2],[0]])

Then, write the following: following:

sage: Matrix(v.base_ring(), 3, 3, v)

v)

This gave an error: error:

inconsistent number of rows: should be 3 but got 1

1