Does this operation exist? What's its name?

1k Views Asked by At

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.

2

There are 2 best solutions below

2
On BEST ANSWER

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.

4
On

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.