# Rearrange equation involving matrix multiplication and Hadamard product

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.

-
Both identities are false; more or less any $2\times 2$ example will fail. – Federico Poloni May 9 '11 at 6:47
Do you mean to say that the example in the textbook is wrong? – misha May 9 '11 at 7:26
What textbook are you using? – J. M. May 9 '11 at 7:53
As it is stated, it seems wrong. Did you maybe forget to specify that some of the matrices you're using are diagonal? – Federico Poloni May 9 '11 at 8:28
@J. M. -- it's from "The H.264 advanced video compression standard" by Richardson – misha May 9 '11 at 8:37

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$.
What is true, though, is that the diagonal entries of $(A \circ B)C^{T}$ and $(A \circ C)B^{T}$ coincide. (See Lemma 5.1.4 on p. 305 of Topics in Matrix Analysis by Horn and Johnson).