I gave a detailed answer to a fuzzy question by Anonymous in the link below:
https://ask.sagemath.org/question/39515/how-to-find-the-permutation-matrix-associated-with-the-similarity-transformation-in-the-following-code/
(But compared to this question, the 39515 question qualifies as a detailed exposition.)
The steps would be:
- check the characteristic polynoials, if there is no match, we can stop here.
- build the eigenvalues, sort them somehow, if there is no match, stop here.
- build the jordan decomposition and match the eigenvectors, allowing rescaling on the one side, and permutations of rows on the other side. A rough match can be done by first rescaling in the two Jordan base change matrices, so that the maximal absolute value occurs for the entry 1 in each
column. column.