diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-01-23 18:22:18 -0500 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-01-23 18:22:18 -0500 |
commit | 8df5bca979cc6acdf85215fda611e45211ed09ae (patch) | |
tree | 370abfb73b0b202faa07660703c47cdec4a9c3a0 | |
parent | cc1f70abc3a8599ad256eeb206a0b82e42109a21 (diff) |
rename build stages to multiples of 10; old stage 2 becomes stage 15, while stage 20 generates errors (instead of warnings) on conflicting API.
-rw-r--r-- | Eigen/Core | 40 | ||||
-rw-r--r-- | Eigen/src/Core/Dot.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Map.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 14 | ||||
-rw-r--r-- | Eigen/src/Eigen2Support/Meta.h | 53 | ||||
-rw-r--r-- | test/eigen2/CMakeLists.txt | 2 |
6 files changed, 86 insertions, 33 deletions
diff --git a/Eigen/Core b/Eigen/Core index 9b58dc28c..52307a717 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -221,31 +221,35 @@ 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 STAGE4_FULL_EIGEN3_STRICTNESS 4 -#define STAGE9_NO_EIGEN2_SUPPORT 9 - -#ifdef EIGEN2_SUPPORT_STAGE1_FULL_EIGEN2_API +#define STAGE10_FULL_EIGEN2_API 10 +#define STAGE15_RESOLVE_API_CONFLICTS_WARN 15 +#define STAGE20_RESOLVE_API_CONFLICTS 20 +#define STAGE30_FULL_EIGEN3_API 30 +#define STAGE40_FULL_EIGEN3_STRICTNESS 40 +#define STAGE99_NO_EIGEN2_SUPPORT 99 + +#ifdef EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API + #define EIGEN2_SUPPORT + #define EIGEN2_SUPPORT_STAGE STAGE10_FULL_EIGEN2_API +#elif defined EIGEN2_SUPPORT_STAGE15_RESOLVE_API_CONFLICTS_WARN #define EIGEN2_SUPPORT - #define EIGEN2_SUPPORT_STAGE STAGE1_FULL_EIGEN2_API -#elif defined EIGEN2_SUPPORT_STAGE2_RESOLVE_API_CONFLICTS + #define EIGEN2_SUPPORT_STAGE STAGE15_RESOLVE_API_CONFLICTS_WARN +#elif defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS #define EIGEN2_SUPPORT - #define EIGEN2_SUPPORT_STAGE STAGE2_RESOLVE_API_CONFLICTS -#elif defined EIGEN2_SUPPORT_STAGE3_FULL_EIGEN3_API + #define EIGEN2_SUPPORT_STAGE STAGE20_RESOLVE_API_CONFLICTS +#elif defined EIGEN2_SUPPORT_STAGE30_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_STAGE STAGE30_FULL_EIGEN3_API +#elif defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS #define EIGEN2_SUPPORT - #define EIGEN2_SUPPORT_STAGE STAGE4_FULL_EIGEN3_STRICTNESS + #define EIGEN2_SUPPORT_STAGE STAGE40_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 - #define EIGEN2_SUPPORT_STAGE STAGE3_FULL_EIGEN3_API + #define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API + #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API #else - #define EIGEN2_SUPPORT_STAGE STAGE9_NO_EIGEN2_SUPPORT -#endif + #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT +#endif #ifdef EIGEN2_SUPPORT #undef minor diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 4f6219540..16496273c 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -81,19 +81,19 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const eigen_assert(size() == other.size()); -#if EIGEN2_SUPPORT_STAGE >= STAGE3_FULL_EIGEN3_API +#if EIGEN2_SUPPORT_STAGE >= STAGE30_FULL_EIGEN3_API return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other); #else return internal::dot_nocheck<OtherDerived,Derived>::run(other,*this); #endif } -#if EIGEN2_SUPPORT_STAGE <= STAGE3_FULL_EIGEN3_API +#if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API /** \returns the dot product of *this with other, with the Eigen2 convention that the dot product is linear in the first variable * (conjugating the second variable). Of course this only makes a difference in the complex case. * - * This method is only available in EIGEN2_SUPPORT mode. With EIGEN2_SUPPORT_STAGE1_FULL_EIGEN2_API and - * EIGEN2_SUPPORT_STAGE2_RESOLVE_API_CONFLICTS, the dot() method itself uses it. With EIGEN2_SUPPORT_STAGE3_FULL_EIGEN3_API, + * This method is only available in EIGEN2_SUPPORT mode. With EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API and + * EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS, the dot() method itself uses it. With EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API, * the dot() method no longer uses it, but it's still available. * * \only_for_vectors diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 0823376ab..f78e87e39 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -124,7 +124,7 @@ 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 +#if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API typedef const Scalar* PointerArgType; inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); } #else diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 82377f235..510e7115d 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -200,15 +200,17 @@ template<typename Derived> class MatrixBase const DiagonalProduct<Derived, DiagonalDerived, OnTheRight> operator*(const DiagonalBase<DiagonalDerived> &diagonal) const; - template<typename OtherDerived> - #if EIGEN2_SUPPORT_STAGE == STAGE2_RESOLVE_API_CONFLICTS - EIGEN_DEPRECATED + #if EIGEN2_SUPPORT_STAGE != STAGE20_RESOLVE_API_CONFLICTS + template<typename OtherDerived> + #if EIGEN2_SUPPORT_STAGE == STAGE15_RESOLVE_API_CONFLICTS_WARN + EIGEN_DEPRECATED + #endif + Scalar dot(const MatrixBase<OtherDerived>& other) const; #endif - Scalar dot(const MatrixBase<OtherDerived>& other) const; - #if EIGEN2_SUPPORT_STAGE <= STAGE3_FULL_EIGEN3_API + #if EIGEN2_SUPPORT_STAGE != STAGE99_NO_EIGEN2_SUPPORT template<typename OtherDerived> - #if EIGEN2_SUPPORT_STAGE >= STAGE3_FULL_EIGEN3_API + #if EIGEN2_SUPPORT_STAGE >= STAGE30_FULL_EIGEN3_API EIGEN_DEPRECATED #endif Scalar eigen2_dot(const MatrixBase<OtherDerived>& other) const; diff --git a/Eigen/src/Eigen2Support/Meta.h b/Eigen/src/Eigen2Support/Meta.h index f78db2b8d..6e500b79a 100644 --- a/Eigen/src/Eigen2Support/Meta.h +++ b/Eigen/src/Eigen2Support/Meta.h @@ -29,11 +29,58 @@ template<typename T> struct ei_traits : internal::traits<T> {}; -template<typename T, typename U> -struct ei_is_same_type +struct ei_meta_true { enum { ret = 1 }; }; +struct ei_meta_false { enum { ret = 0 }; }; + +template<bool Condition, typename Then, typename Else> +struct ei_meta_if { typedef Then ret; }; + +template<typename Then, typename Else> +struct ei_meta_if <false, Then, Else> { typedef Else ret; }; + +template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; }; +template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; }; + +template<typename T> struct ei_unref { typedef T type; }; +template<typename T> struct ei_unref<T&> { typedef T type; }; + +template<typename T> struct ei_unpointer { typedef T type; }; +template<typename T> struct ei_unpointer<T*> { typedef T type; }; +template<typename T> struct ei_unpointer<T*const> { typedef T type; }; + +template<typename T> struct ei_unconst { typedef T type; }; +template<typename T> struct ei_unconst<const T> { typedef T type; }; +template<typename T> struct ei_unconst<T const &> { typedef T & type; }; +template<typename T> struct ei_unconst<T const *> { typedef T * type; }; + +template<typename T> struct ei_cleantype { typedef T type; }; +template<typename T> struct ei_cleantype<const T> { typedef typename ei_cleantype<T>::type type; }; +template<typename T> struct ei_cleantype<const T&> { typedef typename ei_cleantype<T>::type type; }; +template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleantype<T>::type type; }; +template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; }; +template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; }; + +/** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. + * Usage example: \code ei_meta_sqrt<1023>::ret \endcode + */ +template<int Y, + int InfX = 0, + int SupX = ((Y==1) ? 1 : Y/2), + bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) > + // use ?: instead of || just to shut up a stupid gcc 4.3 warning +class ei_meta_sqrt { - enum { ret = internal::is_same<T, U>::value }; + enum { + MidX = (InfX+SupX)/2, + TakeInf = MidX*MidX > Y ? 1 : 0, + NewInf = int(TakeInf) ? InfX : int(MidX), + NewSup = int(TakeInf) ? int(MidX) : SupX + }; + public: + enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret }; }; +template<int Y, int InfX, int SupX> +class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; #endif // EIGEN2_META_H diff --git a/test/eigen2/CMakeLists.txt b/test/eigen2/CMakeLists.txt index 3ca6f5e73..9b128396f 100644 --- a/test/eigen2/CMakeLists.txt +++ b/test/eigen2/CMakeLists.txt @@ -2,7 +2,7 @@ add_custom_target(buildtests_eigen2) add_custom_target(check_eigen2 COMMAND "ctest") add_dependencies(check_eigen2 buildtests_eigen2) -add_definitions("-DEIGEN2_SUPPORT_STAGE1_FULL_EIGEN2_API") +add_definitions("-DEIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API") # Macro to add a test # |