Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
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
XprTypethe type of the expression in which we are taking a reshape
Rowsthe number of rows of the reshape we are taking at compile time (optional)
Colsthe number of columns of the reshape we are taking at compile time (optional)
Ordercan 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.

If you want to directly manipulate reshaped expressions, for instance if you want to write a function returning such an expression, 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>
template <typename Derived>
const Eigen::Reshaped<const Derived> reshape_helper(const Eigen::MatrixBase<Derived>& m, int rows, int cols) {
return Eigen::Reshaped<const Derived>(m.derived(), rows, cols);
}
int main(int, char**) {
Eigen::MatrixXd m(3, 4);
m << 1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12;
std::cout << m << std::endl;
Eigen::Ref<const Eigen::MatrixXd> n = reshape_helper(m, 2, 6);
std::cout << "Matrix m is:" << std::endl << m << std::endl;
std::cout << "Matrix n is:" << std::endl << n << std::endl;
}
Derived & derived()
Definition EigenBase.h:49
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
A matrix or vector expression mapping an existing expression.
Definition Ref.h:264
Expression of a fixed-size or dynamic-size reshape.
Definition Reshaped.h:99

Output:

Here is an example illustrating the fixed-size case:

#include <Eigen/Core>
#include <iostream>
template <typename Derived>
}
int main(int, char**) {
Eigen::MatrixXd m(2, 4);
m << 1, 2, 3, 4, 5, 6, 7, 8;
Eigen::MatrixXd n = reshape_helper(m);
std::cout << "matrix m is:" << std::endl << m << std::endl;
std::cout << "matrix n is:" << std::endl << n << std::endl;
return 0;
}

Output:

See also
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)
 

Constructor & Destructor Documentation

◆ 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: