I am looking for a method that can transform a given stochastic matrix $A \in \mathbb{R}^{n \times n}$ in a block matrix (if it exists)
$$ S A S^{-1} = \left(\begin{matrix} B & C \\ 0 & D\end{matrix}\right) $$
where $0$ is a short notation for a matrix containing only zero entries and $S \in GL(n) $.
Is there an algorithm which can determine $S$?
Edit: Is there also an algorithm which can determine $S$ for some fixed $m,l > 1 $ and $0 \in \mathbb{R}^{m \times l}$?
There are lots of ways to do that. If $B$ is allowed to be a scalar, the conceptually easiest way is to take an eigenvector $x$ of $A$ (as $A$ is stochastic, the real eigenvalue $B=1$ always exists) and extend it to an invertible matrix $S^{-1}$ whose first column is $x$. Note, however, that $SAS^{-1}$ is in general no longer stochastic.