class_Block.cpp
Go to the documentation of this file.
1 #include <Eigen/Core>
2 #include <iostream>
3 
4 template<typename Derived>
7 {
8  return Eigen::Block<Derived>(m.derived(), 0, 0, rows, cols);
9 }
10 
11 template<typename Derived>
14 {
15  return Eigen::Block<const Derived>(m.derived(), 0, 0, rows, cols);
16 }
17 
18 int main(int, char**)
19 {
21  std::cout << topLeftCorner(4*m, 2, 3) << std::endl; // calls the const version
22  topLeftCorner(m, 2, 3) *= 5; // calls the non-const version
23  std::cout << "Now the matrix m is:" << std::endl << m << std::endl;
24  return 0;
25 }
Matrix3f m
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:107
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
static const IdentityReturnType Identity()
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
int main(int, char **)
Definition: class_Block.cpp:18
Eigen::Block< Derived > topLeftCorner(Eigen::MatrixBase< Derived > &m, int rows, int cols)
Definition: class_Block.cpp:6