class_VectorBlock.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>(v.derived(), start, end-start);
9 }
10 
11 template<typename Derived>
14 {
15  return Eigen::VectorBlock<const Derived>(v.derived(), start, end-start);
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 << segmentFromRange(2*v, 2, 4) << std::endl; // calls the const version
22  segmentFromRange(v, 1, 3) *= 5; // 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 > segmentFromRange(Eigen::MatrixBase< Derived > &v, int start, int end)
static const lastp1_t end