pBook‎ > ‎Matrix C++ Lib‎ > ‎

Eigen

posted Oct 3, 2014, 3:12 AM by Javad Taghia   [ updated Oct 3, 2014, 3:12 AM ]
1. Download and extract the lib
2. Put it in Solution folder of your VS project
3. Like the figure:

3. Call it in your main file like:

/*
#include <iostream>
#include "..\EigenSource\Eigen\Dense"
using Eigen::MatrixXd;
int main()
{
  MatrixXd m(2,2); // defines a matrix 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;
}
*/

/*
#include <iostream>
#include "..\EigenSource\Eigen\Dense" 
using namespace Eigen;
using namespace std;
int main()
{
  MatrixXd m = MatrixXd::Random(3,3); // initialize a matrix by Random to 3 by 3
  m = (m + MatrixXd::Constant(3,3,1.2)) * 50; // initialize a matrix by Constant 3, 3 value
  cout << "m =" << endl << m << endl;
  VectorXd v(3); // defines a vector
  v << 1, 2, 3; // put values in vector by comma , 
  cout << "m * v =" << endl << m * v << endl;
  getchar();
}
*/

#include <iostream>
#include "..\EigenSource\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;
  getchar();
}
ċ
EigenSource.zip
(2194k)
Javad Taghia,
Oct 3, 2014, 3:12 AM
Comments