Tutorial_ArrayClass_interop_matrix.cpp
Go to the documentation of this file.
1 #include <Eigen/Dense>
2 #include <iostream>
3 
4 using Eigen::MatrixXf;
5 
6 int main()
7 {
8  MatrixXf m(2,2);
9  MatrixXf n(2,2);
10  MatrixXf result(2,2);
11 
12  m << 1,2,
13  3,4;
14  n << 5,6,
15  7,8;
16 
17  result = m * n;
18  std::cout << "-- Matrix m*n: --\n" << result << "\n\n";
19  result = m.array() * n.array();
20  std::cout << "-- Array m*n: --\n" << result << "\n\n";
21  result = m.cwiseProduct(n);
22  std::cout << "-- With cwiseProduct: --\n" << result << "\n\n";
23  result = m.array() + 4;
24  std::cout << "-- Array m + 4: --\n" << result << "\n\n";
25 }
Matrix3f m
int n
Matrix< float, Dynamic, Dynamic > MatrixXf
Dynamic×Dynamic matrix of type float.
Definition: Matrix.h:501