2

Let's say I'm given a vector as follows:

$$x = \begin{bmatrix}1\\2\\3\\4\end{bmatrix}$$

And I'd like to produce the following matrix: $$A = \begin{bmatrix}1 & 2\\ 3 & 4\end{bmatrix}$$

What series of operations can I induce to produce this matrix? I realize that some type of pre-multiplication would be required, or else the dimensions will not make sense.

P.S. Also a generalization to $x$ of size $n^2 \times 1$ would be helpful.

P.P.S. Is there a good resource for learning tricks to convert one form of data to another using matrix operations? It's a skill that seems like it would be useful in many practical contexts.

makansij
  • 1,643
  • 2
    For what its worth, there is no need to have every operation we ever use be defined purely with mathematical symbols. Using words here is perfectly fine to get across your meaning if need be. – JMoravitz Feb 06 '22 at 17:12
  • 1
  • 1
    In MATLAB, use reshape. – Rodrigo de Azevedo Feb 06 '22 at 17:17
  • I'm seeking mathematical operations, not coding actually. Also, if you have a chance to see my PPS in the question, I'd be interested in your opinion. – makansij Feb 06 '22 at 18:01
  • 1
    I think as you learn more matrix algebra, you'll naturally pick up techniques that could be useful for solving this type of problem. Experimentation also helps; if you have some kind of software that can do symbolic operations with matrices (I use Mathematica) then you can try various matrix products to solve this problem and see what works. – Misha Lavrov Feb 06 '22 at 18:21

2 Answers2

5

With the use of the diagonal operator $\operatorname{diag}(\mathbf x)$, which gives the diagonal matrix whose diagonal has the entries of $\mathbf x$ on it, we can write $$ \begin{bmatrix}1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1\end{bmatrix} \operatorname{diag}(a,b,c,d) \begin{bmatrix}1 & 0 \\ 0 & 1 \\ 1 & 0 \\ 0 & 1\end{bmatrix} = \begin{bmatrix}a & b \\ c & d\end{bmatrix} $$ in the $2 \times 2$ case.

In the $n \times n$ case:

  • The first matrix should be a "stretched out" version of the $n\times n$ identity matrix $I_n$: repeat each column of $I_n$, $n$ times. In terms of the Kronecker product we can write this matrix as $I_n \otimes \mathbf j^{\mathsf T}$, where $\mathbf j \in \mathbb R^n$ is the all-$1$ vector.
  • The second matrix should be $n$ copies of $I_n$ stacked on top of each other. In terms of the Kronecker product we can write this as $\mathbf j \otimes I_n$.

Without the diagonal operator, there is no single matrix multiplication that will produce the result. If we do any kind of multiplication with vector $\mathbf x$, the resulting matrix will always have column rank at most $1$.

However, as the other answer points out, we can add together $n$ different matrix multiplications, getting a solution of the form $\sum_{i=1}^n A_i \mathbf x B_i$. Written in terms of the Kronecker product, this solution is $$ \sum_{i=1}^n (I_n \otimes (\mathbf e_i)^{\mathsf T})\mathbf x (\mathbf e_i)^{\mathsf T} $$ where $\mathbf e_i$ is the $i^{\text{th}}$ standard basis vector: the $i^{\text{th}}$ column of $I_n$.

Misha Lavrov
  • 159,700
  • Thanks. Let me understand this very well and see if I have questions. – makansij Feb 06 '22 at 17:52
  • I understand the Kronecker product, and actually I thought of that myself. However in my experience I've never seen a way to convert a Kronecker product into a traditional matrix/vector operations, which is what I'm ultimately looking for. – makansij Feb 07 '22 at 16:08
  • 1
    Well, we are never applying a Kronecker product to the input vector. It is only used to simplify the setup: to define the matrices we'll use. Once we have those matrices, the procedure for any input vector is just standard matrix multiplication (and maybe addition). – Misha Lavrov Feb 07 '22 at 16:10
3

$$ \begin{pmatrix} 1 &0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix} \begin{pmatrix}a \\ b \\ c \\ d \end{pmatrix} \begin{pmatrix}1&0\end{pmatrix} = \begin{pmatrix}a&0\\b&0\end{pmatrix} $$

$$\begin{pmatrix}0&0&1&0\\ 0&0&0&1\end{pmatrix} \begin{pmatrix}a \\ b \\ c \\ d\end{pmatrix} \begin{pmatrix}0&1\end{pmatrix} = \begin{pmatrix}0&c\\0&d\end{pmatrix} $$

Add them together and you are done. I think this generalizes in an obvious way.

Blitzer
  • 2,210
  • Very helpful, thanks. I'm trying to find a way to achieve this my matrix operations alone, and no "diag" operation. I'm just trying to express it in matrix operations. – makansij Feb 07 '22 at 16:07