From 1e1d0c15b5b9bf5ca43e3020aec7aa596e3a167c Mon Sep 17 00:00:00 2001 From: yoco Date: Sat, 18 Jan 2014 04:43:29 +0800 Subject: add example code for Reshape class --- doc/examples/class_Reshape.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doc/examples/class_Reshape.cpp (limited to 'doc/examples/class_Reshape.cpp') diff --git a/doc/examples/class_Reshape.cpp b/doc/examples/class_Reshape.cpp new file mode 100644 index 000000000..b9abdc2d5 --- /dev/null +++ b/doc/examples/class_Reshape.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +using namespace Eigen; + +template +const Reshape +reshape_helper(const MatrixBase& m, int rows, int cols) +{ + return Reshape(m.derived(), rows, cols); +} + +int main(int, char**) +{ + MatrixXd m(3, 4); + m << 1, 4, 7, 10, + 2, 5, 8, 11, + 3, 6, 9, 12; + cout << m << endl; + auto n = reshape_helper(m, 2, 6); + cout << "Matrix m is:" << endl << m << endl; + cout << "Matrix n is:" << endl << n << endl; +} -- cgit v1.2.3