chromium/third_party/eigen3/src/Eigen/src/Core/functors/NullaryFunctors.h

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008-2016 Gael Guennebaud <[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_NULLARY_FUNCTORS_H
#define EIGEN_NULLARY_FUNCTORS_H

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

namespace Eigen {

namespace internal {

template <typename Scalar>
struct scalar_constant_op {};
functor_traits<scalar_constant_op<Scalar>>;

template <typename Scalar>
struct scalar_identity_op {};
functor_traits<scalar_identity_op<Scalar>>;

template <typename Scalar, bool IsInteger>
struct linspaced_op_impl;

linspaced_op_impl<Scalar, false>;

linspaced_op_impl<Scalar, true>;

// ----- Linspace functor ----------------------------------------------------------------

// Forward declaration (we default to random access which does not really give
// us a speed gain when using packet access but it allows to use the functor in
// nested expressions).
template <typename Scalar>
struct linspaced_op;
functor_traits<linspaced_op<Scalar>>;
template <typename Scalar>
struct linspaced_op {};

template <typename Scalar>
struct equalspaced_op {};

functor_traits<equalspaced_op<Scalar>>;

// Linear access is automatically determined from the operator() prototypes available for the given functor.
// If it exposes an operator()(i,j), then we assume the i and j coefficients are required independently
// and linear access is not possible. In all other cases, linear access is enabled.
// Users should not have to deal with this structure.
template <typename Functor>
struct functor_has_linear_access {};

// For unreliable compilers, let's specialize the has_*ary_operator
// helpers so that at least built-in nullary functors work fine.
#if !(EIGEN_COMP_MSVC || EIGEN_COMP_GNUC || (EIGEN_COMP_ICC >= 1600))
template <typename Scalar, typename IndexType>
struct has_nullary_operator<scalar_constant_op<Scalar>, IndexType> {
  enum { value = 1 };
};
template <typename Scalar, typename IndexType>
struct has_unary_operator<scalar_constant_op<Scalar>, IndexType> {
  enum { value = 0 };
};
template <typename Scalar, typename IndexType>
struct has_binary_operator<scalar_constant_op<Scalar>, IndexType> {
  enum { value = 0 };
};

template <typename Scalar, typename IndexType>
struct has_nullary_operator<scalar_identity_op<Scalar>, IndexType> {
  enum { value = 0 };
};
template <typename Scalar, typename IndexType>
struct has_unary_operator<scalar_identity_op<Scalar>, IndexType> {
  enum { value = 0 };
};
template <typename Scalar, typename IndexType>
struct has_binary_operator<scalar_identity_op<Scalar>, IndexType> {
  enum { value = 1 };
};

template <typename Scalar, typename IndexType>
struct has_nullary_operator<linspaced_op<Scalar>, IndexType> {
  enum { value = 0 };
};
template <typename Scalar, typename IndexType>
struct has_unary_operator<linspaced_op<Scalar>, IndexType> {
  enum { value = 1 };
};
template <typename Scalar, typename IndexType>
struct has_binary_operator<linspaced_op<Scalar>, IndexType> {
  enum { value = 0 };
};

template <typename Scalar, typename IndexType>
struct has_nullary_operator<scalar_random_op<Scalar>, IndexType> {
  enum { value = 1 };
};
template <typename Scalar, typename IndexType>
struct has_unary_operator<scalar_random_op<Scalar>, IndexType> {
  enum { value = 0 };
};
template <typename Scalar, typename IndexType>
struct has_binary_operator<scalar_random_op<Scalar>, IndexType> {
  enum { value = 0 };
};
#endif

}  // end namespace internal

}  // end namespace Eigen

#endif  // EIGEN_NULLARY_FUNCTORS_H