diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-05-12 18:09:30 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-05-12 18:09:30 +0000 |
commit | 4317fad8692eabe09bcafdd88de254deb8e3ea6f (patch) | |
tree | 63a1980526cda03e564440cf355fcae5e0d6af3b /Eigen | |
parent | 678f18fce4dec90ffa97b2fb3a92d572fb64c059 (diff) |
* Added several cast to int of the enums (needed for some compilers)
* Fix a mistake in CwiseNullary.
* Added a CoreDeclarions header that declares only the forward declarations
and related basic stuffs.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/Core | 39 | ||||
-rw-r--r-- | Eigen/CoreDeclarations | 47 | ||||
-rw-r--r-- | Eigen/src/Core/Assign.h | 22 | ||||
-rw-r--r-- | Eigen/src/Core/Coeffs.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/CwiseBinaryOp.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/CwiseNullaryOp.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/DiagonalCoeffs.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Dot.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 7 | ||||
-rw-r--r-- | Eigen/src/Core/Minor.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Redux.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Transpose.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/TriangularAssign.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/Visitor.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 10 |
16 files changed, 93 insertions, 78 deletions
diff --git a/Eigen/Core b/Eigen/Core index dfe18fe43..82ca1f165 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -1,39 +1,7 @@ #ifndef EIGEN_CORE_H #define EIGEN_CORE_H -#define EIGEN_WIP_PRODUCT - -#ifdef __GNUC__ -#define EIGEN_GNUC_AT_LEAST(x,y) (__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x -#else -#define EIGEN_GNUC_AT_LEAST(x,y) false -#endif - -#ifndef EIGEN_DONT_VECTORIZE - #if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) ) - #define EIGEN_VECTORIZE - #define EIGEN_VECTORIZE_SSE - #include <emmintrin.h> - #include <xmmintrin.h> - #ifdef __SSE3__ - #include <pmmintrin.h> - #endif - #ifdef __SSSE3__ - #include <tmmintrin.h> - #endif - #elif (defined __ALTIVEC__) - #define EIGEN_VECTORIZE - #define EIGEN_VECTORIZE_ALTIVEC - #include <altivec.h> - // We _need_ to #undef bool as it's defined in <altivec.h> for some reason. - #undef bool - #endif -#endif - -#include <cstdlib> -#include <cmath> -#include <complex> -#include <cassert> +#include "CoreDeclarations" #include <iostream> #ifdef EIGEN_VECTORIZE @@ -43,11 +11,6 @@ extern "C" int posix_memalign (void **, size_t, size_t) throw (); namespace Eigen { -#include "src/Core/util/Macros.h" -#include "src/Core/util/Constants.h" -#include "src/Core/util/ForwardDeclarations.h" -#include "src/Core/util/Meta.h" - #include "src/Core/NumTraits.h" #include "src/Core/MathFunctions.h" #include "src/Core/DummyPacketMath.h" diff --git a/Eigen/CoreDeclarations b/Eigen/CoreDeclarations new file mode 100644 index 000000000..9a44e4dc3 --- /dev/null +++ b/Eigen/CoreDeclarations @@ -0,0 +1,47 @@ +#ifndef EIGEN_CORE_DECLARATIONS_H +#define EIGEN_CORE_DECLARATIONS_H + +#define EIGEN_WIP_PRODUCT + +#ifdef __GNUC__ +#define EIGEN_GNUC_AT_LEAST(x,y) (__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x +#else +#define EIGEN_GNUC_AT_LEAST(x,y) false +#endif + +#ifndef EIGEN_DONT_VECTORIZE + #if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) ) + #define EIGEN_VECTORIZE + #define EIGEN_VECTORIZE_SSE + #include <emmintrin.h> + #include <xmmintrin.h> + #ifdef __SSE3__ + #include <pmmintrin.h> + #endif + #ifdef __SSSE3__ + #include <tmmintrin.h> + #endif + #elif (defined __ALTIVEC__) + #define EIGEN_VECTORIZE + #define EIGEN_VECTORIZE_ALTIVEC + #include <altivec.h> + // We _need_ to #undef bool as it's defined in <altivec.h> for some reason. + #undef bool + #endif +#endif + +#include <cstdlib> +#include <cmath> +#include <complex> +#include <cassert> + +namespace Eigen { + +#include "src/Core/util/Macros.h" +#include "src/Core/util/Constants.h" +#include "src/Core/util/ForwardDeclarations.h" +#include "src/Core/util/Meta.h" + +} // namespace Eigen + +#endif // EIGEN_CORE_DECLARATIONS_H diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index bf57b3754..1eb88d8ff 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -70,8 +70,8 @@ template<typename Derived1, typename Derived2, int Index> struct ei_matrix_assignment_packet_unroller { enum { - row = Derived1::Flags&RowMajorBit ? Index / Derived1::ColsAtCompileTime : Index % Derived1::RowsAtCompileTime, - col = Derived1::Flags&RowMajorBit ? Index % Derived1::ColsAtCompileTime : Index / Derived1::RowsAtCompileTime + row = int(Derived1::Flags)&RowMajorBit ? Index / int(Derived1::ColsAtCompileTime) : Index % Derived1::RowsAtCompileTime, + col = int(Derived1::Flags)&RowMajorBit ? Index % int(Derived1::ColsAtCompileTime) : Index / Derived1::RowsAtCompileTime }; inline static void run(Derived1 &dst, const Derived2 &src) @@ -99,12 +99,12 @@ struct ei_matrix_assignment_packet_unroller<Derived1, Derived2, Dynamic> }; template <typename Derived, typename OtherDerived, -bool Vectorize = (Derived::Flags & OtherDerived::Flags & VectorizableBit) - && ((Derived::Flags&RowMajorBit)==(OtherDerived::Flags&RowMajorBit)) - && ( (Derived::Flags & OtherDerived::Flags & Like1DArrayBit) - ||((Derived::Flags&RowMajorBit) - ? Derived::ColsAtCompileTime!=Dynamic && (Derived::ColsAtCompileTime%ei_packet_traits<typename Derived::Scalar>::size==0) - : Derived::RowsAtCompileTime!=Dynamic && (Derived::RowsAtCompileTime%ei_packet_traits<typename Derived::Scalar>::size==0)) ), +bool Vectorize = (int(Derived::Flags) & int(OtherDerived::Flags) & VectorizableBit) + && ((int(Derived::Flags)&RowMajorBit)==(int(OtherDerived::Flags)&RowMajorBit)) + && ( (int(Derived::Flags) & int(OtherDerived::Flags) & Like1DArrayBit) + ||((int(Derived::Flags)&RowMajorBit) + ? int(Derived::ColsAtCompileTime)!=Dynamic && (int(Derived::ColsAtCompileTime)%ei_packet_traits<typename Derived::Scalar>::size==0) + : int(Derived::RowsAtCompileTime)!=Dynamic && (int(Derived::RowsAtCompileTime)%ei_packet_traits<typename Derived::Scalar>::size==0)) ), bool TriangularAssign = Derived::Flags & (NullLowerBit | NullUpperBit)> struct ei_assignment_impl; @@ -156,7 +156,7 @@ struct ei_assignment_impl<Derived, OtherDerived, false, false> { ei_matrix_assignment_unroller <Derived, OtherDerived, - unroll ? Derived::SizeAtCompileTime : Dynamic + unroll ? int(Derived::SizeAtCompileTime) : Dynamic >::run(dst.derived(), src.derived()); } else @@ -190,8 +190,8 @@ struct ei_assignment_impl<Derived, OtherDerived, true, false> // std::cout << "vectorized unrolled\n"; ei_matrix_assignment_packet_unroller <Derived, OtherDerived, - unroll && int(Derived::SizeAtCompileTime)>=ei_packet_traits<typename Derived::Scalar>::size - ? Derived::SizeAtCompileTime-ei_packet_traits<typename Derived::Scalar>::size + unroll && int(Derived::SizeAtCompileTime)>=int(ei_packet_traits<typename Derived::Scalar>::size) + ? int(Derived::SizeAtCompileTime)-int(ei_packet_traits<typename Derived::Scalar>::size) : Dynamic>::run(dst.const_cast_derived(), src.derived()); } else diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h index 28845cd95..b58b2e0d2 100644 --- a/Eigen/src/Core/Coeffs.h +++ b/Eigen/src/Core/Coeffs.h @@ -256,7 +256,7 @@ template<typename Derived> template<int StoreMode> inline void MatrixBase<Derived>::writePacketCoeff (int row, int col, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x) -{ return derived().template _writePacketCoeff<StoreMode>(row,col,x); } +{ derived().template _writePacketCoeff<StoreMode>(row,col,x); } #endif // EIGEN_COEFFS_H diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index daa81ddb7..dde7de437 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -68,11 +68,11 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > ColsAtCompileTime = Lhs::ColsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime, - Flags = ((LhsFlags | RhsFlags) & ( + Flags = ((int(LhsFlags) | int(RhsFlags)) & ( DefaultLostFlagMask | Like1DArrayBit - | (ei_functor_traits<BinaryOp>::IsVectorizable && ((LhsFlags & RowMajorBit)==(RhsFlags & RowMajorBit)) - ? LhsFlags & RhsFlags & VectorizableBit : 0))), + | (ei_functor_traits<BinaryOp>::IsVectorizable && ((int(LhsFlags) & RowMajorBit)==(int(RhsFlags) & RowMajorBit)) + ? int(LhsFlags) & int(RhsFlags) & VectorizableBit : 0))), CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + ei_functor_traits<BinaryOp>::Cost }; }; diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index ee986de48..8e28919bb 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -155,7 +155,7 @@ template<typename CustomNullaryOp> const CwiseNullaryOp<CustomNullaryOp, Derived> MatrixBase<Derived>::create(const CustomNullaryOp& func) { - return CwiseNullaryOp<CustomNullaryOp, Derived>(rows(), cols(), func); + return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func); } /** \returns an expression of a constant matrix of value \a value diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h index b9471e7a1..38866d95d 100644 --- a/Eigen/src/Core/DiagonalCoeffs.h +++ b/Eigen/src/Core/DiagonalCoeffs.h @@ -46,11 +46,11 @@ struct ei_traits<DiagonalCoeffs<MatrixType> > typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { - RowsAtCompileTime = MatrixType::SizeAtCompileTime == Dynamic ? Dynamic + RowsAtCompileTime = int(MatrixType::SizeAtCompileTime) == Dynamic ? Dynamic : EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime), ColsAtCompileTime = 1, - MaxRowsAtCompileTime = MatrixType::MaxSizeAtCompileTime == Dynamic ? Dynamic + MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic : EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime), MaxColsAtCompileTime = 1, diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 28a93e71d..b0ec14a33 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -85,11 +85,11 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const Scalar res; const bool unroll = SizeAtCompileTime * (_Nested::CoeffReadCost + _OtherNested::CoeffReadCost + NumTraits<Scalar>::MulCost) - + (SizeAtCompileTime - 1) * NumTraits<Scalar>::AddCost + + (int(SizeAtCompileTime) - 1) * NumTraits<Scalar>::AddCost <= EIGEN_UNROLLING_LIMIT; if(unroll) - ei_dot_unroller<SizeAtCompileTime-1, - unroll ? SizeAtCompileTime : Dynamic, + ei_dot_unroller<int(SizeAtCompileTime)-1, + unroll ? int(SizeAtCompileTime) : Dynamic, _Nested, _OtherNested> ::run(nested, otherNested, res); else @@ -135,7 +135,7 @@ template<typename Derived> inline const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::normalized() const { - return (*this) * (Scalar(1)/norm()); + return (*this) * (RealScalar(1)/norm()); } /** \returns true if *this is approximately orthogonal to \a other, diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 5ba37c076..557b93f56 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -46,7 +46,7 @@ inline int ei_log(int) { ei_assert(false); return 0; } inline int ei_sin(int) { ei_assert(false); return 0; } inline int ei_cos(int) { ei_assert(false); return 0; } -#if EIGEN_GNUC_AT_LEAST(4,2) +#if (!(EIGEN_GNUC_AT_LEAST(4,3))) inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); } #else inline int ei_pow(int x, int y) { return std::pow(x, y); } diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 9078e5677..d14fec1f1 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -396,7 +396,7 @@ template<typename Derived> class MatrixBase bool isOrtho(const MatrixBase<OtherDerived>& other, RealScalar prec = precision<Scalar>()) const; bool isOrtho(RealScalar prec = precision<Scalar>()) const; - + template<typename OtherDerived> inline bool operator==(const MatrixBase<OtherDerived>& other) const { return derived().cwiseEqualTo(other.derived()).all(); } @@ -563,6 +563,11 @@ template<typename Derived> class MatrixBase //@{ const QR<typename ei_eval<Derived>::type> qr() const; //@} + + + #ifdef EIGEN_MATRIX_CUSTOM_ADDONS_FILE + #include EIGEN_MATRIX_CUSTOM_ADDONS_FILE + #endif }; diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index 4a0edc3a3..d7e08c4e0 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -45,13 +45,13 @@ struct ei_traits<Minor<MatrixType> > typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? - MatrixType::RowsAtCompileTime - 1 : Dynamic, + int(MatrixType::RowsAtCompileTime) - 1 : Dynamic, ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? - MatrixType::ColsAtCompileTime - 1 : Dynamic, + int(MatrixType::ColsAtCompileTime) - 1 : Dynamic, MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ? - MatrixType::MaxRowsAtCompileTime - 1 : Dynamic, + int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic, MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? - MatrixType::MaxColsAtCompileTime - 1 : Dynamic, + int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic, Flags = _MatrixTypeNested::Flags & DefaultLostFlagMask, CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 5b14f5b27..5672effc7 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -94,7 +94,7 @@ struct ei_traits<PartialRedux<Direction, BinaryOp, MatrixType> > ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime, - Flags = ((RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) + Flags = ((int(RowsAtCompileTime) == Dynamic || int(ColsAtCompileTime) == Dynamic) ? (unsigned int)_MatrixTypeNested::Flags : (unsigned int)_MatrixTypeNested::Flags & ~LargeBit) & DefaultLostFlagMask, TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime, @@ -182,7 +182,7 @@ MatrixBase<Derived>::redux(const BinaryOp& func) const <= EIGEN_UNROLLING_LIMIT; if(unroll) return ei_redux_unroller<BinaryOp, Derived, 0, - unroll ? SizeAtCompileTime : Dynamic> + unroll ? int(SizeAtCompileTime) : Dynamic> ::run(derived(), func); else { @@ -304,7 +304,7 @@ bool MatrixBase<Derived>::all(void) const <= EIGEN_UNROLLING_LIMIT; if(unroll) return ei_all_unroller<Derived, - unroll ? SizeAtCompileTime : Dynamic + unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived()); else { @@ -326,7 +326,7 @@ bool MatrixBase<Derived>::any(void) const <= EIGEN_UNROLLING_LIMIT; if(unroll) return ei_any_unroller<Derived, - unroll ? SizeAtCompileTime : Dynamic + unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived()); else { diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index e7f37bbae..5d4cbd2f4 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -48,7 +48,7 @@ struct ei_traits<Transpose<MatrixType> > ColsAtCompileTime = MatrixType::RowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - Flags = _MatrixTypeNested::Flags ^ RowMajorBit, + Flags = int(_MatrixTypeNested::Flags) ^ RowMajorBit, CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; diff --git a/Eigen/src/Core/TriangularAssign.h b/Eigen/src/Core/TriangularAssign.h index ec208f2ad..7b1be135e 100644 --- a/Eigen/src/Core/TriangularAssign.h +++ b/Eigen/src/Core/TriangularAssign.h @@ -80,7 +80,7 @@ struct ei_assignment_impl<Derived, OtherDerived, DummyVectorize, true> if(unroll) { ei_triangular_assign_unroller - <Derived, OtherDerived, unroll ? Derived::SizeAtCompileTime : Dynamic, Derived::Flags>::run + <Derived, OtherDerived, unroll ? int(Derived::SizeAtCompileTime) : Dynamic, Derived::Flags>::run (dst.derived(), src.derived()); } else diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 9dd8ef661..6e00e4142 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -79,7 +79,7 @@ void MatrixBase<Derived>::visit(Visitor& visitor) const <= EIGEN_UNROLLING_LIMIT; if(unroll) return ei_visitor_unroller<Visitor, Derived, - unroll ? SizeAtCompileTime : Dynamic + unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived(), visitor); else { diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 264802b9b..3c4596d4c 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -158,9 +158,9 @@ class ei_corrected_matrix_flags }; public: - enum { ret = is_vectorizable - ? _flags1 | VectorizableBit - : _flags1 & ~VectorizableBit + enum { ret = int(is_vectorizable) + ? int(_flags1) | int(VectorizableBit) + : int(_flags1) & ~int(VectorizableBit) }; }; @@ -208,8 +208,8 @@ template<typename T, int n=1> struct ei_nested ei_is_temporary<T>::ret, T, typename ei_meta_if< - ei_traits<T>::Flags & EvalBeforeNestingBit - || (n+1) * NumTraits<typename ei_traits<T>::Scalar>::ReadCost < (n-1) * T::CoeffReadCost, + int(ei_traits<T>::Flags) & EvalBeforeNestingBit + || (n+1) * int(NumTraits<typename ei_traits<T>::Scalar>::ReadCost) < (n-1) * int(T::CoeffReadCost), typename ei_eval<T>::type, const T& >::ret |