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::VectorBlock<Derived>
00008 segmentFromRange(MatrixBase<Derived>& v, int start, int end)
00009 {
00010 return Eigen::VectorBlock<Derived>(v.derived(), start, end-start);
00011 }
00012
00013 template<typename Derived>
00014 const Eigen::VectorBlock<const Derived>
00015 segmentFromRange(const MatrixBase<Derived>& v, int start, int end)
00016 {
00017 return Eigen::VectorBlock<const Derived>(v.derived(), start, end-start);
00018 }
00019
00020 int main(int, char**)
00021 {
00022 Matrix<int,1,6> v; v << 1,2,3,4,5,6;
00023 cout << segmentFromRange(2*v, 2, 4) << endl;
00024 segmentFromRange(v, 1, 3) *= 5;
00025 cout << "Now the vector v is:" << endl << v << endl;
00026 return 0;
00027 }