From 183bf54d27c948219585f52657355338eb695d08 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sun, 13 Jan 2008 23:38:48 +0000 Subject: final fixes and updates for alpha3 --- doc/examples/class_FixedBlock.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 doc/examples/class_FixedBlock.cpp (limited to 'doc/examples/class_FixedBlock.cpp') diff --git a/doc/examples/class_FixedBlock.cpp b/doc/examples/class_FixedBlock.cpp new file mode 100644 index 000000000..b34cf13ad --- /dev/null +++ b/doc/examples/class_FixedBlock.cpp @@ -0,0 +1,26 @@ +#include +USING_PART_OF_NAMESPACE_EIGEN +using namespace std; + +template +Eigen::FixedBlock +topLeft2x2Corner(MatrixBase& m) +{ + return Eigen::FixedBlock(m.ref(), 0, 0); +} + +template +const Eigen::FixedBlock +topLeft2x2Corner(const MatrixBase& m) +{ + return Eigen::FixedBlock(m.ref(), 0, 0); +} + +int main(int, char**) +{ + Matrix3d m = Matrix3d::identity(); + cout << topLeft2x2Corner(4*m) << endl; // calls the const version + topLeft2x2Corner(m) *= 2; // calls the non-const version + cout << "Now the matrix m is:" << endl << m << endl; + return 0; +} -- cgit v1.2.3