Matrix equation involving a Hadamard product

hadamard-productlinear algebramatrix equations

I'm trying to find out the solution to B for the following matrix equation:
$$
A^TM_1=A^T(AB\odot M_2)
$$

where $A\in \mathbb{R}^{m\times n}$, $B\in \mathbb{R}^{n\times m}$, and $n<m$.
$M_1, M_2\in \mathbb{R}^{m\times m}$ are not invertible and their diagonal entries equal to $0$, $\odot$ represents the elementwise/Hadamard product.

Best Answer

In this case, there's an efficient approach we can take in which we regard the columns of $B$ separately. Let $M^{(i)}$ denote the $i$th column of $M$; we have $$ [A^T(AB\odot M_2)]^{(i)} = \\ A^T(AB \odot M_2)^{(i)} = \\ A^T([AB]^{(i)} \odot M_2^{(i)}) = \\ A^T(AB^{(i)} \odot M_2^{(i)}) = \\ A^T \operatorname{diag}(M_2^{(i)})AB^{(i)}. $$ We can thus solve for the $i$th column of $B$ (for $i = 1,\dots,m$) by solving the equation $$ [A^T \operatorname{diag}(M_2^{(i)})A]B^{(i)} = [A^TM_1]^{(i)}. $$ For a vector $x = (x_1,\dots,x_n)$, $\operatorname{diag}(x)$ denotes the diagonal matrix $$ \operatorname{diag}(x) = \pmatrix{x_1\\&\ddots \\ && x_n}, $$ where the "blank" entries are zeroes.


More generally, you could use vectorization in order to write out matrix equations like this as a linear system over a vector with $m\cdot n $ entries. In particular, if we take vec to denote column-major vectorization, we have $$ \operatorname{vec}(A^T(AB\odot M_2)) = \\ (I \otimes A^T)\operatorname{vec}(AB\odot M_2) = \\ (I \otimes A^T)\operatorname{diag}(\operatorname{vec}(M_2)) \operatorname{vec}(AB) = \\ (I \otimes A^T)\operatorname{diag}(\operatorname{vec}(M_2)) (I \otimes A)\operatorname{vec}(B). $$ So, the vectorized form of $B$ can be solved for using the equation $$ (I \otimes A^T)\operatorname{diag}(\operatorname{vec}(M_2)) (I \otimes A)\operatorname{vec}(B) = \operatorname{vec}(A^TM_1). $$

Related Question