C++ 矩阵计算库 :Eigen库

本文详细介绍Eigen库的下载、安装配置步骤,并提供VS2013环境下配置Eigen的具体方法。此外,还提供了多个示例代码,展示如何利用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库 - 优快云博客 https://blog.youkuaiyun.com/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 <Eigen\Dense>
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 =\n" << a + b << endl;
    cout << "a - b =\n" << a - b << endl;
    cout << "Doing a += b;" << endl;
    a += b;
    cout << "Now a =\n" << 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 =\n" << -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库使用 - 优快云博客 https://blog.youkuaiyun.com/wokaowokaowokao12345/article/details/53397488

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

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

 Eigen库使用 - 优快云博客 https://blog.youkuaiyun.com/wokaowokaowokao12345/article/details/53397488

 

转载于:https://www.cnblogs.com/wxl845235800/p/8883236.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值