Go to the source code of this file.
Functions | |
template<int Order = ColMajor> | |
Reshaped< Derived,... > | reshaped () |
template<int Order = ColMajor> | |
const Reshaped< const Derived,... > | reshaped () const |
This is the const version of reshaped(). More... | |
template<int Order = ColMajor, typename NRowsType , typename NColsType > | |
Reshaped< Derived,... > | reshaped (NRowsType nRows, NColsType nCols) |
template<int Order = ColMajor, typename NRowsType , typename NColsType > | |
const Reshaped< const Derived,... > | reshaped (NRowsType nRows, NColsType nCols) const |
This is the const version of reshaped(NRowsType,NColsType). More... | |
|
inline |
*this
with columns (or rows) stacked to a linear column vectorOrder | specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor), or follows the natural order of the nested expression (AutoOrder). The default is ColMajor. |
This overloads is essentially a shortcut for A.reshaped<Order>(AutoSize,fix<1>)
.
Order==ColMajor
(the default), then it returns a column-vector from the stacked columns of *this
.Order==RowMajor
, then it returns a column-vector from the stacked rows of *this
.Order==AutoOrder
, then it returns a column-vector with elements stacked following the storage order of *this
. This mode is the recommended one when the particular ordering of the element is not relevant.Example:
Output:
Here is the matrix m: 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9 Here is m.reshaped().transpose(): 7 -2 6 6 9 -6 -3 6 -5 1 0 3 -3 0 9 9 Here is m.reshaped<RowMajor>().transpose(): 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9
If you want more control, you can still fall back to reshaped(NRowsType,NColsType).
|
inline |
This is the const version of reshaped().
|
inline |
*this
with reshaped sizes.nRows | the number of rows in the reshaped expression, specified at either run-time or compile-time, or AutoSize |
nCols | the number of columns in the reshaped expression, specified at either run-time or compile-time, or AutoSize |
Order | specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor), or follows the natural order of the nested expression (AutoOrder). The default is ColMajor. |
NRowsType | the type of the value handling the number of rows, typically Index. |
NColsType | the type of the value handling the number of columns, typically Index. |
Dynamic size example:
Output:
Here is the matrix m: 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9 Here is m.reshaped(2, 8): 7 6 9 -3 -5 0 -3 9 -2 6 -6 6 1 3 0 9
The number of rows nRows and columns nCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. In the later case, n
plays the role of a runtime fallback value in case N
equals Eigen::Dynamic. Here is an example with a fixed number of rows and columns:
Output:
Here is the matrix m: 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9 Here is m.reshaped(fix<2>,fix<8>): 7 6 9 -3 -5 0 -3 9 -2 6 -6 6 1 3 0 9
Finally, one of the sizes parameter can be automatically deduced from the other one by passing AutoSize as in the following example:
Output:
Here is the matrix m: 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9 Here is m.reshaped(2, AutoSize): 7 6 9 -3 -5 0 -3 9 -2 6 -6 6 1 3 0 9 Here is m.reshaped<RowMajor>(AutoSize, fix<8>): 7 9 -5 -3 -2 -6 1 0 6 -3 0 9 6 6 3 9
AutoSize does preserve compile-time sizes when possible, i.e., when the sizes of the input are known at compile time and that the other size is passed at compile-time using Eigen::fix<N> as above.
|
inline |
This is the const version of reshaped(NRowsType,NColsType).