2010-06-29 01:42:09 +08:00
|
|
|
#include <Eigen/Dense>
|
|
|
|
#include <iostream>
|
|
|
|
|
2021-12-08 03:57:38 +08:00
|
|
|
using Eigen::MatrixXf;
|
2010-06-29 01:42:09 +08:00
|
|
|
|
|
|
|
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;
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "-- Matrix m*n: --\n" << result << "\n\n";
|
2010-06-29 01:42:09 +08:00
|
|
|
result = m.array() * n.array();
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "-- Array m*n: --\n" << result << "\n\n";
|
2010-07-13 05:45:57 +08:00
|
|
|
result = m.cwiseProduct(n);
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "-- With cwiseProduct: --\n" << result << "\n\n";
|
2010-06-29 01:42:09 +08:00
|
|
|
result = m.array() + 4;
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "-- Array m + 4: --\n" << result << "\n\n";
|
2010-06-29 01:42:09 +08:00
|
|
|
}
|