Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
TensorDimensionList.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>
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_TENSOR_TENSOR_DIMENSION_LIST_H
12#define EIGEN_TENSOR_TENSOR_DIMENSION_LIST_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
27template <typename Index, std::size_t Rank>
28struct DimensionList {
29 constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const Index operator[](const Index i) const { return i; }
30};
31
32namespace internal {
33
34template <typename Index, std::size_t Rank>
35struct array_size<DimensionList<Index, Rank> > {
36 static constexpr size_t value = Rank;
37};
38template <typename Index, std::size_t Rank>
39struct array_size<const DimensionList<Index, Rank> > {
40 static constexpr size_t value = Rank;
41};
42
43template <DenseIndex n, typename Index, std::size_t Rank>
44constexpr Index array_get(const DimensionList<Index, Rank>&) {
45 return n;
46}
47
48template <typename Index, std::size_t Rank>
49struct index_known_statically_impl<DimensionList<Index, Rank> > {
50 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) { return true; }
51};
52
53template <typename Index, std::size_t Rank>
54struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
55 EIGEN_DEVICE_FUNC static constexpr bool run() { return true; }
56};
57
58template <typename Index, std::size_t Rank>
59struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
60 EIGEN_DEVICE_FUNC static constexpr bool run() { return true; }
61};
62
63template <typename Index, std::size_t Rank>
64struct index_statically_eq_impl<DimensionList<Index, Rank> > {
65 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i == value; }
66};
67
68template <typename Index, std::size_t Rank>
69struct index_statically_ne_impl<DimensionList<Index, Rank> > {
70 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i != value; }
71};
72
73template <typename Index, std::size_t Rank>
74struct index_statically_gt_impl<DimensionList<Index, Rank> > {
75 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i > value; }
76};
77
78template <typename Index, std::size_t Rank>
79struct index_statically_lt_impl<DimensionList<Index, Rank> > {
80 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i < value; }
81};
82
83} // end namespace internal
84} // end namespace Eigen
85
86#endif // EIGEN_TENSOR_TENSOR_DIMENSION_LIST_H
Namespace containing all symbols from the Eigen library.