2010-06-29 01:42:09 +08:00
|
|
|
#include <Eigen/Dense>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace Eigen;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
MatrixXf m(2,2);
|
|
|
|
MatrixXf n(2,2);
|
|
|
|
MatrixXf result(2,2);
|
|
|
|
|
|
|
|
m << 1,2,
|
|
|
|
3,4;
|
|
|
|
n << 5,6,
|
|
|
|
7,8;
|
|
|
|
|
|
|
|
result = m * n;
|
2010-07-13 05:45:57 +08:00
|
|
|
cout << "-- Matrix m*n: --" << endl << result << endl << endl;
|
2010-06-29 01:42:09 +08:00
|
|
|
result = m.array() * n.array();
|
2010-07-13 05:45:57 +08:00
|
|
|
cout << "-- Array m*n: --" << endl << result << endl << endl;
|
|
|
|
result = m.cwiseProduct(n);
|
|
|
|
cout << "-- With cwiseProduct: --" << endl << result << endl << endl;
|
2010-06-29 01:42:09 +08:00
|
|
|
result = m.array() + 4;
|
2010-07-13 05:45:57 +08:00
|
|
|
cout << "-- Array m + 4: --" << endl << result << endl << endl;
|
2010-06-29 01:42:09 +08:00
|
|
|
}
|