$darkmode
Eigen  5.0.1-dev
ReshapedHelper.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_RESHAPED_HELPER_H
11 #define EIGEN_RESHAPED_HELPER_H
12 
13 // IWYU pragma: private
14 #include "../InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 enum AutoSize_t { AutoSize };
19 const int AutoOrder = 2;
20 
21 namespace internal {
22 
23 template <typename SizeType, typename OtherSize, int TotalSize>
24 struct get_compiletime_reshape_size {
25  enum { value = get_fixed_value<SizeType>::value };
26 };
27 
28 template <typename SizeType>
29 Index get_runtime_reshape_size(SizeType size, Index /*other*/, Index /*total*/) {
30  return internal::get_runtime_value(size);
31 }
32 
33 template <typename OtherSize, int TotalSize>
34 struct get_compiletime_reshape_size<AutoSize_t, OtherSize, TotalSize> {
35  enum {
36  other_size = get_fixed_value<OtherSize>::value,
37  value = (TotalSize == Dynamic || other_size == Dynamic) ? Dynamic : TotalSize / other_size
38  };
39 };
40 
41 inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { return total / other; }
42 
43 constexpr int get_compiletime_reshape_order(int flags, int order) {
44  return order == AutoOrder ? flags & RowMajorBit : order;
45 }
46 
47 } // namespace internal
48 
49 } // end namespace Eigen
50 
51 #endif // EIGEN_RESHAPED_HELPER_H
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
const unsigned int RowMajorBit
Definition: Constants.h:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:25