i'm trying to rewrite a linear matrix equation $$ X=A_1XA_2+A_3X^TA_4+B $$
where $ X\in\mathbb{R}^{m\times n} $ and $ A_1\text{, }A_2\text{, }A_3\text{, }A_4\text{, }B $ are matrices of appropriate sizes.
So far i got to express the equation in terms of the components of $X$: $$ X_{ij}-\sum_{k=1}^{m}\sum_{l=1}^{n}\left(A_{1,ik}\cdot A_{2,lj}+A_{3,il}\cdot A_{4,kj}\right)\cdot X_{kl}=B_{ij} $$ but is there any neat way to express this linear system in terms of a coefficient matrix $C$ and unfolded vectors $x$ and $b$ $$ Cx=b $$
so that i can feed the problem to Matlab? I'd rather avoid for loops, since the matrices are quite big and the linear problem is framed inside a bigger, iterative computation.
Thanks!