This commit is contained in:
Gael Guennebaud 2015-02-06 14:27:12 +01:00
commit b50ffaddf2
6 changed files with 24 additions and 6 deletions

View File

@ -133,6 +133,12 @@
#define EIGEN_HAS_VARIADIC_TEMPLATES 1 #define EIGEN_HAS_VARIADIC_TEMPLATES 1
#endif #endif
// Does the compiler support const expressions?
#if (defined(__plusplus) && __cplusplus >= 201402L) || \
EIGEN_GNUC_AT_LEAST(4,9)
#define EIGEN_HAS_CONSTEXPR 1
#endif
/** Allows to disable some optimizations which might affect the accuracy of the result. /** Allows to disable some optimizations which might affect the accuracy of the result.
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them. * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
* They currently include: * They currently include:

View File

@ -10,7 +10,7 @@
#ifndef EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H #ifndef EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
#define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H #define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
#if __cplusplus > 199711L #ifdef EIGEN_HAS_CONSTEXPR
namespace Eigen { namespace Eigen {

View File

@ -53,7 +53,7 @@ struct preserve_inner_most_dims {
static const bool value = false; static const bool value = false;
}; };
#if __cplusplus > 199711L #ifdef EIGEN_HAS_CONSTEXPR
template <typename ReducedDims, int NumTensorDims> template <typename ReducedDims, int NumTensorDims>
struct are_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{ struct are_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{
static const bool value = indices_statically_known_to_increase<ReducedDims>()() && static const bool value = indices_statically_known_to_increase<ReducedDims>()() &&

View File

@ -114,7 +114,15 @@ static void test_static_broadcasting()
{ {
Tensor<float, 3, DataLayout> tensor(8,3,5); Tensor<float, 3, DataLayout> tensor(8,3,5);
tensor.setRandom(); tensor.setRandom();
#ifdef EIGEN_HAS_CONSTEXPR
Eigen::IndexList<Eigen::type2index<2>, Eigen::type2index<3>, Eigen::type2index<4>> broadcasts; Eigen::IndexList<Eigen::type2index<2>, Eigen::type2index<3>, Eigen::type2index<4>> broadcasts;
#else
Eigen::array<int, 3> broadcasts;
broadcasts[0] = 2;
broadcasts[1] = 3;
broadcasts[2] = 4;
#endif
Tensor<float, 3, DataLayout> broadcast; Tensor<float, 3, DataLayout> broadcast;
broadcast = tensor.broadcast(broadcasts); broadcast = tensor.broadcast(broadcasts);

View File

@ -11,6 +11,7 @@
#include <Eigen/CXX11/Tensor> #include <Eigen/CXX11/Tensor>
#ifdef EIGEN_HAS_CONSTEXPR
static void test_static_index_list() static void test_static_index_list()
{ {
@ -254,11 +255,14 @@ static void test_mixed_index_list()
VERIFY_IS_APPROX(result3(0), expected); VERIFY_IS_APPROX(result3(0), expected);
} }
#endif
void test_cxx11_tensor_index_list() void test_cxx11_tensor_index_list()
{ {
#ifdef EIGEN_HAS_CONSTEXPR
CALL_SUBTEST(test_static_index_list()); CALL_SUBTEST(test_static_index_list());
CALL_SUBTEST(test_type2index_list()); CALL_SUBTEST(test_type2index_list());
CALL_SUBTEST(test_dynamic_index_list()); CALL_SUBTEST(test_dynamic_index_list());
CALL_SUBTEST(test_mixed_index_list()); CALL_SUBTEST(test_mixed_index_list());
#endif
} }

View File

@ -284,7 +284,7 @@ static void test_static_dims() {
Tensor<float, 2, DataLayout> out(72, 97); Tensor<float, 2, DataLayout> out(72, 97);
in.setRandom(); in.setRandom();
#if __cplusplus <= 199711L #ifndef EIGEN_HAS_CONSTEXPR
array<int, 2> reduction_axis; array<int, 2> reduction_axis;
reduction_axis[0] = 1; reduction_axis[0] = 1;
reduction_axis[1] = 3; reduction_axis[1] = 3;
@ -314,7 +314,7 @@ static void test_innermost_last_dims() {
in.setRandom(); in.setRandom();
// Reduce on the innermost dimensions. // Reduce on the innermost dimensions.
#if __cplusplus <= 199711L #ifndef EIGEN_HAS_CONSTEXPR
array<int, 2> reduction_axis; array<int, 2> reduction_axis;
reduction_axis[0] = 0; reduction_axis[0] = 0;
reduction_axis[1] = 1; reduction_axis[1] = 1;
@ -345,7 +345,7 @@ static void test_innermost_first_dims() {
in.setRandom(); in.setRandom();
// Reduce on the innermost dimensions. // Reduce on the innermost dimensions.
#if __cplusplus <= 199711L #ifndef EIGEN_HAS_CONSTEXPR
array<int, 2> reduction_axis; array<int, 2> reduction_axis;
reduction_axis[0] = 2; reduction_axis[0] = 2;
reduction_axis[1] = 3; reduction_axis[1] = 3;
@ -376,7 +376,7 @@ static void test_reduce_middle_dims() {
in.setRandom(); in.setRandom();
// Reduce on the innermost dimensions. // Reduce on the innermost dimensions.
#if __cplusplus <= 199711L #ifndef EIGEN_HAS_CONSTEXPR
array<int, 2> reduction_axis; array<int, 2> reduction_axis;
reduction_axis[0] = 1; reduction_axis[0] = 1;
reduction_axis[1] = 2; reduction_axis[1] = 2;