# Does this operation exist? What's its name?

I need to do something like this

$$\begin{bmatrix} A \\ B \\ C \\ \end{bmatrix} \begin{bmatrix} x_1 & x_2 & \cdots & x_n \\ y_1 & y_2 & \cdots & y_n \\ z_1 & z_2 & \cdots & z_n \\ \end{bmatrix} = \begin{bmatrix} A x_1 & A x_2 & \cdots & A x_n \\ B y_1 & B y_2 & \cdots & B y_n \\ C z_1 & C z_2 & \cdots & C z_n \\ \end{bmatrix}$$

You get the idea.

I want to know if this operation already has a name, in order to see if my linear algebra library already supports it.

• Take the "n" row vectors, multiply each one by $A,B,C,...$. You can quickly implement a looping operation for it. – Billy Rubina Oct 10 '16 at 0:14
• Are the elements $A, B, C, x_1, x_2, \dots, y_1, y_2, \dots$ numbers or matrices/vectors? – JiK Oct 10 '16 at 9:39

Note that your RHS can be obtained by matrix multiplication: $$\begin{bmatrix}A&0&0\\0&B&0\\0&0&C\end{bmatrix} \begin{bmatrix} x_1&x_2&\cdots&x_n\\ y_1&y_2&\cdots&y_n\\ z_1&z_2&\cdots&z_n \end{bmatrix}.$$ The left matrix is a block matrix (in fact a block diagonal matrix). Your linear algebra library will likely have a way to construct these from an array of smaller matrices, and then you can use matrix multiplication.

• You're right, I'll try it this way. – almosnow Oct 10 '16 at 1:04
• If done naively by actually constructing the diagonal matrix as a non-sparse matrix and then multiplying, this will increase the time requirement quite significantly. – JiK Oct 10 '16 at 9:40

For the sake of another answer, you might want to take a look at Hadamard product of matricies. Basically you are doing the Hadamard product for $[A,B,C]^T$ and each column of the second matrix.

[Added:] If you know MATLAB, you might want to take a look at the Element-wise multiplication.

• $\begin{bmatrix}A&B\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=[Ax+By]$ is different from $\begin{bmatrix}Ax\\By\end{bmatrix}$. – stewbasic Oct 10 '16 at 0:16
• @stewbasic: You are right! I have just edited my answer. – Jack Oct 10 '16 at 0:19
• First time I've heard about that one. I always referred to it as element-wise multiplication. Are they the same thing? Or am I missing something else? – almosnow Oct 10 '16 at 0:24
• @almosnow: Well, MATLAB calls it "Element-wise multiplication". – Jack Oct 10 '16 at 0:26