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