Solutions of $XA=XAX$. All matrices are real and $n \times n$. The matrix $A$ is given. I am interested in solving $XA=XAX$. In particular, I would like some characterization of matrices that satisfy this equation.
For instance, a useful characterization would be: any valid $X$ is related in some concrete way to the row space of $A$, or any valid $X$ is related in some way to the eigenvectors of $A$. I want to describe the set of admissible $X$es in terms of some known decomposition of $A$ or some property of $A$.
In case this leads to a larger set of admissible solutions, I am also interested, as a separate problem, in the complex relaxation, i.e. $A$ is real but $X$ can be complex.
I apologize if my question is very trivial - I have no experience solving matrix equations like that. In case my question is a special case of some long-established theory, please just point me to a book or an article.
 A: For invertible solutions $X$ this is a special case of the Sylvester equation, i.e. $AX=A$,  where the solutions are well known. The general case is part of the Riccati equation (with $B=-A$, $C=D=0$)
$$
XAX + XB + CX + D = 0.
$$
There are several references on the Riccati equation, see for example the book of Peter Lancaster; Leiba Rodman (1995), Algebraic Riccati equation.

A: Not a complete answer, but an attempt to get things started:

Rewrite the equation like so:
$$
XA = XAX \implies\\
XAI - XAX = 0 \implies\\
XA(I - X) = 0
$$
The question now amounts to "when is this product equal to zero?"
For one, if any of these matrices are equal to zero, then the product must be.  In particular, this gives us $X = 0$ and $X = I$ as solutions.
We could also have that the product of two consecutive matrices is zero.  This happens precisely when the columns of $I-X$ are in the nullspace of $A$, or if the columns of $A$ are in the nullspace of $X$.  These are fairly easy to characterize.
The only remaining case, then, is if no consecutive two multiply to zero, but the entire product is zero.  In particular, this means that neither $X$ nor $X-I$ can have full rank, so that both $0$ and $1$ must be eigenvalues of $X$.
We can say the following: let $N$ be the nullspace of $X$.  The columns of $A(I-X)$ are all in $N$, so that the columns of $(I-X)$ must be in $A^{-1}(N)$.
I have no idea where to go from there, but I hope that this helps.

An idea when $A$ is invertible:
note that $A$ has a square root.  Define $Y = \sqrt{A}X\sqrt{A}$, so that the above equation becomes
$$
\sqrt{A}^{-1}Y\sqrt{A}^{-1}A(I-\sqrt{A}^{-1}Y\sqrt{A}^{-1}) = 0\implies\\
\sqrt{A}^{-1}Y\sqrt{A}(I-\sqrt{A}^{-1}Y\sqrt{A}^{-1}) = 0 \implies\\
\sqrt{A}^{-1}Y(A-Y)\sqrt{A}^{-1} = 0 \implies\\
Y(A-Y) = 0
$$
Now, suppose that $A$ is diagonalizable with $A = S^{-1}DS$ for invertible $S$ and diagonalizable $D$.  We have
$$
Y(A-Y) = 0 \implies\\
S^{-1}Y(A-Y)S = 0 \implies\\
S^{-1}YS\; S^{-1}(A - Y)S = 0 \implies\\
S^{-1}YS \; (S^{-1}AS - S^{-1}Y S) = 0 \implies\\
Z(D - Z) = 0
$$
Where I've defined $Z = S^{-1}YS$.
