I have the following equation:


$Y = [ C \bullet R ] \times X \times[C^T \bullet R^T ]$


In my textbook, this conveniently rearranges to:


$Y = [ C \times X \times C^T ] \bullet [R \bullet R^T ]$


where $\times$ denotes matrix multiplication, $\bullet$ is Hadamard (pointwise multiplication), and $R^T$ is the transposition of $R$.


How do they manage to rearrange this?


I've played around with it, and it seems that they're using the following identity:


$[ A \bullet B ] \times C = A \bullet [B \times C]$


I've tried proving it true, without success. For example, if


$D = [ A \bullet B ] \times C$ and $E = A \bullet [B \times C]$,


then


$D\_{00} = \sum\_{k=0}^m A\_{0k} B\_{0k}C\_{k0}$


$E\_{00} = A\_{00} \sum\_{k=0}^m B\_{0k}C\_{k0}$


As $D\_{00} \neq E\_{00}$, the identity is false.


Where have I gone wrong?


**EDIT**


I'm working with $4 \times 4$ matrices here.


**EDIT 2**


Here are the matrices I'm dealing with:


$
C = 
\begin{pmatrix}
1 & 1 & 1 & 1\\\\
2 & 1 & -1 & -2\\\\
1 & -1 & -1 & 1\\\\
1 & -2 & 2 & -1\\\\
\end{pmatrix}
$


$
R =
\begin{pmatrix}
\frac{1}{2} & \frac{1}{2} & \frac{1}{2} & \frac{1}{2}\\\\
\frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}}\\\\
\frac{1}{2} & \frac{1}{2} & \frac{1}{2} & \frac{1}{2}\\\\
\frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}} & \frac{1}{\sqrt{10}}\\\\
\end{pmatrix}
$


$X$ is an arbitrary matrix with integer-only values.



Rearrange equation involving matrix multiplication and Hadamard product
With these matrices the identity is true.


In order to prove it, notice that $R=DE$, where $D=\operatorname{diag}(\frac12,\frac1{\sqrt{10}},\frac12,\frac1{\sqrt{10}})$ and $E$ is the matrix of all ones. You can juggle around the diagonal factor $D$ (your proof shows that the "triple product identity" holds if $A$ is diagonal) and in particular you can reabsorb it into $C$, which is particularly convenient since now $Q=DC$ is orthogonal (that's where all those $\sqrt{10}$ come from, I guess). 
So after moving the diagonal factors the two terms become
$$
Y\_1=(Q \bullet E)\times X\times (Q^T\bullet E^T)
$$
$$
Y\_2=(Q \times X \times Q^T) \bullet (E\bullet E^T)
$$
Here all the remaining Hadamard products have $E$ as one factor and thus are trivial.


Anyway, it definitely looks like someone is overcomplicating things in that book; they could have removed those $R$s and those Hadamard products completely: you can replace every $R\bullet M$ with $D\times M$ and every $M\bullet R^T$ with $M\times D$.


