Eigen矩阵运算

没有接触过Eigen的请http://www.cnblogs.com/salan668/p/3643321.html

下面简单介绍实现矩阵的乘法,其它类似

#include <Eigen/Dense>

#include<iostream>
using namespace std ;
using namespace Eigen;
int main()
{
MatrixXf m(1,2);//
MatrixXf n(2,2); //2行2列
MatrixXf result(1,1);//结果
double result1;
m<<1,2;
n<<5,6,7,8;
result=m*n*m.transpose();//m转置
result1=result.sum();//计算后得到一个数,不然还是矩阵
cout<<"--Matrix m*n"<<endl <<result<<endl ;
cout<<"--sum(Matrix m*n)"<<endl <<result1<<endl ;
system("pause");
}

你可能感兴趣的:(Eigen矩阵运算)