cart-elc

Source code for CART-ELC
git clone git://git.laack.co/cart-elc.git
Log | Files | Refs | README | LICENSE

class_Reshaped.cpp (545B)


      1 #include <Eigen/Core>
      2 #include <iostream>
      3 using namespace std;
      4 using namespace Eigen;
      5 
      6 template<typename Derived>
      7 const Reshaped<const Derived>
      8 reshape_helper(const MatrixBase<Derived>& m, int rows, int cols)
      9 {
     10   return Reshaped<const Derived>(m.derived(), rows, cols);
     11 }
     12 
     13 int 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 }