python实现用改进的乘幂法求方阵的按模最大特征值和特征向量
先放代码,有时间补内容import numpy as npdef MaxFabs(v): m,n = v.shape assert n == 1 ans = 0 for i in range(m): if ans < np.fabs(v[i]): ans = v[i] maxn = i return ansdef PowerMethod(a,v,g): m,n = a.shape