Jordan标准形与sympy

使用python的符号计算库sympy来计算矩阵的标准形

import numpy as np
from sympy import Matrix
import sympy
import pprint

1.求的标准形

A = np.array([[3,1,0,0],[-4,-1,0,0],[6,2,0,-1],[-2,0,1,2]])
a = Matrix(A)
P, Ja = a.jordan_form()
pprint.pprint(Ja)
Matrix([
[1, 1, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 1],
[0, 0, 0, 1]])

1.求的标准形

B = np.array([[-1,-4,-8],[1,3,8],[0,0,-1]])
b = Matrix(B)
P,Jb = b.jordan_form()
pprint.pprint(Jb)
Matrix([
[-1, 0, 0],
[ 0, 1, 1],
[ 0, 0, 1]])

你可能感兴趣的:(Jordan标准形与sympy)