Warning, file /include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_CXX11_TENSOR_TENSOR_INITIALIZER_H
0011 #define EIGEN_CXX11_TENSOR_TENSOR_INITIALIZER_H
0012
0013 #if EIGEN_HAS_VARIADIC_TEMPLATES
0014
0015 #include <initializer_list>
0016
0017 namespace Eigen {
0018
0019
0020
0021
0022
0023
0024 namespace internal {
0025
0026 template <typename Derived, int N>
0027 struct Initializer {
0028 typedef std::initializer_list<
0029 typename Initializer<Derived, N - 1>::InitList> InitList;
0030
0031 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor,
0032 Eigen::array<typename traits<Derived>::Index, traits<Derived>::NumDimensions>* indices,
0033 const InitList& vals) {
0034 int i = 0;
0035 for (const auto& v : vals) {
0036 (*indices)[traits<Derived>::NumDimensions - N] = i++;
0037 Initializer<Derived, N - 1>::run(tensor, indices, v);
0038 }
0039 }
0040 };
0041
0042 template <typename Derived>
0043 struct Initializer<Derived, 1> {
0044 typedef std::initializer_list<typename traits<Derived>::Scalar> InitList;
0045
0046 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor,
0047 Eigen::array<typename traits<Derived>::Index, traits<Derived>::NumDimensions>* indices,
0048 const InitList& vals) {
0049 int i = 0;
0050
0051 for (const auto& v : vals) {
0052 (*indices)[traits<Derived>::NumDimensions - 1] = i++;
0053 tensor.coeffRef(*indices) = v;
0054 }
0055 }
0056 };
0057
0058 template <typename Derived>
0059 struct Initializer<Derived, 0> {
0060 typedef typename traits<Derived>::Scalar InitList;
0061
0062 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor,
0063 Eigen::array<typename traits<Derived>::Index, traits<Derived>::NumDimensions>*,
0064 const InitList& v) {
0065 tensor.coeffRef(0) = v;
0066 }
0067 };
0068
0069
0070 template <typename Derived, int N>
0071 void initialize_tensor(TensorEvaluator<Derived, DefaultDevice>& tensor,
0072 const typename Initializer<Derived, traits<Derived>::NumDimensions>::InitList& vals) {
0073 Eigen::array<typename traits<Derived>::Index, traits<Derived>::NumDimensions> indices;
0074 Initializer<Derived, traits<Derived>::NumDimensions>::run(tensor, &indices, vals);
0075 }
0076
0077 }
0078 }
0079
0080 #endif
0081
0082 #endif