# Matrix equation involving a Hadamard product?

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_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.

• Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or closed. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers. Apr 17, 2023 at 12:50

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).$$
• Now I want to find solutions for matrices $A$ and $B$ in the following equations: $$\left\{ \begin{matrix} (I\otimes A^T) \operatorname{vec}(M_1) = (I \otimes A^T)\operatorname{diag}(\operatorname{vec}(M_2)) (I \otimes A)\operatorname{vec}(B) \\ (B\otimes I) \operatorname{vec}(M_1) = (B\otimes I)\operatorname{diag}(\operatorname{vec}(M_2)) (B^T\otimes I)\operatorname{vec}(A) \end{matrix} \right..$$ However, I'm stuck on this step. We can get $\operatorname{vec}(B)$ in the first equation, but how to transform it into $(B\otimes I)$? Apr 21, 2023 at 16:40