TITLE: Express Hadamard product as a normal matrix product
QUESTION [12 upvotes]: I have $N^2$ equations which I can write as the following Hadamard product. Is there a way I can get rid of the Hadamard product and express this using usual matrix operations?
$\left[ 
\begin{matrix}
0 & a_{21} & \cdots & a_{n1} \\
a_{12} & 0  & \cdots & a_{n2} \\
 \vdots & \vdots & \ddots & \vdots\\
a_{1n} & a_{2n} &\cdots & 0\\
\end{matrix} 
\right]\bigcirc \left[\begin{matrix}
b_1 & b_2 & \cdots & b_n \\
b_1 & b_2 & \cdots & b_n \\
 \vdots & \vdots & \ddots & \vdots\\
b_1 & b_2 & \cdots & b_n\\
\end{matrix} 
\right]=\left[ 
\begin{matrix}
c_{11} & c_{21} & \cdots & c_{n1} \\
c_{12} & c_{22}  & \cdots & a_{n2} \\
 \vdots & \vdots & \ddots & \vdots\\
c_{1n} & c_{2n} &\cdots & c_{nn}\\
\end{matrix} 
\right]$

REPLY [2 votes]: Define the ${\mathbb R}^n$ vectors
$$b = \pmatrix{b_1\\b_2\\ \vdots\\b_n},\quad u = \pmatrix{1\\1\\ \vdots\\1}$$
and note that
$B=ub^T$
Then we can use the Diag() operator to write
$$\eqalign{
C &= A\circ ub^T \cr
  &= {\rm Diag}(u)\cdot A\cdot{\rm Diag}(b) \cr
  &= I\cdot A\cdot{\rm Diag}(b) \cr
  &= A\cdot{\rm Diag}(b) \cr
}$$