class_Block.cpp
Go to the documentation of this file.
00001 #include <Eigen/Core>
00002 #include <iostream>
00003 using namespace Eigen;
00004 using namespace std;
00005 
00006 template<typename Derived>
00007 Eigen::Block<Derived>
00008 topLeftCorner(MatrixBase<Derived>& m, int rows, int cols)
00009 {
00010   return Eigen::Block<Derived>(m.derived(), 0, 0, rows, cols);
00011 }
00012 
00013 template<typename Derived>
00014 const Eigen::Block<const Derived>
00015 topLeftCorner(const MatrixBase<Derived>& m, int rows, int cols)
00016 {
00017   return Eigen::Block<const Derived>(m.derived(), 0, 0, rows, cols);
00018 }
00019 
00020 int main(int, char**)
00021 {
00022   Matrix4d m = Matrix4d::Identity();
00023   cout << topLeftCorner(4*m, 2, 3) << endl; // calls the const version
00024   topLeftCorner(m, 2, 3) *= 5;              // calls the non-const version
00025   cout << "Now the matrix m is:" << endl << m << endl;
00026   return 0;
00027 }


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:34