mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-11-27 06:30:28 +08:00
constexpr reshape helper
This commit is contained in:
parent
403fa33409
commit
df87d40e34
@ -41,10 +41,9 @@ inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index to
|
||||
return total/other;
|
||||
}
|
||||
|
||||
template<int Flags, int Order>
|
||||
struct get_compiletime_reshape_order {
|
||||
enum { value = Order == AutoOrder ? Flags & RowMajorBit : Order };
|
||||
};
|
||||
constexpr inline int get_compiletime_reshape_order(int flags, int order) {
|
||||
return order == AutoOrder ? flags & RowMajorBit : order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ EIGEN_DEVICE_FUNC
|
||||
inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
|
||||
internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
|
||||
internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
|
||||
internal::get_compiletime_reshape_order<Flags,Order>::value>
|
||||
internal::get_compiletime_reshape_order(Flags, Order)>
|
||||
reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
|
||||
{
|
||||
return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
|
||||
internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
|
||||
internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
|
||||
internal::get_compiletime_reshape_order<Flags,Order>::value>
|
||||
internal::get_compiletime_reshape_order(Flags, Order)>
|
||||
(derived(),
|
||||
internal::get_runtime_reshape_size(nRows,internal::get_runtime_value(nCols),size()),
|
||||
internal::get_runtime_reshape_size(nCols,internal::get_runtime_value(nRows),size()));
|
||||
@ -129,12 +129,12 @@ reshaped() EIGEN_RESHAPED_METHOD_CONST
|
||||
template<int Order>
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
|
||||
internal::get_compiletime_reshape_order<Flags,Order>::value>
|
||||
internal::get_compiletime_reshape_order(Flags, Order)>
|
||||
reshaped() EIGEN_RESHAPED_METHOD_CONST
|
||||
{
|
||||
EIGEN_STATIC_ASSERT(Order==RowMajor || Order==ColMajor || Order==AutoOrder, INVALID_TEMPLATE_PARAMETER);
|
||||
return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
|
||||
internal::get_compiletime_reshape_order<Flags,Order>::value>
|
||||
internal::get_compiletime_reshape_order(Flags, Order)>
|
||||
(derived(), size(), 1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user