Fixes compilation errors triggered when compiling the tensor contraction code with cxx11 enabled.

This commit is contained in:
Benoit Steiner
2014-06-09 10:06:57 -07:00
parent a669052f12
commit a77458a8ff
3 changed files with 27 additions and 12 deletions

View File

@@ -66,6 +66,12 @@ template<std::size_t I, class T, std::size_t N> constexpr inline T const& array_
#undef STD_GET_ARR_HACK
template <typename T> struct array_size;
template<class T, std::size_t N> struct array_size<const std::array<T,N> > {
static const size_t value = N;
};
/* Suppose you have a template of the form
* template<typename T> struct X;
* And you want to specialize it in such a way:

View File

@@ -182,23 +182,32 @@ array<t, n> repeat(t v) {
}
template<std::size_t n, typename t>
t array_prod(const array<t, n>& a) {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const array<t, n>& a) {
t prod = 1;
for (size_t i = 0; i < n; ++i) { prod *= a[i]; }
return prod;
}
template<typename t>
t array_prod(const array<t, 0>& /*a*/) {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const array<t, 0>& /*a*/) {
return 0;
}
template<std::size_t I, class T, std::size_t N> inline T& array_get(array<T,N>& a) {
template<std::size_t I, class T, std::size_t N>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(array<T,N>& a) {
return a[I];
}
template<std::size_t I, class T, std::size_t N> inline const T& array_get(const array<T,N>& a) {
template<std::size_t I, class T, std::size_t N> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const T& array_get(const array<T,N>& a) {
return a[I];
}
template <typename T> struct array_size;
template<class T, std::size_t N> struct array_size<const array<T,N> > {
static const size_t value = N;
};
struct sum_op {
template<typename A, typename B> static inline bool run(A a, B b) { return a + b; }
};