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