chromium/third_party/eigen3/src/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.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_DIMENSIONS_H
#define EIGEN_CXX11_TENSOR_TENSOR_DIMENSIONS_H

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

namespace Eigen {

/** \internal
 *
 * \class TensorDimensions
 * \ingroup CXX11_Tensor_Module
 *
 * \brief Set of classes used to encode and store the dimensions of a Tensor.
 *
 * The Sizes class encodes as part of the type the number of dimensions and the
 * sizes corresponding to each dimension. It uses no storage space since it is
 * entirely known at compile time.
 * The DSizes class is its dynamic sibling: the number of dimensions is known
 * at compile time but the sizes are set during execution.
 *
 * \sa Tensor
 */

// Boilerplate code
namespace internal {

template <std::ptrdiff_t n, typename Dimension>
struct dget {};

template <typename Index, std::ptrdiff_t NumIndices, std::ptrdiff_t n, bool RowMajor>
struct fixed_size_tensor_index_linearization_helper {};

fixed_size_tensor_index_linearization_helper<Index, NumIndices, 0, RowMajor>;

template <typename Index, std::ptrdiff_t n>
struct fixed_size_tensor_index_extraction_helper {};

fixed_size_tensor_index_extraction_helper<Index, 0>;

}  // end namespace internal

// Fixed size
template <typename std::ptrdiff_t... Indices>
struct Sizes {};

namespace internal {
template <typename std::ptrdiff_t... Indices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes<Indices...>&) {}
}  // namespace internal

// Boilerplate
namespace internal {
template <typename Index, std::ptrdiff_t NumIndices, std::ptrdiff_t n, bool RowMajor>
struct tensor_index_linearization_helper {};

tensor_index_linearization_helper<Index, NumIndices, 0, RowMajor>;
}  // end namespace internal

// Dynamic size
template <typename DenseIndex, int NumDims>
struct DSizes : array<DenseIndex, NumDims> {};

template <typename IndexType, int NumDims>
std::ostream& operator<<(std::ostream& os, const DSizes<IndexType, NumDims>& dims) {}

// Boilerplate
namespace internal {
template <typename Index, std::ptrdiff_t NumIndices, std::ptrdiff_t n, bool RowMajor>
struct tensor_vsize_index_linearization_helper {};

tensor_vsize_index_linearization_helper<Index, NumIndices, 0, RowMajor>;
}  // end namespace internal

namespace internal {

array_size<const DSizes<DenseIndex, NumDims>>;
array_size<DSizes<DenseIndex, NumDims>>;
array_size<const Sizes<Indices...>>;
array_size<Sizes<Indices...>>;
template <std::ptrdiff_t n, typename std::ptrdiff_t... Indices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<Indices...>&) {}
template <std::ptrdiff_t n>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<>&) {}

template <typename Dims1, typename Dims2, ptrdiff_t n, ptrdiff_t m>
struct sizes_match_below_dim {};
sizes_match_below_dim<Dims1, Dims2, n, n>;
sizes_match_below_dim<Dims1, Dims2, 0, 0>;

}  // end namespace internal

template <typename Dims1, typename Dims2>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool dimensions_match(Dims1 dims1, Dims2 dims2) {}

}  // end namespace Eigen

#endif  // EIGEN_CXX11_TENSOR_TENSOR_DIMENSIONS_H