blob: b6d4085dea39cc0d291ddc4670bf034d2c48ccae [file] [log] [blame]
Austin Schuhc55b0172022-02-20 17:52:35 -08001#include <Eigen/Core>
2#include <iostream>
3using namespace Eigen;
4using namespace std;
5
6template<typename Derived>
7Eigen::Reshaped<Derived, 4, 2>
8reshape_helper(MatrixBase<Derived>& m)
9{
10 return Eigen::Reshaped<Derived, 4, 2>(m.derived());
11}
12
13int main(int, char**)
14{
15 MatrixXd m(2, 4);
16 m << 1, 2, 3, 4,
17 5, 6, 7, 8;
18 MatrixXd n = reshape_helper(m);
19 cout << "matrix m is:" << endl << m << endl;
20 cout << "matrix n is:" << endl << n << endl;
21 return 0;
22}