tut_arithmetic_add_sub.cpp revision c981c48f5bc9aefeffc0bcb0cc3934c2fae179dd
1#include <iostream>
2#include <Eigen/Dense>
3
4using namespace Eigen;
5
6int main()
7{
8  Matrix2d a;
9  a << 1, 2,
10       3, 4;
11  MatrixXd b(2,2);
12  b << 2, 3,
13       1, 4;
14  std::cout << "a + b =\n" << a + b << std::endl;
15  std::cout << "a - b =\n" << a - b << std::endl;
16  std::cout << "Doing a += b;" << std::endl;
17  a += b;
18  std::cout << "Now a =\n" << a << std::endl;
19  Vector3d v(1,2,3);
20  Vector3d w(1,0,0);
21  std::cout << "-v + w - v =\n" << -v + w - v << std::endl;
22}
23