1
0
mirror of https://gitlab.com/libeigen/eigen.git synced 2025-06-22 20:29:26 +08:00
eigen/doc/examples/Tutorial_ArrayClass_interop_matrix.cpp

23 lines
535 B
C++

#include <Eigen/Dense>
#include <iostream>
using Eigen::MatrixXf;
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;
std::cout << "-- Matrix m*n: --\n" << result << "\n\n";
result = m.array() * n.array();
std::cout << "-- Array m*n: --\n" << result << "\n\n";
result = m.cwiseProduct(n);
std::cout << "-- With cwiseProduct: --\n" << result << "\n\n";
result = m.array() + 4;
std::cout << "-- Array m + 4: --\n" << result << "\n\n";
}