mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-27 07:29:52 +08:00
21 lines
878 B
C++
21 lines
878 B
C++
const int size = 6;
|
|
MatrixXd mat1(size, size);
|
|
mat1.topLeftCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
|
|
mat1.topRightCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
|
|
mat1.bottomLeftCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
|
|
mat1.bottomRightCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
|
|
std::cout << mat1 << std::endl << std::endl;
|
|
|
|
MatrixXd mat2(size, size);
|
|
mat2.topLeftCorner(size/2, size/2).setZero();
|
|
mat2.topRightCorner(size/2, size/2).setIdentity();
|
|
mat2.bottomLeftCorner(size/2, size/2).setIdentity();
|
|
mat2.bottomRightCorner(size/2, size/2).setZero();
|
|
std::cout << mat2 << std::endl << std::endl;
|
|
|
|
MatrixXd mat3(size, size);
|
|
mat3 << MatrixXd::Zero(size/2, size/2), MatrixXd::Identity(size/2, size/2),
|
|
MatrixXd::Identity(size/2, size/2), MatrixXd::Zero(size/2, size/2);
|
|
std::cout << mat3 << std::endl;
|
|
|