# Express Hadamard product as a normal matrix product

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]$

• You could write the first matrix as a column vector, and the second as a row vector. – Gerry Myerson May 29 '13 at 13:05

You can achieve the stated goal by applying the vec operation to both sides of the equation \eqalign{ A\circ B &= C \cr {\rm vec}(A)\circ {\rm vec}(B) &= {\rm vec}(C) \cr {\rm Diag}\Big({\rm vec}(A)\Big) {\rm vec}(B) &= {\rm vec}(C) \cr {\cal A}\,b &= c \cr } but why on earth would you want to do that?

Since $\,b,c\in {\mathbb R}^{N^2}$ and $\,{\cal A}\in{\mathbb R}^{N^2\times N^2}$ the operation count went from $N^2$ to $N^4$

As stated in this thread given task is impossible in general. If you try to express it in terms of being $$A \circ B = X \cdot B$$

for your case counter-example reduces to the following:

$$A=\begin{pmatrix} 0 & 1 \\ 1 & 0 \\ \end{pmatrix},\, B=\begin{pmatrix} 1 & 1 \\ 1 & 1 \\ \end{pmatrix}$$ then $$2 = rank (A) = rank(A \circ B) = rank(X \cdot B) \le rank (B) = 1$$

which is obviously incorrect. The same could be deduced for other cases of general A or B, satisfying your conditions.

I believe this still may be possible if you restrict A and B to meet rank, and maybe other conditions.

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 }