ReshapedHelper.h
Go to the documentation of this file.
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 
11 #ifndef EIGEN_RESHAPED_HELPER_H
12 #define EIGEN_RESHAPED_HELPER_H
13 
14 #include "../InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
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*/) {
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 inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) {
41  return total/other;
42 }
43 
44 constexpr inline int get_compiletime_reshape_order(int flags, int order) {
45  return order == AutoOrder ? flags & RowMajorBit : order;
46 }
47 
48 }
49 
50 } // end namespace Eigen
51 
52 #endif // EIGEN_RESHAPED_HELPER_H
const unsigned int RowMajorBit
Definition: Constants.h:68
Index get_runtime_reshape_size(SizeType size, Index, Index)
Index get_runtime_value(const T &x)
constexpr int get_compiletime_reshape_order(int flags, int order)
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int AutoOrder
const int Dynamic
Definition: Constants.h:24