Eigen  5.0.1
 
Loading...
Searching...
No Matches
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_RESHAPED_HELPER_H
12#define EIGEN_RESHAPED_HELPER_H
13
14// IWYU pragma: private
15#include "../InternalHeaderCheck.h"
16
17namespace Eigen {
18
19enum AutoSize_t { AutoSize };
20const int AutoOrder = 2;
21
22namespace internal {
23
24template <typename SizeType, typename OtherSize, int TotalSize>
25struct get_compiletime_reshape_size : get_fixed_value<SizeType> {};
26
27template <typename SizeType>
28Index get_runtime_reshape_size(SizeType size, Index /*other*/, Index /*total*/) {
29 return internal::get_runtime_value(size);
30}
31
32template <typename OtherSize, int TotalSize>
33struct get_compiletime_reshape_size<AutoSize_t, OtherSize, TotalSize> {
34 enum {
35 other_size = get_fixed_value<OtherSize>::value,
36 value = (TotalSize == Dynamic || other_size == Dynamic) ? Dynamic : TotalSize / other_size
37 };
38};
39
40inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { return total / other; }
41
42constexpr int get_compiletime_reshape_order(int flags, int order) {
43 return order == AutoOrder ? flags & RowMajorBit : order;
44}
45
46} // namespace internal
47
48} // end namespace Eigen
49
50#endif // EIGEN_RESHAPED_HELPER_H
constexpr unsigned int RowMajorBit
Definition Constants.h:71