In [1]: import numpy as np
In [2]: from sympy import Matrix
In [3]: a = np.array([[5, 4, 2, 1], [0, 1, -1, -1], [-1, -1, 3, 0], [1, 1, -1, 2]])
In [4]: m = Matrix(a)
In [5]: m
Out[5]:
Matrix([
[ 5, 4, 2, 1],
[ 0, 1, -1, -1],
[-1, -1, 3, 0],
[ 1, 1, -1, 2]])
In [6]: P, J = m.jordan_form()
In [7]: J
Out[7]:
Matrix([
[1, 0, 0, 0],
[0, 2, 0, 0],
[0, 0, 4, 1],
[0, 0, 0, 4]])