WPILibC++ 2023.4.3-108-ge5452e3
ReshapedMethods.h
Go to the documentation of this file.
1
2#ifdef EIGEN_PARSED_BY_DOXYGEN
3
4/// \returns an expression of \c *this with reshaped sizes.
5///
6/// \param nRows the number of rows in the reshaped expression, specified at either run-time or compile-time, or AutoSize
7/// \param nCols the number of columns in the reshaped expression, specified at either run-time or compile-time, or AutoSize
8/// \tparam Order specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor),
9/// or follows the \em natural order of the nested expression (AutoOrder). The default is ColMajor.
10/// \tparam NRowsType the type of the value handling the number of rows, typically Index.
11/// \tparam NColsType the type of the value handling the number of columns, typically Index.
12///
13/// Dynamic size example: \include MatrixBase_reshaped_int_int.cpp
14/// Output: \verbinclude MatrixBase_reshaped_int_int.out
15///
16/// The number of rows \a nRows and columns \a nCols can also be specified at compile-time by passing Eigen::fix<N>,
17/// or Eigen::fix<N>(n) as arguments. In the later case, \c n plays the role of a runtime fallback value in case \c N equals Eigen::Dynamic.
18/// Here is an example with a fixed number of rows and columns:
19/// \include MatrixBase_reshaped_fixed.cpp
20/// Output: \verbinclude MatrixBase_reshaped_fixed.out
21///
22/// Finally, one of the sizes parameter can be automatically deduced from the other one by passing AutoSize as in the following example:
23/// \include MatrixBase_reshaped_auto.cpp
24/// Output: \verbinclude MatrixBase_reshaped_auto.out
25/// AutoSize does preserve compile-time sizes when possible, i.e., when the sizes of the input are known at compile time \b and
26/// that the other size is passed at compile-time using Eigen::fix<N> as above.
27///
28/// \sa class Reshaped, fix, fix<N>(int)
29///
30template<int Order = ColMajor, typename NRowsType, typename NColsType>
32inline Reshaped<Derived,...>
33reshaped(NRowsType nRows, NColsType nCols);
34
35/// This is the const version of reshaped(NRowsType,NColsType).
36template<int Order = ColMajor, typename NRowsType, typename NColsType>
38inline const Reshaped<const Derived,...>
39reshaped(NRowsType nRows, NColsType nCols) const;
40
41/// \returns an expression of \c *this with columns (or rows) stacked to a linear column vector
42///
43/// \tparam Order specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor),
44/// or follows the \em natural order of the nested expression (AutoOrder). The default is ColMajor.
45///
46/// This overloads is essentially a shortcut for `A.reshaped<Order>(AutoSize,fix<1>)`.
47///
48/// - If `Order==ColMajor` (the default), then it returns a column-vector from the stacked columns of \c *this.
49/// - If `Order==RowMajor`, then it returns a column-vector from the stacked rows of \c *this.
50/// - If `Order==AutoOrder`, then it returns a column-vector with elements stacked following the storage order of \c *this.
51/// This mode is the recommended one when the particular ordering of the element is not relevant.
52///
53/// Example:
54/// \include MatrixBase_reshaped_to_vector.cpp
55/// Output: \verbinclude MatrixBase_reshaped_to_vector.out
56///
57/// If you want more control, you can still fall back to reshaped(NRowsType,NColsType).
58///
59/// \sa reshaped(NRowsType,NColsType), class Reshaped
60///
61template<int Order = ColMajor>
63inline Reshaped<Derived,...>
64reshaped();
65
66/// This is the const version of reshaped().
67template<int Order = ColMajor>
69inline const Reshaped<const Derived,...>
70reshaped() const;
71
72#else
73
74// This file is automatically included twice to generate const and non-const versions
75
76#ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
77#define EIGEN_RESHAPED_METHOD_CONST const
78#else
79#define EIGEN_RESHAPED_METHOD_CONST
80#endif
81
82#ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
83
84// This part is included once
85
86#endif
87
88template<typename NRowsType, typename NColsType>
90inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
91 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
92 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value>
93reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
94{
95 return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
96 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
97 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value>
98 (derived(),
101}
102
103template<int Order, typename NRowsType, typename NColsType>
105inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
106 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
107 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
108 internal::get_compiletime_reshape_order<Flags,Order>::value>
109reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
110{
111 return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
112 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
113 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
114 internal::get_compiletime_reshape_order<Flags,Order>::value>
115 (derived(),
118}
119
120// Views as linear vectors
121
123inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1>
125{
126 return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1>(derived(),size(),1);
127}
128
129template<int Order>
131inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
132 internal::get_compiletime_reshape_order<Flags,Order>::value>
134{
135 EIGEN_STATIC_ASSERT(Order==RowMajor || Order==ColMajor || Order==AutoOrder, INVALID_TEMPLATE_PARAMETER);
136 return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
137 internal::get_compiletime_reshape_order<Flags,Order>::value>
138 (derived(), size(), 1);
139}
140
141#undef EIGEN_RESHAPED_METHOD_CONST
142
143#ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
144#define EIGEN_RESHAPED_METHOD_2ND_PASS
145#include "ReshapedMethods.h"
146#undef EIGEN_RESHAPED_METHOD_2ND_PASS
147#endif
148
149#endif // EIGEN_PARSED_BY_DOXYGEN
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_RESHAPED_METHOD_CONST
Definition: ReshapedMethods.h:77
EIGEN_DEVICE_FUNC Reshaped< EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size< NRowsType, NColsType, SizeAtCompileTime >::value, internal::get_compiletime_reshape_size< NColsType, NRowsType, SizeAtCompileTime >::value > reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
Definition: ReshapedMethods.h:93
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:127
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:321
Index get_runtime_reshape_size(SizeType size, Index, Index)
Definition: ReshapedHelper.h:27
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
EIGEN_DEVICE_FUNC Index get_runtime_value(const T &x)
Definition: IntegralConstant.h:156
const int AutoOrder
Definition: ReshapedHelper.h:17