Eigen線性算術(shù)的 C++ 模板庫
Eigen 是一個(gè)線性算術(shù)的C++模板庫,包括:vectors, matrices, 以及相關(guān)算法。功能強(qiáng)大、快速、優(yōu)雅以及支持多平臺(tái)。
示例代碼:
#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Matrix2d a;
a << 1, 2,
3, 4;
MatrixXd b(2,2);
b << 2, 3,
1, 4;
std::cout << "a + b =\n" << a + b << std::endl;
std::cout << "a - b =\n" << a - b << std::endl;
std::cout << "Doing a += b;" << std::endl;
a += b;
std::cout << "Now a =\n" << a << std::endl;
Vector3d v(1,2,3);
Vector3d w(1,0,0);
std::cout << "-v + w - v =\n" << -v + w - v << std::endl;
}
評論
圖片
表情
