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