[問題] Eigen與matlab算出來的eigenvector不同

看板C_and_CPP (C/C++)作者 (饅頭)時間13年前 (2013/01/03 19:17), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) Eigen 問題(Question): 複數3X3矩陣求eigenvalue及eigenvector,Eigen求出的3個eigenvalue與matlab一致, 但當求出的eigenvalue虛部不為0的時候,Eigen與matlab所求出的eigenvector不同。 餵入的資料(Input): 3x3矩陣A row1:11 -12 13 row2:-4 -5 6 row3:-2 -3 -4 預期的正確結果(Expected Output): matlab求出的eigenvalue: (-5.5000,5.4544) (-5.5000,-5.4544) (13.0000,0) Eigen求出的eigenvalue: (-5.5,5.45436) (-5.5,-5.45436) (13,-5.55112e-017) matlab求出的eigenvector: (0.4166,-0.2392) (0.4166,0.2392) (0.9683,0.0000) (0.7016,0.0000) (0.7016,0.0000) (-0.2391,0.0000) (0.2193,0.4784) (0.2193,-0.4784) (-0.0717,0.0000) 錯誤結果(Wrong Output): Eigen求出的eigenvector: (-0.354681,0.323992) (-0.33201,0.347186) (0.96809,-0.0221236) (-0.684885,0.152448) (-0.168056,0.681223) (-0.239035,0.00546261) (-0.317965,-0.419311) (0.411937,0.327462) (-0.0717104,0.00163878) 程式碼(Code):(請善用置底文網頁, 記得排版) 由於求出的eigenvalue及eigenvector有可能是複數, 因此利用Eigen中的ComplexEigenSolver求解 //Eigen Matrix3cd A; A(0,0)=(0,11); A(0, 1)=(0,-12); A(0, 2)=(0,13); A(1, 0)=(0,-4); A(1, 1)=(0,-5); A(1, 2)=(0,6); A(2, 0)=(0,-2); A(2, 1)=(0,-3); A(2, 2)=(0,-4); cout << "Here is the matrix A:\n" << A << endl; ComplexEigenSolver<Matrix3cd> ces; ces.compute(A); cout << "The eigenvalues of A are:" << endl << ces.eigenvalues().real() << endl; cout << "The matrix of eigenvectors, V, is:" << endl << ces.eigenvectors().real() << endl << endl; //matlab A=[11 -12 13;-4 -5 6;-2 -3 -4]; [vec_x, val_x] = eig(A); 補充說明(Supplement): 拜託各位了,實在不清楚哪裡出問題,試了好久QQ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.118.175.165 ※ 編輯: lin780222 來自: 140.118.175.165 (01/03 19:25)
文章代碼(AID): #1GvMZaAa (C_and_CPP)
文章代碼(AID): #1GvMZaAa (C_and_CPP)