diff options
-rw-r--r-- | Eigen/Core | 12 | ||||
-rw-r--r-- | Eigen/src/Core/Map.h | 20 | ||||
-rw-r--r-- | test/eigen2/map.cpp | 4 |
3 files changed, 23 insertions, 13 deletions
diff --git a/Eigen/Core b/Eigen/Core index 2870d128e..9b58dc28c 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -221,10 +221,11 @@ inline static const char *SimdInstructionSetsInUse(void) { #endif } -#define STAGE1_FULL_EIGEN2_API 1 -#define STAGE2_RESOLVE_API_CONFLICTS 2 -#define STAGE3_FULL_EIGEN3_API 3 -#define STAGE9_NO_EIGEN2_SUPPORT 9 +#define STAGE1_FULL_EIGEN2_API 1 +#define STAGE2_RESOLVE_API_CONFLICTS 2 +#define STAGE3_FULL_EIGEN3_API 3 +#define STAGE4_FULL_EIGEN3_STRICTNESS 4 +#define STAGE9_NO_EIGEN2_SUPPORT 9 #ifdef EIGEN2_SUPPORT_STAGE1_FULL_EIGEN2_API #define EIGEN2_SUPPORT @@ -235,6 +236,9 @@ inline static const char *SimdInstructionSetsInUse(void) { #elif defined EIGEN2_SUPPORT_STAGE3_FULL_EIGEN3_API #define EIGEN2_SUPPORT #define EIGEN2_SUPPORT_STAGE STAGE3_FULL_EIGEN3_API +#elif defined EIGEN2_SUPPORT_STAGE4_FULL_EIGEN3_STRICTNESS + #define EIGEN2_SUPPORT + #define EIGEN2_SUPPORT_STAGE STAGE4_FULL_EIGEN3_STRICTNESS #elif defined EIGEN2_SUPPORT // default to stage 3, that's what it's always meant #define EIGEN2_SUPPORT_STAGE3_FULL_EIGEN3_API diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index e9534b6bb..0823376ab 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -124,7 +124,13 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma EIGEN_DENSE_PUBLIC_INTERFACE(Map) typedef typename Base::PointerType PointerType; - +#if EIGEN2_SUPPORT_STAGE <= STAGE3_FULL_EIGEN3_API + typedef const Scalar* PointerArgType; + inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); } +#else + typedef PointerType PointerArgType; + inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; } +#endif inline Index innerStride() const { @@ -144,8 +150,8 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma * \param data pointer to the array to map * \param stride optional Stride object, passing the strides. */ - inline Map(PointerType data, const StrideType& stride = StrideType()) - : Base(data), m_stride(stride) + inline Map(PointerArgType data, const StrideType& stride = StrideType()) + : Base(cast_to_pointer_type(data)), m_stride(stride) { PlainObjectType::Base::_check_template_params(); } @@ -156,8 +162,8 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma * \param size the size of the vector expression * \param stride optional Stride object, passing the strides. */ - inline Map(PointerType data, Index size, const StrideType& stride = StrideType()) - : Base(data, size), m_stride(stride) + inline Map(PointerArgType data, Index size, const StrideType& stride = StrideType()) + : Base(cast_to_pointer_type(data), size), m_stride(stride) { PlainObjectType::Base::_check_template_params(); } @@ -169,8 +175,8 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma * \param cols the number of columns of the matrix expression * \param stride optional Stride object, passing the strides. */ - inline Map(PointerType data, Index rows, Index cols, const StrideType& stride = StrideType()) - : Base(data, rows, cols), m_stride(stride) + inline Map(PointerArgType data, Index rows, Index cols, const StrideType& stride = StrideType()) + : Base(cast_to_pointer_type(data), rows, cols), m_stride(stride) { PlainObjectType::Base::_check_template_params(); } diff --git a/test/eigen2/map.cpp b/test/eigen2/map.cpp index ebdfbc8ed..3c51eec16 100644 --- a/test/eigen2/map.cpp +++ b/test/eigen2/map.cpp @@ -38,7 +38,7 @@ template<typename VectorType> void map_class_vector(const VectorType& m) Map<VectorType, Aligned>(array1, size) = VectorType::Random(size); Map<VectorType>(array2, size) = Map<VectorType>(array1, size); - Map<VectorType>(array3unaligned, size) = Map<VectorType>(array1, size); + Map<VectorType>(array3unaligned, size) = Map<VectorType>((const Scalar*)array1, size); // test non-const-correctness support in eigen2 VectorType ma1 = Map<VectorType>(array1, size); VectorType ma2 = Map<VectorType, Aligned>(array2, size); VectorType ma3 = Map<VectorType>(array3unaligned, size); @@ -65,7 +65,7 @@ template<typename MatrixType> void map_class_matrix(const MatrixType& m) for(int i = 0; i < size+1; i++) array3[i] = Scalar(1); Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3; Map<MatrixType, Aligned>(array1, rows, cols) = MatrixType::Ones(rows,cols); - Map<MatrixType>(array2, rows, cols) = Map<MatrixType>(array1, rows, cols); + Map<MatrixType>(array2, rows, cols) = Map<MatrixType>((const Scalar*)array1, rows, cols); // test non-const-correctness support in eigen2 Map<MatrixType>(array3unaligned, rows, cols) = Map<MatrixType>(array1, rows, cols); MatrixType ma1 = Map<MatrixType>(array1, rows, cols); MatrixType ma2 = Map<MatrixType, Aligned>(array2, rows, cols); |