概述
http://eigen.tuxfamily.org/dox/classEigen_1_1EigenSolver.html
Eigen中的矩阵类型一般都是用类似MatrixXXX来表示,可以根据该名字来判断其数据类型,比如说’d’代表double并不是用来表示整数的,;‘f’代表float; ‘i’代表整数;‘c’代表complex,即复数;’d’表示dynamic,即表示矩阵中有些维数是不确定的,动态的……举例子比如说:Matrix2cd,表示的是2*2维的,其每个元素都是复数,复数的实部和虚部都为double类型。
| inline |
Constructor; computes eigendecomposition of given matrix.
-
Parameters
-
[in] matrix Square matrix whose eigendecomposition is to be computed. [in] computeEigenvectors If true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed.
This constructor calls compute() to compute the eigenvalues and eigenvectors.
Example:
MatrixXd A =
MatrixXd::Random(6,6);
cout <<
"Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
EigenSolver<MatrixXd> es(A);
cout <<
"The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
cout <<
"The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
complex<double> lambda = es.eigenvalues()[0];
cout <<
"Consider the first eigenvalue, lambda = " << lambda << endl;
VectorXcd v = es.eigenvectors().col(0);
cout <<
"If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
cout <<
"... and A * v = " << endl << A.cast<complex<double> >() * v << endl << endl;
MatrixXcd D = es.eigenvalues().asDiagonal();
MatrixXcd V = es.eigenvectors();
cout <<
"Finally, V * D * V^(-1) = " << endl << V * D * V.inverse() << endl;
Output:
Here is a random 6x6 matrix, A: 0.68 -0.33 -0.27 -0.717 -0.687 0.0259 -0.211 0.536 0.0268 0.214 -0.198 0.678 0.566 -0.444 0.904 -0.967 -0.74 0.225 0.597 0.108 0.832 -0.514 -0.782 -0.408 0.823 -0.0452 0.271 -0.726 0.998 0.275 -0.605 0.258 0.435 0.608 -0.563 0.0486 The eigenvalues of A are: (0.049,1.06) (0.049,-1.06) (0.967,0) (0.353,0) (0.618,0.129) (0.618,-0.129) The matrix of eigenvectors, V, is: (-0.292,-0.454) (-0.292,0.454) (-0.0607,0) (-0.733,0) (0.59,-0.122) (0.59,0.122) (0.134,-0.104) (0.134,0.104) (-0.799,0) (0.136,0) (0.335,0.368) (0.335,-0.368) (-0.422,-0.18) (-0.422,0.18) (0.192,0) (0.0563,0) (-0.335,-0.143) (-0.335,0.143) (-0.589,0.0274) (-0.589,-0.0274) (-0.0788,0) (-0.627,0) (0.322,-0.156) (0.322,0.156) (-0.248,0.132) (-0.248,-0.132) (0.401,0) (0.218,0) (-0.335,-0.076) (-0.335,0.076) (0.105,0.18) (0.105,-0.18) (-0.392,0) (-0.00564,0) (-0.0324,0.103) (-0.0324,-0.103) Consider the first eigenvalue, lambda = (0.049,1.06) If v is the corresponding eigenvector, then lambda * v = (0.466,-0.331) (0.117,0.137) (0.17,-0.456) (-0.0578,-0.622) (-0.152,-0.256) (-0.186,0.12) ... and A * v = (0.466,-0.331) (0.117,0.137) (0.17,-0.456) (-0.0578,-0.622) (-0.152,-0.256) (-0.186,0.12) Finally, V * D * V^(-1) = (0.68,1.9e-16) (-0.33,4.82e-17) (-0.27,-2.37e-16) (-0.717,1.6e-16) (-0.687,-2.2e-16) (0.0259,2.72e-16) (-0.211,2.22e-16) (0.536,4.16e-17) (0.0268,-2.98e-16) (0.214,0) (-0.198,6.66e-16) (0.678,6.66e-16) (0.566,1.22e-15) (-0.444,1.11e-16) (0.904,-4.61e-16) (-0.967,-3.61e-16) (-0.74,7.22e-16) (0.225,8.88e-16) (0.597,1.6e-15) (0.108,1.84e-16) (0.832,-5.6e-16) (-0.514,-4.44e-16) (-0.782,1.28e-15) (-0.408,9.44e-16) (0.823,-8.33e-16) (-0.0452,-2.71e-16) (0.271,5.53e-16) (-0.726,7.77e-16) (0.998,-2.33e-15) (0.275,-1.67e-15) (-0.605,1.03e-15) (0.258,1.91e-16) (0.435,-4.6e-16) (0.608,-6.38e-16) (-0.563,1.69e-15) (0.0486,1.25e-15)
最后
以上就是务实寒风为你收集整理的Eigen库 求解特征值特征向量的全部内容,希望文章能够帮你解决Eigen库 求解特征值特征向量所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复