# What linear-algebra operation produces this vector?

Define an $N\times N$ matrix $$A = \begin{bmatrix} a_{11} & & & \\ a_{21} & a_{22} & & \\ \vdots & & \ddots & \\ a_{N1} & \dots & & a_{NN} \end{bmatrix}$$ and a vector $$x = \begin{bmatrix} x_{1} \\ x_{2} \\ \vdots \\ x_{N} \end{bmatrix}$$ What is the simplest operation that produces the following vector: $$v = \begin{bmatrix} a_{11}x_{1} \\ a_{21}x_2 + a_{22}x_2 \\ a_{31}x_3 + a_{32}x_3 + a_{33}x_3 \\ \vdots\\ a_{N1}x_N + \dots + a_{NN}x_N \end{bmatrix}$$ I.e. each row in this vector is the dot product between row $j$ in $A$ and a vector filled with $x_j$.

This is clearly not the product $A x$. I have looked at elementary matrix multiplication and it does not seem like there is a simple operation in terms of that. One way to actually achieve it is split $A$ into $N$ matrices with each of the rows of $A$, then defining $N$ vectors filled with $x_1, x_2$ respectively etc, and then doing products and adding all the resulting vectors. Clearly, that seems like an overly complicated solution.

Have I missed something simple?

• "This is clearly not the product Ax" ?? How so ? – Hippalectryon Sep 16 '15 at 19:55
• It is clearly the product $Ax$. – Calle Sep 16 '15 at 19:58
• @Calle: In the product $Ax$ the second component is $a_{21}x_1+a_{22}x_2$ and so one for the other components. – Emilio Novati Sep 16 '15 at 20:01
• Oh boy, did I mess up reading this. Sorry about that. – Calle Sep 16 '15 at 20:02

Given a matrix $$A = \begin{bmatrix} a_{11} & & & \\ a_{21} & a_{22} & & \\ \vdots & & \ddots & \\ a_{N1} & \dots & & a_{NN} \end{bmatrix}$$
$$B = \begin{bmatrix} a_{11} & & & \\ 0 & a_{21} + a_{22} & & \\ \vdots & & \ddots & \\ 0 & \dots & & \sum_{j=1}^N a_{Nj} \end{bmatrix}$$
If I well understand $a$ is a trinagular matrix, so you can define the matrix $D(A)$ as a diagonal matrix with the diagonal element $d_{ii}=\sum_j a_{ij}$ and the request vector is $D(A)x$.
Assuming the matrix $\bf A$ has all 0s on it's strictly upper triangular part, a way to build the matrix bharb proposes is to do "$\textrm{diag}(\bf A 1)$" where 1 is the column vector filled with ones of such a size that the product is defined.