在运行时设置矩阵的大小

#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
using namespace std;
int main()
{
  MatrixXd m = MatrixXd::Random(3,3);
  m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
  cout << "m =" << endl << m << endl;
  VectorXd v(3);
  v << 1, 2, 3;
  cout << "m * v =" << endl << m * v << endl;
}

在编译时设置矩阵的大小

#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
using namespace std;
int main()
{
  Matrix3d m = Matrix3d::Random();
  m = (m + Matrix3d::Constant(1.2)) * 50;
  cout << "m =" << endl << m << endl;
  Vector3d v(1,2,3);
  
  cout << "m * v =" << endl << m * v << endl;
}

运行实例结果如下所示

EIgen的Matrices和Vectors

代码详解

EIgen的Matrices和Vectors

EIgen的Matrices和Vectors

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

相关文章:

  • 2021-10-27
  • 2022-01-11
  • 2021-08-22
  • 2021-06-09
  • 2022-01-02
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2021-12-28
  • 2021-04-06
  • 2022-12-23
  • 2021-11-04
  • 2021-04-25
  • 2023-03-15
相关资源
相似解决方案