Solving the matrix equation How can I solve the matrix equation of the form
$$
\mathbf{SXK} + \mathbf{X} = \mathbf{Y}
$$
Here $\mathbf{S}$ and $\mathbf{K}$ are symmetric matrices, in addition $\mathbf{K}$ is a sparse symmetric matrix.  $X$ is the variable. Though $\mathbf{S}$ and $\mathbf{K}$ are symmetric, it is not invertible in general and $\mathbf{X}$ is not symmetric. Is it possible to find a closed-form solution for $\mathbf{X}$ ?. Is there any relevant literature study about solving such equations ?
 A: The symmetry of $S$ and $K$ allow for you to write them as diagonalized matrices. Suppose we have
$$S=PDP^{-1},\;\;\;\;K=QCQ^{-1}$$
for diagonal matrices $C$ and $D$. We also may write $X$ as 
$$X=PP^{-1}XQQ^{-1}$$
which gives us
$$PDP^{-1}XQCQ^{-1}+PP^{-1}XQQ^{-1}=Y$$
Letting $Z=P^{-1}XQ$, we have
$$PDZCQ^{-1}+PQ^{-1}Z=Y$$
or
$$DZC+Z=P^{-1}YQ$$
The matrix $DZC$ is the matrix $Z$ with rows scaled by elements of $D$ and columns scaled by elements of $C$. This leads to a system of equations that look like
$$[D]_i[Z]_{ij}[C]_j+[Z]_{ij}=[P^{-1}YQ]_{ij}$$
The existence and uniqueness of a solution can now be seen, as it is dependent upon the value of $[D]_i[C]_j$. Provided that this is not $-1$, then
$$[Z]_{ij}=\frac{[P^{-1}YQ]_{ij}}{[D]_i[C]_j+1}$$
The matrix $X$ may the be recovered by $X=PZQ^{-1}$.
A: This equation is similar to the discrete Lyapunov equation and can be solved in a similar way. Using the equality 
$$ \operatorname{vec}(ABC)=(C^{T} \otimes A)\operatorname{vec}(B) $$
one obtains the system of linear equations
$$
\left( K^T \otimes S+I_{n^2} \right)\operatorname{vec}(X)=\operatorname{vec}(Y).
$$
