I have a vector $a=[a_1 \space a_2 \space a_3 \space a_4 \space a_5 \space \cdots a_n]$ and I want to generate following matrix 'A' from it.

$$A=\begin{bmatrix}a_1 & a_2 &a_3\\a_2 & a_3 & a_4\\a_3 & a_4 & a_5\\\vdots & \vdots & \vdots\\a_{n-2} & a_{n-1} & a_n\end{bmatrix}$$

I am looking for a way that can make this vector-to-matrix transformation possible. Secondly, since reverse diagonal elements are same in A, is there a special name for A. Its reverse diagonal elements are same.


It’s not going to be a particularly simple expression, but you can generate $A$ from $a$ with a sequence of matrix operations. I’ll describe the building blocks here and let you work out the specific operations for what you’re trying to do on your own.

  1. Left-multiplying a matrix by the $k$th row of the identity matrix picks out the $k$th row of that matrix. If it’s a column vector, this will pick out the $k$th element.
  2. Right-multiplying by the $k$th column of the identity picks out the $k$th column.
  3. Right-multiplying a column vector with $m$ rows by a row vector with $n$ produces an $m\times n$ matrix.

From the first point it follows that left-multiplying by a permutation of the identity will apply the same permutation to the rows of the matrix. Similarly, right-multiplying by a permutation of the identity will permute the columns.

To trim off the trailing $k$ elements of column vector, the first point tells us that we should multiply by the identity matrix with the last $k$ rows deleted.

Applying the second and third points, we can find that multiplying a column vector $v$ by the row vector $(1,0,0)$ produces the matrix $(v,0,0)$, i.e., the matrix with $v$ as its first column and zeros everywhere else.

To get you started, the matrix that rotates the elements of an $n$-element column vector down one slot would be $$ R=\pmatrix{ 0&1&0&\cdots&0 \\ 0&0&1&\cdots&0 \\ \vdots&\vdots&\vdots&\ddots&\vdots \\ 1&0&0&\cdots&0 }, $$ i.e., $I$ with its rows rotated down by one.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.