From 44861dcbfeee041223c4aac1ee075e92fa4daa01 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Sep 2016 12:42:15 +0200 Subject: update --- eigen/doc/examples/class_FixedVectorBlock.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 eigen/doc/examples/class_FixedVectorBlock.cpp (limited to 'eigen/doc/examples/class_FixedVectorBlock.cpp') diff --git a/eigen/doc/examples/class_FixedVectorBlock.cpp b/eigen/doc/examples/class_FixedVectorBlock.cpp new file mode 100644 index 0000000..c88c9fb --- /dev/null +++ b/eigen/doc/examples/class_FixedVectorBlock.cpp @@ -0,0 +1,27 @@ +#include +#include +using namespace Eigen; +using namespace std; + +template +Eigen::VectorBlock +firstTwo(MatrixBase& v) +{ + return Eigen::VectorBlock(v.derived(), 0); +} + +template +const Eigen::VectorBlock +firstTwo(const MatrixBase& v) +{ + return Eigen::VectorBlock(v.derived(), 0); +} + +int main(int, char**) +{ + Matrix v; v << 1,2,3,4,5,6; + cout << firstTwo(4*v) << endl; // calls the const version + firstTwo(v) *= 2; // calls the non-const version + cout << "Now the vector v is:" << endl << v << endl; + return 0; +} -- cgit v1.2.3