I'm solving the following for $X$ with $A,B$ singular positive semidefinite matrices.
$$AX + XA = B$$
Because $A$, $B$ are singular, standard Lyapunov solver fails
However, if I heuristically skip dividing by 0 elements in Matlab implementation of the Lyapunov solver, I get the same answer as the least squares solution to $(A\otimes I + I\otimes A)\operatorname{vec}X=\operatorname{vec}B$
Does this appear in the literature, or does someone see a way to prove that this works?
(originally posted on math.SE)