python矩阵操作

曲线拟合时要进行矩阵计算
a*b 相当于数学中的 a·b
如下面 a·d=b
d=a’·b d等于a的逆点乘b
import numpy as np
//定义一个3行3列的矩阵
a=np.mat([[9,52,381],[52,381,3017],[381,3017,25317]])
//定义一个1行3列的矩阵
b=np.mat([[13.4597],[-3.6053],[0.2676]])

a*b
matrix([[ 35.6173],
[ 133.6343],
[1025.7848]])
c=a.I //计算a的逆矩阵,c为a的逆矩阵

c
matrix([[ 0.80697144, -0.24797213, 0.01740632],
[-0.24797213, 0.12278115, -0.01089992],
[ 0.01740632, -0.01089992, 0.00107648]])

d=c*b
d
matrix([[11.76026531],
[-3.78321022],
[ 0.27386941]])

猜你喜欢

转载自blog.csdn.net/haodawei123/article/details/88229450
今日推荐