C++ 矩阵计算库 :Eigen库

Eigen http://eigen.tuxfamily.org/index.php?title=Main_Page   

下载http://bitbucket.org/eigen/eigen/get/3.3.4.zip  

2.91M

Eigen  3.3.4  API documentation

配置:vs2013配置Eigen库 - CSDN博客 https://blog.csdn.net/u012428169/article/details/71169546

项目-》属性-》c++常规--附加包含目录,添加解压文件夹目录即可(可重命名)。

测试代码:

// EigenTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>  
#include <Eigen/Dense>  
#include <Eigen/Dense>
using Eigen::MatrixXd;

using namespace std; 

int _tmain(int argc, _TCHAR* argv[])
{
    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 << m << std::endl;
    system("pause");
    return 0;
}
#include "stdafx.h"
#include <iostream>
#include <EigenDense>
using namespace std;
using namespace Eigen;
void main()
{
    Matrix2d a;
    a << 1, 2,
        3, 4;
    MatrixXd b(2, 2);
    b << 2, 3,
        1, 4;
    cout << "a + b =
" << a + b << endl;
    cout << "a - b =
" << a - b << endl;
    cout << "Doing a += b;" << endl;
    a += b;
    cout << "Now a =
" << a << endl;
    cout << "a^T=  " << a.transpose() << endl;
    cout << "a*b= " << a*b << endl;
    Vector3d v(1, 2, 3);
    Vector3d w(1, 0, 0);
    cout << "-v + w - v =
" << -v + w - v << endl;
    cout << v << endl;
    cout << v.transpose() << endl;
    system("pause");
}

使用:

Eigen: The Matrix class http://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html

Matrix:

Matrix<typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime>
typedef Matrix<float, 4, 4> Matrix4f;

typedef Matrix<double, Dynamic, Dynamic> MatrixXd;

Vectors:

typedef Matrix<float, 3, 1> Vector3f;
typedef Matrix<int, 1, 2> RowVector2i;

Eigen库使用 - CSDN博客 https://blog.csdn.net/wokaowokaowokao12345/article/details/53397488

Eigen:矩阵计算简单用法(一)_暗海辰_新浪博客 http://blog.sina.com.cn/s/blog_691fc8920102v02r.html

Eigen介绍及简单使用(转置、共轭、伴随、矩阵相乘、矩阵向量相乘、求解矩阵的特征值和特征向量等) - CSDN博客 https://blog.csdn.net/fengbingchun/article/details/47378515

 Eigen库使用 - CSDN博客 https://blog.csdn.net/wokaowokaowokao12345/article/details/53397488

原文地址:https://www.cnblogs.com/wxl845235800/p/8883236.html