![]() |
Eigen-unsupported
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com> 00005 // 00006 // This Source Code Form is subject to the terms of the Mozilla 00007 // Public License v. 2.0. If a copy of the MPL was not distributed 00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00009 00010 #ifndef EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H 00011 #define EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H 00012 00013 namespace Eigen { 00014 00025 template <typename Index, std::size_t Rank> struct DimensionList { 00026 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE 00027 const Index operator[] (const Index i) const { return i; } 00028 }; 00029 00030 namespace internal { 00031 00032 template<typename Index, std::size_t Rank> struct array_size<DimensionList<Index, Rank> > { 00033 static const size_t value = Rank; 00034 }; 00035 template<typename Index, std::size_t Rank> struct array_size<const DimensionList<Index, Rank> > { 00036 static const size_t value = Rank; 00037 }; 00038 00039 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(DimensionList<Index, Rank>&) { 00040 return n; 00041 } 00042 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(const DimensionList<Index, Rank>&) { 00043 return n; 00044 } 00045 00046 00047 #if EIGEN_HAS_CONSTEXPR 00048 template <typename Index, std::size_t Rank> 00049 struct index_known_statically_impl<DimensionList<Index, Rank> > { 00050 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) { 00051 return true; 00052 } 00053 }; 00054 template <typename Index, std::size_t Rank> 00055 struct index_known_statically_impl<const DimensionList<Index, Rank> > { 00056 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) { 00057 return true; 00058 } 00059 }; 00060 00061 template <typename Index, std::size_t Rank> 00062 struct all_indices_known_statically_impl<DimensionList<Index, Rank> > { 00063 EIGEN_DEVICE_FUNC static constexpr bool run() { 00064 return true; 00065 } 00066 }; 00067 template <typename Index, std::size_t Rank> 00068 struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > { 00069 EIGEN_DEVICE_FUNC static constexpr bool run() { 00070 return true; 00071 } 00072 }; 00073 00074 template <typename Index, std::size_t Rank> 00075 struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > { 00076 EIGEN_DEVICE_FUNC static constexpr bool run() { 00077 return true; 00078 } 00079 }; 00080 template <typename Index, std::size_t Rank> 00081 struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > { 00082 EIGEN_DEVICE_FUNC static constexpr bool run() { 00083 return true; 00084 } 00085 }; 00086 00087 template <typename Index, std::size_t Rank> 00088 struct index_statically_eq_impl<DimensionList<Index, Rank> > { 00089 static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00090 return i == value; 00091 } 00092 }; 00093 template <typename Index, std::size_t Rank> 00094 struct index_statically_eq_impl<const DimensionList<Index, Rank> > { 00095 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00096 return i == value; 00097 } 00098 }; 00099 00100 template <typename Index, std::size_t Rank> 00101 struct index_statically_ne_impl<DimensionList<Index, Rank> > { 00102 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00103 return i != value; 00104 } 00105 }; 00106 template <typename Index, std::size_t Rank> 00107 struct index_statically_ne_impl<const DimensionList<Index, Rank> > { 00108 static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00109 return i != value; 00110 } 00111 }; 00112 00113 template <typename Index, std::size_t Rank> 00114 struct index_statically_gt_impl<DimensionList<Index, Rank> > { 00115 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00116 return i > value; 00117 } 00118 }; 00119 template <typename Index, std::size_t Rank> 00120 struct index_statically_gt_impl<const DimensionList<Index, Rank> > { 00121 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00122 return i > value; 00123 } 00124 }; 00125 00126 template <typename Index, std::size_t Rank> 00127 struct index_statically_lt_impl<DimensionList<Index, Rank> > { 00128 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00129 return i < value; 00130 } 00131 }; 00132 template <typename Index, std::size_t Rank> 00133 struct index_statically_lt_impl<const DimensionList<Index, Rank> > { 00134 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) { 00135 return i < value; 00136 } 00137 }; 00138 00139 #else 00140 template <typename Index, std::size_t Rank> 00141 struct index_known_statically_impl<DimensionList<Index, Rank> > { 00142 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) { 00143 return true; 00144 } 00145 }; 00146 template <typename Index, std::size_t Rank> 00147 struct index_known_statically_impl<const DimensionList<Index, Rank> > { 00148 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) { 00149 return true; 00150 } 00151 }; 00152 00153 template <typename Index, std::size_t Rank> 00154 struct all_indices_known_statically_impl<DimensionList<Index, Rank> > { 00155 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() { 00156 return true; 00157 } 00158 }; 00159 template <typename Index, std::size_t Rank> 00160 struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > { 00161 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() { 00162 return true; 00163 } 00164 }; 00165 00166 template <typename Index, std::size_t Rank> 00167 struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > { 00168 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() { 00169 return true; 00170 } 00171 }; 00172 template <typename Index, std::size_t Rank> 00173 struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > { 00174 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() { 00175 return true; 00176 } 00177 }; 00178 00179 template <typename Index, std::size_t Rank> 00180 struct index_statically_eq_impl<DimensionList<Index, Rank> > { 00181 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00182 return false; 00183 } 00184 }; 00185 template <typename Index, std::size_t Rank> 00186 struct index_statically_eq_impl<const DimensionList<Index, Rank> > { 00187 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00188 return false; 00189 } 00190 }; 00191 00192 template <typename Index, std::size_t Rank> 00193 struct index_statically_ne_impl<DimensionList<Index, Rank> > { 00194 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex){ 00195 return false; 00196 } 00197 }; 00198 template <typename Index, std::size_t Rank> 00199 struct index_statically_ne_impl<const DimensionList<Index, Rank> > { 00200 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00201 return false; 00202 } 00203 }; 00204 00205 template <typename Index, std::size_t Rank> 00206 struct index_statically_gt_impl<DimensionList<Index, Rank> > { 00207 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00208 return false; 00209 } 00210 }; 00211 template <typename Index, std::size_t Rank> 00212 struct index_statically_gt_impl<const DimensionList<Index, Rank> > { 00213 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00214 return false; 00215 } 00216 }; 00217 00218 template <typename Index, std::size_t Rank> 00219 struct index_statically_lt_impl<DimensionList<Index, Rank> > { 00220 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00221 return false; 00222 } 00223 }; 00224 template <typename Index, std::size_t Rank> 00225 struct index_statically_lt_impl<const DimensionList<Index, Rank> > { 00226 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) { 00227 return false; 00228 } 00229 }; 00230 #endif 00231 00232 } // end namespace internal 00233 } // end namespace Eigen 00234 00235 00236 #endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H