[136] | 1 | #include <Eigen/Dense>
|
---|
| 2 | #include <iostream>
|
---|
| 3 |
|
---|
| 4 | using namespace Eigen;
|
---|
| 5 | using namespace std;
|
---|
| 6 |
|
---|
| 7 | int main(int, char**)
|
---|
| 8 | {
|
---|
| 9 | cout.precision(3);
|
---|
| 10 | const int size = 6;
|
---|
| 11 | MatrixXd mat1(size, size);
|
---|
| 12 | mat1.topLeftCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
|
---|
| 13 | mat1.topRightCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
|
---|
| 14 | mat1.bottomLeftCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
|
---|
| 15 | mat1.bottomRightCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
|
---|
| 16 | std::cout << mat1 << std::endl << std::endl;
|
---|
| 17 |
|
---|
| 18 | MatrixXd mat2(size, size);
|
---|
| 19 | mat2.topLeftCorner(size/2, size/2).setZero();
|
---|
| 20 | mat2.topRightCorner(size/2, size/2).setIdentity();
|
---|
| 21 | mat2.bottomLeftCorner(size/2, size/2).setIdentity();
|
---|
| 22 | mat2.bottomRightCorner(size/2, size/2).setZero();
|
---|
| 23 | std::cout << mat2 << std::endl << std::endl;
|
---|
| 24 |
|
---|
| 25 | MatrixXd mat3(size, size);
|
---|
| 26 | mat3 << MatrixXd::Zero(size/2, size/2), MatrixXd::Identity(size/2, size/2),
|
---|
| 27 | MatrixXd::Identity(size/2, size/2), MatrixXd::Zero(size/2, size/2);
|
---|
| 28 | std::cout << mat3 << std::endl;
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | return 0;
|
---|
| 32 | }
|
---|