2

Consider the matrix $A$ and column vector $b$ where,

$A = \begin{bmatrix}1 & 2\\3 & 4\end{bmatrix}$ and $b = \begin{bmatrix}1\\3\end{bmatrix}$

In the R statistics software, the the code A*b performs element-wise multiplication of the columns in $A$ with the column vector $b$ returning a matrix with the same dimensions as $A$, i.e.

$A*b = \begin{bmatrix}1 & 2\\3 & 4\end{bmatrix} * \begin{bmatrix}1\\3\end{bmatrix} = \begin{bmatrix}1\times1 & 2\times1\\3\times3 & 4\times3\end{bmatrix}=\begin{bmatrix}1 & 2\\9 & 12\end{bmatrix}$

Is there a name for this operation? Can this operation be expressed using common matrix notation?

CFD
  • 223

2 Answers2

3

It can be written as

$A\circ(bu)$ where $u$ is row vector of ones and $\circ$ is the hadamard product

Asinomás
  • 105,651
2

Let us call $\text{Diag}(b)$ the diagonal matrix, the diagonal of which is $b$

$$ \text{Diag} (b) = \begin{bmatrix} 1 & 0\\0 & 3\end{bmatrix} $$

Then

$$ \text{Diag} (b) \times A = \begin{bmatrix} 1 & 2\\9 & 12\end{bmatrix} $$

Damien
  • 1,762