I have huge datasets consisting of numpy arrays. Suppose A
and B
are two square matrices of size n
. A
and B
are similar if there exists a nonsingular matrix of size n
, S
, such that A=S^{-1}*B*S
.
How can I determine if two matrices are similar in sympy/numpy? If the matrices are similar, how can I find the invertible matrix S
?
The algorithm is explained here:
This answer shows how to use numpy to calculate the Jordan Normal forms. If you calculate them for
A
andB
and they are equal, thenA
andB
are similar.