You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
878 B

  1. const int size = 6;
  2. MatrixXd mat1(size, size);
  3. mat1.topLeftCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
  4. mat1.topRightCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
  5. mat1.bottomLeftCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
  6. mat1.bottomRightCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
  7. std::cout << mat1 << std::endl << std::endl;
  8. MatrixXd mat2(size, size);
  9. mat2.topLeftCorner(size/2, size/2).setZero();
  10. mat2.topRightCorner(size/2, size/2).setIdentity();
  11. mat2.bottomLeftCorner(size/2, size/2).setIdentity();
  12. mat2.bottomRightCorner(size/2, size/2).setZero();
  13. std::cout << mat2 << std::endl << std::endl;
  14. MatrixXd mat3(size, size);
  15. mat3 << MatrixXd::Zero(size/2, size/2), MatrixXd::Identity(size/2, size/2),
  16. MatrixXd::Identity(size/2, size/2), MatrixXd::Zero(size/2, size/2);
  17. std::cout << mat3 << std::endl;