本文介绍了来自numpy.eig的特征向量不正交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题如下:使用scipy.linalg.eig获得特征向量和特征值我看到我所有的特征值都具有多重性1,但是当我运行下面的代码时,并不能确认特征向量是正交的.在这种情况下.有什么原因呢?或如何解决?

my problem is the following: using scipy.linalg.eig to get eigenvectors and eigenvalues i see that all my eigenvalues have multiplicity 1 yet when i run the code below it doesn't confirm that the eigenvectors are orthogonal as they should be in this case. any reason why this would be? or how to fix it?

import scipy as SP
import numpy as NP
from scipy import linalg
from numpy import linspace,asscalar,argsort
import cmath
import time

matA=SP.array([[-0.0001, 0., 0., 0.00001, 0., 0., 0.00002, 0.],[0., -0.0002, 0., 
  0., 0., 0., 0., 0.],[0., 0., -0.00015, 0., 0., -9.*10**-6, 
  0., -0.00005],[0.00001, 0., 0., -0.0001, 0., 0.00001, 1.*10**-6, 
  0.],[0., 0., 0., -5.*10**-6, -0.0001, 0., 0., 0.],[0., -9.*10**-6, 
  0., 0.00001, 0., -0.0002, 0., 0.00005],[0., 0., 0., 0.00002, 0., 
  0., -0.0001, 0.],[0., 0.00004, 0., 0., 0., 0.00005, 0., -0.00015]])

matB=SP.array([[0., 0., 0., 0., 0., 0., 0., 0.],[0., 0., 1.5*10**-10, 0., 0., 0., 
  0., 0.],[0., -1.5*10**-10, 0., 0., 0., 0., 0., 0.],[0., 0., 0., 0.,
   0., 0., 0., 0.],[0., 0., 0., 0., 0., 3.*10**-10, 0., 0.],[0., 0., 
  0., 0., -3.*10**-10, 0., 2.*10**-10, 0.],[0., 0., 0., 0., 
  0., -2.*10**-10, 0., 0.],[0., 0., 0., 0., 0., 0., 0., 0.]])

matdim=len(matB[0])

#coefficient matrix for original ODE
def matM(x):
    return matA+(x**2)*matB

#define sorted eigensystem function
def eigsys(x):
    evs,EVS=linalg.eig(matM(x),check_finite=False)
    absevs=abs(evs)
    idx=argsort(absevs)[::-1]
    evs=evs[idx]
    EVS=EVS[:,idx]
    return (evs,EVS)

#check for orthogonality
eigvecs=SP.transpose(eigsys(60000)[1])
for j in range(8):
    for i in range(8):
        print SP.vdot(eigvecs[i],eigvecs[j])

#show eigenvalues all have multiplicity 1
print eigsys(60000)[0]  

推荐答案

为什么它们应该正交?您的矩阵

Why should they be orthogonal? Your matrix

a=matM(60000)

远非对称,

abs(a-a.T).max() -> 2.16

abs(a).max() -> 1.08

所以我不一定会期望正交特征向量.函数matM或数据matAmatB是否有错误?

so I wouldn't necessarily expect orthogonal eigenvectors. Is it possibile that the function matM or the data matA or matB is wrong?

这篇关于来自numpy.eig的特征向量不正交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 17:18