# Is there a transformation matrix A that multiplied to a B adds each two rows of B?

I have a $m \times n$ matrix $B$ and want to the $\frac{m}{2} \times n$ matrix $B'$ where each two rows of $B$ are added. Is there a $\frac{m}{2} \times m$ matrix $A$ such that $AB=B'$, and what are clever ways to find such tranformation matrices?

-

Yes there is

$$\left(\begin{array}{ccccccc} 1 & 1 & 0 & 0 & 0 & \dots & 0 \\ 0 & 0 & 1 & 1 & 0 & \dots & 0 \\ \vdots & & & & \ddots & & \vdots \\ 0 & 0 & 0 & 0 & \dots & 1 & 1\end{array}\right)$$

This is easy to construct because the basic idea of a row vector multiplied by a matrix is you take a linear combination of the rows. If you have a column of row vectors, you just put the resultant answers into a column.

Edit: Here's another way of thinking about it:

Let $e_i^T \in \mathbb{R}^{1 \times n}$ be the $i^{th}$ standard basis row vector $(0, 0, \dots, 1, \dots, 0, 0)$ where the $1$ is in the $i^{th}$ position.

If $A$ is an $m \times n$ matrix, consider the term:$$e_i^T A$$ If you carry out the calculation, you see this is just the $i^{th}$ row of $A$, let's call this $A_i$. If we then take linear combinations of this equation, we have: $$(k_1 e_1^T + k_2 e_2^T A + \dots + k_n e_n^T) A = k_1 A_1 + k_2 A_2 + \dots + k_n A_n$$

This means any row vector multiplied by $A$, the quantity $(k_1, k_2, \dots, k_n) A$ is simply a linear combination of the rows of $A$.

In particular, $$(1, 1, 0, 0, 0, \dots, 0) A$$ is the sum of the first two rows of $A$. Similarly, $$(0, 0, 1, 1, 0, \dots, 0) A$$ is the sum of the third and fourth rows of $A$.

Now what happens if we start stacking these row vectors on top of each other and then multiplying by $A$?

$$\left(\begin{array}{c} \mathbf{r_1}^T \\ \mathbf{r_2}^T \\ \vdots \\ \mathbf{r_k}^T \end{array}\right) A = \left(\begin{array}{c} \mathbf{r_1}^T A \\ \mathbf{r_2}^T A \\ \vdots \\ \mathbf{r_k}^T A \end{array}\right)$$

This means that the answer you get is simply the result of stacking the answers of applying each of the single row vectors multiplying by $A$. That should be enough to answer your question but I will include some more info if you're interested.

First of all, row vectors take linear combinations of the matrices rows. Column vectors take linear combinations of the matrices columns.

Applying this knowledge can make certain calculations significantly easier:

What is:

$$\left(\begin{array}{cc} 2 & 3 \\ -1 & 4\end{array}\right) \left(\begin{array}{cc} 0 & 1 \\ 1 & 1\end{array}\right)$$

The first column of the answer will simply be the second column of the first matrix. The second column of the answer will just be the sum of the two columns of the first matrix.

$$\left(\begin{array}{cc} 2 & 3 \\ -1 & 4\end{array}\right) \left(\begin{array}{cc} 0 & 1 \\ 1 & 1\end{array}\right) = \left(\begin{array}{cc} 3 & 5 \\ 4 & 3\end{array}\right)$$

What is:

$$\left(\begin{array}{cc} 1 & 0 \\ -1 & 1\end{array}\right) \left(\begin{array}{cc} 4 & 2 \\ 5 & 1\end{array}\right)$$

The answer will have the same first row of the right hand matrix, and its second row will be the second row subtract the first row of the right hand matrix.

$$\left(\begin{array}{cc} 1 & 0 \\ -1 & 1\end{array}\right) \left(\begin{array}{cc} 4 & 2 \\ 5 & 1\end{array}\right) = \left(\begin{array}{cc} 4 & 2 \\ 1 & -1\end{array}\right)$$

-
Thanks a lot, great answer – Copi Mar 6 '13 at 11:20

Hint:

If $v=\left(0,0,\ldots,0,1,0,\ldots,0,1,0,\ldots,0\right)\in\mathbb R^{1\times m}$ where the $1$ are in the $i$ and $j$ position then $vB$ is the vector we obtain by adding the $i^{th}$ and $j^{th}$ row of $B$.

Now we want a matrix $A=\begin{pmatrix}v_1\\v_2\\\vdots\\v_{\frac m2}\end{pmatrix}$ ($v_i$ are the rows of $A$) such that $$AB=\begin{pmatrix}v_1B\\v_2B\\\vdots\\v_{\frac m2}B\end{pmatrix}=\ldots$$

-