source: pacpussensors/trunk/Vislab/lib3dv-1.2.0/lib3dv/eigen/doc/examples/class_FixedBlock.cpp

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

Doc

File size: 697 bytes
Line 
1#include <Eigen/Core>
2#include <iostream>
3using namespace Eigen;
4using namespace std;
5
6template<typename Derived>
7Eigen::Block<Derived, 2, 2>
8topLeft2x2Corner(MatrixBase<Derived>& m)
9{
10 return Eigen::Block<Derived, 2, 2>(m.derived(), 0, 0);
11}
12
13template<typename Derived>
14const Eigen::Block<const Derived, 2, 2>
15topLeft2x2Corner(const MatrixBase<Derived>& m)
16{
17 return Eigen::Block<const Derived, 2, 2>(m.derived(), 0, 0);
18}
19
20int main(int, char**)
21{
22 Matrix3d m = Matrix3d::Identity();
23 cout << topLeft2x2Corner(4*m) << endl; // calls the const version
24 topLeft2x2Corner(m) *= 2; // calls the non-const version
25 cout << "Now the matrix m is:" << endl << m << endl;
26 return 0;
27}
Note: See TracBrowser for help on using the repository browser.