chromium/third_party/eigen3/src/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2014 Benoit Steiner <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
#define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H

// IWYU pragma: private
#include "./InternalHeaderCheck.h"

namespace Eigen {

/** \internal
 *
 * \class TensorIndexList
 * \ingroup CXX11_Tensor_Module
 *
 * \brief Set of classes used to encode a set of Tensor dimensions/indices.
 *
 * The indices in the list can be known at compile time or at runtime. A mix
 * of static and dynamic indices can also be provided if needed. The tensor
 * code will attempt to take advantage of the indices that are known at
 * compile time to optimize the code it generates.
 *
 * This functionality requires a c++11 compliant compiler. If your compiler
 * is older you need to use arrays of indices instead.
 *
 * Several examples are provided in the cxx11_tensor_index_list.cpp file.
 *
 * \sa Tensor
 */

template <Index n>
struct type2index {};

// This can be used with IndexPairList to get compile-time constant pairs,
// such as IndexPairList<type2indexpair<1,2>, type2indexpair<3,4>>().
template <Index f, Index s>
struct type2indexpair {};

NumTraits<type2index<n>>;

namespace internal {
template <typename T>
EIGEN_DEVICE_FUNC void update_value(T& val, Index new_val) {}
template <Index n>
EIGEN_DEVICE_FUNC void update_value(type2index<n>& val, Index new_val) {}

template <typename T>
EIGEN_DEVICE_FUNC void update_value(T& val, IndexPair<Index> new_val) {}
template <Index f, Index s>
EIGEN_DEVICE_FUNC void update_value(type2indexpair<f, s>& val, IndexPair<Index> new_val) {}

template <typename T>
struct is_compile_time_constant {};

is_compile_time_constant<type2index<idx>>;
is_compile_time_constant<const type2index<idx>>;
is_compile_time_constant<type2index<idx> &>;
is_compile_time_constant<const type2index<idx> &>;

is_compile_time_constant<type2indexpair<f, s>>;
is_compile_time_constant<const type2indexpair<f, s>>;
is_compile_time_constant<type2indexpair<f, s> &>;
is_compile_time_constant<const type2indexpair<f, s> &>;

template <typename... T>
struct IndexTuple;

IndexTuple<T, O...>;

IndexTuple<T>;

template <int N, typename... T>
struct IndexTupleExtractor;

IndexTupleExtractor<N, T, O...>;

IndexTupleExtractor<0, T, O...>;

template <int N, typename T, typename... O>
EIGEN_DEVICE_FUNC constexpr typename IndexTupleExtractor<N, T, O...>::ValType& array_get(IndexTuple<T, O...>& tuple) {}
template <int N, typename T, typename... O>
EIGEN_DEVICE_FUNC constexpr const typename IndexTupleExtractor<N, T, O...>::ValType& array_get(
    const IndexTuple<T, O...>& tuple) {}
array_size<IndexTuple<T, O...>>;
array_size<const IndexTuple<T, O...>>;

template <Index Idx, typename ValueT>
struct tuple_coeff {};

tuple_coeff<0, ValueT>;
}  // namespace internal

template <typename FirstType, typename... OtherTypes>
struct IndexList : internal::IndexTuple<FirstType, OtherTypes...> {};

template <typename FirstType, typename... OtherTypes>
std::ostream& operator<<(std::ostream& os, const IndexList<FirstType, OtherTypes...>& dims) {}

template <typename FirstType, typename... OtherTypes>
constexpr IndexList<FirstType, OtherTypes...> make_index_list(FirstType val1, OtherTypes... other_vals) {}

template <typename FirstType, typename... OtherTypes>
struct IndexPairList : internal::IndexTuple<FirstType, OtherTypes...> {};

namespace internal {

template <typename FirstType, typename... OtherTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index array_prod(const IndexList<FirstType, OtherTypes...>& sizes) {}

array_size<IndexList<FirstType, OtherTypes...>>;
array_size<const IndexList<FirstType, OtherTypes...>>;

array_size<IndexPairList<FirstType, OtherTypes...>>;
array_size<const IndexPairList<FirstType, OtherTypes...>>;

template <Index N, typename FirstType, typename... OtherTypes>
EIGEN_DEVICE_FUNC constexpr Index array_get(IndexList<FirstType, OtherTypes...>& a) {}
template <Index N, typename FirstType, typename... OtherTypes>
EIGEN_DEVICE_FUNC constexpr Index array_get(const IndexList<FirstType, OtherTypes...>& a) {}

template <typename T>
struct index_known_statically_impl {};

index_known_statically_impl<IndexList<FirstType, OtherTypes...>>;

index_known_statically_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename T>
struct all_indices_known_statically_impl {};

all_indices_known_statically_impl<IndexList<FirstType, OtherTypes...>>;

all_indices_known_statically_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename T>
struct indices_statically_known_to_increase_impl {};

indices_statically_known_to_increase_impl<IndexList<FirstType, OtherTypes...>>;

indices_statically_known_to_increase_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename Tx>
struct index_statically_eq_impl {};

index_statically_eq_impl<IndexList<FirstType, OtherTypes...>>;

index_statically_eq_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename T>
struct index_statically_ne_impl {};

index_statically_ne_impl<IndexList<FirstType, OtherTypes...>>;

index_statically_ne_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename T>
struct index_statically_gt_impl {};

index_statically_gt_impl<IndexList<FirstType, OtherTypes...>>;

index_statically_gt_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename T>
struct index_statically_lt_impl {};

index_statically_lt_impl<IndexList<FirstType, OtherTypes...>>;

index_statically_lt_impl<const IndexList<FirstType, OtherTypes...>>;

template <typename Tx>
struct index_pair_first_statically_eq_impl {};

index_pair_first_statically_eq_impl<IndexPairList<FirstType, OtherTypes...>>;

index_pair_first_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...>>;

template <typename Tx>
struct index_pair_second_statically_eq_impl {};

index_pair_second_statically_eq_impl<IndexPairList<FirstType, OtherTypes...>>;

index_pair_second_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...>>;

}  // end namespace internal
}  // end namespace Eigen

namespace Eigen {
namespace internal {
template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_known_statically(Index i) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool all_indices_known_statically() {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool indices_statically_known_to_increase() {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_eq(Index i, Index value) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_ne(Index i, Index value) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_gt(Index i, Index value) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_lt(Index i, Index value) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_pair_first_statically_eq(Index i, Index value) {}

template <typename T>
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_pair_second_statically_eq(Index i, Index value) {}

}  // end namespace internal
}  // end namespace Eigen

#endif  // EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H