Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 Eigen  3.4.99 (git rev 10c77b0ff44d0b9cb0b252cfa0ccaaa39d3c5da4)
Eigen::Reshaped< XprType, Rows, Cols, Order > Class Template Reference

## Detailed Description

### template<typename XprType, int Rows, int Cols, int Order> class Eigen::Reshaped< XprType, Rows, Cols, Order >

Expression of a fixed-size or dynamic-size reshape.

Template Parameters
 XprType the type of the expression in which we are taking a reshape Rows the number of rows of the reshape we are taking at compile time (optional) Cols the number of columns of the reshape we are taking at compile time (optional) Order can be ColMajor or RowMajor, default is ColMajor.

This class represents an expression of either a fixed-size or dynamic-size reshape. It is the return type of DenseBase::reshaped(NRowsType,NColsType) and most of the time this is the only way it is used.

However, in C++98, if you want to directly maniputate reshaped expressions, for instance if you want to write a function returning such an expression, you will need to use this class. In C++11, it is advised to use the auto keyword for such use cases.

Here is an example illustrating the dynamic case:

#include <Eigen/Core>
#include <iostream>
using namespace std;
using namespace Eigen;
template<typename Derived>
const Reshaped<const Derived>
reshape_helper(const MatrixBase<Derived>& m, int rows, int cols)
{
return Reshaped<const Derived>(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;
Ref<const MatrixXd> n = reshape_helper(m, 2, 6);
cout << "Matrix m is:" << endl << m << endl;
cout << "Matrix n is:" << endl << n << endl;
}
Namespace containing all symbols from the Eigen library.
Definition: Core:134

Output:

 1  4  7 10
2  5  8 11
3  6  9 12
Matrix m is:
1  4  7 10
2  5  8 11
3  6  9 12
Matrix n is:
1  3  5  7  9 11
2  4  6  8 10 12


Here is an example illustrating the fixed-size case:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
reshape_helper(MatrixBase<Derived>& m)
{
return Eigen::Reshaped<Derived, 4, 2>(m.derived());
}
int main(int, char**)
{
MatrixXd m(2, 4);
m << 1, 2, 3, 4,
5, 6, 7, 8;
MatrixXd n = reshape_helper(m);
cout << "matrix m is:" << endl << m << endl;
cout << "matrix n is:" << endl << n << endl;
return 0;
}
Expression of a fixed-size or dynamic-size reshape.
Definition: Reshaped.h:98

Output:

matrix m is:
1 2 3 4
5 6 7 8
matrix n is:
1 3
5 7
2 4
6 8

DenseBase::reshaped(NRowsType,NColsType)

Inherits Eigen::ReshapedImpl< XprType, Rows, Cols, Order, internal::traits< XprType >::StorageKind >.

## Public Member Functions

Reshaped (XprType &xpr)

Reshaped (XprType &xpr, Index reshapeRows, Index reshapeCols)

## ◆ Reshaped() [1/2]

template<typename XprType , int Rows, int Cols, int Order>
 Eigen::Reshaped< XprType, Rows, Cols, Order >::Reshaped ( XprType & xpr )
inline

Fixed-size constructor

## ◆ Reshaped() [2/2]

template<typename XprType , int Rows, int Cols, int Order>
 Eigen::Reshaped< XprType, Rows, Cols, Order >::Reshaped ( XprType & xpr, Index reshapeRows, Index reshapeCols )
inline

Dynamic-size constructor

The documentation for this class was generated from the following file: