source: pacpussensors/trunk/Vislab/lib3dv/eigen/Eigen-install/doc/snippets/compile_Tutorial_AdvancedInitialization_ThreeWays.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 1.0 KB
Line 
1#include <Eigen/Dense>
2#include <iostream>
3
4using namespace Eigen;
5using namespace std;
6
7int main(int, char**)
8{
9 cout.precision(3);
10 const int size = 6;
11MatrixXd mat1(size, size);
12mat1.topLeftCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
13mat1.topRightCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
14mat1.bottomLeftCorner(size/2, size/2) = MatrixXd::Identity(size/2, size/2);
15mat1.bottomRightCorner(size/2, size/2) = MatrixXd::Zero(size/2, size/2);
16std::cout << mat1 << std::endl << std::endl;
17
18MatrixXd mat2(size, size);
19mat2.topLeftCorner(size/2, size/2).setZero();
20mat2.topRightCorner(size/2, size/2).setIdentity();
21mat2.bottomLeftCorner(size/2, size/2).setIdentity();
22mat2.bottomRightCorner(size/2, size/2).setZero();
23std::cout << mat2 << std::endl << std::endl;
24
25MatrixXd mat3(size, size);
26mat3 << 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);
28std::cout << mat3 << std::endl;
29
30
31 return 0;
32}
Note: See TracBrowser for help on using the repository browser.