Matrix类详解

时间:2024-05-23 22:31:07

Matrix的三参数定义原型

Matrix类详解

Matrix的三参数实例

Matrix类详解

列Vector与行Vector的常用定义

Matrix类详解

动态向量与数组的定义

Matrix类详解

Vector与Matrix构造器

Matrix类详解

Matrix类详解

Matrix类详解

矩阵与向量的系数存储操作实例

#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;
}

Matrix类详解

矩阵的comma-initialization

Matrix类详解

Matrix和Vector的设置大小操作实例

#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
  MatrixXd m(2,5);
  m.resize(4,3);
  std::cout << "The matrix m is of size "
            << m.rows() << "x" << m.cols() << std::endl;
  std::cout << "It has " << m.size() << " coefficients" << std::endl;
  VectorXd v(2);
  v.resize(5);
  std::cout << "The vector v is of size " << v.size() << std::endl;
  std::cout << "As a matrix, v is of size "
            << v.rows() << "x" << v.cols() << std::endl;
}

Matrix类详解

#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
  Matrix4d m;
  m.resize(4,4); // no operation
  std::cout << "The matrix m is of size "
            << m.rows() << "x" << m.cols() << std::endl;
}

Matrix类详解

Matrix类详解

多个可选参数的矩阵模板定义

Matrix类详解

Matrix与Vector的便捷别名定义

Matrix类详解

参考网址:http://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html