Eigen是一個高層次的C ++庫,有效支持線性代數,矩陣和矢量運算,數值分析及其相關的算法。Eigen是一個開源庫,從3.1.1版本開始遵從MPL2許可。
基本介紹
- 外文名:Eigen
- 性質:開源C++模板庫
簡介
基本功能
歷史版本
實例
#include <iostream>#include <Eigen/Dense>using namespace Eigen;int main(){MatrixXd m(2,2);m(0,0) = 3;m(1,0) = 2.5;m(0,1) = -1;m(1,1) = m(1,0) + m(0,1);std::cout << "Here is the matrix m:\n" << m << std::endl;VectorXd v(2);v(0) = 4;v(1) = v(0) - 1;std::cout << "Here is the vector v:\n" << v << std::endl;}
Here is the matrix m: 3 -12.5 1.5Here is the vector v:43
#include <iostream>#include <Eigen/Dense>using namespace std;using namespace Eigen;int main(){Matrix2f A;A << 1, 2, 2, 3;cout << "Here is the matrix A:\n" << A << endl;SelfAdjointEigenSolver<Matrix2f> eigensolver(A);if (eigensolver.info() != Success) abort();cout << "The eigenvalues of A are:\n" << eigensolver.eigenvalues() << endl;cout << "Here's a matrix whose columns are eigenvectors of A \n"<< "corresponding to these eigenvalues:\n"<< eigensolver.eigenvectors() << endl;}
Here is the matrix A:1 22 3The eigenvalues of A are:-0.236 4.24Here's a matrix whose columns are eigenvectors of A corresponding to these eigenvalues:-0.851 -0.526 0.526 -0.851