Let us suppose a matrix $\mathbf{A}$ and a vector $\mathbf{b}$.
$$ A = \begin{bmatrix}a_{11} & a_{12} & a_{13}\\ a_{21} & a_{22} & a_{23}\\ a_{31} & a_{32} & a_{33} \end{bmatrix} $$
and a vector $\mathbf{b}$ $$b = \begin{bmatrix}b_{1} & b_{2} & b_{3}\end{bmatrix}$$
I want to create a matrix $\mathbf{C}$ whose lines be the lines of $\mathbf{A}$ multiplied by $\mathbf{b}$, yielding
$$ C = \begin{bmatrix}a_{11}b_1 & a_{12}b_2 & a_{13}b_3\\ a_{21}b_1 & a_{22}b_2 & a_{23}b_3\\ a_{31}b_1 & a_{32}b_2 & a_{33}b_3 \end{bmatrix} $$
For it, I am using a Do
loop, as follows
Do[C[[i, ;;]] = A[[i, ;;]]*b, {i, 1, Length@A}]
Does anyone know a built-in function able to do that?
b#&/@A
$\endgroup$A.DiagonalMatrix[b]
? $\endgroup$A.DiagonalMatrix[SparseArray[b]]
might be faster. $\endgroup$