Tutorial_BlockOperations_block_assignment.cpp 523 B

123456789101112131415161718
  1. #include <Eigen/Dense>
  2. #include <iostream>
  3. using namespace std;
  4. using namespace Eigen;
  5. int main()
  6. {
  7. Array22f m;
  8. m << 1,2,
  9. 3,4;
  10. Array44f a = Array44f::Constant(0.6);
  11. cout << "Here is the array a:" << endl << a << endl << endl;
  12. a.block<2,2>(1,1) = m;
  13. cout << "Here is now a with m copied into its central 2x2 block:" << endl << a << endl << endl;
  14. a.block(0,0,2,3) = a.block(2,1,2,3);
  15. cout << "Here is now a with bottom-right 2x3 block copied into top-left 2x3 block:" << endl << a << endl << endl;
  16. }