diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-10-25 10:15:22 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-10-25 10:15:22 -0400 |
commit | 4716040703be1ee906439385d20475dcddad5ce3 (patch) | |
tree | 8efd3cf3007d8360e66f38e2d280127cbb70daa6 /Eigen/src/Core | |
parent | ca85a1f6c5fc33ac382aa2d7ba2da63d55d3223e (diff) |
bug #86 : use internal:: namespace instead of ei_ prefix
Diffstat (limited to 'Eigen/src/Core')
83 files changed, 3760 insertions, 3524 deletions
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index 03b70fa29..0861d7ab1 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h @@ -39,12 +39,14 @@ * * \sa \ref TutorialArrayClass, \ref TopicClassHierarchy */ +namespace internal { template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > +struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > { typedef ArrayXpr XprKind; typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase; }; +} template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> class Array @@ -60,7 +62,7 @@ class Array protected: template <typename Derived, typename OtherDerived, bool IsVector> - friend struct ei_conservative_resize_like_impl; + friend struct internal::conservative_resize_like_impl; using Base::m_storage; public: @@ -126,8 +128,8 @@ class Array #ifndef EIGEN_PARSED_BY_DOXYGEN // FIXME is it still needed ?? /** \internal */ - Array(ei_constructor_without_unaligned_array_assert) - : Base(ei_constructor_without_unaligned_array_assert()) + Array(internal::constructor_without_unaligned_array_assert) + : Base(internal::constructor_without_unaligned_array_assert()) { Base::_check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED @@ -145,8 +147,8 @@ class Array { Base::_check_template_params(); EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array) - ei_assert(dim > 0); - ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); + eigen_assert(dim > 0); + eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } @@ -241,7 +243,7 @@ class Array private: template<typename MatrixType, typename OtherDerived, bool SwapPointers> - friend struct ei_matrix_swap_impl; + friend struct internal::matrix_swap_impl; }; /** \defgroup arraytypedefs Global array typedefs diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index f0fbcd4ff..40a6fc8bb 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -53,16 +53,16 @@ template<typename Derived> class ArrayBase #ifndef EIGEN_PARSED_BY_DOXYGEN /** The base class for a given storage type. */ typedef ArrayBase StorageBaseType; - + typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl; - using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, - typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*; + using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar, + typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; typedef DenseBase<Derived> Base; @@ -99,17 +99,17 @@ template<typename Derived> class ArrayBase * reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either * PlainObject or const PlainObject&. */ - typedef Array<typename ei_traits<Derived>::Scalar, - ei_traits<Derived>::RowsAtCompileTime, - ei_traits<Derived>::ColsAtCompileTime, - AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<Derived>::MaxRowsAtCompileTime, - ei_traits<Derived>::MaxColsAtCompileTime + typedef Array<typename internal::traits<Derived>::Scalar, + internal::traits<Derived>::RowsAtCompileTime, + internal::traits<Derived>::ColsAtCompileTime, + AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), + internal::traits<Derived>::MaxRowsAtCompileTime, + internal::traits<Derived>::MaxColsAtCompileTime > PlainObject; /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType; + typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase @@ -129,7 +129,7 @@ template<typename Derived> class ArrayBase */ Derived& operator=(const ArrayBase& other) { - return ei_assign_selector<Derived,Derived>::run(derived(), other.derived()); + return internal::assign_selector<Derived,Derived>::run(derived(), other.derived()); } Derived& operator+=(const Scalar& scalar) @@ -185,7 +185,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & ArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other) { - SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other; return derived(); } @@ -199,7 +199,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other) { - SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other.derived(); return derived(); } @@ -213,7 +213,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & ArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other) { - SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other.derived(); return derived(); } @@ -227,7 +227,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other) { - SelfCwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_quotient_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other.derived(); return derived(); } diff --git a/Eigen/src/Core/ArrayWrapper.h b/Eigen/src/Core/ArrayWrapper.h index dc5bba443..814313f20 100644 --- a/Eigen/src/Core/ArrayWrapper.h +++ b/Eigen/src/Core/ArrayWrapper.h @@ -35,12 +35,15 @@ * * \sa MatrixBase::array(), class MatrixWrapper */ + +namespace internal { template<typename ExpressionType> -struct ei_traits<ArrayWrapper<ExpressionType> > - : public ei_traits<typename ei_cleantype<typename ExpressionType::Nested>::type > +struct traits<ArrayWrapper<ExpressionType> > + : public traits<typename cleantype<typename ExpressionType::Nested>::type > { typedef ArrayXpr XprKind; }; +} template<typename ExpressionType> class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > @@ -50,7 +53,7 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper) - typedef typename ei_nested<ExpressionType>::type NestedExpressionType; + typedef typename internal::nested<ExpressionType>::type NestedExpressionType; inline ArrayWrapper(const ExpressionType& matrix) : m_expression(matrix) {} @@ -121,12 +124,14 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > * \sa MatrixBase::matrix(), class ArrayWrapper */ +namespace internal { template<typename ExpressionType> -struct ei_traits<MatrixWrapper<ExpressionType> > - : public ei_traits<typename ei_cleantype<typename ExpressionType::Nested>::type > +struct traits<MatrixWrapper<ExpressionType> > + : public traits<typename cleantype<typename ExpressionType::Nested>::type > { typedef MatrixXpr XprKind; }; +} template<typename ExpressionType> class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> > @@ -136,7 +141,7 @@ class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> > EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper) - typedef typename ei_nested<ExpressionType>::type NestedExpressionType; + typedef typename internal::nested<ExpressionType>::type NestedExpressionType; inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {} diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 335a888f6..37b0049a2 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -27,12 +27,14 @@ #ifndef EIGEN_ASSIGN_H #define EIGEN_ASSIGN_H +namespace internal { + /*************************************************************************** * Part 1 : the logic deciding a strategy for traversal and unrolling * ***************************************************************************/ template <typename Derived, typename OtherDerived> -struct ei_assign_traits +struct assign_traits { public: enum { @@ -51,7 +53,7 @@ private: : int(Derived::Flags)&RowMajorBit ? int(Derived::MaxColsAtCompileTime) : int(Derived::MaxRowsAtCompileTime), MaxSizeAtCompileTime = Derived::SizeAtCompileTime, - PacketSize = ei_packet_traits<typename Derived::Scalar>::size + PacketSize = packet_traits<typename Derived::Scalar>::size }; enum { @@ -143,7 +145,7 @@ public: ************************/ template<typename Derived1, typename Derived2, int Index, int Stop> -struct ei_assign_DefaultTraversal_CompleteUnrolling +struct assign_DefaultTraversal_CompleteUnrolling { enum { outer = Index / Derived1::InnerSizeAtCompileTime, @@ -153,28 +155,28 @@ struct ei_assign_DefaultTraversal_CompleteUnrolling EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { dst.copyCoeffByOuterInner(outer, inner, src); - ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src); + assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src); } }; template<typename Derived1, typename Derived2, int Stop> -struct ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Stop, Stop> +struct assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Stop, Stop> { EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {} }; template<typename Derived1, typename Derived2, int Index, int Stop> -struct ei_assign_DefaultTraversal_InnerUnrolling +struct assign_DefaultTraversal_InnerUnrolling { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int outer) { dst.copyCoeffByOuterInner(outer, Index, src); - ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src, outer); + assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src, outer); } }; template<typename Derived1, typename Derived2, int Stop> -struct ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Stop, Stop> +struct assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Stop, Stop> { EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &, int) {} }; @@ -184,17 +186,17 @@ struct ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Stop, Stop> ***********************/ template<typename Derived1, typename Derived2, int Index, int Stop> -struct ei_assign_LinearTraversal_CompleteUnrolling +struct assign_LinearTraversal_CompleteUnrolling { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { dst.copyCoeff(Index, src); - ei_assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src); + assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src); } }; template<typename Derived1, typename Derived2, int Stop> -struct ei_assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Stop, Stop> +struct assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Stop, Stop> { EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {} }; @@ -204,41 +206,41 @@ struct ei_assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Stop, Sto **************************/ template<typename Derived1, typename Derived2, int Index, int Stop> -struct ei_assign_innervec_CompleteUnrolling +struct assign_innervec_CompleteUnrolling { enum { outer = Index / Derived1::InnerSizeAtCompileTime, inner = Index % Derived1::InnerSizeAtCompileTime, - JointAlignment = ei_assign_traits<Derived1,Derived2>::JointAlignment + JointAlignment = assign_traits<Derived1,Derived2>::JointAlignment }; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { dst.template copyPacketByOuterInner<Derived2, Aligned, JointAlignment>(outer, inner, src); - ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, - Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src); + assign_innervec_CompleteUnrolling<Derived1, Derived2, + Index+packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src); } }; template<typename Derived1, typename Derived2, int Stop> -struct ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, Stop, Stop> +struct assign_innervec_CompleteUnrolling<Derived1, Derived2, Stop, Stop> { EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {} }; template<typename Derived1, typename Derived2, int Index, int Stop> -struct ei_assign_innervec_InnerUnrolling +struct assign_innervec_InnerUnrolling { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int outer) { dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, Index, src); - ei_assign_innervec_InnerUnrolling<Derived1, Derived2, - Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src, outer); + assign_innervec_InnerUnrolling<Derived1, Derived2, + Index+packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src, outer); } }; template<typename Derived1, typename Derived2, int Stop> -struct ei_assign_innervec_InnerUnrolling<Derived1, Derived2, Stop, Stop> +struct assign_innervec_InnerUnrolling<Derived1, Derived2, Stop, Stop> { EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &, int) {} }; @@ -248,22 +250,22 @@ struct ei_assign_innervec_InnerUnrolling<Derived1, Derived2, Stop, Stop> ***************************************************************************/ template<typename Derived1, typename Derived2, - int Traversal = ei_assign_traits<Derived1, Derived2>::Traversal, - int Unrolling = ei_assign_traits<Derived1, Derived2>::Unrolling> -struct ei_assign_impl; + int Traversal = assign_traits<Derived1, Derived2>::Traversal, + int Unrolling = assign_traits<Derived1, Derived2>::Unrolling> +struct assign_impl; /************************ *** Default traversal *** ************************/ template<typename Derived1, typename Derived2, int Unrolling> -struct ei_assign_impl<Derived1, Derived2, InvalidTraversal, Unrolling> +struct assign_impl<Derived1, Derived2, InvalidTraversal, Unrolling> { inline static void run(Derived1 &, const Derived2 &) { } }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, NoUnrolling> +struct assign_impl<Derived1, Derived2, DefaultTraversal, NoUnrolling> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -277,24 +279,24 @@ struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, NoUnrolling> }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, CompleteUnrolling> +struct assign_impl<Derived1, Derived2, DefaultTraversal, CompleteUnrolling> { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> + assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> ::run(dst, src); } }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, InnerUnrolling> +struct assign_impl<Derived1, Derived2, DefaultTraversal, InnerUnrolling> { typedef typename Derived1::Index Index; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { const Index outerSize = dst.outerSize(); for(Index outer = 0; outer < outerSize; ++outer) - ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> + assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> ::run(dst, src, outer); } }; @@ -304,7 +306,7 @@ struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, InnerUnrolling> ***********************/ template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, LinearTraversal, NoUnrolling> +struct assign_impl<Derived1, Derived2, LinearTraversal, NoUnrolling> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -316,11 +318,11 @@ struct ei_assign_impl<Derived1, Derived2, LinearTraversal, NoUnrolling> }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, LinearTraversal, CompleteUnrolling> +struct assign_impl<Derived1, Derived2, LinearTraversal, CompleteUnrolling> { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - ei_assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> + assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> ::run(dst, src); } }; @@ -330,14 +332,14 @@ struct ei_assign_impl<Derived1, Derived2, LinearTraversal, CompleteUnrolling> **************************/ template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, NoUnrolling> +struct assign_impl<Derived1, Derived2, InnerVectorizedTraversal, NoUnrolling> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) { const Index innerSize = dst.innerSize(); const Index outerSize = dst.outerSize(); - const Index packetSize = ei_packet_traits<typename Derived1::Scalar>::size; + const Index packetSize = packet_traits<typename Derived1::Scalar>::size; for(Index outer = 0; outer < outerSize; ++outer) for(Index inner = 0; inner < innerSize; inner+=packetSize) dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, inner, src); @@ -345,24 +347,24 @@ struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, NoUnrolling> }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, CompleteUnrolling> +struct assign_impl<Derived1, Derived2, InnerVectorizedTraversal, CompleteUnrolling> { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> + assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime> ::run(dst, src); } }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, InnerUnrolling> +struct assign_impl<Derived1, Derived2, InnerVectorizedTraversal, InnerUnrolling> { typedef typename Derived1::Index Index; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { const Index outerSize = dst.outerSize(); for(Index outer = 0; outer < outerSize; ++outer) - ei_assign_innervec_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> + assign_innervec_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> ::run(dst, src, outer); } }; @@ -372,14 +374,14 @@ struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, InnerUnrolli ***************************/ template <bool IsAligned = false> -struct ei_unaligned_assign_impl +struct unaligned_assign_impl { template <typename Derived, typename OtherDerived> static EIGEN_STRONG_INLINE void run(const Derived&, OtherDerived&, typename Derived::Index, typename Derived::Index) {} }; template <> -struct ei_unaligned_assign_impl<false> +struct unaligned_assign_impl<false> { // MSVC must not inline this functions. If it does, it fails to optimize the // packet access path. @@ -397,45 +399,45 @@ struct ei_unaligned_assign_impl<false> }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, LinearVectorizedTraversal, NoUnrolling> +struct assign_impl<Derived1, Derived2, LinearVectorizedTraversal, NoUnrolling> { typedef typename Derived1::Index Index; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { const Index size = dst.size(); - typedef ei_packet_traits<typename Derived1::Scalar> PacketTraits; + typedef packet_traits<typename Derived1::Scalar> PacketTraits; enum { packetSize = PacketTraits::size, - dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : int(ei_assign_traits<Derived1,Derived2>::DstIsAligned) , - srcAlignment = ei_assign_traits<Derived1,Derived2>::JointAlignment + dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : int(assign_traits<Derived1,Derived2>::DstIsAligned) , + srcAlignment = assign_traits<Derived1,Derived2>::JointAlignment }; - const Index alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0 - : ei_first_aligned(&dst.coeffRef(0), size); + const Index alignedStart = assign_traits<Derived1,Derived2>::DstIsAligned ? 0 + : first_aligned(&dst.coeffRef(0), size); const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize; - ei_unaligned_assign_impl<ei_assign_traits<Derived1,Derived2>::DstIsAligned!=0>::run(src,dst,0,alignedStart); + unaligned_assign_impl<assign_traits<Derived1,Derived2>::DstIsAligned!=0>::run(src,dst,0,alignedStart); for(Index index = alignedStart; index < alignedEnd; index += packetSize) { dst.template copyPacket<Derived2, dstAlignment, srcAlignment>(index, src); } - ei_unaligned_assign_impl<>::run(src,dst,alignedEnd,size); + unaligned_assign_impl<>::run(src,dst,alignedEnd,size); } }; template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, LinearVectorizedTraversal, CompleteUnrolling> +struct assign_impl<Derived1, Derived2, LinearVectorizedTraversal, CompleteUnrolling> { typedef typename Derived1::Index Index; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { enum { size = Derived1::SizeAtCompileTime, - packetSize = ei_packet_traits<typename Derived1::Scalar>::size, + packetSize = packet_traits<typename Derived1::Scalar>::size, alignedSize = (size/packetSize)*packetSize }; - ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, alignedSize>::run(dst, src); - ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, alignedSize, size>::run(dst, src); + assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, alignedSize>::run(dst, src); + assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, alignedSize, size>::run(dst, src); } }; @@ -444,24 +446,24 @@ struct ei_assign_impl<Derived1, Derived2, LinearVectorizedTraversal, CompleteUnr ***************************/ template<typename Derived1, typename Derived2> -struct ei_assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling> +struct assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) { - typedef ei_packet_traits<typename Derived1::Scalar> PacketTraits; + typedef packet_traits<typename Derived1::Scalar> PacketTraits; enum { packetSize = PacketTraits::size, alignable = PacketTraits::AlignedOnScalar, - dstAlignment = alignable ? Aligned : int(ei_assign_traits<Derived1,Derived2>::DstIsAligned) , - srcAlignment = ei_assign_traits<Derived1,Derived2>::JointAlignment + dstAlignment = alignable ? Aligned : int(assign_traits<Derived1,Derived2>::DstIsAligned) , + srcAlignment = assign_traits<Derived1,Derived2>::JointAlignment }; const Index packetAlignedMask = packetSize - 1; const Index innerSize = dst.innerSize(); const Index outerSize = dst.outerSize(); const Index alignedStep = alignable ? (packetSize - dst.outerStride() % packetSize) & packetAlignedMask : 0; - Index alignedStart = ((!alignable) || ei_assign_traits<Derived1,Derived2>::DstIsAligned) ? 0 - : ei_first_aligned(&dst.coeffRef(0,0), innerSize); + Index alignedStart = ((!alignable) || assign_traits<Derived1,Derived2>::DstIsAligned) ? 0 + : first_aligned(&dst.coeffRef(0,0), innerSize); for(Index outer = 0; outer < outerSize; ++outer) { @@ -483,6 +485,8 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling> } }; +} // end namespace internal + /*************************************************************************** * Part 4 : implementation of DenseBase methods ***************************************************************************/ @@ -493,26 +497,26 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived> ::lazyAssign(const DenseBase<OtherDerived>& other) { enum{ - SameType = ei_is_same_type<typename Derived::Scalar,typename OtherDerived::Scalar>::ret + SameType = internal::is_same_type<typename Derived::Scalar,typename OtherDerived::Scalar>::ret }; EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - - #ifdef EIGEN_DEBUG_ASSIGN - ei_assign_traits<Derived, OtherDerived>::debug(); + internal::assign_traits<Derived, OtherDerived>::debug(); #endif - ei_assert(rows() == other.rows() && cols() == other.cols()); - ei_assign_impl<Derived, OtherDerived, int(SameType) ? int(ei_assign_traits<Derived, OtherDerived>::Traversal) - : int(InvalidTraversal)>::run(derived(),other.derived()); + eigen_assert(rows() == other.rows() && cols() == other.cols()); + internal::assign_impl<Derived, OtherDerived, int(SameType) ? int(internal::assign_traits<Derived, OtherDerived>::Traversal) + : int(InvalidTraversal)>::run(derived(),other.derived()); #ifndef EIGEN_NO_DEBUG checkTransposeAliasing(other.derived()); #endif return derived(); } +namespace internal { + template<typename Derived, typename OtherDerived, bool EvalBeforeAssigning = (int(OtherDerived::Flags) & EvalBeforeAssigningBit) != 0, bool NeedToTranspose = Derived::IsVectorAtCompileTime @@ -522,49 +526,51 @@ template<typename Derived, typename OtherDerived, // revert to || as soon as not needed anymore. (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1)) && int(Derived::SizeAtCompileTime) != 1> -struct ei_assign_selector; +struct assign_selector; template<typename Derived, typename OtherDerived> -struct ei_assign_selector<Derived,OtherDerived,false,false> { +struct assign_selector<Derived,OtherDerived,false,false> { EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); } }; template<typename Derived, typename OtherDerived> -struct ei_assign_selector<Derived,OtherDerived,true,false> { +struct assign_selector<Derived,OtherDerived,true,false> { EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); } }; template<typename Derived, typename OtherDerived> -struct ei_assign_selector<Derived,OtherDerived,false,true> { +struct assign_selector<Derived,OtherDerived,false,true> { EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); } }; template<typename Derived, typename OtherDerived> -struct ei_assign_selector<Derived,OtherDerived,true,true> { +struct assign_selector<Derived,OtherDerived,true,true> { EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); } }; +} // end namespace internal + template<typename Derived> template<typename OtherDerived> EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other) { - return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived()); + return internal::assign_selector<Derived,OtherDerived>::run(derived(), other.derived()); } template<typename Derived> EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other) { - return ei_assign_selector<Derived,Derived>::run(derived(), other.derived()); + return internal::assign_selector<Derived,Derived>::run(derived(), other.derived()); } template<typename Derived> EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other) { - return ei_assign_selector<Derived,Derived>::run(derived(), other.derived()); + return internal::assign_selector<Derived,Derived>::run(derived(), other.derived()); } template<typename Derived> template <typename OtherDerived> EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const DenseBase<OtherDerived>& other) { - return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived()); + return internal::assign_selector<Derived,OtherDerived>::run(derived(), other.derived()); } template<typename Derived> diff --git a/Eigen/src/Core/BandMatrix.h b/Eigen/src/Core/BandMatrix.h index 2f94d12dc..d5c0957ee 100644 --- a/Eigen/src/Core/BandMatrix.h +++ b/Eigen/src/Core/BandMatrix.h @@ -43,8 +43,10 @@ * * \sa class TridiagonalMatrix */ + +namespace internal { template<typename _Scalar, int Rows, int Cols, int Supers, int Subs, int Options> -struct ei_traits<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> > +struct traits<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> > { typedef _Scalar Scalar; typedef Dense StorageKind; @@ -58,6 +60,7 @@ struct ei_traits<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> > Flags = LvalueBit }; }; +} template<typename _Scalar, int Rows, int Cols, int Supers, int Subs, int Options> class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> > @@ -65,14 +68,14 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt public: enum { - Flags = ei_traits<BandMatrix>::Flags, - CoeffReadCost = ei_traits<BandMatrix>::CoeffReadCost, - RowsAtCompileTime = ei_traits<BandMatrix>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<BandMatrix>::ColsAtCompileTime, - MaxRowsAtCompileTime = ei_traits<BandMatrix>::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ei_traits<BandMatrix>::MaxColsAtCompileTime + Flags = internal::traits<BandMatrix>::Flags, + CoeffReadCost = internal::traits<BandMatrix>::CoeffReadCost, + RowsAtCompileTime = internal::traits<BandMatrix>::RowsAtCompileTime, + ColsAtCompileTime = internal::traits<BandMatrix>::ColsAtCompileTime, + MaxRowsAtCompileTime = internal::traits<BandMatrix>::MaxRowsAtCompileTime, + MaxColsAtCompileTime = internal::traits<BandMatrix>::MaxColsAtCompileTime }; - typedef typename ei_traits<BandMatrix>::Scalar Scalar; + typedef typename internal::traits<BandMatrix>::Scalar Scalar; typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> DenseMatrixType; typedef typename DenseMatrixType::Index Index; @@ -144,8 +147,8 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt : EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime, ColsAtCompileTime - ActualIndex)) }; typedef Block<DataType,1, DiagonalSize> BuildType; - typedef typename ei_meta_if<Conjugate, - CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>,BuildType >, + typedef typename internal::meta_if<Conjugate, + CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,BuildType >, BuildType>::ret Type; }; @@ -164,14 +167,14 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt /** \returns a vector expression of the \a i -th sub or super diagonal */ inline Block<DataType,1,Dynamic> diagonal(Index i) { - ei_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); + eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); return Block<DataType,1,Dynamic>(m_data, supers()-i, std::max<Index>(0,i), 1, diagonalLength(i)); } /** \returns a vector expression of the \a i -th sub or super diagonal */ inline const Block<DataType,1,Dynamic> diagonal(Index i) const { - ei_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); + eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); return Block<DataType,1,Dynamic>(m_data, supers()-i, std::max<Index>(0,i), 1, diagonalLength(i)); } @@ -199,9 +202,9 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt { return i<0 ? std::min(cols(),rows()+i) : std::min(rows(),cols()-i); } DataType m_data; - ei_variable_if_dynamic<Index, Rows> m_rows; - ei_variable_if_dynamic<Index, Supers> m_supers; - ei_variable_if_dynamic<Index, Subs> m_subs; + internal::variable_if_dynamic<Index, Rows> m_rows; + internal::variable_if_dynamic<Index, Supers> m_supers; + internal::variable_if_dynamic<Index, Subs> m_subs; }; /** diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index a770b9721..76fb46e25 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -58,54 +58,57 @@ * * \sa DenseBase::block(Index,Index,Index,Index), DenseBase::block(Index,Index), class VectorBlock */ + +namespace internal { template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool HasDirectAccess> -struct ei_traits<Block<XprType, BlockRows, BlockCols, InnerPanel, HasDirectAccess> > : ei_traits<XprType> +struct traits<Block<XprType, BlockRows, BlockCols, InnerPanel, HasDirectAccess> > : traits<XprType> { - typedef typename ei_traits<XprType>::Scalar Scalar; - typedef typename ei_traits<XprType>::StorageKind StorageKind; - typedef typename ei_traits<XprType>::XprKind XprKind; - typedef typename ei_nested<XprType>::type XprTypeNested; - typedef typename ei_unref<XprTypeNested>::type _XprTypeNested; + typedef typename traits<XprType>::Scalar Scalar; + typedef typename traits<XprType>::StorageKind StorageKind; + typedef typename traits<XprType>::XprKind XprKind; + typedef typename nested<XprType>::type XprTypeNested; + typedef typename unref<XprTypeNested>::type _XprTypeNested; enum{ - MatrixRows = ei_traits<XprType>::RowsAtCompileTime, - MatrixCols = ei_traits<XprType>::ColsAtCompileTime, + MatrixRows = traits<XprType>::RowsAtCompileTime, + MatrixCols = traits<XprType>::ColsAtCompileTime, RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows, ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols, MaxRowsAtCompileTime = BlockRows==0 ? 0 : RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) - : int(ei_traits<XprType>::MaxRowsAtCompileTime), + : int(traits<XprType>::MaxRowsAtCompileTime), MaxColsAtCompileTime = BlockCols==0 ? 0 : ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) - : int(ei_traits<XprType>::MaxColsAtCompileTime), - XprTypeIsRowMajor = (int(ei_traits<XprType>::Flags)&RowMajorBit) != 0, + : int(traits<XprType>::MaxColsAtCompileTime), + XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0, IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1 : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0 : XprTypeIsRowMajor, HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor), InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime), InnerStrideAtCompileTime = HasSameStorageOrderAsXprType - ? int(ei_inner_stride_at_compile_time<XprType>::ret) - : int(ei_outer_stride_at_compile_time<XprType>::ret), + ? int(inner_stride_at_compile_time<XprType>::ret) + : int(outer_stride_at_compile_time<XprType>::ret), OuterStrideAtCompileTime = HasSameStorageOrderAsXprType - ? int(ei_outer_stride_at_compile_time<XprType>::ret) - : int(ei_inner_stride_at_compile_time<XprType>::ret), - MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % ei_packet_traits<Scalar>::size) == 0) + ? int(outer_stride_at_compile_time<XprType>::ret) + : int(inner_stride_at_compile_time<XprType>::ret), + MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % packet_traits<Scalar>::size) == 0) && (InnerStrideAtCompileTime == 1) ? PacketAccessBit : 0, - MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && ((OuterStrideAtCompileTime % ei_packet_traits<Scalar>::size) == 0)) ? AlignedBit : 0, + MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && ((OuterStrideAtCompileTime % packet_traits<Scalar>::size) == 0)) ? AlignedBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, - Flags0 = ei_traits<XprType>::Flags & (HereditaryBits | MaskPacketAccessBit | LvalueBit | DirectAccessBit | MaskAlignedBit), + Flags0 = traits<XprType>::Flags & (HereditaryBits | MaskPacketAccessBit | LvalueBit | DirectAccessBit | MaskAlignedBit), Flags1 = Flags0 | FlagsLinearAccessBit, Flags = (Flags1 & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) }; }; +} template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool HasDirectAccess> class Block - : public ei_dense_xpr_base<Block<XprType, BlockRows, BlockCols, InnerPanel, HasDirectAccess> >::type + : public internal::dense_xpr_base<Block<XprType, BlockRows, BlockCols, InnerPanel, HasDirectAccess> >::type { public: - typedef typename ei_dense_xpr_base<Block>::type Base; + typedef typename internal::dense_xpr_base<Block>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Block) class InnerIterator; @@ -123,7 +126,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H m_blockRows(BlockRows==1 ? 1 : xpr.rows()), m_blockCols(BlockCols==1 ? 1 : xpr.cols()) { - ei_assert( (i>=0) && ( + eigen_assert( (i>=0) && ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows()) ||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols()))); } @@ -135,7 +138,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H m_blockRows(BlockRows), m_blockCols(BlockCols) { EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) - ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() + eigen_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols()); } @@ -147,9 +150,9 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H : m_xpr(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols) { - ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) + eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); - ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() + eigen_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= xpr.cols()); } @@ -223,10 +226,10 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H protected: const typename XprType::Nested m_xpr; - const ei_variable_if_dynamic<Index, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow; - const ei_variable_if_dynamic<Index, XprType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol; - const ei_variable_if_dynamic<Index, RowsAtCompileTime> m_blockRows; - const ei_variable_if_dynamic<Index, ColsAtCompileTime> m_blockCols; + const internal::variable_if_dynamic<Index, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow; + const internal::variable_if_dynamic<Index, XprType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol; + const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_blockRows; + const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_blockCols; }; /** \internal */ @@ -251,7 +254,7 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true> BlockCols==1 ? 1 : xpr.cols()), m_xpr(xpr) { - ei_assert( (i>=0) && ( + eigen_assert( (i>=0) && ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows()) ||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols()))); init(); @@ -262,7 +265,7 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true> inline Block(const XprType& xpr, Index startRow, Index startCol) : Base(&xpr.const_cast_derived().coeffRef(startRow,startCol)), m_xpr(xpr) { - ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() + eigen_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols()); init(); } @@ -275,9 +278,9 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true> : Base(&xpr.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols), m_xpr(xpr) { - ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) + eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); - ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() + eigen_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= xpr.cols()); init(); } @@ -285,7 +288,7 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true> /** \sa MapBase::innerStride() */ inline Index innerStride() const { - return ei_traits<Block>::HasSameStorageOrderAsXprType + return internal::traits<Block>::HasSameStorageOrderAsXprType ? m_xpr.innerStride() : m_xpr.outerStride(); } @@ -314,7 +317,7 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true> protected: void init() { - m_outerStride = ei_traits<Block>::HasSameStorageOrderAsXprType + m_outerStride = internal::traits<Block>::HasSameStorageOrderAsXprType ? m_xpr.outerStride() : m_xpr.innerStride(); } diff --git a/Eigen/src/Core/BooleanRedux.h b/Eigen/src/Core/BooleanRedux.h index 9f9d1b594..5c3444a57 100644 --- a/Eigen/src/Core/BooleanRedux.h +++ b/Eigen/src/Core/BooleanRedux.h @@ -25,8 +25,10 @@ #ifndef EIGEN_ALLANDANY_H #define EIGEN_ALLANDANY_H +namespace internal { + template<typename Derived, int UnrollCount> -struct ei_all_unroller +struct all_unroller { enum { col = (UnrollCount-1) / Derived::RowsAtCompileTime, @@ -35,24 +37,24 @@ struct ei_all_unroller inline static bool run(const Derived &mat) { - return ei_all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col); + return all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col); } }; template<typename Derived> -struct ei_all_unroller<Derived, 1> +struct all_unroller<Derived, 1> { inline static bool run(const Derived &mat) { return mat.coeff(0, 0); } }; template<typename Derived> -struct ei_all_unroller<Derived, Dynamic> +struct all_unroller<Derived, Dynamic> { inline static bool run(const Derived &) { return false; } }; template<typename Derived, int UnrollCount> -struct ei_any_unroller +struct any_unroller { enum { col = (UnrollCount-1) / Derived::RowsAtCompileTime, @@ -61,22 +63,24 @@ struct ei_any_unroller inline static bool run(const Derived &mat) { - return ei_any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col); + return any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col); } }; template<typename Derived> -struct ei_any_unroller<Derived, 1> +struct any_unroller<Derived, 1> { inline static bool run(const Derived &mat) { return mat.coeff(0, 0); } }; template<typename Derived> -struct ei_any_unroller<Derived, Dynamic> +struct any_unroller<Derived, Dynamic> { inline static bool run(const Derived &) { return false; } }; +} // end namespace internal + /** \returns true if all coefficients are true * * Example: \include MatrixBase_all.cpp @@ -94,7 +98,7 @@ inline bool DenseBase<Derived>::all() const && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT }; if(unroll) - return ei_all_unroller<Derived, + return internal::all_unroller<Derived, unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived()); else @@ -120,7 +124,7 @@ inline bool DenseBase<Derived>::any() const && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT }; if(unroll) - return ei_any_unroller<Derived, + return internal::any_unroller<Derived, unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived()); else diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index da8df5592..92422bf2f 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -64,12 +64,12 @@ struct CommaInitializer m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = 1; - ei_assert(m_row<m_xpr.rows() + eigen_assert(m_row<m_xpr.rows() && "Too many rows passed to comma initializer (operator<<)"); } - ei_assert(m_col<m_xpr.cols() + eigen_assert(m_col<m_xpr.cols() && "Too many coefficients passed to comma initializer (operator<<)"); - ei_assert(m_currentBlockRows==1); + eigen_assert(m_currentBlockRows==1); m_xpr.coeffRef(m_row, m_col++) = s; return *this; } @@ -83,12 +83,12 @@ struct CommaInitializer m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = other.rows(); - ei_assert(m_row+m_currentBlockRows<=m_xpr.rows() + eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows() && "Too many rows passed to comma initializer (operator<<)"); } - ei_assert(m_col<m_xpr.cols() + eigen_assert(m_col<m_xpr.cols() && "Too many coefficients passed to comma initializer (operator<<)"); - ei_assert(m_currentBlockRows==other.rows()); + eigen_assert(m_currentBlockRows==other.rows()); if (OtherDerived::SizeAtCompileTime != Dynamic) m_xpr.template block<OtherDerived::RowsAtCompileTime != Dynamic ? OtherDerived::RowsAtCompileTime : 1, OtherDerived::ColsAtCompileTime != Dynamic ? OtherDerived::ColsAtCompileTime : 1> @@ -101,7 +101,7 @@ struct CommaInitializer inline ~CommaInitializer() { - ei_assert((m_row+m_currentBlockRows) == m_xpr.rows() + eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows() && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"); } diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 5def0db2a..8e9761640 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -45,56 +45,59 @@ * * \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp */ + +namespace internal { template<typename BinaryOp, typename Lhs, typename Rhs> -struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > +struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > { - // we must not inherit from ei_traits<Lhs> since it has + // we must not inherit from traits<Lhs> since it has // the potential to cause problems with MSVC - typedef typename ei_cleantype<Lhs>::type Ancestor; - typedef typename ei_traits<Ancestor>::XprKind XprKind; + typedef typename cleantype<Lhs>::type Ancestor; + typedef typename traits<Ancestor>::XprKind XprKind; enum { - RowsAtCompileTime = ei_traits<Ancestor>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<Ancestor>::ColsAtCompileTime, - MaxRowsAtCompileTime = ei_traits<Ancestor>::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ei_traits<Ancestor>::MaxColsAtCompileTime + RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime, + ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime, + MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime, + MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime }; // even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor), // we still want to handle the case when the result type is different. - typedef typename ei_result_of< + typedef typename result_of< BinaryOp( typename Lhs::Scalar, typename Rhs::Scalar ) >::type Scalar; - typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageKind, - typename ei_traits<Rhs>::StorageKind>::ret StorageKind; - typedef typename ei_promote_index_type<typename ei_traits<Lhs>::Index, - typename ei_traits<Rhs>::Index>::type Index; + typedef typename promote_storage_type<typename traits<Lhs>::StorageKind, + typename traits<Rhs>::StorageKind>::ret StorageKind; + typedef typename promote_index_type<typename traits<Lhs>::Index, + typename traits<Rhs>::Index>::type Index; typedef typename Lhs::Nested LhsNested; typedef typename Rhs::Nested RhsNested; - typedef typename ei_unref<LhsNested>::type _LhsNested; - typedef typename ei_unref<RhsNested>::type _RhsNested; + typedef typename unref<LhsNested>::type _LhsNested; + typedef typename unref<RhsNested>::type _RhsNested; enum { LhsCoeffReadCost = _LhsNested::CoeffReadCost, RhsCoeffReadCost = _RhsNested::CoeffReadCost, LhsFlags = _LhsNested::Flags, RhsFlags = _RhsNested::Flags, - SameType = ei_is_same_type<typename _LhsNested::Scalar,typename _RhsNested::Scalar>::ret, + SameType = is_same_type<typename _LhsNested::Scalar,typename _RhsNested::Scalar>::ret, StorageOrdersAgree = (int(Lhs::Flags)&RowMajorBit)==(int(Rhs::Flags)&RowMajorBit), Flags0 = (int(LhsFlags) | int(RhsFlags)) & ( HereditaryBits | (int(LhsFlags) & int(RhsFlags) & ( AlignedBit | (StorageOrdersAgree ? LinearAccessBit : 0) - | (ei_functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0) + | (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0) ) ) ), Flags = (Flags0 & ~RowMajorBit) | (LhsFlags & RowMajorBit), - CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + ei_functor_traits<BinaryOp>::Cost + CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + functor_traits<BinaryOp>::Cost }; }; +} // end namespace internal // we require Lhs and Rhs to have the same scalar type. Currently there is no example of a binary functor // that would take two operands of different types. If there were such an example, then this check should be @@ -104,33 +107,33 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > // So allowing mixing different types gives very unexpected errors when enabling vectorization, when the user tries to // add together a float matrix and a double matrix. #define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \ - EIGEN_STATIC_ASSERT((ei_functor_allows_mixing_real_and_complex<BINOP>::ret \ - ? int(ei_is_same_type<typename NumTraits<LHS>::Real, typename NumTraits<RHS>::Real>::ret) \ - : int(ei_is_same_type<LHS, RHS>::ret)), \ + EIGEN_STATIC_ASSERT((internal::functor_allows_mixing_real_and_complex<BINOP>::ret \ + ? int(internal::is_same_type<typename NumTraits<LHS>::Real, typename NumTraits<RHS>::Real>::ret) \ + : int(internal::is_same_type<LHS, RHS>::ret)), \ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind> class CwiseBinaryOpImpl; template<typename BinaryOp, typename Lhs, typename Rhs> -class CwiseBinaryOp : ei_no_assignment_operator, +class CwiseBinaryOp : internal::no_assignment_operator, public CwiseBinaryOpImpl< BinaryOp, Lhs, Rhs, - typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageKind, - typename ei_traits<Rhs>::StorageKind>::ret> + typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind, + typename internal::traits<Rhs>::StorageKind>::ret> { public: typedef typename CwiseBinaryOpImpl< BinaryOp, Lhs, Rhs, - typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageKind, - typename ei_traits<Rhs>::StorageKind>::ret>::Base Base; + typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind, + typename internal::traits<Rhs>::StorageKind>::ret>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp) - typedef typename ei_nested<Lhs>::type LhsNested; - typedef typename ei_nested<Rhs>::type RhsNested; - typedef typename ei_unref<LhsNested>::type _LhsNested; - typedef typename ei_unref<RhsNested>::type _RhsNested; + typedef typename internal::nested<Lhs>::type LhsNested; + typedef typename internal::nested<Rhs>::type RhsNested; + typedef typename internal::unref<LhsNested>::type _LhsNested; + typedef typename internal::unref<RhsNested>::type _RhsNested; EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& lhs, const Rhs& rhs, const BinaryOp& func = BinaryOp()) : m_lhs(lhs), m_rhs(rhs), m_functor(func) @@ -138,19 +141,19 @@ class CwiseBinaryOp : ei_no_assignment_operator, EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar); // require the sizes to match EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs) - ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); + eigen_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); } EIGEN_STRONG_INLINE Index rows() const { // return the fixed size type if available to enable compile time optimizations - if (ei_traits<typename ei_cleantype<LhsNested>::type>::RowsAtCompileTime==Dynamic) + if (internal::traits<typename internal::cleantype<LhsNested>::type>::RowsAtCompileTime==Dynamic) return m_rhs.rows(); else return m_lhs.rows(); } EIGEN_STRONG_INLINE Index cols() const { // return the fixed size type if available to enable compile time optimizations - if (ei_traits<typename ei_cleantype<LhsNested>::type>::ColsAtCompileTime==Dynamic) + if (internal::traits<typename internal::cleantype<LhsNested>::type>::ColsAtCompileTime==Dynamic) return m_rhs.cols(); else return m_lhs.cols(); @@ -171,12 +174,12 @@ class CwiseBinaryOp : ei_no_assignment_operator, template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Dense> - : public ei_dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type + : public internal::dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type { typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived; public: - typedef typename ei_dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base; + typedef typename internal::dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base; EIGEN_DENSE_PUBLIC_INTERFACE( Derived ) EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const @@ -215,7 +218,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other) { - SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other.derived(); return derived(); } @@ -229,7 +232,7 @@ template<typename OtherDerived> EIGEN_STRONG_INLINE Derived & MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other) { - SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived()); tmp = other.derived(); return derived(); } diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 0b8e7c0c1..a2f504985 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -42,32 +42,35 @@ * * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr() */ + +namespace internal { template<typename NullaryOp, typename PlainObjectType> -struct ei_traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : ei_traits<PlainObjectType> +struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType> { enum { - Flags = (ei_traits<PlainObjectType>::Flags + Flags = (traits<PlainObjectType>::Flags & ( HereditaryBits - | (ei_functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0) - | (ei_functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0))) - | (ei_functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit), - CoeffReadCost = ei_functor_traits<NullaryOp>::Cost + | (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0) + | (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0))) + | (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit), + CoeffReadCost = functor_traits<NullaryOp>::Cost }; }; +} template<typename NullaryOp, typename PlainObjectType> -class CwiseNullaryOp : ei_no_assignment_operator, - public ei_dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type +class CwiseNullaryOp : internal::no_assignment_operator, + public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type { public: - typedef typename ei_dense_xpr_base<CwiseNullaryOp>::type Base; + typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp) CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp()) : m_rows(rows), m_cols(cols), m_functor(func) { - ei_assert(rows >= 0 + eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); @@ -99,8 +102,8 @@ class CwiseNullaryOp : ei_no_assignment_operator, } protected: - const ei_variable_if_dynamic<Index, RowsAtCompileTime> m_rows; - const ei_variable_if_dynamic<Index, ColsAtCompileTime> m_cols; + const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows; + const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols; const NullaryOp m_functor; }; @@ -185,7 +188,7 @@ template<typename Derived> EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Constant(Index rows, Index cols, const Scalar& value) { - return DenseBase<Derived>::NullaryExpr(rows, cols, ei_scalar_constant_op<Scalar>(value)); + return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value)); } /** \returns an expression of a constant matrix of value \a value @@ -207,7 +210,7 @@ template<typename Derived> EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Constant(Index size, const Scalar& value) { - return DenseBase<Derived>::NullaryExpr(size, ei_scalar_constant_op<Scalar>(value)); + return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value)); } /** \returns an expression of a constant matrix of value \a value @@ -224,7 +227,7 @@ EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Constant(const Scalar& value) { EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value)); + return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op<Scalar>(value)); } /** @@ -247,7 +250,7 @@ EIGEN_STRONG_INLINE const typename DenseBase<Derived>::SequentialLinSpacedReturn DenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return DenseBase<Derived>::NullaryExpr(size, ei_linspaced_op<Scalar,false>(low,high,size)); + return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,false>(low,high,size)); } /** @@ -260,7 +263,7 @@ DenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& hig { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, ei_linspaced_op<Scalar,false>(low,high,Derived::SizeAtCompileTime)); + return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,false>(low,high,Derived::SizeAtCompileTime)); } /** @@ -280,7 +283,7 @@ EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedRetu DenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return DenseBase<Derived>::NullaryExpr(size, ei_linspaced_op<Scalar,true>(low,high,size)); + return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,true>(low,high,size)); } /** @@ -293,7 +296,7 @@ DenseBase<Derived>::LinSpaced(const Scalar& low, const Scalar& high) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, ei_linspaced_op<Scalar,true>(low,high,Derived::SizeAtCompileTime)); + return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,true>(low,high,Derived::SizeAtCompileTime)); } /** \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */ @@ -303,7 +306,7 @@ bool DenseBase<Derived>::isApproxToConstant { for(Index j = 0; j < cols(); ++j) for(Index i = 0; i < rows(); ++i) - if(!ei_isApprox(this->coeff(i, j), value, prec)) + if(!internal::isApprox(this->coeff(i, j), value, prec)) return false; return true; } @@ -390,7 +393,7 @@ template<typename Derived> EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index size, const Scalar& low, const Scalar& high) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return derived() = Derived::NullaryExpr(size, ei_linspaced_op<Scalar,false>(low,high,size)); + return derived() = Derived::NullaryExpr(size, internal::linspaced_op<Scalar,false>(low,high,size)); } // zero: @@ -469,7 +472,7 @@ bool DenseBase<Derived>::isZero(RealScalar prec) const { for(Index j = 0; j < cols(); ++j) for(Index i = 0; i < rows(); ++i) - if(!ei_isMuchSmallerThan(this->coeff(i, j), static_cast<Scalar>(1), prec)) + if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<Scalar>(1), prec)) return false; return true; } @@ -668,7 +671,7 @@ template<typename Derived> EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType MatrixBase<Derived>::Identity(Index rows, Index cols) { - return DenseBase<Derived>::NullaryExpr(rows, cols, ei_scalar_identity_op<Scalar>()); + return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>()); } /** \returns an expression of the identity matrix (not necessarily square). @@ -686,7 +689,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType MatrixBase<Derived>::Identity() { EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>()); + return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>()); } /** \returns true if *this is approximately equal to the identity matrix @@ -708,12 +711,12 @@ bool MatrixBase<Derived>::isIdentity { if(i == j) { - if(!ei_isApprox(this->coeff(i, j), static_cast<Scalar>(1), prec)) + if(!internal::isApprox(this->coeff(i, j), static_cast<Scalar>(1), prec)) return false; } else { - if(!ei_isMuchSmallerThan(this->coeff(i, j), static_cast<RealScalar>(1), prec)) + if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<RealScalar>(1), prec)) return false; } } @@ -721,8 +724,10 @@ bool MatrixBase<Derived>::isIdentity return true; } +namespace internal { + template<typename Derived, bool Big = (Derived::SizeAtCompileTime>=16)> -struct ei_setIdentity_impl +struct setIdentity_impl { static EIGEN_STRONG_INLINE Derived& run(Derived& m) { @@ -731,7 +736,7 @@ struct ei_setIdentity_impl }; template<typename Derived> -struct ei_setIdentity_impl<Derived, true> +struct setIdentity_impl<Derived, true> { typedef typename Derived::Index Index; static EIGEN_STRONG_INLINE Derived& run(Derived& m) @@ -743,6 +748,8 @@ struct ei_setIdentity_impl<Derived, true> } }; +} // end namespace internal + /** Writes the identity expression (not necessarily square) into *this. * * Example: \include MatrixBase_setIdentity.cpp @@ -753,7 +760,7 @@ struct ei_setIdentity_impl<Derived, true> template<typename Derived> EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity() { - return ei_setIdentity_impl<Derived>::run(derived()); + return internal::setIdentity_impl<Derived>::run(derived()); } /** \brief Resizes to the given size, and writes the identity expression (not necessarily square) into *this. diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 4c92f36bb..284eb39b0 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -45,33 +45,36 @@ * * \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp */ + +namespace internal { template<typename UnaryOp, typename XprType> -struct ei_traits<CwiseUnaryOp<UnaryOp, XprType> > - : ei_traits<XprType> +struct traits<CwiseUnaryOp<UnaryOp, XprType> > + : traits<XprType> { - typedef typename ei_result_of< + typedef typename result_of< UnaryOp(typename XprType::Scalar) >::type Scalar; typedef typename XprType::Nested XprTypeNested; - typedef typename ei_unref<XprTypeNested>::type _XprTypeNested; + typedef typename unref<XprTypeNested>::type _XprTypeNested; enum { Flags = _XprTypeNested::Flags & ( HereditaryBits | LinearAccessBit | AlignedBit - | (ei_functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)), - CoeffReadCost = _XprTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost + | (functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)), + CoeffReadCost = _XprTypeNested::CoeffReadCost + functor_traits<UnaryOp>::Cost }; }; +} template<typename UnaryOp, typename XprType, typename StorageKind> class CwiseUnaryOpImpl; template<typename UnaryOp, typename XprType> -class CwiseUnaryOp : ei_no_assignment_operator, - public CwiseUnaryOpImpl<UnaryOp, XprType, typename ei_traits<XprType>::StorageKind> +class CwiseUnaryOp : internal::no_assignment_operator, + public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind> { public: - typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename ei_traits<XprType>::StorageKind>::Base Base; + typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename internal::traits<XprType>::StorageKind>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp) inline CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp()) @@ -84,11 +87,11 @@ class CwiseUnaryOp : ei_no_assignment_operator, const UnaryOp& functor() const { return m_functor; } /** \returns the nested expression */ - const typename ei_cleantype<typename XprType::Nested>::type& + const typename internal::cleantype<typename XprType::Nested>::type& nestedExpression() const { return m_xpr; } /** \returns the nested expression */ - typename ei_cleantype<typename XprType::Nested>::type& + typename internal::cleantype<typename XprType::Nested>::type& nestedExpression() { return m_xpr.const_cast_derived(); } protected: @@ -100,12 +103,12 @@ class CwiseUnaryOp : ei_no_assignment_operator, // It can be used for any expression types implementing the dense concept. template<typename UnaryOp, typename XprType> class CwiseUnaryOpImpl<UnaryOp,XprType,Dense> - : public ei_dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type + : public internal::dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type { public: typedef CwiseUnaryOp<UnaryOp, XprType> Derived; - typedef typename ei_dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base; + typedef typename internal::dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Derived) EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index 37c58223e..8b5a69513 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -38,39 +38,42 @@ * * \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp */ + +namespace internal { template<typename ViewOp, typename MatrixType> -struct ei_traits<CwiseUnaryView<ViewOp, MatrixType> > - : ei_traits<MatrixType> +struct traits<CwiseUnaryView<ViewOp, MatrixType> > + : traits<MatrixType> { - typedef typename ei_result_of< - ViewOp(typename ei_traits<MatrixType>::Scalar) + typedef typename result_of< + ViewOp(typename traits<MatrixType>::Scalar) >::type Scalar; typedef typename MatrixType::Nested MatrixTypeNested; - typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename cleantype<MatrixTypeNested>::type _MatrixTypeNested; enum { - Flags = (ei_traits<_MatrixTypeNested>::Flags & (HereditaryBits | LvalueBit | LinearAccessBit | DirectAccessBit)), - CoeffReadCost = ei_traits<_MatrixTypeNested>::CoeffReadCost + ei_functor_traits<ViewOp>::Cost, - MatrixTypeInnerStride = ei_inner_stride_at_compile_time<MatrixType>::ret, + Flags = (traits<_MatrixTypeNested>::Flags & (HereditaryBits | LvalueBit | LinearAccessBit | DirectAccessBit)), + CoeffReadCost = traits<_MatrixTypeNested>::CoeffReadCost + functor_traits<ViewOp>::Cost, + MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret, // need to cast the sizeof's from size_t to int explicitly, otherwise: // "error: no integral type can represent all of the enumerator values InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic ? int(Dynamic) : int(MatrixTypeInnerStride) - * int(sizeof(typename ei_traits<MatrixType>::Scalar) / sizeof(Scalar)), - OuterStrideAtCompileTime = ei_outer_stride_at_compile_time<MatrixType>::ret + * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)), + OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret }; }; +} template<typename ViewOp, typename MatrixType, typename StorageKind> class CwiseUnaryViewImpl; template<typename ViewOp, typename MatrixType> -class CwiseUnaryView : ei_no_assignment_operator, - public CwiseUnaryViewImpl<ViewOp, MatrixType, typename ei_traits<MatrixType>::StorageKind> +class CwiseUnaryView : internal::no_assignment_operator, + public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind> { public: - typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename ei_traits<MatrixType>::StorageKind>::Base Base; + typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView) inline CwiseUnaryView(const MatrixType& mat, const ViewOp& func = ViewOp()) @@ -85,33 +88,33 @@ class CwiseUnaryView : ei_no_assignment_operator, const ViewOp& functor() const { return m_functor; } /** \returns the nested expression */ - const typename ei_cleantype<typename MatrixType::Nested>::type& + const typename internal::cleantype<typename MatrixType::Nested>::type& nestedExpression() const { return m_matrix; } /** \returns the nested expression */ - typename ei_cleantype<typename MatrixType::Nested>::type& + typename internal::cleantype<typename MatrixType::Nested>::type& nestedExpression() { return m_matrix.const_cast_derived(); } protected: // FIXME changed from MatrixType::Nested because of a weird compilation error with sun CC - const typename ei_nested<MatrixType>::type m_matrix; + const typename internal::nested<MatrixType>::type m_matrix; ViewOp m_functor; }; template<typename ViewOp, typename MatrixType> class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense> - : public ei_dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type + : public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type { public: typedef CwiseUnaryView<ViewOp, MatrixType> Derived; - typedef typename ei_dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base; + typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Derived) inline Index innerStride() const { - return derived().nestedExpression().innerStride() * sizeof(typename ei_traits<MatrixType>::Scalar) / sizeof(Scalar); + return derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar); } inline Index outerStride() const diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 3ef58ab03..f8ad160bf 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -40,22 +40,22 @@ */ template<typename Derived> class DenseBase #ifndef EIGEN_PARSED_BY_DOXYGEN - : public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, - typename NumTraits<typename ei_traits<Derived>::Scalar>::Real> + : public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar, + typename NumTraits<typename internal::traits<Derived>::Scalar>::Real> #else : public DenseCoeffsBase<Derived> #endif // not EIGEN_PARSED_BY_DOXYGEN { public: - using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, - typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*; + using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar, + typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*; class InnerIterator; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; /**< The type of indices */ - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; /**< The type of indices */ + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; typedef DenseCoeffsBase<Derived> Base; @@ -93,26 +93,26 @@ template<typename Derived> class DenseBase enum { - RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, + RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime, /**< The number of rows at compile-time. This is just a copy of the value provided * by the \a Derived type. If a value is not known at compile-time, * it is set to the \a Dynamic constant. * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ - ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, + ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime, /**< The number of columns at compile-time. This is just a copy of the value provided * by the \a Derived type. If a value is not known at compile-time, * it is set to the \a Dynamic constant. * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ - SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime, - ei_traits<Derived>::ColsAtCompileTime>::ret), + SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime, + internal::traits<Derived>::ColsAtCompileTime>::ret), /**< This is equal to the number of coefficients, i.e. the number of * rows times the number of columns, or to \a Dynamic if this is not * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ - MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime, + MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime, /**< This value is equal to the maximum possible number of rows that this expression * might have. If this expression might have an arbitrarily high number of rows, * this value is set to \a Dynamic. @@ -123,7 +123,7 @@ template<typename Derived> class DenseBase * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime */ - MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime, + MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime, /**< This value is equal to the maximum possible number of columns that this expression * might have. If this expression might have an arbitrarily high number of columns, * this value is set to \a Dynamic. @@ -134,8 +134,8 @@ template<typename Derived> class DenseBase * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime */ - MaxSizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::MaxRowsAtCompileTime, - ei_traits<Derived>::MaxColsAtCompileTime>::ret), + MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime, + internal::traits<Derived>::MaxColsAtCompileTime>::ret), /**< This value is equal to the maximum possible number of coefficients that this expression * might have. If this expression might have an arbitrarily high number of coefficients, * this value is set to \a Dynamic. @@ -146,14 +146,14 @@ template<typename Derived> class DenseBase * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime */ - IsVectorAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime == 1 - || ei_traits<Derived>::MaxColsAtCompileTime == 1, + IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1 + || internal::traits<Derived>::MaxColsAtCompileTime == 1, /**< This is set to true if either the number of rows or the number of * columns is known at compile-time to be equal to 1. Indeed, in that case, * we are dealing with a column-vector (if there is only one column) or with * a row-vector (if there is only one row). */ - Flags = ei_traits<Derived>::Flags, + Flags = internal::traits<Derived>::Flags, /**< This stores expression \ref flags flags which may or may not be inherited by new expressions * constructed from this one. See the \ref flags "list of flags". */ @@ -163,13 +163,13 @@ template<typename Derived> class DenseBase InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime : int(IsRowMajor) ? ColsAtCompileTime : RowsAtCompileTime, - CoeffReadCost = ei_traits<Derived>::CoeffReadCost, + CoeffReadCost = internal::traits<Derived>::CoeffReadCost, /**< This is a rough measure of how expensive it is to read one coefficient from * this expression. */ - InnerStrideAtCompileTime = ei_inner_stride_at_compile_time<Derived>::ret, - OuterStrideAtCompileTime = ei_outer_stride_at_compile_time<Derived>::ret + InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret, + OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret }; /** \returns the number of nonzero coefficients which is in practice the number @@ -209,7 +209,7 @@ template<typename Derived> class DenseBase void resize(Index size) { EIGEN_ONLY_USED_FOR_DEBUG(size); - ei_assert(size == this->size() + eigen_assert(size == this->size() && "DenseBase::resize() does not actually allow to resize."); } /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are @@ -220,20 +220,20 @@ template<typename Derived> class DenseBase { EIGEN_ONLY_USED_FOR_DEBUG(rows); EIGEN_ONLY_USED_FOR_DEBUG(cols); - ei_assert(rows == this->rows() && cols == this->cols() + eigen_assert(rows == this->rows() && cols == this->cols() && "DenseBase::resize() does not actually allow to resize."); } #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType; + typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType; /** \internal Represents a vector with linearly spaced coefficients that allows sequential access only. */ - typedef CwiseNullaryOp<ei_linspaced_op<Scalar,false>,Derived> SequentialLinSpacedReturnType; + typedef CwiseNullaryOp<internal::linspaced_op<Scalar,false>,Derived> SequentialLinSpacedReturnType; /** \internal Represents a vector with linearly spaced coefficients that allows random access. */ - typedef CwiseNullaryOp<ei_linspaced_op<Scalar,true>,Derived> RandomAccessLinSpacedReturnType; + typedef CwiseNullaryOp<internal::linspaced_op<Scalar,true>,Derived> RandomAccessLinSpacedReturnType; /** \internal the return type of MatrixBase::eigenvalues() */ - typedef Matrix<typename NumTraits<typename ei_traits<Derived>::Scalar>::Real, ei_traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType; + typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN @@ -381,12 +381,12 @@ template<typename Derived> class DenseBase * Notice that in the case of a plain matrix or vector (not an expression) this function just returns * a const reference, in order to avoid a useless copy. */ - EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const + EIGEN_STRONG_INLINE const typename internal::eval<Derived>::type eval() const { // Even though MSVC does not honor strong inlining when the return type // is a dynamic matrix, we desperately need strong inlining for fixed // size types on MSVC. - return typename ei_eval<Derived>::type(derived()); + return typename internal::eval<Derived>::type(derived()); } template<typename OtherDerived> @@ -395,8 +395,8 @@ template<typename Derived> class DenseBase inline const NestByValue<Derived> nestByValue() const; inline const ForceAlignedAccess<Derived> forceAlignedAccess() const; inline ForceAlignedAccess<Derived> forceAlignedAccess(); - template<bool Enable> inline const typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf() const; - template<bool Enable> inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf(); + template<bool Enable> inline const typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf() const; + template<bool Enable> inline typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf(); Scalar sum() const; Scalar mean() const; @@ -404,17 +404,17 @@ template<typename Derived> class DenseBase Scalar prod() const; - typename ei_traits<Derived>::Scalar minCoeff() const; - typename ei_traits<Derived>::Scalar maxCoeff() const; + typename internal::traits<Derived>::Scalar minCoeff() const; + typename internal::traits<Derived>::Scalar maxCoeff() const; - typename ei_traits<Derived>::Scalar minCoeff(Index* row, Index* col) const; - typename ei_traits<Derived>::Scalar maxCoeff(Index* row, Index* col) const; + typename internal::traits<Derived>::Scalar minCoeff(Index* row, Index* col) const; + typename internal::traits<Derived>::Scalar maxCoeff(Index* row, Index* col) const; - typename ei_traits<Derived>::Scalar minCoeff(Index* index) const; - typename ei_traits<Derived>::Scalar maxCoeff(Index* index) const; + typename internal::traits<Derived>::Scalar minCoeff(Index* index) const; + typename internal::traits<Derived>::Scalar maxCoeff(Index* index) const; template<typename BinaryOp> - typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type + typename internal::result_of<BinaryOp(typename internal::traits<Derived>::Scalar)>::type redux(const BinaryOp& func) const; template<typename Visitor> @@ -433,9 +433,9 @@ template<typename Derived> class DenseBase const VectorwiseOp<Derived,Vertical> colwise() const; VectorwiseOp<Derived,Vertical> colwise(); - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols); - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(Index size); - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(); + static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols); + static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index size); + static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(); template<typename ThenDerived,typename ElseDerived> const Select<Derived,ThenDerived,ElseDerived> @@ -482,7 +482,7 @@ template<typename Derived> class DenseBase // disable the use of evalTo for dense objects with a nice compilation error template<typename Dest> inline void evalTo(Dest& ) const { - EIGEN_STATIC_ASSERT((ei_is_same_type<Dest,void>::ret),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS); + EIGEN_STATIC_ASSERT((internal::is_same_type<Dest,void>::ret),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS); } protected: @@ -493,7 +493,7 @@ template<typename Derived> class DenseBase * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down */ #ifdef EIGEN_INTERNAL_DEBUGGING - EIGEN_STATIC_ASSERT(ei_are_flags_consistent<Flags>::ret, + EIGEN_STATIC_ASSERT(internal::are_flags_consistent<Flags>::ret, INVALID_MATRIXBASE_TEMPLATE_PARAMETERS) EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor)) && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))), diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index 918b246a8..d39aafc08 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -40,15 +40,15 @@ template<typename Derived> class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> { public: - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; - typedef typename ei_meta_if<bool(ei_traits<Derived>::Flags&LvalueBit), + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; + typedef typename internal::meta_if<bool(internal::traits<Derived>::Flags&LvalueBit), const Scalar&, - typename ei_meta_if<ei_is_arithmetic<Scalar>::ret, Scalar, const Scalar>::ret + typename internal::meta_if<internal::is_arithmetic<Scalar>::ret, Scalar, const Scalar>::ret >::ret CoeffReturnType; - typedef typename ei_makeconst_return_type<typename ei_packet_traits<Scalar>::type>::type PacketReturnType; + typedef typename internal::makeconst_return_type<typename internal::packet_traits<Scalar>::type>::type PacketReturnType; typedef EigenBase<Derived> Base; using Base::rows; @@ -88,7 +88,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> */ EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().coeff(row, col); } @@ -105,7 +105,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> */ EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const { - ei_assert(row >= 0 && row < rows() + eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().coeff(row, col); } @@ -128,7 +128,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); return derived().coeff(index); } @@ -146,7 +146,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> { EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime, THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD) - ei_assert(index >= 0 && index < size()); + eigen_assert(index >= 0 && index < size()); return derived().coeff(index); } @@ -163,7 +163,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> EIGEN_STRONG_INLINE CoeffReturnType operator()(Index index) const { - ei_assert(index >= 0 && index < size()); + eigen_assert(index >= 0 && index < size()); return derived().coeff(index); } @@ -199,7 +199,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> template<int LoadMode> EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().template packet<LoadMode>(row,col); } @@ -224,7 +224,7 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> template<int LoadMode> EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); return derived().template packet<LoadMode>(index); } @@ -267,10 +267,10 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; using Base::coeff; @@ -303,7 +303,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, */ EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().coeffRef(row, col); } @@ -323,7 +323,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, EIGEN_STRONG_INLINE Scalar& operator()(Index row, Index col) { - ei_assert(row >= 0 && row < rows() + eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().coeffRef(row, col); } @@ -347,7 +347,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); return derived().coeffRef(index); } @@ -363,7 +363,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, { EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime, THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD) - ei_assert(index >= 0 && index < size()); + eigen_assert(index >= 0 && index < size()); return derived().coeffRef(index); } @@ -379,7 +379,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, EIGEN_STRONG_INLINE Scalar& operator()(Index index) { - ei_assert(index >= 0 && index < size()); + eigen_assert(index >= 0 && index < size()); return derived().coeffRef(index); } @@ -414,9 +414,9 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<int StoreMode> EIGEN_STRONG_INLINE void writePacket - (Index row, Index col, const typename ei_packet_traits<Scalar>::type& x) + (Index row, Index col, const typename internal::packet_traits<Scalar>::type& x) { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); derived().template writePacket<StoreMode>(row,col,x); } @@ -424,7 +424,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<int StoreMode> EIGEN_STRONG_INLINE void writePacketByOuterInner - (Index outer, Index inner, const typename ei_packet_traits<Scalar>::type& x) + (Index outer, Index inner, const typename internal::packet_traits<Scalar>::type& x) { writePacket<StoreMode>(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner), @@ -442,9 +442,9 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<int StoreMode> EIGEN_STRONG_INLINE void writePacket - (Index index, const typename ei_packet_traits<Scalar>::type& x) + (Index index, const typename internal::packet_traits<Scalar>::type& x) { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); derived().template writePacket<StoreMode>(index,x); } @@ -461,7 +461,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<typename OtherDerived> EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, const DenseBase<OtherDerived>& other) { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); derived().coeffRef(row, col) = other.derived().coeff(row, col); } @@ -477,7 +477,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<typename OtherDerived> EIGEN_STRONG_INLINE void copyCoeff(Index index, const DenseBase<OtherDerived>& other) { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); derived().coeffRef(index) = other.derived().coeff(index); } @@ -502,7 +502,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<typename OtherDerived, int StoreMode, int LoadMode> EIGEN_STRONG_INLINE void copyPacket(Index row, Index col, const DenseBase<OtherDerived>& other) { - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); derived().template writePacket<StoreMode>(row, col, other.derived().template packet<LoadMode>(row, col)); @@ -519,7 +519,7 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, template<typename OtherDerived, int StoreMode, int LoadMode> EIGEN_STRONG_INLINE void copyPacket(Index index, const DenseBase<OtherDerived>& other) { - ei_internal_assert(index >= 0 && index < size()); + eigen_internal_assert(index >= 0 && index < size()); derived().template writePacket<StoreMode>(index, other.derived().template packet<LoadMode>(index)); } @@ -553,8 +553,8 @@ class DenseCoeffsBase<Derived, DirectAccessors> : public DenseCoeffsBase<Derived public: typedef DenseCoeffsBase<Derived, WriteAccessors> Base; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; using Base::rows; @@ -606,57 +606,61 @@ class DenseCoeffsBase<Derived, DirectAccessors> : public DenseCoeffsBase<Derived } }; +namespace internal { + template<typename Derived, bool JustReturnZero> -struct ei_first_aligned_impl +struct first_aligned_impl { inline static typename Derived::Index run(const Derived&) { return 0; } }; template<typename Derived> -struct ei_first_aligned_impl<Derived, false> +struct first_aligned_impl<Derived, false> { inline static typename Derived::Index run(const Derived& m) { - return ei_first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size()); + return first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size()); } }; /** \internal \returns the index of the first element of the array that is well aligned for vectorization. * - * There is also the variant ei_first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more + * There is also the variant first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more * documentation. */ template<typename Derived> -inline static typename Derived::Index ei_first_aligned(const Derived& m) +inline static typename Derived::Index first_aligned(const Derived& m) { - return ei_first_aligned_impl + return first_aligned_impl <Derived, (Derived::Flags & AlignedBit) || !(Derived::Flags & DirectAccessBit)> ::run(m); } -template<typename Derived, bool HasDirectAccess = ei_has_direct_access<Derived>::ret> -struct ei_inner_stride_at_compile_time +template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret> +struct inner_stride_at_compile_time { - enum { ret = ei_traits<Derived>::InnerStrideAtCompileTime }; + enum { ret = traits<Derived>::InnerStrideAtCompileTime }; }; template<typename Derived> -struct ei_inner_stride_at_compile_time<Derived, false> +struct inner_stride_at_compile_time<Derived, false> { enum { ret = 0 }; }; -template<typename Derived, bool HasDirectAccess = ei_has_direct_access<Derived>::ret> -struct ei_outer_stride_at_compile_time +template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret> +struct outer_stride_at_compile_time { - enum { ret = ei_traits<Derived>::OuterStrideAtCompileTime }; + enum { ret = traits<Derived>::OuterStrideAtCompileTime }; }; template<typename Derived> -struct ei_outer_stride_at_compile_time<Derived, false> +struct outer_stride_at_compile_time<Derived, false> { enum { ret = 0 }; }; +} // end namespace internal + #endif // EIGEN_DENSECOEFFSBASE_H diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index da6c3754f..446335568 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -33,7 +33,9 @@ #define EIGEN_INT_DEBUG_MATRIX_CTOR #endif -struct ei_constructor_without_unaligned_array_assert {}; +namespace internal { + +struct constructor_without_unaligned_array_assert {}; /** \internal * Static array. If the MatrixOptions require auto-alignment, the array will be automatically aligned: @@ -43,39 +45,41 @@ template <typename T, int Size, int MatrixOptions, int Alignment = (MatrixOptions&DontAlign) ? 0 : (((Size*sizeof(T))%16)==0) ? 16 : 0 > -struct ei_matrix_array +struct matrix_array { T array[Size]; - ei_matrix_array() {} - ei_matrix_array(ei_constructor_without_unaligned_array_assert) {} + matrix_array() {} + matrix_array(constructor_without_unaligned_array_assert) {} }; #ifdef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) #else #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ - ei_assert((reinterpret_cast<size_t>(array) & sizemask) == 0 \ + eigen_assert((reinterpret_cast<size_t>(array) & sizemask) == 0 \ && "this assertion is explained here: " \ "http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html" \ " **** READ THIS WEB PAGE !!! ****"); #endif template <typename T, int Size, int MatrixOptions> -struct ei_matrix_array<T, Size, MatrixOptions, 16> +struct matrix_array<T, Size, MatrixOptions, 16> { EIGEN_ALIGN16 T array[Size]; - ei_matrix_array() { EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf) } - ei_matrix_array(ei_constructor_without_unaligned_array_assert) {} + matrix_array() { EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf) } + matrix_array(constructor_without_unaligned_array_assert) {} }; template <typename T, int MatrixOptions, int Alignment> -struct ei_matrix_array<T, 0, MatrixOptions, Alignment> +struct matrix_array<T, 0, MatrixOptions, Alignment> { EIGEN_ALIGN16 T array[1]; - ei_matrix_array() {} - ei_matrix_array(ei_constructor_without_unaligned_array_assert) {} + matrix_array() {} + matrix_array(constructor_without_unaligned_array_assert) {} }; +} // end namespace internal + /** \internal * * \class DenseStorage @@ -93,11 +97,11 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt // purely fixed-size matrix template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage { - ei_matrix_array<T,Size,_Options> m_data; + internal::matrix_array<T,Size,_Options> m_data; public: inline explicit DenseStorage() {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) - : m_data(ei_constructor_without_unaligned_array_assert()) {} + inline DenseStorage(internal::constructor_without_unaligned_array_assert) + : m_data(internal::constructor_without_unaligned_array_assert()) {} inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); } inline static DenseIndex rows(void) {return _Rows;} @@ -113,7 +117,7 @@ template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0 { public: inline explicit DenseStorage() {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) {} + inline DenseStorage(internal::constructor_without_unaligned_array_assert) {} inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} inline void swap(DenseStorage& ) {} inline static DenseIndex rows(void) {return _Rows;} @@ -127,13 +131,13 @@ template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0 // dynamic-size matrix with fixed-size storage template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options> { - ei_matrix_array<T,Size,_Options> m_data; + internal::matrix_array<T,Size,_Options> m_data; DenseIndex m_rows; DenseIndex m_cols; public: inline explicit DenseStorage() : m_rows(0), m_cols(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) - : m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} + inline DenseStorage(internal::constructor_without_unaligned_array_assert) + : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} inline DenseStorage(DenseIndex, DenseIndex rows, DenseIndex cols) : m_rows(rows), m_cols(cols) {} inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } @@ -148,12 +152,12 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic // dynamic-size matrix with fixed-size storage and fixed width template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options> { - ei_matrix_array<T,Size,_Options> m_data; + internal::matrix_array<T,Size,_Options> m_data; DenseIndex m_rows; public: inline explicit DenseStorage() : m_rows(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) - : m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0) {} + inline DenseStorage(internal::constructor_without_unaligned_array_assert) + : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {} inline DenseStorage(DenseIndex, DenseIndex rows, DenseIndex) : m_rows(rows) {} inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } inline DenseIndex rows(void) const {return m_rows;} @@ -167,12 +171,12 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si // dynamic-size matrix with fixed-size storage and fixed height template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options> { - ei_matrix_array<T,Size,_Options> m_data; + internal::matrix_array<T,Size,_Options> m_data; DenseIndex m_cols; public: inline explicit DenseStorage() : m_cols(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) - : m_data(ei_constructor_without_unaligned_array_assert()), m_cols(0) {} + inline DenseStorage(internal::constructor_without_unaligned_array_assert) + : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {} inline DenseStorage(DenseIndex, DenseIndex, DenseIndex cols) : m_cols(cols) {} inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } inline DenseIndex rows(void) const {return _Rows;} @@ -191,19 +195,19 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam DenseIndex m_cols; public: inline explicit DenseStorage() : m_data(0), m_rows(0), m_cols(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) + inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0), m_cols(0) {} inline DenseStorage(DenseIndex size, DenseIndex rows, DenseIndex cols) - : m_data(ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols) + : m_data(internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols) { EIGEN_INT_DEBUG_MATRIX_CTOR } - inline ~DenseStorage() { ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); } + inline ~DenseStorage() { internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); } inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } inline DenseIndex rows(void) const {return m_rows;} inline DenseIndex cols(void) const {return m_cols;} inline void conservativeResize(DenseIndex size, DenseIndex rows, DenseIndex cols) { - m_data = ei_conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols); + m_data = internal::conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols); m_rows = rows; m_cols = cols; } @@ -211,9 +215,9 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam { if(size != m_rows*m_cols) { - ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); + internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); if (size) - m_data = ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size); + m_data = internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size); else m_data = 0; EIGEN_INT_DEBUG_MATRIX_CTOR @@ -232,25 +236,25 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro DenseIndex m_cols; public: inline explicit DenseStorage() : m_data(0), m_cols(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} - inline DenseStorage(DenseIndex size, DenseIndex, DenseIndex cols) : m_data(ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_cols(cols) + inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} + inline DenseStorage(DenseIndex size, DenseIndex, DenseIndex cols) : m_data(internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_cols(cols) { EIGEN_INT_DEBUG_MATRIX_CTOR } - inline ~DenseStorage() { ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); } + inline ~DenseStorage() { internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); } inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } inline static DenseIndex rows(void) {return _Rows;} inline DenseIndex cols(void) const {return m_cols;} inline void conservativeResize(DenseIndex size, DenseIndex, DenseIndex cols) { - m_data = ei_conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols); + m_data = internal::conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols); m_cols = cols; } EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex, DenseIndex cols) { if(size != _Rows*m_cols) { - ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); + internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); if (size) - m_data = ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size); + m_data = internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size); else m_data = 0; EIGEN_INT_DEBUG_MATRIX_CTOR @@ -268,25 +272,25 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn DenseIndex m_rows; public: inline explicit DenseStorage() : m_data(0), m_rows(0) {} - inline DenseStorage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} - inline DenseStorage(DenseIndex size, DenseIndex rows, DenseIndex) : m_data(ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_rows(rows) + inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} + inline DenseStorage(DenseIndex size, DenseIndex rows, DenseIndex) : m_data(internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size)), m_rows(rows) { EIGEN_INT_DEBUG_MATRIX_CTOR } - inline ~DenseStorage() { ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); } + inline ~DenseStorage() { internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); } inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } inline DenseIndex rows(void) const {return m_rows;} inline static DenseIndex cols(void) {return _Cols;} inline void conservativeResize(DenseIndex size, DenseIndex rows, DenseIndex) { - m_data = ei_conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols); + m_data = internal::conditional_aligned_realloc_new<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols); m_rows = rows; } EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex rows, DenseIndex) { if(size != m_rows*_Cols) { - ei_conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); + internal::conditional_aligned_delete<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); if (size) - m_data = ei_conditional_aligned_new<T,(_Options&DontAlign)==0>(size); + m_data = internal::conditional_aligned_new<T,(_Options&DontAlign)==0>(size); else m_data = 0; EIGEN_INT_DEBUG_MATRIX_CTOR diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index 0b7d14179..1a86b4e39 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -43,12 +43,14 @@ * * \sa MatrixBase::diagonal(), MatrixBase::diagonal(Index) */ + +namespace internal { template<typename MatrixType, int DiagIndex> -struct ei_traits<Diagonal<MatrixType,DiagIndex> > - : ei_traits<MatrixType> +struct traits<Diagonal<MatrixType,DiagIndex> > + : traits<MatrixType> { - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; typedef typename MatrixType::StorageKind StorageKind; enum { AbsDiagIndex = DiagIndex<0 ? -DiagIndex : DiagIndex, // only used if DiagIndex != Dynamic @@ -64,18 +66,19 @@ struct ei_traits<Diagonal<MatrixType,DiagIndex> > MaxColsAtCompileTime = 1, Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | LvalueBit | DirectAccessBit) & ~RowMajorBit, CoeffReadCost = _MatrixTypeNested::CoeffReadCost, - MatrixTypeOuterStride = ei_outer_stride_at_compile_time<MatrixType>::ret, + MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret, InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1, OuterStrideAtCompileTime = 0 }; }; +} template<typename MatrixType, int DiagIndex> class Diagonal - : public ei_dense_xpr_base< Diagonal<MatrixType,DiagIndex> >::type + : public internal::dense_xpr_base< Diagonal<MatrixType,DiagIndex> >::type { public: - typedef typename ei_dense_xpr_base<Diagonal>::type Base; + typedef typename internal::dense_xpr_base<Diagonal>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) inline Diagonal(const MatrixType& matrix, Index index = DiagIndex) : m_matrix(matrix), m_index(index) {} @@ -119,7 +122,7 @@ template<typename MatrixType, int DiagIndex> class Diagonal protected: const typename MatrixType::Nested m_matrix; - const ei_variable_if_dynamic<Index, DiagIndex> m_index; + const internal::variable_if_dynamic<Index, DiagIndex> m_index; private: // some compilers may fail to optimize std::max etc in case of compile-time constants... diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 630c172ed..af16cf563 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -31,10 +31,10 @@ template<typename Derived> class DiagonalBase : public EigenBase<Derived> { public: - typedef typename ei_traits<Derived>::DiagonalVectorType DiagonalVectorType; + typedef typename internal::traits<Derived>::DiagonalVectorType DiagonalVectorType; typedef typename DiagonalVectorType::Scalar Scalar; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; enum { RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, @@ -70,7 +70,7 @@ class DiagonalBase : public EigenBase<Derived> const DiagonalProduct<MatrixDerived, Derived, OnTheLeft> operator*(const MatrixBase<MatrixDerived> &matrix) const; - inline const DiagonalWrapper<CwiseUnaryOp<ei_scalar_inverse_op<Scalar>, DiagonalVectorType> > + inline const DiagonalWrapper<CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, DiagonalVectorType> > inverse() const { return diagonal().cwiseInverse(); @@ -98,9 +98,11 @@ void DiagonalBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const * * \sa class DiagonalWrapper */ + +namespace internal { template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime> -struct ei_traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> > - : ei_traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > +struct traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> > + : traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > { typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType; typedef Dense StorageKind; @@ -109,18 +111,18 @@ struct ei_traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> Flags = LvalueBit }; }; - +} template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime> class DiagonalMatrix : public DiagonalBase<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> > { public: #ifndef EIGEN_PARSED_BY_DOXYGEN - typedef typename ei_traits<DiagonalMatrix>::DiagonalVectorType DiagonalVectorType; + typedef typename internal::traits<DiagonalMatrix>::DiagonalVectorType DiagonalVectorType; typedef const DiagonalMatrix& Nested; typedef _Scalar Scalar; - typedef typename ei_traits<DiagonalMatrix>::StorageKind StorageKind; - typedef typename ei_traits<DiagonalMatrix>::Index Index; + typedef typename internal::traits<DiagonalMatrix>::StorageKind StorageKind; + typedef typename internal::traits<DiagonalMatrix>::Index Index; #endif protected: @@ -204,8 +206,10 @@ class DiagonalMatrix * * \sa class DiagonalMatrix, class DiagonalBase, MatrixBase::asDiagonal() */ + +namespace internal { template<typename _DiagonalVectorType> -struct ei_traits<DiagonalWrapper<_DiagonalVectorType> > +struct traits<DiagonalWrapper<_DiagonalVectorType> > { typedef _DiagonalVectorType DiagonalVectorType; typedef typename DiagonalVectorType::Scalar Scalar; @@ -216,13 +220,14 @@ struct ei_traits<DiagonalWrapper<_DiagonalVectorType> > ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, MaxRowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, MaxColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - Flags = ei_traits<DiagonalVectorType>::Flags & LvalueBit + Flags = traits<DiagonalVectorType>::Flags & LvalueBit }; }; +} template<typename _DiagonalVectorType> class DiagonalWrapper - : public DiagonalBase<DiagonalWrapper<_DiagonalVectorType> >, ei_no_assignment_operator + : public DiagonalBase<DiagonalWrapper<_DiagonalVectorType> >, internal::no_assignment_operator { public: #ifndef EIGEN_PARSED_BY_DOXYGEN @@ -265,21 +270,20 @@ MatrixBase<Derived>::asDiagonal() const * \sa asDiagonal() */ template<typename Derived> -bool MatrixBase<Derived>::isDiagonal -(RealScalar prec) const +bool MatrixBase<Derived>::isDiagonal(RealScalar prec) const { if(cols() != rows()) return false; RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1); for(Index j = 0; j < cols(); ++j) { - RealScalar absOnDiagonal = ei_abs(coeff(j,j)); + RealScalar absOnDiagonal = internal::abs(coeff(j,j)); if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal; } for(Index j = 0; j < cols(); ++j) for(Index i = 0; i < j; ++i) { - if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false; - if(!ei_isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false; + if(!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false; + if(!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false; } return true; } diff --git a/Eigen/src/Core/DiagonalProduct.h b/Eigen/src/Core/DiagonalProduct.h index 14c49e828..6c9b62920 100644 --- a/Eigen/src/Core/DiagonalProduct.h +++ b/Eigen/src/Core/DiagonalProduct.h @@ -26,11 +26,12 @@ #ifndef EIGEN_DIAGONALPRODUCT_H #define EIGEN_DIAGONALPRODUCT_H +namespace internal { template<typename MatrixType, typename DiagonalType, int ProductOrder> -struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > - : ei_traits<MatrixType> +struct traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > + : traits<MatrixType> { - typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar; + typedef typename scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar; enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, @@ -40,7 +41,7 @@ struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > _StorageOrder = MatrixType::Flags & RowMajorBit ? RowMajor : ColMajor, _PacketOnDiag = !((int(_StorageOrder) == RowMajor && int(ProductOrder) == OnTheLeft) ||(int(_StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), - _SameTypes = ei_is_same_type<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ret, + _SameTypes = is_same_type<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ret, // FIXME currently we need same types, but in the future the next rule should be the one //_Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && ((!_PacketOnDiag) || (_SameTypes && bool(int(DiagonalType::Flags)&PacketAccessBit))), _Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && _SameTypes && ((!_PacketOnDiag) || (bool(int(DiagonalType::Flags)&PacketAccessBit))), @@ -49,9 +50,10 @@ struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > CoeffReadCost = NumTraits<Scalar>::MulCost + MatrixType::CoeffReadCost + DiagonalType::DiagonalVectorType::CoeffReadCost }; }; +} template<typename MatrixType, typename DiagonalType, int ProductOrder> -class DiagonalProduct : ei_no_assignment_operator, +class DiagonalProduct : internal::no_assignment_operator, public MatrixBase<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > { public: @@ -62,7 +64,7 @@ class DiagonalProduct : ei_no_assignment_operator, inline DiagonalProduct(const MatrixType& matrix, const DiagonalType& diagonal) : m_matrix(matrix), m_diagonal(diagonal) { - ei_assert(diagonal.diagonal().size() == (ProductOrder == OnTheLeft ? matrix.rows() : matrix.cols())); + eigen_assert(diagonal.diagonal().size() == (ProductOrder == OnTheLeft ? matrix.rows() : matrix.cols())); } inline Index rows() const { return m_matrix.rows(); } @@ -81,27 +83,27 @@ class DiagonalProduct : ei_no_assignment_operator, }; const Index indexInDiagonalVector = ProductOrder == OnTheLeft ? row : col; - return packet_impl<LoadMode>(row,col,indexInDiagonalVector,typename ei_meta_if< + return packet_impl<LoadMode>(row,col,indexInDiagonalVector,typename internal::meta_if< ((int(StorageOrder) == RowMajor && int(ProductOrder) == OnTheLeft) - ||(int(StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), ei_meta_true, ei_meta_false>::ret()); + ||(int(StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), internal::meta_true, internal::meta_false>::ret()); } protected: template<int LoadMode> - EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, ei_meta_true) const + EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::meta_true) const { - return ei_pmul(m_matrix.template packet<LoadMode>(row, col), - ei_pset1<PacketScalar>(m_diagonal.diagonal().coeff(id))); + return internal::pmul(m_matrix.template packet<LoadMode>(row, col), + internal::pset1<PacketScalar>(m_diagonal.diagonal().coeff(id))); } template<int LoadMode> - EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, ei_meta_false) const + EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::meta_false) const { enum { InnerSize = (MatrixType::Flags & RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime, DiagonalVectorPacketLoadMode = (LoadMode == Aligned && ((InnerSize%16) == 0)) ? Aligned : Unaligned }; - return ei_pmul(m_matrix.template packet<LoadMode>(row, col), + return internal::pmul(m_matrix.template packet<LoadMode>(row, col), m_diagonal.diagonal().template packet<DiagonalVectorPacketLoadMode>(id)); } diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 7fb7f0de6..9e02f1bf3 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -25,6 +25,8 @@ #ifndef EIGEN_DOT_H #define EIGEN_DOT_H +namespace internal { + // helper function for dot(). The problem is that if we put that in the body of dot(), then upon calling dot // with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE // looking at the static assertions. Thus this is a trick to get better compile errors. @@ -37,23 +39,25 @@ template<typename T, typename U, // revert to || as soon as not needed anymore. (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1)) > -struct ei_dot_nocheck +struct dot_nocheck { - static inline typename ei_traits<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) + static inline typename traits<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) { - return a.template binaryExpr<ei_scalar_conj_product_op<typename ei_traits<T>::Scalar> >(b).sum(); + return a.template binaryExpr<scalar_conj_product_op<typename traits<T>::Scalar> >(b).sum(); } }; template<typename T, typename U> -struct ei_dot_nocheck<T, U, true> +struct dot_nocheck<T, U, true> { - static inline typename ei_traits<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) + static inline typename traits<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) { - return a.transpose().template binaryExpr<ei_scalar_conj_product_op<typename ei_traits<T>::Scalar> >(b).sum(); + return a.transpose().template binaryExpr<scalar_conj_product_op<typename traits<T>::Scalar> >(b).sum(); } }; +} // end namespace internal + /** \returns the dot product of *this with other. * * \only_for_vectors @@ -66,18 +70,18 @@ struct ei_dot_nocheck<T, U, true> */ template<typename Derived> template<typename OtherDerived> -typename ei_traits<Derived>::Scalar +typename internal::traits<Derived>::Scalar MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) - EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<Scalar, typename OtherDerived::Scalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - ei_assert(size() == other.size()); + eigen_assert(size() == other.size()); - return ei_dot_nocheck<Derived,OtherDerived>::run(*this, other); + return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other); } //---------- implementation of L2 norm and related functions ---------- @@ -87,9 +91,9 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const * \sa dot(), norm() */ template<typename Derived> -EIGEN_STRONG_INLINE typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const +EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const { - return ei_real((*this).cwiseAbs2().sum()); + return internal::real((*this).cwiseAbs2().sum()); } /** \returns the \em l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself. @@ -97,9 +101,9 @@ EIGEN_STRONG_INLINE typename NumTraits<typename ei_traits<Derived>::Scalar>::Rea * \sa dot(), squaredNorm() */ template<typename Derived> -inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const +inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const { - return ei_sqrt(squaredNorm()); + return internal::sqrt(squaredNorm()); } /** \returns an expression of the quotient of *this by its own norm. @@ -112,8 +116,8 @@ template<typename Derived> inline const typename MatrixBase<Derived>::PlainObject MatrixBase<Derived>::normalized() const { - typedef typename ei_nested<Derived>::type Nested; - typedef typename ei_unref<Nested>::type _Nested; + typedef typename internal::nested<Derived>::type Nested; + typedef typename internal::unref<Nested>::type _Nested; _Nested n(derived()); return n / n.norm(); } @@ -132,43 +136,47 @@ inline void MatrixBase<Derived>::normalize() //---------- implementation of other norms ---------- +namespace internal { + template<typename Derived, int p> -struct ei_lpNorm_selector +struct lpNorm_selector { - typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar; + typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar; inline static RealScalar run(const MatrixBase<Derived>& m) { - return ei_pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p); + return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p); } }; template<typename Derived> -struct ei_lpNorm_selector<Derived, 1> +struct lpNorm_selector<Derived, 1> { - inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) + inline static typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) { return m.cwiseAbs().sum(); } }; template<typename Derived> -struct ei_lpNorm_selector<Derived, 2> +struct lpNorm_selector<Derived, 2> { - inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) + inline static typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) { return m.norm(); } }; template<typename Derived> -struct ei_lpNorm_selector<Derived, Infinity> +struct lpNorm_selector<Derived, Infinity> { - inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) + inline static typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) { return m.cwiseAbs().maxCoeff(); } }; +} // end namespace internal + /** \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values * of the coefficients of *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^\infty \f$ * norm, that is the maximum of the absolute values of the coefficients of *this. @@ -177,10 +185,10 @@ struct ei_lpNorm_selector<Derived, Infinity> */ template<typename Derived> template<int p> -inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real +inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::lpNorm() const { - return ei_lpNorm_selector<Derived, p>::run(*this); + return internal::lpNorm_selector<Derived, p>::run(*this); } //---------- implementation of isOrthogonal / isUnitary ---------- @@ -196,9 +204,9 @@ template<typename OtherDerived> bool MatrixBase<Derived>::isOrthogonal (const MatrixBase<OtherDerived>& other, RealScalar prec) const { - typename ei_nested<Derived,2>::type nested(derived()); - typename ei_nested<OtherDerived,2>::type otherNested(other.derived()); - return ei_abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm(); + typename internal::nested<Derived,2>::type nested(derived()); + typename internal::nested<OtherDerived,2>::type otherNested(other.derived()); + return internal::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm(); } /** \returns true if *this is approximately an unitary matrix, @@ -218,10 +226,10 @@ bool MatrixBase<Derived>::isUnitary(RealScalar prec) const typename Derived::Nested nested(derived()); for(Index i = 0; i < cols(); ++i) { - if(!ei_isApprox(nested.col(i).squaredNorm(), static_cast<RealScalar>(1), prec)) + if(!internal::isApprox(nested.col(i).squaredNorm(), static_cast<RealScalar>(1), prec)) return false; for(Index j = 0; j < i; ++j) - if(!ei_isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast<Scalar>(1), prec)) + if(!internal::isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast<Scalar>(1), prec)) return false; } return true; diff --git a/Eigen/src/Core/EigenBase.h b/Eigen/src/Core/EigenBase.h index d07fea9a2..69e964350 100644 --- a/Eigen/src/Core/EigenBase.h +++ b/Eigen/src/Core/EigenBase.h @@ -39,10 +39,10 @@ */ template<typename Derived> struct EigenBase { -// typedef typename ei_plain_matrix_type<Derived>::type PlainObject; +// typedef typename internal::plain_matrix_type<Derived>::type PlainObject; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; /** \returns a reference to the derived object */ Derived& derived() { return *static_cast<Derived*>(this); } diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h index 9211c50e8..8d2207a7f 100644 --- a/Eigen/src/Core/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -40,11 +40,14 @@ * * \sa MatrixBase::flagged() */ + +namespace internal { template<typename ExpressionType, unsigned int Added, unsigned int Removed> -struct ei_traits<Flagged<ExpressionType, Added, Removed> > : ei_traits<ExpressionType> +struct traits<Flagged<ExpressionType, Added, Removed> > : traits<ExpressionType> { enum { Flags = (ExpressionType::Flags | Added) & ~Removed }; }; +} template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged : public MatrixBase<Flagged<ExpressionType, Added, Removed> > @@ -53,7 +56,7 @@ template<typename ExpressionType, unsigned int Added, unsigned int Removed> clas typedef MatrixBase<Flagged> Base; EIGEN_DENSE_PUBLIC_INTERFACE(Flagged) - typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret, + typedef typename internal::meta_if<internal::must_nest_by_value<ExpressionType>::ret, ExpressionType, const ExpressionType&>::ret ExpressionTypeNested; typedef typename ExpressionType::InnerIterator InnerIterator; diff --git a/Eigen/src/Core/ForceAlignedAccess.h b/Eigen/src/Core/ForceAlignedAccess.h index 06d78fbe2..727b87e64 100644 --- a/Eigen/src/Core/ForceAlignedAccess.h +++ b/Eigen/src/Core/ForceAlignedAccess.h @@ -37,16 +37,19 @@ * * \sa MatrixBase::forceAlignedAccess() */ + +namespace internal { template<typename ExpressionType> -struct ei_traits<ForceAlignedAccess<ExpressionType> > : public ei_traits<ExpressionType> +struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType> {}; +} template<typename ExpressionType> class ForceAlignedAccess - : public ei_dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type + : public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type { public: - typedef typename ei_dense_xpr_base<ForceAlignedAccess>::type Base; + typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess) inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {} @@ -134,7 +137,7 @@ MatrixBase<Derived>::forceAlignedAccess() */ template<typename Derived> template<bool Enable> -inline typename ei_makeconst<typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret>::type +inline typename internal::makeconst<typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret>::type MatrixBase<Derived>::forceAlignedAccessIf() const { return derived(); @@ -145,7 +148,7 @@ MatrixBase<Derived>::forceAlignedAccessIf() const */ template<typename Derived> template<bool Enable> -inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret +inline typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret MatrixBase<Derived>::forceAlignedAccessIf() { return derived(); diff --git a/Eigen/src/Core/Functors.h b/Eigen/src/Core/Functors.h index 052bcc35c..6716ccae8 100644 --- a/Eigen/src/Core/Functors.h +++ b/Eigen/src/Core/Functors.h @@ -25,6 +25,8 @@ #ifndef EIGEN_FUNCTORS_H #define EIGEN_FUNCTORS_H +namespace internal { + // associative functors: /** \internal @@ -32,21 +34,21 @@ * * \sa class CwiseBinaryOp, MatrixBase::operator+, class VectorwiseOp, MatrixBase::sum() */ -template<typename Scalar> struct ei_scalar_sum_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_sum_op) +template<typename Scalar> struct scalar_sum_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_padd(a,b); } + { return internal::padd(a,b); } template<typename Packet> EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return ei_predux(a); } + { return internal::predux(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_sum_op<Scalar> > { +struct functor_traits<scalar_sum_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasAdd + PacketAccess = packet_traits<Scalar>::HasAdd }; }; @@ -55,47 +57,47 @@ struct ei_functor_traits<ei_scalar_sum_op<Scalar> > { * * \sa class CwiseBinaryOp, Cwise::operator*(), class VectorwiseOp, MatrixBase::redux() */ -template<typename LhsScalar,typename RhsScalar> struct ei_scalar_product_op { +template<typename LhsScalar,typename RhsScalar> struct scalar_product_op { enum { - Vectorizable = ei_is_same_type<LhsScalar,RhsScalar>::ret && ei_packet_traits<LhsScalar>::HasMul && ei_packet_traits<RhsScalar>::HasMul + Vectorizable = is_same_type<LhsScalar,RhsScalar>::ret && packet_traits<LhsScalar>::HasMul && packet_traits<RhsScalar>::HasMul }; - typedef typename ei_scalar_product_traits<LhsScalar,RhsScalar>::ReturnType result_type; - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_product_op) + typedef typename scalar_product_traits<LhsScalar,RhsScalar>::ReturnType result_type; + EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op) EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a * b; } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_pmul(a,b); } + { return internal::pmul(a,b); } template<typename Packet> EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const - { return ei_predux_mul(a); } + { return internal::predux_mul(a); } }; template<typename LhsScalar,typename RhsScalar> -struct ei_functor_traits<ei_scalar_product_op<LhsScalar,RhsScalar> > { +struct functor_traits<scalar_product_op<LhsScalar,RhsScalar> > { enum { Cost = (NumTraits<LhsScalar>::MulCost + NumTraits<RhsScalar>::MulCost)/2, // rough estimate! - PacketAccess = ei_scalar_product_op<LhsScalar,RhsScalar>::Vectorizable + PacketAccess = scalar_product_op<LhsScalar,RhsScalar>::Vectorizable }; }; /** \internal * \brief Template functor to compute the conjugate product of two scalars * - * This is a short cut for ei_conj(x) * y which is needed for optimization purpose + * This is a short cut for conj(x) * y which is needed for optimization purpose */ -template<typename Scalar> struct ei_scalar_conj_product_op { +template<typename Scalar> struct scalar_conj_product_op { enum { Conj = NumTraits<Scalar>::IsComplex }; - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_conj_product_op) + EIGEN_EMPTY_STRUCT_CTOR(scalar_conj_product_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const - { return ei_conj_helper<Scalar,Scalar,Conj,false>().pmul(a,b); } + { return conj_helper<Scalar,Scalar,Conj,false>().pmul(a,b); } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_conj_helper<Packet,Packet,Conj,false>().pmul(a,b); } + { return conj_helper<Packet,Packet,Conj,false>().pmul(a,b); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_conj_product_op<Scalar> > { +struct functor_traits<scalar_conj_product_op<Scalar> > { enum { Cost = NumTraits<Scalar>::MulCost, - PacketAccess = ei_packet_traits<Scalar>::HasMul + PacketAccess = packet_traits<Scalar>::HasMul }; }; @@ -104,21 +106,21 @@ struct ei_functor_traits<ei_scalar_conj_product_op<Scalar> > { * * \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class VectorwiseOp, MatrixBase::minCoeff() */ -template<typename Scalar> struct ei_scalar_min_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_min_op) +template<typename Scalar> struct scalar_min_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_min_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::min(a, b); } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_pmin(a,b); } + { return internal::pmin(a,b); } template<typename Packet> EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return ei_predux_min(a); } + { return internal::predux_min(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_min_op<Scalar> > { +struct functor_traits<scalar_min_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasMin + PacketAccess = packet_traits<Scalar>::HasMin }; }; @@ -127,21 +129,21 @@ struct ei_functor_traits<ei_scalar_min_op<Scalar> > { * * \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class VectorwiseOp, MatrixBase::maxCoeff() */ -template<typename Scalar> struct ei_scalar_max_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_max_op) +template<typename Scalar> struct scalar_max_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::max(a, b); } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_pmax(a,b); } + { return internal::pmax(a,b); } template<typename Packet> EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return ei_predux_max(a); } + { return internal::predux_max(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_max_op<Scalar> > { +struct functor_traits<scalar_max_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasMax + PacketAccess = packet_traits<Scalar>::HasMax }; }; @@ -150,19 +152,19 @@ struct ei_functor_traits<ei_scalar_max_op<Scalar> > { * * \sa MatrixBase::stableNorm(), class Redux */ -template<typename Scalar> struct ei_scalar_hypot_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_hypot_op) +template<typename Scalar> struct scalar_hypot_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_hypot_op) // typedef typename NumTraits<Scalar>::Real result_type; EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& _x, const Scalar& _y) const { Scalar p = std::max(_x, _y); Scalar q = std::min(_x, _y); Scalar qp = q/p; - return p * ei_sqrt(Scalar(1) + qp*qp); + return p * sqrt(Scalar(1) + qp*qp); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_hypot_op<Scalar> > { +struct functor_traits<scalar_hypot_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess=0 }; }; @@ -173,18 +175,18 @@ struct ei_functor_traits<ei_scalar_hypot_op<Scalar> > { * * \sa class CwiseBinaryOp, MatrixBase::operator- */ -template<typename Scalar> struct ei_scalar_difference_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_difference_op) +template<typename Scalar> struct scalar_difference_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_psub(a,b); } + { return internal::psub(a,b); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_difference_op<Scalar> > { +struct functor_traits<scalar_difference_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasSub + PacketAccess = packet_traits<Scalar>::HasSub }; }; @@ -193,18 +195,18 @@ struct ei_functor_traits<ei_scalar_difference_op<Scalar> > { * * \sa class CwiseBinaryOp, Cwise::operator/() */ -template<typename Scalar> struct ei_scalar_quotient_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_quotient_op) +template<typename Scalar> struct scalar_quotient_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a / b; } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return ei_pdiv(a,b); } + { return internal::pdiv(a,b); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_quotient_op<Scalar> > { +struct functor_traits<scalar_quotient_op<Scalar> > { enum { Cost = 2 * NumTraits<Scalar>::MulCost, - PacketAccess = ei_packet_traits<Scalar>::HasDiv + PacketAccess = packet_traits<Scalar>::HasDiv }; }; @@ -215,18 +217,18 @@ struct ei_functor_traits<ei_scalar_quotient_op<Scalar> > { * * \sa class CwiseUnaryOp, MatrixBase::operator- */ -template<typename Scalar> struct ei_scalar_opposite_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_opposite_op) +template<typename Scalar> struct scalar_opposite_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_opposite_op) EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return ei_pnegate(a); } + { return internal::pnegate(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_opposite_op<Scalar> > +struct functor_traits<scalar_opposite_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasNegate }; + PacketAccess = packet_traits<Scalar>::HasNegate }; }; /** \internal @@ -234,20 +236,20 @@ struct ei_functor_traits<ei_scalar_opposite_op<Scalar> > * * \sa class CwiseUnaryOp, Cwise::abs */ -template<typename Scalar> struct ei_scalar_abs_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_abs_op) +template<typename Scalar> struct scalar_abs_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_abs_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return ei_abs(a); } + EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return abs(a); } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return ei_pabs(a); } + { return internal::pabs(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_abs_op<Scalar> > +struct functor_traits<scalar_abs_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, - PacketAccess = ei_packet_traits<Scalar>::HasAbs + PacketAccess = packet_traits<Scalar>::HasAbs }; }; @@ -256,35 +258,35 @@ struct ei_functor_traits<ei_scalar_abs_op<Scalar> > * * \sa class CwiseUnaryOp, Cwise::abs2 */ -template<typename Scalar> struct ei_scalar_abs2_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_abs2_op) +template<typename Scalar> struct scalar_abs2_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_abs2_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return ei_abs2(a); } + EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return abs2(a); } template<typename Packet> EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return ei_pmul(a,a); } + { return internal::pmul(a,a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_abs2_op<Scalar> > -{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasAbs2 }; }; +struct functor_traits<scalar_abs2_op<Scalar> > +{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasAbs2 }; }; /** \internal * \brief Template functor to compute the conjugate of a complex value * * \sa class CwiseUnaryOp, MatrixBase::conjugate() */ -template<typename Scalar> struct ei_scalar_conjugate_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_conjugate_op) - EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return ei_conj(a); } +template<typename Scalar> struct scalar_conjugate_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op) + EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return conj(a); } template<typename Packet> - EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return ei_pconj(a); } + EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_conjugate_op<Scalar> > +struct functor_traits<scalar_conjugate_op<Scalar> > { enum { Cost = NumTraits<Scalar>::IsComplex ? NumTraits<Scalar>::AddCost : 0, - PacketAccess = ei_packet_traits<Scalar>::HasConj + PacketAccess = packet_traits<Scalar>::HasConj }; }; @@ -294,14 +296,14 @@ struct ei_functor_traits<ei_scalar_conjugate_op<Scalar> > * \sa class CwiseUnaryOp, MatrixBase::cast() */ template<typename Scalar, typename NewType> -struct ei_scalar_cast_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_cast_op) +struct scalar_cast_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op) typedef NewType result_type; - EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return ei_cast<Scalar, NewType>(a); } + EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return cast<Scalar, NewType>(a); } }; template<typename Scalar, typename NewType> -struct ei_functor_traits<ei_scalar_cast_op<Scalar,NewType> > -{ enum { Cost = ei_is_same_type<Scalar, NewType>::ret ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; }; +struct functor_traits<scalar_cast_op<Scalar,NewType> > +{ enum { Cost = is_same_type<Scalar, NewType>::ret ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; }; /** \internal * \brief Template functor to extract the real part of a complex @@ -309,13 +311,13 @@ struct ei_functor_traits<ei_scalar_cast_op<Scalar,NewType> > * \sa class CwiseUnaryOp, MatrixBase::real() */ template<typename Scalar> -struct ei_scalar_real_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_real_op) +struct scalar_real_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_real_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return ei_real(a); } + EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return real(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_real_op<Scalar> > +struct functor_traits<scalar_real_op<Scalar> > { enum { Cost = 0, PacketAccess = false }; }; /** \internal @@ -324,13 +326,13 @@ struct ei_functor_traits<ei_scalar_real_op<Scalar> > * \sa class CwiseUnaryOp, MatrixBase::imag() */ template<typename Scalar> -struct ei_scalar_imag_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_imag_op) +struct scalar_imag_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return ei_imag(a); } + EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return imag(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_imag_op<Scalar> > +struct functor_traits<scalar_imag_op<Scalar> > { enum { Cost = 0, PacketAccess = false }; }; /** \internal @@ -339,13 +341,13 @@ struct ei_functor_traits<ei_scalar_imag_op<Scalar> > * \sa class CwiseUnaryOp, MatrixBase::real() */ template<typename Scalar> -struct ei_scalar_real_ref_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_real_ref_op) +struct scalar_real_ref_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_real_ref_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return ei_real_ref(*const_cast<Scalar*>(&a)); } + EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return real_ref(*const_cast<Scalar*>(&a)); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_real_ref_op<Scalar> > +struct functor_traits<scalar_real_ref_op<Scalar> > { enum { Cost = 0, PacketAccess = false }; }; /** \internal @@ -354,13 +356,13 @@ struct ei_functor_traits<ei_scalar_real_ref_op<Scalar> > * \sa class CwiseUnaryOp, MatrixBase::imag() */ template<typename Scalar> -struct ei_scalar_imag_ref_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_imag_ref_op) +struct scalar_imag_ref_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_ref_op) typedef typename NumTraits<Scalar>::Real result_type; - EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return ei_imag_ref(*const_cast<Scalar*>(&a)); } + EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return imag_ref(*const_cast<Scalar*>(&a)); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_imag_ref_op<Scalar> > +struct functor_traits<scalar_imag_ref_op<Scalar> > { enum { Cost = 0, PacketAccess = false }; }; /** \internal @@ -369,15 +371,15 @@ struct ei_functor_traits<ei_scalar_imag_ref_op<Scalar> > * * \sa class CwiseUnaryOp, Cwise::exp() */ -template<typename Scalar> struct ei_scalar_exp_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_exp_op) - inline const Scalar operator() (const Scalar& a) const { return ei_exp(a); } - typedef typename ei_packet_traits<Scalar>::type Packet; - inline Packet packetOp(const Packet& a) const { return ei_pexp(a); } +template<typename Scalar> struct scalar_exp_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op) + inline const Scalar operator() (const Scalar& a) const { return exp(a); } + typedef typename packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return internal::pexp(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_exp_op<Scalar> > -{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasExp }; }; +struct functor_traits<scalar_exp_op<Scalar> > +{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasExp }; }; /** \internal * @@ -385,81 +387,81 @@ struct ei_functor_traits<ei_scalar_exp_op<Scalar> > * * \sa class CwiseUnaryOp, Cwise::log() */ -template<typename Scalar> struct ei_scalar_log_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_log_op) - inline const Scalar operator() (const Scalar& a) const { return ei_log(a); } - typedef typename ei_packet_traits<Scalar>::type Packet; - inline Packet packetOp(const Packet& a) const { return ei_plog(a); } +template<typename Scalar> struct scalar_log_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op) + inline const Scalar operator() (const Scalar& a) const { return log(a); } + typedef typename packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return internal::plog(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_log_op<Scalar> > -{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasLog }; }; +struct functor_traits<scalar_log_op<Scalar> > +{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog }; }; /** \internal * \brief Template functor to multiply a scalar by a fixed other one * * \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/ */ -/* NOTE why doing the ei_pset1() in packetOp *is* an optimization ? - * indeed it seems better to declare m_other as a Packet and do the ei_pset1() once +/* NOTE why doing the pset1() in packetOp *is* an optimization ? + * indeed it seems better to declare m_other as a Packet and do the pset1() once * in the constructor. However, in practice: * - GCC does not like m_other as a Packet and generate a load every time it needs it - * - on the other hand GCC is able to moves the ei_pset1() away the loop :) + * - on the other hand GCC is able to moves the pset1() away the loop :) * - simpler code ;) * (ICC and gcc 4.4 seems to perform well in both cases, the issue is visible with y = a*x + b*y) */ template<typename Scalar> -struct ei_scalar_multiple_op { - typedef typename ei_packet_traits<Scalar>::type Packet; +struct scalar_multiple_op { + typedef typename packet_traits<Scalar>::type Packet; // FIXME default copy constructors seems bugged with std::complex<> - EIGEN_STRONG_INLINE ei_scalar_multiple_op(const ei_scalar_multiple_op& other) : m_other(other.m_other) { } - EIGEN_STRONG_INLINE ei_scalar_multiple_op(const Scalar& other) : m_other(other) { } + EIGEN_STRONG_INLINE scalar_multiple_op(const scalar_multiple_op& other) : m_other(other.m_other) { } + EIGEN_STRONG_INLINE scalar_multiple_op(const Scalar& other) : m_other(other) { } EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; } EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return ei_pmul(a, ei_pset1<Packet>(m_other)); } - typename ei_makeconst<typename NumTraits<Scalar>::Nested>::type m_other; + { return internal::pmul(a, pset1<Packet>(m_other)); } + typename makeconst<typename NumTraits<Scalar>::Nested>::type m_other; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_multiple_op<Scalar> > -{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasMul }; }; +struct functor_traits<scalar_multiple_op<Scalar> > +{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; }; template<typename Scalar1, typename Scalar2> -struct ei_scalar_multiple2_op { - typedef typename ei_scalar_product_traits<Scalar1,Scalar2>::ReturnType result_type; - EIGEN_STRONG_INLINE ei_scalar_multiple2_op(const ei_scalar_multiple2_op& other) : m_other(other.m_other) { } - EIGEN_STRONG_INLINE ei_scalar_multiple2_op(const Scalar2& other) : m_other(other) { } +struct scalar_multiple2_op { + typedef typename scalar_product_traits<Scalar1,Scalar2>::ReturnType result_type; + EIGEN_STRONG_INLINE scalar_multiple2_op(const scalar_multiple2_op& other) : m_other(other.m_other) { } + EIGEN_STRONG_INLINE scalar_multiple2_op(const Scalar2& other) : m_other(other) { } EIGEN_STRONG_INLINE result_type operator() (const Scalar1& a) const { return a * m_other; } - typename ei_makeconst<typename NumTraits<Scalar2>::Nested>::type m_other; + typename makeconst<typename NumTraits<Scalar2>::Nested>::type m_other; }; template<typename Scalar1,typename Scalar2> -struct ei_functor_traits<ei_scalar_multiple2_op<Scalar1,Scalar2> > +struct functor_traits<scalar_multiple2_op<Scalar1,Scalar2> > { enum { Cost = NumTraits<Scalar1>::MulCost, PacketAccess = false }; }; template<typename Scalar, bool IsInteger> -struct ei_scalar_quotient1_impl { - typedef typename ei_packet_traits<Scalar>::type Packet; +struct scalar_quotient1_impl { + typedef typename packet_traits<Scalar>::type Packet; // FIXME default copy constructors seems bugged with std::complex<> - EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const ei_scalar_quotient1_impl& other) : m_other(other.m_other) { } - EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const Scalar& other) : m_other(static_cast<Scalar>(1) / other) {} + EIGEN_STRONG_INLINE scalar_quotient1_impl(const scalar_quotient1_impl& other) : m_other(other.m_other) { } + EIGEN_STRONG_INLINE scalar_quotient1_impl(const Scalar& other) : m_other(static_cast<Scalar>(1) / other) {} EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; } EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return ei_pmul(a, ei_pset1<Packet>(m_other)); } + { return internal::pmul(a, pset1<Packet>(m_other)); } const Scalar m_other; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_quotient1_impl<Scalar,false> > -{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasMul }; }; +struct functor_traits<scalar_quotient1_impl<Scalar,false> > +{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; }; template<typename Scalar> -struct ei_scalar_quotient1_impl<Scalar,true> { +struct scalar_quotient1_impl<Scalar,true> { // FIXME default copy constructors seems bugged with std::complex<> - EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const ei_scalar_quotient1_impl& other) : m_other(other.m_other) { } - EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const Scalar& other) : m_other(other) {} + EIGEN_STRONG_INLINE scalar_quotient1_impl(const scalar_quotient1_impl& other) : m_other(other.m_other) { } + EIGEN_STRONG_INLINE scalar_quotient1_impl(const Scalar& other) : m_other(other) {} EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a / m_other; } - typename ei_makeconst<typename NumTraits<Scalar>::Nested>::type m_other; + typename makeconst<typename NumTraits<Scalar>::Nested>::type m_other; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_quotient1_impl<Scalar,true> > +struct functor_traits<scalar_quotient1_impl<Scalar,true> > { enum { Cost = 2 * NumTraits<Scalar>::MulCost, PacketAccess = false }; }; /** \internal @@ -471,43 +473,43 @@ struct ei_functor_traits<ei_scalar_quotient1_impl<Scalar,true> > * \sa class CwiseUnaryOp, MatrixBase::operator/ */ template<typename Scalar> -struct ei_scalar_quotient1_op : ei_scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger > { - EIGEN_STRONG_INLINE ei_scalar_quotient1_op(const Scalar& other) - : ei_scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger >(other) {} +struct scalar_quotient1_op : scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger > { + EIGEN_STRONG_INLINE scalar_quotient1_op(const Scalar& other) + : scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger >(other) {} }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_quotient1_op<Scalar> > -: ei_functor_traits<ei_scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger> > +struct functor_traits<scalar_quotient1_op<Scalar> > +: functor_traits<scalar_quotient1_impl<Scalar, NumTraits<Scalar>::IsInteger> > {}; // nullary functors template<typename Scalar> -struct ei_scalar_constant_op { - typedef typename ei_packet_traits<Scalar>::type Packet; - EIGEN_STRONG_INLINE ei_scalar_constant_op(const ei_scalar_constant_op& other) : m_other(other.m_other) { } - EIGEN_STRONG_INLINE ei_scalar_constant_op(const Scalar& other) : m_other(other) { } +struct scalar_constant_op { + typedef typename packet_traits<Scalar>::type Packet; + EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) { } + EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) { } template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index, Index = 0) const { return m_other; } template<typename Index> - EIGEN_STRONG_INLINE const Packet packetOp(Index, Index = 0) const { return ei_pset1<Packet>(m_other); } + EIGEN_STRONG_INLINE const Packet packetOp(Index, Index = 0) const { return internal::pset1<Packet>(m_other); } const Scalar m_other; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_constant_op<Scalar> > +struct functor_traits<scalar_constant_op<Scalar> > // FIXME replace this packet test by a safe one -{ enum { Cost = 1, PacketAccess = ei_packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; }; +{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; }; -template<typename Scalar> struct ei_scalar_identity_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_identity_op) +template<typename Scalar> struct scalar_identity_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op) template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const { return row==col ? Scalar(1) : Scalar(0); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_identity_op<Scalar> > +struct functor_traits<scalar_identity_op<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false, IsRepeatable = true }; }; -template <typename Scalar, bool RandomAccess> struct ei_linspaced_op_impl; +template <typename Scalar, bool RandomAccess> struct linspaced_op_impl; // linear access for packet ops: // 1) initialization @@ -515,19 +517,19 @@ template <typename Scalar, bool RandomAccess> struct ei_linspaced_op_impl; // 2) each step // base += [size*step, ..., size*step] template <typename Scalar> -struct ei_linspaced_op_impl<Scalar,false> +struct linspaced_op_impl<Scalar,false> { - typedef typename ei_packet_traits<Scalar>::type Packet; + typedef typename packet_traits<Scalar>::type Packet; - ei_linspaced_op_impl(Scalar low, Scalar step) : + linspaced_op_impl(Scalar low, Scalar step) : m_low(low), m_step(step), - m_packetStep(ei_pset1<Packet>(ei_packet_traits<Scalar>::size*step)), - m_base(ei_padd(ei_pset1<Packet>(low),ei_pmul(ei_pset1<Packet>(step),ei_plset<Scalar>(-ei_packet_traits<Scalar>::size)))) {} + m_packetStep(pset1<Packet>(packet_traits<Scalar>::size*step)), + m_base(padd(pset1<Packet>(low),pmul(pset1<Packet>(step),plset<Scalar>(-packet_traits<Scalar>::size)))) {} template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+i*m_step; } template<typename Index> - EIGEN_STRONG_INLINE const Packet packetOp(Index) const { return m_base = ei_padd(m_base,m_packetStep); } + EIGEN_STRONG_INLINE const Packet packetOp(Index) const { return m_base = padd(m_base,m_packetStep); } const Scalar m_low; const Scalar m_step; @@ -539,20 +541,20 @@ struct ei_linspaced_op_impl<Scalar,false> // 1) each step // [low, ..., low] + ( [step, ..., step] * ( [i, ..., i] + [0, ..., size] ) ) template <typename Scalar> -struct ei_linspaced_op_impl<Scalar,true> +struct linspaced_op_impl<Scalar,true> { - typedef typename ei_packet_traits<Scalar>::type Packet; + typedef typename packet_traits<Scalar>::type Packet; - ei_linspaced_op_impl(Scalar low, Scalar step) : + linspaced_op_impl(Scalar low, Scalar step) : m_low(low), m_step(step), - m_lowPacket(ei_pset1<Packet>(m_low)), m_stepPacket(ei_pset1<Packet>(m_step)), m_interPacket(ei_plset<Scalar>(0)) {} + m_lowPacket(pset1<Packet>(m_low)), m_stepPacket(pset1<Packet>(m_step)), m_interPacket(plset<Scalar>(0)) {} template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+i*m_step; } template<typename Index> EIGEN_STRONG_INLINE const Packet packetOp(Index i) const - { return ei_padd(m_lowPacket, ei_pmul(m_stepPacket, ei_padd(ei_pset1<Packet>(i),m_interPacket))); } + { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(i),m_interPacket))); } const Scalar m_low; const Scalar m_step; @@ -566,13 +568,13 @@ struct ei_linspaced_op_impl<Scalar,true> // Forward declaration (we default to random access which does not really give // us a speed gain when using packet access but it allows to use the functor in // nested expressions). -template <typename Scalar, bool RandomAccess = true> struct ei_linspaced_op; -template <typename Scalar, bool RandomAccess> struct ei_functor_traits< ei_linspaced_op<Scalar,RandomAccess> > -{ enum { Cost = 1, PacketAccess = ei_packet_traits<Scalar>::HasSetLinear, IsRepeatable = true }; }; -template <typename Scalar, bool RandomAccess> struct ei_linspaced_op +template <typename Scalar, bool RandomAccess = true> struct linspaced_op; +template <typename Scalar, bool RandomAccess> struct functor_traits< linspaced_op<Scalar,RandomAccess> > +{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::HasSetLinear, IsRepeatable = true }; }; +template <typename Scalar, bool RandomAccess> struct linspaced_op { - typedef typename ei_packet_traits<Scalar>::type Packet; - ei_linspaced_op(Scalar low, Scalar high, int num_steps) : impl(low, (high-low)/(num_steps-1)) {} + typedef typename packet_traits<Scalar>::type Packet; + linspaced_op(Scalar low, Scalar high, int num_steps) : impl(low, (high-low)/(num_steps-1)) {} template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); } @@ -582,7 +584,7 @@ template <typename Scalar, bool RandomAccess> struct ei_linspaced_op template<typename Index> EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const { - ei_assert(col==0 || row==0); + eigen_assert(col==0 || row==0); return impl(col + row); } @@ -594,65 +596,65 @@ template <typename Scalar, bool RandomAccess> struct ei_linspaced_op template<typename Index> EIGEN_STRONG_INLINE const Packet packetOp(Index row, Index col) const { - ei_assert(col==0 || row==0); + eigen_assert(col==0 || row==0); return impl(col + row); } // This proxy object handles the actual required temporaries, the different // implementations (random vs. sequential access) as well as the // correct piping to size 2/4 packet operations. - const ei_linspaced_op_impl<Scalar,RandomAccess> impl; + const linspaced_op_impl<Scalar,RandomAccess> impl; }; -// all functors allow linear access, except ei_scalar_identity_op. So we fix here a quick meta +// all functors allow linear access, except scalar_identity_op. So we fix here a quick meta // to indicate whether a functor allows linear access, just always answering 'yes' except for -// ei_scalar_identity_op. -// FIXME move this to ei_functor_traits adding a ei_functor_default -template<typename Functor> struct ei_functor_has_linear_access { enum { ret = 1 }; }; -template<typename Scalar> struct ei_functor_has_linear_access<ei_scalar_identity_op<Scalar> > { enum { ret = 0 }; }; +// scalar_identity_op. +// FIXME move this to functor_traits adding a functor_default +template<typename Functor> struct functor_has_linear_access { enum { ret = 1 }; }; +template<typename Scalar> struct functor_has_linear_access<scalar_identity_op<Scalar> > { enum { ret = 0 }; }; // in CwiseBinaryOp, we require the Lhs and Rhs to have the same scalar type, except for multiplication // where we only require them to have the same _real_ scalar type so one may multiply, say, float by complex<float>. -// FIXME move this to ei_functor_traits adding a ei_functor_default -template<typename Functor> struct ei_functor_allows_mixing_real_and_complex { enum { ret = 0 }; }; -template<typename LhsScalar,typename RhsScalar> struct ei_functor_allows_mixing_real_and_complex<ei_scalar_product_op<LhsScalar,RhsScalar> > { enum { ret = 1 }; }; +// FIXME move this to functor_traits adding a functor_default +template<typename Functor> struct functor_allows_mixing_real_and_complex { enum { ret = 0 }; }; +template<typename LhsScalar,typename RhsScalar> struct functor_allows_mixing_real_and_complex<scalar_product_op<LhsScalar,RhsScalar> > { enum { ret = 1 }; }; /** \internal * \brief Template functor to add a scalar to a fixed other one * \sa class CwiseUnaryOp, Array::operator+ */ -/* If you wonder why doing the ei_pset1() in packetOp() is an optimization check ei_scalar_multiple_op */ +/* If you wonder why doing the pset1() in packetOp() is an optimization check scalar_multiple_op */ template<typename Scalar> -struct ei_scalar_add_op { - typedef typename ei_packet_traits<Scalar>::type Packet; +struct scalar_add_op { + typedef typename packet_traits<Scalar>::type Packet; // FIXME default copy constructors seems bugged with std::complex<> - inline ei_scalar_add_op(const ei_scalar_add_op& other) : m_other(other.m_other) { } - inline ei_scalar_add_op(const Scalar& other) : m_other(other) { } + inline scalar_add_op(const scalar_add_op& other) : m_other(other.m_other) { } + inline scalar_add_op(const Scalar& other) : m_other(other) { } inline Scalar operator() (const Scalar& a) const { return a + m_other; } inline const Packet packetOp(const Packet& a) const - { return ei_padd(a, ei_pset1<Packet>(m_other)); } + { return internal::padd(a, pset1<Packet>(m_other)); } const Scalar m_other; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_add_op<Scalar> > -{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = ei_packet_traits<Scalar>::HasAdd }; }; +struct functor_traits<scalar_add_op<Scalar> > +{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = packet_traits<Scalar>::HasAdd }; }; /** \internal * \brief Template functor to compute the square root of a scalar * \sa class CwiseUnaryOp, Cwise::sqrt() */ -template<typename Scalar> struct ei_scalar_sqrt_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_sqrt_op) - inline const Scalar operator() (const Scalar& a) const { return ei_sqrt(a); } - typedef typename ei_packet_traits<Scalar>::type Packet; - inline Packet packetOp(const Packet& a) const { return ei_psqrt(a); } +template<typename Scalar> struct scalar_sqrt_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op) + inline const Scalar operator() (const Scalar& a) const { return sqrt(a); } + typedef typename packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> > +struct functor_traits<scalar_sqrt_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, - PacketAccess = ei_packet_traits<Scalar>::HasSqrt + PacketAccess = packet_traits<Scalar>::HasSqrt }; }; @@ -660,18 +662,18 @@ struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> > * \brief Template functor to compute the cosine of a scalar * \sa class CwiseUnaryOp, Cwise::cos() */ -template<typename Scalar> struct ei_scalar_cos_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_cos_op) - inline Scalar operator() (const Scalar& a) const { return ei_cos(a); } - typedef typename ei_packet_traits<Scalar>::type Packet; - inline Packet packetOp(const Packet& a) const { return ei_pcos(a); } +template<typename Scalar> struct scalar_cos_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op) + inline Scalar operator() (const Scalar& a) const { return cos(a); } + typedef typename packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return internal::pcos(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_cos_op<Scalar> > +struct functor_traits<scalar_cos_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, - PacketAccess = ei_packet_traits<Scalar>::HasCos + PacketAccess = packet_traits<Scalar>::HasCos }; }; @@ -679,18 +681,18 @@ struct ei_functor_traits<ei_scalar_cos_op<Scalar> > * \brief Template functor to compute the sine of a scalar * \sa class CwiseUnaryOp, Cwise::sin() */ -template<typename Scalar> struct ei_scalar_sin_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_sin_op) - inline const Scalar operator() (const Scalar& a) const { return ei_sin(a); } - typedef typename ei_packet_traits<Scalar>::type Packet; - inline Packet packetOp(const Packet& a) const { return ei_psin(a); } +template<typename Scalar> struct scalar_sin_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op) + inline const Scalar operator() (const Scalar& a) const { return sin(a); } + typedef typename packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return internal::psin(a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_sin_op<Scalar> > +struct functor_traits<scalar_sin_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, - PacketAccess = ei_packet_traits<Scalar>::HasSin + PacketAccess = packet_traits<Scalar>::HasSin }; }; @@ -699,15 +701,15 @@ struct ei_functor_traits<ei_scalar_sin_op<Scalar> > * \sa class CwiseUnaryOp, Cwise::pow */ template<typename Scalar> -struct ei_scalar_pow_op { +struct scalar_pow_op { // FIXME default copy constructors seems bugged with std::complex<> - inline ei_scalar_pow_op(const ei_scalar_pow_op& other) : m_exponent(other.m_exponent) { } - inline ei_scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {} - inline Scalar operator() (const Scalar& a) const { return ei_pow(a, m_exponent); } + inline scalar_pow_op(const scalar_pow_op& other) : m_exponent(other.m_exponent) { } + inline scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {} + inline Scalar operator() (const Scalar& a) const { return internal::pow(a, m_exponent); } const Scalar m_exponent; }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_pow_op<Scalar> > +struct functor_traits<scalar_pow_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; }; /** \internal @@ -715,155 +717,157 @@ struct ei_functor_traits<ei_scalar_pow_op<Scalar> > * \sa class CwiseUnaryOp, Cwise::inverse() */ template<typename Scalar> -struct ei_scalar_inverse_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_inverse_op) +struct scalar_inverse_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_inverse_op) inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; } template<typename Packet> inline const Packet packetOp(const Packet& a) const - { return ei_pdiv(ei_pset1<Packet>(Scalar(1)),a); } + { return internal::pdiv(pset1<Packet>(Scalar(1)),a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_inverse_op<Scalar> > -{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasDiv }; }; +struct functor_traits<scalar_inverse_op<Scalar> > +{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasDiv }; }; /** \internal * \brief Template functor to compute the square of a scalar * \sa class CwiseUnaryOp, Cwise::square() */ template<typename Scalar> -struct ei_scalar_square_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_square_op) +struct scalar_square_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_square_op) inline Scalar operator() (const Scalar& a) const { return a*a; } template<typename Packet> inline const Packet packetOp(const Packet& a) const - { return ei_pmul(a,a); } + { return internal::pmul(a,a); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_square_op<Scalar> > -{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasMul }; }; +struct functor_traits<scalar_square_op<Scalar> > +{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; }; /** \internal * \brief Template functor to compute the cube of a scalar * \sa class CwiseUnaryOp, Cwise::cube() */ template<typename Scalar> -struct ei_scalar_cube_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_cube_op) +struct scalar_cube_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_cube_op) inline Scalar operator() (const Scalar& a) const { return a*a*a; } template<typename Packet> inline const Packet packetOp(const Packet& a) const - { return ei_pmul(a,ei_pmul(a,a)); } + { return internal::pmul(a,pmul(a,a)); } }; template<typename Scalar> -struct ei_functor_traits<ei_scalar_cube_op<Scalar> > -{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasMul }; }; +struct functor_traits<scalar_cube_op<Scalar> > +{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; }; // default functor traits for STL functors: template<typename T> -struct ei_functor_traits<std::multiplies<T> > +struct functor_traits<std::multiplies<T> > { enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::divides<T> > +struct functor_traits<std::divides<T> > { enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::plus<T> > +struct functor_traits<std::plus<T> > { enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::minus<T> > +struct functor_traits<std::minus<T> > { enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::negate<T> > +struct functor_traits<std::negate<T> > { enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::logical_or<T> > +struct functor_traits<std::logical_or<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::logical_and<T> > +struct functor_traits<std::logical_and<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::logical_not<T> > +struct functor_traits<std::logical_not<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::greater<T> > +struct functor_traits<std::greater<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::less<T> > +struct functor_traits<std::less<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::greater_equal<T> > +struct functor_traits<std::greater_equal<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::less_equal<T> > +struct functor_traits<std::less_equal<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::equal_to<T> > +struct functor_traits<std::equal_to<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::not_equal_to<T> > +struct functor_traits<std::not_equal_to<T> > { enum { Cost = 1, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::binder2nd<T> > -{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; }; +struct functor_traits<std::binder2nd<T> > +{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::binder1st<T> > -{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; }; +struct functor_traits<std::binder1st<T> > +{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::unary_negate<T> > -{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; }; +struct functor_traits<std::unary_negate<T> > +{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; }; template<typename T> -struct ei_functor_traits<std::binary_negate<T> > -{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; }; +struct functor_traits<std::binary_negate<T> > +{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; }; #ifdef EIGEN_STDEXT_SUPPORT template<typename T0,typename T1> -struct ei_functor_traits<std::project1st<T0,T1> > +struct functor_traits<std::project1st<T0,T1> > { enum { Cost = 0, PacketAccess = false }; }; template<typename T0,typename T1> -struct ei_functor_traits<std::project2nd<T0,T1> > +struct functor_traits<std::project2nd<T0,T1> > { enum { Cost = 0, PacketAccess = false }; }; template<typename T0,typename T1> -struct ei_functor_traits<std::select2nd<std::pair<T0,T1> > > +struct functor_traits<std::select2nd<std::pair<T0,T1> > > { enum { Cost = 0, PacketAccess = false }; }; template<typename T0,typename T1> -struct ei_functor_traits<std::select1st<std::pair<T0,T1> > > +struct functor_traits<std::select1st<std::pair<T0,T1> > > { enum { Cost = 0, PacketAccess = false }; }; template<typename T0,typename T1> -struct ei_functor_traits<std::unary_compose<T0,T1> > -{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost, PacketAccess = false }; }; +struct functor_traits<std::unary_compose<T0,T1> > +{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost, PacketAccess = false }; }; template<typename T0,typename T1,typename T2> -struct ei_functor_traits<std::binary_compose<T0,T1,T2> > -{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost + ei_functor_traits<T2>::Cost, PacketAccess = false }; }; +struct functor_traits<std::binary_compose<T0,T1,T2> > +{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost + functor_traits<T2>::Cost, PacketAccess = false }; }; #endif // EIGEN_STDEXT_SUPPORT -// allow to add new functors and specializations of ei_functor_traits from outside Eigen. -// this macro is really needed because ei_functor_traits must be specialized after it is declared but before it is used... +// allow to add new functors and specializations of functor_traits from outside Eigen. +// this macro is really needed because functor_traits must be specialized after it is declared but before it is used... #ifdef EIGEN_FUNCTORS_PLUGIN #include EIGEN_FUNCTORS_PLUGIN #endif +} // end namespace internal + #endif // EIGEN_FUNCTORS_H diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index 4a3b5e4dc..0a3620df9 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -28,8 +28,6 @@ // TODO support small integer types properly i.e. do exact compare on coeffs --- taking a HS norm is guaranteed to cause integer overflow. -#ifndef EIGEN_LEGACY_COMPARES - /** \returns \c true if \c *this is approximately equal to \a other, within the precision * determined by \a prec. * @@ -42,10 +40,10 @@ * \note Because of the multiplicativeness of this comparison, one can't use this function * to check whether \c *this is approximately equal to the zero matrix or vector. * Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix - * or vector. If you want to test whether \c *this is zero, use ei_isMuchSmallerThan(const + * or vector. If you want to test whether \c *this is zero, use internal::isMuchSmallerThan(const * RealScalar&, RealScalar) instead. * - * \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const + * \sa internal::isMuchSmallerThan(const RealScalar&, RealScalar) const */ template<typename Derived> template<typename OtherDerived> @@ -54,10 +52,10 @@ bool DenseBase<Derived>::isApprox( RealScalar prec ) const { - const typename ei_nested<Derived,2>::type nested(derived()); - const typename ei_nested<OtherDerived,2>::type otherNested(other.derived()); -// std::cerr << typeid(Derived).name() << " => " << typeid(typename ei_nested<Derived,2>::type).name() << "\n"; -// std::cerr << typeid(OtherDerived).name() << " => " << typeid(typename ei_nested<OtherDerived,2>::type).name() << "\n"; + const typename internal::nested<Derived,2>::type nested(derived()); + const typename internal::nested<OtherDerived,2>::type otherNested(other.derived()); +// std::cerr << typeid(Derived).name() << " => " << typeid(typename internal::nested<Derived,2>::type).name() << "\n"; +// std::cerr << typeid(OtherDerived).name() << " => " << typeid(typename internal::nested<OtherDerived,2>::type).name() << "\n"; // return false; return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * std::min(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum()); } @@ -104,137 +102,4 @@ bool DenseBase<Derived>::isMuchSmallerThan( return derived().cwiseAbs2().sum() <= prec * prec * other.derived().cwiseAbs2().sum(); } -#else - -template<typename Derived, typename OtherDerived=Derived, bool IsVector=Derived::IsVectorAtCompileTime> -struct ei_fuzzy_selector; - -/** \returns \c true if \c *this is approximately equal to \a other, within the precision - * determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$ - * are considered to be approximately equal within precision \f$ p \f$ if - * \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f] - * For matrices, the comparison is done on all columns. - * - * \note Because of the multiplicativeness of this comparison, one can't use this function - * to check whether \c *this is approximately equal to the zero matrix or vector. - * Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix - * or vector. If you want to test whether \c *this is zero, use ei_isMuchSmallerThan(const - * RealScalar&, RealScalar) instead. - * - * \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const - */ -template<typename Derived> -template<typename OtherDerived> -bool DenseBase<Derived>::isApprox( - const DenseBase<OtherDerived>& other, - RealScalar prec -) const -{ - return ei_fuzzy_selector<Derived,OtherDerived>::isApprox(derived(), other.derived(), prec); -} - -/** \returns \c true if the norm of \c *this is much smaller than \a other, - * within the precision determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is - * considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if - * \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f] - * For matrices, the comparison is done on all columns. - * - * \sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const - */ -template<typename Derived> -bool DenseBase<Derived>::isMuchSmallerThan( - const typename NumTraits<Scalar>::Real& other, - RealScalar prec -) const -{ - return ei_fuzzy_selector<Derived>::isMuchSmallerThan(derived(), other, prec); -} - -/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other, - * within the precision determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is - * considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if - * \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f] - * For matrices, the comparison is done on all columns. - * - * \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const - */ -template<typename Derived> -template<typename OtherDerived> -bool DenseBase<Derived>::isMuchSmallerThan( - const DenseBase<OtherDerived>& other, - RealScalar prec -) const -{ - return ei_fuzzy_selector<Derived,OtherDerived>::isMuchSmallerThan(derived(), other.derived(), prec); -} - - -template<typename Derived, typename OtherDerived> -struct ei_fuzzy_selector<Derived,OtherDerived,true> -{ - typedef typename Derived::RealScalar RealScalar; - static bool isApprox(const Derived& self, const OtherDerived& other, RealScalar prec) - { - EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) - ei_assert(self.size() == other.size()); - return((self - other).squaredNorm() <= std::min(self.squaredNorm(), other.squaredNorm()) * prec * prec); - } - static bool isMuchSmallerThan(const Derived& self, const RealScalar& other, RealScalar prec) - { - return(self.squaredNorm() <= ei_abs2(other * prec)); - } - static bool isMuchSmallerThan(const Derived& self, const OtherDerived& other, RealScalar prec) - { - EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) - ei_assert(self.size() == other.size()); - return(self.squaredNorm() <= other.squaredNorm() * prec * prec); - } -}; - -template<typename Derived, typename OtherDerived> -struct ei_fuzzy_selector<Derived,OtherDerived,false> -{ - typedef typename Derived::RealScalar RealScalar; - typedef typename Derived::Index Index; - static bool isApprox(const Derived& self, const OtherDerived& other, RealScalar prec) - { - EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) - ei_assert(self.rows() == other.rows() && self.cols() == other.cols()); - typename Derived::Nested nested(self); - typename OtherDerived::Nested otherNested(other); - for(Index i = 0; i < self.cols(); ++i) - if((nested.col(i) - otherNested.col(i)).squaredNorm() - > std::min(nested.col(i).squaredNorm(), otherNested.col(i).squaredNorm()) * prec * prec) - return false; - return true; - } - static bool isMuchSmallerThan(const Derived& self, const RealScalar& other, RealScalar prec) - { - typename Derived::Nested nested(self); - for(Index i = 0; i < self.cols(); ++i) - if(nested.col(i).squaredNorm() > ei_abs2(other * prec)) - return false; - return true; - } - static bool isMuchSmallerThan(const Derived& self, const OtherDerived& other, RealScalar prec) - { - EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) - ei_assert(self.rows() == other.rows() && self.cols() == other.cols()); - typename Derived::Nested nested(self); - typename OtherDerived::Nested otherNested(other); - for(Index i = 0; i < self.cols(); ++i) - if(nested.col(i).squaredNorm() > otherNested.col(i).squaredNorm() * prec * prec) - return false; - return true; - } -}; - -#endif - #endif // EIGEN_FUZZY_H diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 8ace18174..7d3fdadf0 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -26,6 +26,8 @@ #ifndef EIGEN_GENERIC_PACKET_MATH_H #define EIGEN_GENERIC_PACKET_MATH_H +namespace internal { + /** \internal * \file GenericPacketMath.h * @@ -50,7 +52,7 @@ #define EIGEN_DEBUG_UNALIGNED_STORE #endif -struct ei_default_packet_traits +struct default_packet_traits { enum { HasAdd = 1, @@ -79,7 +81,7 @@ struct ei_default_packet_traits }; }; -template<typename T> struct ei_packet_traits : ei_default_packet_traits +template<typename T> struct packet_traits : default_packet_traits { typedef T type; enum { @@ -103,92 +105,92 @@ template<typename T> struct ei_packet_traits : ei_default_packet_traits /** \internal \returns a + b (coeff-wise) */ template<typename Packet> inline Packet -ei_padd(const Packet& a, +padd(const Packet& a, const Packet& b) { return a+b; } /** \internal \returns a - b (coeff-wise) */ template<typename Packet> inline Packet -ei_psub(const Packet& a, +psub(const Packet& a, const Packet& b) { return a-b; } /** \internal \returns -a (coeff-wise) */ template<typename Packet> inline Packet -ei_pnegate(const Packet& a) { return -a; } +pnegate(const Packet& a) { return -a; } /** \internal \returns conj(a) (coeff-wise) */ template<typename Packet> inline Packet -ei_pconj(const Packet& a) { return ei_conj(a); } +pconj(const Packet& a) { return conj(a); } /** \internal \returns a * b (coeff-wise) */ template<typename Packet> inline Packet -ei_pmul(const Packet& a, +pmul(const Packet& a, const Packet& b) { return a*b; } /** \internal \returns a / b (coeff-wise) */ template<typename Packet> inline Packet -ei_pdiv(const Packet& a, +pdiv(const Packet& a, const Packet& b) { return a/b; } /** \internal \returns the min of \a a and \a b (coeff-wise) */ template<typename Packet> inline Packet -ei_pmin(const Packet& a, +pmin(const Packet& a, const Packet& b) { return std::min(a, b); } /** \internal \returns the max of \a a and \a b (coeff-wise) */ template<typename Packet> inline Packet -ei_pmax(const Packet& a, +pmax(const Packet& a, const Packet& b) { return std::max(a, b); } /** \internal \returns the absolute value of \a a */ template<typename Packet> inline Packet -ei_pabs(const Packet& a) { return ei_abs(a); } +pabs(const Packet& a) { return abs(a); } /** \internal \returns the bitwise and of \a a and \a b */ template<typename Packet> inline Packet -ei_pand(const Packet& a, const Packet& b) { return a & b; } +pand(const Packet& a, const Packet& b) { return a & b; } /** \internal \returns the bitwise or of \a a and \a b */ template<typename Packet> inline Packet -ei_por(const Packet& a, const Packet& b) { return a | b; } +por(const Packet& a, const Packet& b) { return a | b; } /** \internal \returns the bitwise xor of \a a and \a b */ template<typename Packet> inline Packet -ei_pxor(const Packet& a, const Packet& b) { return a ^ b; } +pxor(const Packet& a, const Packet& b) { return a ^ b; } /** \internal \returns the bitwise andnot of \a a and \a b */ template<typename Packet> inline Packet -ei_pandnot(const Packet& a, const Packet& b) { return a & (!b); } +pandnot(const Packet& a, const Packet& b) { return a & (!b); } /** \internal \returns a packet version of \a *from, from must be 16 bytes aligned */ template<typename Packet> inline Packet -ei_pload(const typename ei_unpacket_traits<Packet>::type* from) { return *from; } +pload(const typename unpacket_traits<Packet>::type* from) { return *from; } /** \internal \returns a packet version of \a *from, (un-aligned load) */ template<typename Packet> inline Packet -ei_ploadu(const typename ei_unpacket_traits<Packet>::type* from) { return *from; } +ploadu(const typename unpacket_traits<Packet>::type* from) { return *from; } /** \internal \returns a packet with elements of \a *from duplicated, e.g.: (from[0],from[0],from[1],from[1]) */ template<typename Packet> inline Packet -ei_ploaddup(const typename ei_unpacket_traits<Packet>::type* from) { return *from; } +ploaddup(const typename unpacket_traits<Packet>::type* from) { return *from; } /** \internal \returns a packet with constant coefficients \a a, e.g.: (a,a,a,a) */ template<typename Packet> inline Packet -ei_pset1(const typename ei_unpacket_traits<Packet>::type& a) { return a; } +pset1(const typename unpacket_traits<Packet>::type& a) { return a; } /** \internal \brief Returns a packet with coefficients (a,a+1,...,a+packet_size-1). */ -template<typename Scalar> inline typename ei_packet_traits<Scalar>::type -ei_plset(const Scalar& a) { return a; } +template<typename Scalar> inline typename packet_traits<Scalar>::type +plset(const Scalar& a) { return a; } /** \internal copy the packet \a from to \a *to, \a to must be 16 bytes aligned */ -template<typename Scalar, typename Packet> inline void ei_pstore(Scalar* to, const Packet& from) +template<typename Scalar, typename Packet> inline void pstore(Scalar* to, const Packet& from) { (*to) = from; } /** \internal copy the packet \a from to \a *to, (un-aligned store) */ -template<typename Scalar, typename Packet> inline void ei_pstoreu(Scalar* to, const Packet& from) +template<typename Scalar, typename Packet> inline void pstoreu(Scalar* to, const Packet& from) { (*to) = from; } /** \internal tries to do cache prefetching of \a addr */ -template<typename Scalar> inline void ei_prefetch(const Scalar* addr) +template<typename Scalar> inline void prefetch(const Scalar* addr) { #if !defined(_MSC_VER) __builtin_prefetch(addr); @@ -196,31 +198,31 @@ __builtin_prefetch(addr); } /** \internal \returns the first element of a packet */ -template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_pfirst(const Packet& a) +template<typename Packet> inline typename unpacket_traits<Packet>::type pfirst(const Packet& a) { return a; } /** \internal \returns a packet where the element i contains the sum of the packet of \a vec[i] */ template<typename Packet> inline Packet -ei_preduxp(const Packet* vecs) { return vecs[0]; } +preduxp(const Packet* vecs) { return vecs[0]; } /** \internal \returns the sum of the elements of \a a*/ -template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_predux(const Packet& a) +template<typename Packet> inline typename unpacket_traits<Packet>::type predux(const Packet& a) { return a; } /** \internal \returns the product of the elements of \a a*/ -template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_predux_mul(const Packet& a) +template<typename Packet> inline typename unpacket_traits<Packet>::type predux_mul(const Packet& a) { return a; } /** \internal \returns the min of the elements of \a a*/ -template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_predux_min(const Packet& a) +template<typename Packet> inline typename unpacket_traits<Packet>::type predux_min(const Packet& a) { return a; } /** \internal \returns the max of the elements of \a a*/ -template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_predux_max(const Packet& a) +template<typename Packet> inline typename unpacket_traits<Packet>::type predux_max(const Packet& a) { return a; } /** \internal \returns the reversed elements of \a a*/ -template<typename Packet> inline Packet ei_preverse(const Packet& a) +template<typename Packet> inline Packet preverse(const Packet& a) { return a; } /************************** @@ -229,23 +231,23 @@ template<typename Packet> inline Packet ei_preverse(const Packet& a) /** \internal \returns the sin of \a a (coeff-wise) */ template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ei_psin(const Packet& a) { return ei_sin(a); } +Packet psin(const Packet& a) { return sin(a); } /** \internal \returns the cos of \a a (coeff-wise) */ template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ei_pcos(const Packet& a) { return ei_cos(a); } +Packet pcos(const Packet& a) { return cos(a); } /** \internal \returns the exp of \a a (coeff-wise) */ template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ei_pexp(const Packet& a) { return ei_exp(a); } +Packet pexp(const Packet& a) { return exp(a); } /** \internal \returns the log of \a a (coeff-wise) */ template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ei_plog(const Packet& a) { return ei_log(a); } +Packet plog(const Packet& a) { return log(a); } /** \internal \returns the square-root of \a a (coeff-wise) */ template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ei_psqrt(const Packet& a) { return ei_sqrt(a); } +Packet psqrt(const Packet& a) { return sqrt(a); } /*************************************************************************** * The following functions might not have to be overwritten for vectorized types @@ -253,36 +255,36 @@ Packet ei_psqrt(const Packet& a) { return ei_sqrt(a); } /** \internal \returns a * b + c (coeff-wise) */ template<typename Packet> inline Packet -ei_pmadd(const Packet& a, +pmadd(const Packet& a, const Packet& b, const Packet& c) -{ return ei_padd(ei_pmul(a, b),c); } +{ return padd(pmul(a, b),c); } /** \internal \returns a packet version of \a *from. * \If LoadMode equals Aligned, \a from must be 16 bytes aligned */ template<typename Packet, int LoadMode> -inline Packet ei_ploadt(const typename ei_unpacket_traits<Packet>::type* from) +inline Packet ploadt(const typename unpacket_traits<Packet>::type* from) { if(LoadMode == Aligned) - return ei_pload<Packet>(from); + return pload<Packet>(from); else - return ei_ploadu<Packet>(from); + return ploadu<Packet>(from); } /** \internal copy the packet \a from to \a *to. * If StoreMode equals Aligned, \a to must be 16 bytes aligned */ template<typename Scalar, typename Packet, int LoadMode> -inline void ei_pstoret(Scalar* to, const Packet& from) +inline void pstoret(Scalar* to, const Packet& from) { if(LoadMode == Aligned) - ei_pstore(to, from); + pstore(to, from); else - ei_pstoreu(to, from); + pstoreu(to, from); } -/** \internal default implementation of ei_palign() allowing partial specialization */ +/** \internal default implementation of palign() allowing partial specialization */ template<int Offset,typename PacketType> -struct ei_palign_impl +struct palign_impl { // by default data are aligned, so there is nothing to be done :) inline static void run(PacketType&, const PacketType&) {} @@ -291,20 +293,22 @@ struct ei_palign_impl /** \internal update \a first using the concatenation of the \a Offset last elements * of \a first and packet_size minus \a Offset first elements of \a second */ template<int Offset,typename PacketType> -inline void ei_palign(PacketType& first, const PacketType& second) +inline void palign(PacketType& first, const PacketType& second) { - ei_palign_impl<Offset,PacketType>::run(first,second); + palign_impl<Offset,PacketType>::run(first,second); } /*************************************************************************** * Fast complex products (GCC generates a function call which is very slow) ***************************************************************************/ -template<> inline std::complex<float> ei_pmul(const std::complex<float>& a, const std::complex<float>& b) -{ return std::complex<float>(ei_real(a)*ei_real(b) - ei_imag(a)*ei_imag(b), ei_imag(a)*ei_real(b) + ei_real(a)*ei_imag(b)); } +template<> inline std::complex<float> pmul(const std::complex<float>& a, const std::complex<float>& b) +{ return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); } + +template<> inline std::complex<double> pmul(const std::complex<double>& a, const std::complex<double>& b) +{ return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); } -template<> inline std::complex<double> ei_pmul(const std::complex<double>& a, const std::complex<double>& b) -{ return std::complex<double>(ei_real(a)*ei_real(b) - ei_imag(a)*ei_imag(b), ei_imag(a)*ei_real(b) + ei_real(a)*ei_imag(b)); } +} // end namespace internal #endif // EIGEN_GENERIC_PACKET_MATH_H diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index 001c5b0b6..44d610f25 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -28,7 +28,7 @@ #define EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(NAME,FUNCTOR) \ template<typename Derived> \ - inline const Eigen::CwiseUnaryOp<Eigen::FUNCTOR<typename Derived::Scalar>, Derived> \ + inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, Derived> \ NAME(const Eigen::ArrayBase<Derived>& x) { \ return x.derived(); \ } @@ -38,7 +38,7 @@ template<typename Derived> \ struct NAME##_retval<ArrayBase<Derived> > \ { \ - typedef const Eigen::CwiseUnaryOp<Eigen::FUNCTOR<typename Derived::Scalar>, Derived> type; \ + typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, Derived> type; \ }; \ template<typename Derived> \ struct NAME##_impl<ArrayBase<Derived> > \ @@ -52,17 +52,17 @@ namespace std { - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,ei_scalar_real_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,ei_scalar_imag_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,ei_scalar_sin_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,ei_scalar_cos_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,ei_scalar_exp_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,ei_scalar_log_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,ei_scalar_abs_op) - EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,ei_scalar_sqrt_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,scalar_real_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,scalar_sqrt_op) template<typename Derived> - inline const Eigen::CwiseUnaryOp<Eigen::ei_scalar_pow_op<typename Derived::Scalar>, Derived> + inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar>, Derived> pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) { \ return x.derived().pow(exponent); \ } @@ -70,17 +70,20 @@ namespace std namespace Eigen { - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_real,ei_scalar_real_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_imag,ei_scalar_imag_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_sin,ei_scalar_sin_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_cos,ei_scalar_cos_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_exp,ei_scalar_exp_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_log,ei_scalar_log_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_abs,ei_scalar_abs_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_abs2,ei_scalar_abs2_op) - EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(ei_sqrt,ei_scalar_sqrt_op) + namespace internal + { + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sqrt,scalar_sqrt_op) + } } -// TODO: cleanly disable those functions that are not supported on Array (ei_real_ref, ei_random, ei_isApprox...) +// TODO: cleanly disable those functions that are not supported on Array (internal::real_ref, internal::random, internal::isApprox...) #endif // EIGEN_GLOBAL_FUNCTIONS_H diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index 7c742d867..baaf046ce 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -30,6 +30,11 @@ enum { DontAlignCols = 1 }; enum { StreamPrecision = -1, FullPrecision = -2 }; +namespace internal { +template<typename Derived> +std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt); +} + /** \class IOFormat * \ingroup Core_Module * @@ -106,7 +111,7 @@ class WithFormat friend std::ostream & operator << (std::ostream & s, const WithFormat& wf) { - return ei_print_matrix(s, wf.m_matrix.eval(), wf.m_format); + return internal::print_matrix(s, wf.m_matrix.eval(), wf.m_format); } protected: @@ -128,18 +133,20 @@ DenseBase<Derived>::format(const IOFormat& fmt) const return WithFormat<Derived>(derived(), fmt); } +namespace internal { + template<typename Scalar, bool IsInteger> -struct ei_significant_decimals_default_impl +struct significant_decimals_default_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline int run() { - return ei_cast<RealScalar,int>(std::ceil(-ei_log(NumTraits<RealScalar>::epsilon())/ei_log(RealScalar(10)))); + return cast<RealScalar,int>(std::ceil(-log(NumTraits<RealScalar>::epsilon())/log(RealScalar(10)))); } }; template<typename Scalar> -struct ei_significant_decimals_default_impl<Scalar, true> +struct significant_decimals_default_impl<Scalar, true> { static inline int run() { @@ -148,14 +155,14 @@ struct ei_significant_decimals_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_significant_decimals_impl - : ei_significant_decimals_default_impl<Scalar, NumTraits<Scalar>::IsInteger> +struct significant_decimals_impl + : significant_decimals_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; /** \internal * print the matrix \a _m to the output stream \a s using the output format \a fmt */ template<typename Derived> -std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt) +std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt) { if(_m.size() == 0) { @@ -182,7 +189,7 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm } else { - explicit_precision = ei_significant_decimals_impl<Scalar>::run(); + explicit_precision = significant_decimals_impl<Scalar>::run(); } } else @@ -228,6 +235,8 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm return s; } +} // end namespace internal + /** \relates DenseBase * * Outputs the matrix, to the given stream. @@ -244,7 +253,7 @@ std::ostream & operator << (std::ostream & s, const DenseBase<Derived> & m) { - return ei_print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); + return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); } #endif // EIGEN_IO_H diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 763948453..d163e371a 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -76,9 +76,11 @@ * * \sa Matrix::Map() */ + +namespace internal { template<typename PlainObjectType, int MapOptions, typename StrideType> -struct ei_traits<Map<PlainObjectType, MapOptions, StrideType> > - : public ei_traits<PlainObjectType> +struct traits<Map<PlainObjectType, MapOptions, StrideType> > + : public traits<PlainObjectType> { typedef typename PlainObjectType::Index Index; typedef typename PlainObjectType::Scalar Scalar; @@ -99,7 +101,7 @@ struct ei_traits<Map<PlainObjectType, MapOptions, StrideType> > || HasNoOuterStride || ( OuterStrideAtCompileTime!=Dynamic && ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ), - Flags0 = ei_traits<PlainObjectType>::Flags, + Flags0 = traits<PlainObjectType>::Flags, Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit), Flags2 = HasNoStride ? int(Flags1) : int(Flags1 & ~LinearAccessBit), Flags = KeepsPacketAccess ? int(Flags2) : (int(Flags2) & ~PacketAccessBit) @@ -107,6 +109,7 @@ struct ei_traits<Map<PlainObjectType, MapOptions, StrideType> > private: enum { Options }; // Expressions don't support Options }; +} template<typename PlainObjectType, int MapOptions, typename StrideType> class Map : public MapBase<Map<PlainObjectType, MapOptions, StrideType> > diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 6b1a25ce2..b1cc3245d 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -34,22 +34,22 @@ * \sa class Map, class Block */ template<typename Derived> class MapBase - : public ei_dense_xpr_base<Derived>::type + : public internal::dense_xpr_base<Derived>::type { public: - typedef typename ei_dense_xpr_base<Derived>::type Base; + typedef typename internal::dense_xpr_base<Derived>::type Base; enum { - RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, + RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime, + ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime, SizeAtCompileTime = Base::SizeAtCompileTime }; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; using Base::derived; @@ -111,40 +111,40 @@ template<typename Derived> class MapBase inline const Scalar& coeff(Index index) const { - ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit)); + eigen_assert(Derived::IsVectorAtCompileTime || (internal::traits<Derived>::Flags & LinearAccessBit)); return m_data[index * innerStride()]; } inline Scalar& coeffRef(Index index) { - ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit)); + eigen_assert(Derived::IsVectorAtCompileTime || (internal::traits<Derived>::Flags & LinearAccessBit)); return const_cast<Scalar*>(m_data)[index * innerStride()]; } template<int LoadMode> inline PacketScalar packet(Index row, Index col) const { - return ei_ploadt<PacketScalar, LoadMode> + return internal::ploadt<PacketScalar, LoadMode> (m_data + (col * colStride() + row * rowStride())); } template<int LoadMode> inline PacketScalar packet(Index index) const { - return ei_ploadt<PacketScalar, LoadMode>(m_data + index * innerStride()); + return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride()); } template<int StoreMode> inline void writePacket(Index row, Index col, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, StoreMode> + internal::pstoret<Scalar, PacketScalar, StoreMode> (const_cast<Scalar*>(m_data) + (col * colStride() + row * rowStride()), x); } template<int StoreMode> inline void writePacket(Index index, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, StoreMode> + internal::pstoret<Scalar, PacketScalar, StoreMode> (const_cast<Scalar*>(m_data) + index * innerStride(), x); } @@ -160,15 +160,15 @@ template<typename Derived> class MapBase m_cols(ColsAtCompileTime == Dynamic ? size : Index(ColsAtCompileTime)) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - ei_assert(size >= 0); - ei_assert(data == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == size); + eigen_assert(size >= 0); + eigen_assert(data == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == size); checkSanity(); } inline MapBase(const Scalar* data, Index rows, Index cols) : m_data(data), m_rows(rows), m_cols(cols) { - ei_assert( (data == 0) + eigen_assert( (data == 0) || ( rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols))); checkSanity(); @@ -186,16 +186,16 @@ template<typename Derived> class MapBase void checkSanity() const { - EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(ei_traits<Derived>::Flags&PacketAccessBit, - ei_inner_stride_at_compile_time<Derived>::ret==1), + EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(internal::traits<Derived>::Flags&PacketAccessBit, + internal::inner_stride_at_compile_time<Derived>::ret==1), PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1); - ei_assert(EIGEN_IMPLIES(ei_traits<Derived>::Flags&AlignedBit, (size_t(m_data) % (sizeof(Scalar)*ei_packet_traits<Scalar>::size)) == 0) + eigen_assert(EIGEN_IMPLIES(internal::traits<Derived>::Flags&AlignedBit, (size_t(m_data) % (sizeof(Scalar)*internal::packet_traits<Scalar>::size)) == 0) && "data is not aligned"); } const Scalar* EIGEN_RESTRICT m_data; - const ei_variable_if_dynamic<Index, RowsAtCompileTime> m_rows; - const ei_variable_if_dynamic<Index, ColsAtCompileTime> m_cols; + const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows; + const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols; }; #endif // EIGEN_MAPBASE_H diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 53e576258..600545b95 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -25,20 +25,22 @@ #ifndef EIGEN_MATHFUNCTIONS_H #define EIGEN_MATHFUNCTIONS_H -/** \internal \struct ei_global_math_functions_filtering_base +namespace internal { + +/** \internal \struct global_math_functions_filtering_base * * What it does: * Defines a typedef 'type' as follows: * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then - * ei_global_math_functions_filtering_base<T>::type is a typedef for it. - * - otherwise, ei_global_math_functions_filtering_base<T>::type is a typedef for T. + * global_math_functions_filtering_base<T>::type is a typedef for it. + * - otherwise, global_math_functions_filtering_base<T>::type is a typedef for T. * * How it's used: - * To allow to defined the global math functions (like ei_sin...) in certain cases, like the Array expressions. - * When you do ei_sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know - * is that it inherits ArrayBase. So we implement a partial specialization of ei_sin_impl for ArrayBase<Derived>. - * So we must make sure to use ei_sin_impl<ArrayBase<Derived> > and not ei_sin_impl<Derived>, otherwise our partial specialization - * won't be used. How does ei_sin know that? That's exactly what ei_global_math_functions_filtering_base tells it. + * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions. + * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know + * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase<Derived>. + * So we must make sure to use sin_impl<ArrayBase<Derived> > and not sin_impl<Derived>, otherwise our partial specialization + * won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells it. * * How it's implemented: * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you replace @@ -46,32 +48,32 @@ */ template<typename T, typename dummy = void> -struct ei_global_math_functions_filtering_base +struct global_math_functions_filtering_base { typedef T type; }; -template<typename T> struct ei_always_void { typedef void type; }; +template<typename T> struct always_void { typedef void type; }; template<typename T> -struct ei_global_math_functions_filtering_base +struct global_math_functions_filtering_base <T, - typename ei_always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type + typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type > { typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type; }; -#define EIGEN_MATHFUNC_IMPL(func, scalar) ei_##func##_impl<typename ei_global_math_functions_filtering_base<scalar>::type> -#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename ei_##func##_retval<typename ei_global_math_functions_filtering_base<scalar>::type>::type +#define EIGEN_MATHFUNC_IMPL(func, scalar) func##_impl<typename global_math_functions_filtering_base<scalar>::type> +#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename func##_retval<typename global_math_functions_filtering_base<scalar>::type>::type /**************************************************************************** -* Implementation of ei_real * +* Implementation of real * ****************************************************************************/ template<typename Scalar> -struct ei_real_impl +struct real_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar& x) @@ -81,7 +83,7 @@ struct ei_real_impl }; template<typename RealScalar> -struct ei_real_impl<std::complex<RealScalar> > +struct real_impl<std::complex<RealScalar> > { static inline RealScalar run(const std::complex<RealScalar>& x) { @@ -90,23 +92,23 @@ struct ei_real_impl<std::complex<RealScalar> > }; template<typename Scalar> -struct ei_real_retval +struct real_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(real, Scalar) ei_real(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_imag * +* Implementation of imag * ****************************************************************************/ template<typename Scalar> -struct ei_imag_impl +struct imag_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar&) @@ -116,7 +118,7 @@ struct ei_imag_impl }; template<typename RealScalar> -struct ei_imag_impl<std::complex<RealScalar> > +struct imag_impl<std::complex<RealScalar> > { static inline RealScalar run(const std::complex<RealScalar>& x) { @@ -125,23 +127,23 @@ struct ei_imag_impl<std::complex<RealScalar> > }; template<typename Scalar> -struct ei_imag_retval +struct imag_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) ei_imag(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_real_ref * +* Implementation of real_ref * ****************************************************************************/ template<typename Scalar> -struct ei_real_ref_impl +struct real_ref_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar& run(Scalar& x) @@ -155,29 +157,29 @@ struct ei_real_ref_impl }; template<typename Scalar> -struct ei_real_ref_retval +struct real_ref_retval { typedef typename NumTraits<Scalar>::Real & type; }; template<typename Scalar> -inline typename ei_makeconst< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type ei_real_ref(const Scalar& x) +inline typename makeconst< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x) { - return ei_real_ref_impl<Scalar>::run(x); + return real_ref_impl<Scalar>::run(x); } template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) ei_real_ref(Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) { return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_imag_ref * +* Implementation of imag_ref * ****************************************************************************/ template<typename Scalar, bool IsComplex> -struct ei_imag_ref_default_impl +struct imag_ref_default_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar& run(Scalar& x) @@ -191,7 +193,7 @@ struct ei_imag_ref_default_impl }; template<typename Scalar> -struct ei_imag_ref_default_impl<Scalar, false> +struct imag_ref_default_impl<Scalar, false> { static inline Scalar run(Scalar&) { @@ -204,32 +206,32 @@ struct ei_imag_ref_default_impl<Scalar, false> }; template<typename Scalar> -struct ei_imag_ref_impl : ei_imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {}; +struct imag_ref_impl : imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {}; template<typename Scalar> -struct ei_imag_ref_retval +struct imag_ref_retval { typedef typename NumTraits<Scalar>::Real & type; }; template<typename Scalar> -inline typename ei_makeconst< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type ei_imag_ref(const Scalar& x) +inline typename makeconst< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x) { - return ei_imag_ref_impl<Scalar>::run(x); + return imag_ref_impl<Scalar>::run(x); } template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) ei_imag_ref(Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) { return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_conj * +* Implementation of conj * ****************************************************************************/ template<typename Scalar> -struct ei_conj_impl +struct conj_impl { static inline Scalar run(const Scalar& x) { @@ -238,7 +240,7 @@ struct ei_conj_impl }; template<typename RealScalar> -struct ei_conj_impl<std::complex<RealScalar> > +struct conj_impl<std::complex<RealScalar> > { static inline std::complex<RealScalar> run(const std::complex<RealScalar>& x) { @@ -247,23 +249,23 @@ struct ei_conj_impl<std::complex<RealScalar> > }; template<typename Scalar> -struct ei_conj_retval +struct conj_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) ei_conj(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_abs * +* Implementation of abs * ****************************************************************************/ template<typename Scalar> -struct ei_abs_impl +struct abs_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar& x) @@ -273,23 +275,23 @@ struct ei_abs_impl }; template<typename Scalar> -struct ei_abs_retval +struct abs_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(abs, Scalar) ei_abs(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(abs, Scalar) abs(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(abs, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_abs2 * +* Implementation of abs2 * ****************************************************************************/ template<typename Scalar> -struct ei_abs2_impl +struct abs2_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar& x) @@ -299,7 +301,7 @@ struct ei_abs2_impl }; template<typename RealScalar> -struct ei_abs2_impl<std::complex<RealScalar> > +struct abs2_impl<std::complex<RealScalar> > { static inline RealScalar run(const std::complex<RealScalar>& x) { @@ -308,92 +310,92 @@ struct ei_abs2_impl<std::complex<RealScalar> > }; template<typename Scalar> -struct ei_abs2_retval +struct abs2_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) ei_abs2(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_norm1 * +* Implementation of norm1 * ****************************************************************************/ template<typename Scalar, bool IsComplex> -struct ei_norm1_default_impl +struct norm1_default_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar& x) { - return ei_abs(ei_real(x)) + ei_abs(ei_imag(x)); + return abs(real(x)) + abs(imag(x)); } }; template<typename Scalar> -struct ei_norm1_default_impl<Scalar, false> +struct norm1_default_impl<Scalar, false> { static inline Scalar run(const Scalar& x) { - return ei_abs(x); + return abs(x); } }; template<typename Scalar> -struct ei_norm1_impl : ei_norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {}; +struct norm1_impl : norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {}; template<typename Scalar> -struct ei_norm1_retval +struct norm1_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) ei_norm1(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_hypot * +* Implementation of hypot * ****************************************************************************/ template<typename Scalar> -struct ei_hypot_impl +struct hypot_impl { typedef typename NumTraits<Scalar>::Real RealScalar; static inline RealScalar run(const Scalar& x, const Scalar& y) { - RealScalar _x = ei_abs(x); - RealScalar _y = ei_abs(y); + RealScalar _x = abs(x); + RealScalar _y = abs(y); RealScalar p = std::max(_x, _y); RealScalar q = std::min(_x, _y); RealScalar qp = q/p; - return p * ei_sqrt(RealScalar(1) + qp*qp); + return p * sqrt(RealScalar(1) + qp*qp); } }; template<typename Scalar> -struct ei_hypot_retval +struct hypot_retval { typedef typename NumTraits<Scalar>::Real type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) ei_hypot(const Scalar& x, const Scalar& y) +inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) { return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y); } /**************************************************************************** -* Implementation of ei_cast * +* Implementation of cast * ****************************************************************************/ template<typename OldType, typename NewType> -struct ei_cast_impl +struct cast_impl { static inline NewType run(const OldType& x) { @@ -401,20 +403,20 @@ struct ei_cast_impl } }; -// here, for once, we're plainly returning NewType: we don't want ei_cast to do weird things. +// here, for once, we're plainly returning NewType: we don't want cast to do weird things. template<typename OldType, typename NewType> -inline NewType ei_cast(const OldType& x) +inline NewType cast(const OldType& x) { - return ei_cast_impl<OldType, NewType>::run(x); + return cast_impl<OldType, NewType>::run(x); } /**************************************************************************** -* Implementation of ei_sqrt * +* Implementation of sqrt * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_sqrt_default_impl +struct sqrt_default_impl { static inline Scalar run(const Scalar& x) { @@ -423,7 +425,7 @@ struct ei_sqrt_default_impl }; template<typename Scalar> -struct ei_sqrt_default_impl<Scalar, true> +struct sqrt_default_impl<Scalar, true> { static inline Scalar run(const Scalar&) { @@ -433,26 +435,26 @@ struct ei_sqrt_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_sqrt_impl : ei_sqrt_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct sqrt_impl : sqrt_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_sqrt_retval +struct sqrt_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) ei_sqrt(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(sqrt, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_exp * +* Implementation of exp * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_exp_default_impl +struct exp_default_impl { static inline Scalar run(const Scalar& x) { @@ -461,7 +463,7 @@ struct ei_exp_default_impl }; template<typename Scalar> -struct ei_exp_default_impl<Scalar, true> +struct exp_default_impl<Scalar, true> { static inline Scalar run(const Scalar&) { @@ -471,26 +473,26 @@ struct ei_exp_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_exp_impl : ei_exp_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct exp_impl : exp_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_exp_retval +struct exp_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(exp, Scalar) ei_exp(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(exp, Scalar) exp(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(exp, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_cos * +* Implementation of cos * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_cos_default_impl +struct cos_default_impl { static inline Scalar run(const Scalar& x) { @@ -499,7 +501,7 @@ struct ei_cos_default_impl }; template<typename Scalar> -struct ei_cos_default_impl<Scalar, true> +struct cos_default_impl<Scalar, true> { static inline Scalar run(const Scalar&) { @@ -509,26 +511,26 @@ struct ei_cos_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_cos_impl : ei_cos_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct cos_impl : cos_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_cos_retval +struct cos_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(cos, Scalar) ei_cos(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(cos, Scalar) cos(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(cos, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_sin * +* Implementation of sin * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_sin_default_impl +struct sin_default_impl { static inline Scalar run(const Scalar& x) { @@ -537,7 +539,7 @@ struct ei_sin_default_impl }; template<typename Scalar> -struct ei_sin_default_impl<Scalar, true> +struct sin_default_impl<Scalar, true> { static inline Scalar run(const Scalar&) { @@ -547,26 +549,26 @@ struct ei_sin_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_sin_impl : ei_sin_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct sin_impl : sin_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_sin_retval +struct sin_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(sin, Scalar) ei_sin(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(sin, Scalar) sin(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(sin, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_log * +* Implementation of log * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_log_default_impl +struct log_default_impl { static inline Scalar run(const Scalar& x) { @@ -575,7 +577,7 @@ struct ei_log_default_impl }; template<typename Scalar> -struct ei_log_default_impl<Scalar, true> +struct log_default_impl<Scalar, true> { static inline Scalar run(const Scalar&) { @@ -585,26 +587,26 @@ struct ei_log_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_log_impl : ei_log_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct log_impl : log_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_log_retval +struct log_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(log, Scalar) ei_log(const Scalar& x) +inline EIGEN_MATHFUNC_RETVAL(log, Scalar) log(const Scalar& x) { return EIGEN_MATHFUNC_IMPL(log, Scalar)::run(x); } /**************************************************************************** -* Implementation of ei_atan2 * +* Implementation of atan2 * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_atan2_default_impl +struct atan2_default_impl { typedef Scalar retval; static inline Scalar run(const Scalar& x, const Scalar& y) @@ -614,7 +616,7 @@ struct ei_atan2_default_impl }; template<typename Scalar> -struct ei_atan2_default_impl<Scalar, true> +struct atan2_default_impl<Scalar, true> { static inline Scalar run(const Scalar&, const Scalar&) { @@ -624,26 +626,26 @@ struct ei_atan2_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_atan2_impl : ei_atan2_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct atan2_impl : atan2_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_atan2_retval +struct atan2_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(atan2, Scalar) ei_atan2(const Scalar& x, const Scalar& y) +inline EIGEN_MATHFUNC_RETVAL(atan2, Scalar) atan2(const Scalar& x, const Scalar& y) { return EIGEN_MATHFUNC_IMPL(atan2, Scalar)::run(x, y); } /**************************************************************************** -* Implementation of ei_pow * +* Implementation of pow * ****************************************************************************/ template<typename Scalar, bool IsInteger> -struct ei_pow_default_impl +struct pow_default_impl { typedef Scalar retval; static inline Scalar run(const Scalar& x, const Scalar& y) @@ -653,12 +655,12 @@ struct ei_pow_default_impl }; template<typename Scalar> -struct ei_pow_default_impl<Scalar, true> +struct pow_default_impl<Scalar, true> { static inline Scalar run(Scalar x, Scalar y) { Scalar res = 1; - ei_assert(!NumTraits<Scalar>::IsSigned || y >= 0); + eigen_assert(!NumTraits<Scalar>::IsSigned || y >= 0); if(y & 1) res *= x; y >>= 1; while(y) @@ -672,43 +674,43 @@ struct ei_pow_default_impl<Scalar, true> }; template<typename Scalar> -struct ei_pow_impl : ei_pow_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; +struct pow_impl : pow_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_pow_retval +struct pow_retval { typedef Scalar type; }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(pow, Scalar) ei_pow(const Scalar& x, const Scalar& y) +inline EIGEN_MATHFUNC_RETVAL(pow, Scalar) pow(const Scalar& x, const Scalar& y) { return EIGEN_MATHFUNC_IMPL(pow, Scalar)::run(x, y); } /**************************************************************************** -* Implementation of ei_random * +* Implementation of random * ****************************************************************************/ template<typename Scalar, bool IsComplex, bool IsInteger> -struct ei_random_default_impl {}; +struct random_default_impl {}; template<typename Scalar> -struct ei_random_impl : ei_random_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {}; +struct random_impl : random_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar> -struct ei_random_retval +struct random_retval { typedef Scalar type; }; -template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) ei_random(const Scalar& x, const Scalar& y); -template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) ei_random(); +template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y); +template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(); template<typename Scalar> -struct ei_random_default_impl<Scalar, false, false> +struct random_default_impl<Scalar, false, false> { static inline Scalar run(const Scalar& x, const Scalar& y) { @@ -721,7 +723,7 @@ struct ei_random_default_impl<Scalar, false, false> }; template<typename Scalar> -struct ei_random_default_impl<Scalar, false, true> +struct random_default_impl<Scalar, false, true> { static inline Scalar run(const Scalar& x, const Scalar& y) { @@ -734,28 +736,28 @@ struct ei_random_default_impl<Scalar, false, true> }; template<typename Scalar> -struct ei_random_default_impl<Scalar, true, false> +struct random_default_impl<Scalar, true, false> { static inline Scalar run(const Scalar& x, const Scalar& y) { - return Scalar(ei_random(ei_real(x), ei_real(y)), - ei_random(ei_imag(x), ei_imag(y))); + return Scalar(random(real(x), real(y)), + random(imag(x), imag(y))); } static inline Scalar run() { typedef typename NumTraits<Scalar>::Real RealScalar; - return Scalar(ei_random<RealScalar>(), ei_random<RealScalar>()); + return Scalar(random<RealScalar>(), random<RealScalar>()); } }; template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(random, Scalar) ei_random(const Scalar& x, const Scalar& y) +inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y) { return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y); } template<typename Scalar> -inline EIGEN_MATHFUNC_RETVAL(random, Scalar) ei_random() +inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random() { return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(); } @@ -767,20 +769,20 @@ inline EIGEN_MATHFUNC_RETVAL(random, Scalar) ei_random() template<typename Scalar, bool IsComplex, bool IsInteger> -struct ei_scalar_fuzzy_default_impl {}; +struct scalar_fuzzy_default_impl {}; template<typename Scalar> -struct ei_scalar_fuzzy_default_impl<Scalar, false, false> +struct scalar_fuzzy_default_impl<Scalar, false, false> { typedef typename NumTraits<Scalar>::Real RealScalar; template<typename OtherScalar> static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec) { - return ei_abs(x) <= ei_abs(y) * prec; + return abs(x) <= abs(y) * prec; } static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) { - return ei_abs(x - y) <= std::min(ei_abs(x), ei_abs(y)) * prec; + return abs(x - y) <= std::min(abs(x), abs(y)) * prec; } static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec) { @@ -789,7 +791,7 @@ struct ei_scalar_fuzzy_default_impl<Scalar, false, false> }; template<typename Scalar> -struct ei_scalar_fuzzy_default_impl<Scalar, false, true> +struct scalar_fuzzy_default_impl<Scalar, false, true> { typedef typename NumTraits<Scalar>::Real RealScalar; template<typename OtherScalar> @@ -808,57 +810,57 @@ struct ei_scalar_fuzzy_default_impl<Scalar, false, true> }; template<typename Scalar> -struct ei_scalar_fuzzy_default_impl<Scalar, true, false> +struct scalar_fuzzy_default_impl<Scalar, true, false> { typedef typename NumTraits<Scalar>::Real RealScalar; template<typename OtherScalar> static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec) { - return ei_abs2(x) <= ei_abs2(y) * prec * prec; + return abs2(x) <= abs2(y) * prec * prec; } static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) { - return ei_abs2(x - y) <= std::min(ei_abs2(x), ei_abs2(y)) * prec * prec; + return abs2(x - y) <= std::min(abs2(x), abs2(y)) * prec * prec; } }; template<typename Scalar> -struct ei_scalar_fuzzy_impl : ei_scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {}; +struct scalar_fuzzy_impl : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {}; template<typename Scalar, typename OtherScalar> -inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, +inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) { - return ei_scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision); + return scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision); } template<typename Scalar> -inline bool ei_isApprox(const Scalar& x, const Scalar& y, +inline bool isApprox(const Scalar& x, const Scalar& y, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) { - return ei_scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision); + return scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision); } template<typename Scalar> -inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, +inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) { - return ei_scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision); + return scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision); } /****************************************** *** The special case of the bool type *** ******************************************/ -template<> struct ei_random_impl<bool> +template<> struct random_impl<bool> { static inline bool run() { - return ei_random<int>(0,1)==0 ? false : true; + return random<int>(0,1)==0 ? false : true; } }; -template<> struct ei_scalar_fuzzy_impl<bool> +template<> struct scalar_fuzzy_impl<bool> { static inline bool isApprox(bool x, bool y, bool) { @@ -866,4 +868,6 @@ template<> struct ei_scalar_fuzzy_impl<bool> } }; +} // end namespace internal + #endif // EIGEN_MATHFUNCTIONS_H diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 7bc234453..e0dbd101e 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -109,8 +109,10 @@ * * \see MatrixBase for the majority of the API methods for matrices, \ref TopicClassHierarchy */ + +namespace internal { template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > +struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > { typedef _Scalar Scalar; typedef Dense StorageKind; @@ -121,13 +123,14 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > ColsAtCompileTime = _Cols, MaxRowsAtCompileTime = _MaxRows, MaxColsAtCompileTime = _MaxCols, - Flags = ei_compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret, + Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret, CoeffReadCost = NumTraits<Scalar>::ReadCost, Options = _Options, InnerStrideAtCompileTime = 1, OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime }; }; +} template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> class Matrix @@ -217,8 +220,8 @@ class Matrix } // FIXME is it still needed - Matrix(ei_constructor_without_unaligned_array_assert) - : Base(ei_constructor_without_unaligned_array_assert()) + Matrix(internal::constructor_without_unaligned_array_assert) + : Base(internal::constructor_without_unaligned_array_assert()) { Base::_check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } /** \brief Constructs a vector or row-vector with given dimension. \only_for_vectors @@ -232,8 +235,8 @@ class Matrix { Base::_check_template_params(); EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix) - ei_assert(dim > 0); - ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); + eigen_assert(dim > 0); + eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } @@ -340,7 +343,7 @@ class Matrix protected: template <typename Derived, typename OtherDerived, bool IsVector> - friend struct ei_conservative_resize_like_impl; + friend struct internal::conservative_resize_like_impl; using Base::m_storage; }; diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 3e45cdaf1..5ef723e8c 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -61,10 +61,10 @@ template<typename Derived> class MatrixBase public: #ifndef EIGEN_PARSED_BY_DOXYGEN typedef MatrixBase StorageBaseType; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; typedef DenseBase<Derived> Base; @@ -115,30 +115,30 @@ template<typename Derived> class MatrixBase * the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed * that the return type of eval() is either PlainObject or const PlainObject&. */ - typedef Matrix<typename ei_traits<Derived>::Scalar, - ei_traits<Derived>::RowsAtCompileTime, - ei_traits<Derived>::ColsAtCompileTime, - AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<Derived>::MaxRowsAtCompileTime, - ei_traits<Derived>::MaxColsAtCompileTime + typedef Matrix<typename internal::traits<Derived>::Scalar, + internal::traits<Derived>::RowsAtCompileTime, + internal::traits<Derived>::ColsAtCompileTime, + AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), + internal::traits<Derived>::MaxRowsAtCompileTime, + internal::traits<Derived>::MaxColsAtCompileTime > PlainObject; #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType; + typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType; /** \internal the return type of MatrixBase::adjoint() */ - typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex, - CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<Derived> >, + typedef typename internal::meta_if<NumTraits<Scalar>::IsComplex, + CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<Derived> >, Transpose<Derived> >::ret AdjointReturnType; /** \internal Return type of eigenvalues() */ - typedef Matrix<std::complex<RealScalar>, ei_traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType; + typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType; /** \internal the return type of identity */ - typedef CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> IdentityReturnType; + typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,Derived> IdentityReturnType; /** \internal the return type of unit vectors */ - typedef Block<CwiseNullaryOp<ei_scalar_identity_op<Scalar>, SquareMatrixType>, - ei_traits<Derived>::RowsAtCompileTime, - ei_traits<Derived>::ColsAtCompileTime> BasisReturnType; + typedef Block<CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>, + internal::traits<Derived>::RowsAtCompileTime, + internal::traits<Derived>::ColsAtCompileTime> BasisReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase @@ -277,8 +277,8 @@ template<typename Derived> class MatrixBase inline const ForceAlignedAccess<Derived> forceAlignedAccess() const; inline ForceAlignedAccess<Derived> forceAlignedAccess(); - template<bool Enable> inline typename ei_makeconst<typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret>::type forceAlignedAccessIf() const; - template<bool Enable> inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf(); + template<bool Enable> inline typename internal::makeconst<typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret>::type forceAlignedAccessIf() const; + template<bool Enable> inline typename internal::meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf(); Scalar trace() const; @@ -299,7 +299,7 @@ template<typename Derived> class MatrixBase const FullPivLU<PlainObject> fullPivLu() const; const PartialPivLU<PlainObject> partialPivLu() const; const PartialPivLU<PlainObject> lu() const; - const ei_inverse_impl<Derived> inverse() const; + const internal::inverse_impl<Derived> inverse() const; template<typename ResultType> void computeInverseAndDetWithCheck( ResultType& inverse, @@ -346,9 +346,9 @@ template<typename Derived> class MatrixBase SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1 }; typedef Block<Derived, - ei_traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1, - ei_traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; - typedef CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, + internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1, + internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; + typedef CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, StartMinusOne > HNormalizedReturnType; HNormalizedReturnType hnormalized() const; @@ -383,7 +383,7 @@ template<typename Derived> class MatrixBase ///////// MatrixFunctions module ///////// - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::stem_function<Scalar>::type StemFunction; const MatrixExponentialReturnValue<Derived> exp() const; const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const; const MatrixFunctionReturnValue<Derived> cosh() const; diff --git a/Eigen/src/Core/NestByValue.h b/Eigen/src/Core/NestByValue.h index 885002e26..a6104d2a4 100644 --- a/Eigen/src/Core/NestByValue.h +++ b/Eigen/src/Core/NestByValue.h @@ -38,16 +38,19 @@ * * \sa MatrixBase::nestByValue() */ + +namespace internal { template<typename ExpressionType> -struct ei_traits<NestByValue<ExpressionType> > : public ei_traits<ExpressionType> +struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType> {}; +} template<typename ExpressionType> class NestByValue - : public ei_dense_xpr_base< NestByValue<ExpressionType> >::type + : public internal::dense_xpr_base< NestByValue<ExpressionType> >::type { public: - typedef typename ei_dense_xpr_base<NestByValue>::type Base; + typedef typename internal::dense_xpr_base<NestByValue>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index 53ad3bfee..fe63477bc 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -51,17 +51,17 @@ class NoAlias * \sa MatrixBase::lazyAssign() */ template<typename OtherDerived> EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) - { return ei_assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); } + { return internal::assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); } /** \sa MatrixBase::operator+= */ template<typename OtherDerived> EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) { - typedef SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder; + typedef SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder; SelfAdder tmp(m_expression); - typedef typename ei_nested<OtherDerived>::type OtherDerivedNested; - typedef typename ei_cleantype<OtherDerivedNested>::type _OtherDerivedNested; - ei_assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived())); + typedef typename internal::nested<OtherDerived>::type OtherDerivedNested; + typedef typename internal::cleantype<OtherDerivedNested>::type _OtherDerivedNested; + internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived())); return m_expression; } @@ -69,11 +69,11 @@ class NoAlias template<typename OtherDerived> EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other) { - typedef SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder; + typedef SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder; SelfAdder tmp(m_expression); - typedef typename ei_nested<OtherDerived>::type OtherDerivedNested; - typedef typename ei_cleantype<OtherDerivedNested>::type _OtherDerivedNested; - ei_assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived())); + typedef typename internal::nested<OtherDerived>::type OtherDerivedNested; + typedef typename internal::cleantype<OtherDerivedNested>::type _OtherDerivedNested; + internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived())); return m_expression; } diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h index 9e6e35a04..fb7b0b0c4 100644 --- a/Eigen/src/Core/NumTraits.h +++ b/Eigen/src/Core/NumTraits.h @@ -40,7 +40,7 @@ * is a typedef to \a U. * \li A typedef \a NonInteger, giving the type that should be used for operations producing non-integral values, * such as quotients, square roots, etc. If \a T is a floating-point type, then this typedef just gives - * \a T again. Note however that many Eigen functions such as ei_sqrt simply refuse to + * \a T again. Note however that many Eigen functions such as internal::sqrt simply refuse to * take integers. Outside of a few cases, Eigen doesn't do automatic type promotion. Thus, this typedef is * only intended as a helper for code that needs to explicitly promote types. * \li A typedef \a Nested giving the type to use to nest a value inside of the expression tree. If you don't know what @@ -71,9 +71,9 @@ template<typename T> struct GenericNumTraits }; typedef T Real; - typedef typename ei_meta_if< + typedef typename internal::meta_if< IsInteger, - typename ei_meta_if<sizeof(T)<=2, float, double>::ret, + typename internal::meta_if<sizeof(T)<=2, float, double>::ret, T >::ret NonInteger; typedef T Nested; diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index afe37ef6d..9e99b6f91 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -48,20 +48,25 @@ * * \sa class DiagonalMatrix */ -template<typename PermutationType, typename MatrixType, int Side, bool Transposed=false> struct ei_permut_matrix_product_retval; + +namespace internal { + +template<typename PermutationType, typename MatrixType, int Side, bool Transposed=false> struct permut_matrix_product_retval; template<int SizeAtCompileTime, int MaxSizeAtCompileTime> -struct ei_traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > - : ei_traits<Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > +struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > + : traits<Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > {}; +} // end namespace internal + template<int SizeAtCompileTime, int MaxSizeAtCompileTime> class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > { public: #ifndef EIGEN_PARSED_BY_DOXYGEN - typedef ei_traits<PermutationMatrix> Traits; + typedef internal::traits<PermutationMatrix> Traits; typedef Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> DenseMatrixType; enum { @@ -211,7 +216,7 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, */ PermutationMatrix& applyTranspositionOnTheLeft(Index i, Index j) { - ei_assert(i>=0 && j>=0 && i<m_indices.size() && j<m_indices.size()); + eigen_assert(i>=0 && j>=0 && i<m_indices.size() && j<m_indices.size()); for(Index k = 0; k < m_indices.size(); ++k) { if(m_indices.coeff(k) == i) m_indices.coeffRef(k) = j; @@ -230,7 +235,7 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, */ PermutationMatrix& applyTranspositionOnTheRight(Index i, Index j) { - ei_assert(i>=0 && j>=0 && i<m_indices.size() && j<m_indices.size()); + eigen_assert(i>=0 && j>=0 && i<m_indices.size() && j<m_indices.size()); std::swap(m_indices.coeffRef(i), m_indices.coeffRef(j)); return *this; } @@ -262,7 +267,7 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, PermutationMatrix(Product_t, const PermutationMatrix& lhs, const PermutationMatrix& rhs) : m_indices(lhs.m_indices.size()) { - ei_assert(lhs.cols() == rhs.rows()); + eigen_assert(lhs.cols() == rhs.rows()); for (int i=0; i<rows();++i) m_indices.coeffRef(i) = lhs.m_indices.coeff(rhs.m_indices.coeff(i)); } #endif @@ -301,11 +306,11 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, /** \returns the matrix with the permutation applied to the columns. */ template<typename Derived, int SizeAtCompileTime, int MaxSizeAtCompileTime> -inline const ei_permut_matrix_product_retval<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> +inline const internal::permut_matrix_product_retval<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> operator*(const MatrixBase<Derived>& matrix, const PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> &permutation) { - return ei_permut_matrix_product_retval + return internal::permut_matrix_product_retval <PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> (permutation, matrix.derived()); } @@ -313,29 +318,31 @@ operator*(const MatrixBase<Derived>& matrix, /** \returns the matrix with the permutation applied to the rows. */ template<typename Derived, int SizeAtCompileTime, int MaxSizeAtCompileTime> -inline const ei_permut_matrix_product_retval +inline const internal::permut_matrix_product_retval <PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheLeft> operator*(const PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> &permutation, const MatrixBase<Derived>& matrix) { - return ei_permut_matrix_product_retval + return internal::permut_matrix_product_retval <PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheLeft> (permutation, matrix.derived()); } +namespace internal { + template<typename PermutationType, typename MatrixType, int Side, bool Transposed> -struct ei_traits<ei_permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> > +struct traits<permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> > { typedef typename MatrixType::PlainObject ReturnType; }; template<typename PermutationType, typename MatrixType, int Side, bool Transposed> -struct ei_permut_matrix_product_retval - : public ReturnByValue<ei_permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> > +struct permut_matrix_product_retval + : public ReturnByValue<permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> > { - typedef typename ei_cleantype<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; + typedef typename cleantype<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; - ei_permut_matrix_product_retval(const PermutationType& perm, const MatrixType& matrix) + permut_matrix_product_retval(const PermutationType& perm, const MatrixType& matrix) : m_permutation(perm), m_matrix(matrix) {} @@ -346,7 +353,7 @@ struct ei_permut_matrix_product_retval { const int n = Side==OnTheLeft ? rows() : cols(); - if(ei_is_same_type<MatrixTypeNestedCleaned,Dest>::ret && ei_extract_data(dst) == ei_extract_data(m_matrix)) + if(is_same_type<MatrixTypeNestedCleaned,Dest>::ret && extract_data(dst) == extract_data(m_matrix)) { // apply the permutation inplace Matrix<bool,PermutationType::RowsAtCompileTime,1,0,PermutationType::MaxRowsAtCompileTime> mask(m_permutation.size()); @@ -396,10 +403,12 @@ struct ei_permut_matrix_product_retval /* Template partial specialization for transposed/inverse permutations */ template<int SizeAtCompileTime, int MaxSizeAtCompileTime> -struct ei_traits<Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > > - : ei_traits<Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > +struct traits<Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > > + : traits<Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > {}; +} // end namespace internal + template<int SizeAtCompileTime, int MaxSizeAtCompileTime> class Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > : public EigenBase<Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > > @@ -409,7 +418,7 @@ class Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > public: #ifndef EIGEN_PARSED_BY_DOXYGEN - typedef ei_traits<PermutationType> Traits; + typedef internal::traits<PermutationType> Traits; typedef Matrix<int,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> DenseMatrixType; enum { @@ -446,19 +455,19 @@ class Transpose<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime> > /** \returns the matrix with the inverse permutation applied to the columns. */ template<typename Derived> friend - inline const ei_permut_matrix_product_retval<PermutationType, Derived, OnTheRight, true> + inline const internal::permut_matrix_product_retval<PermutationType, Derived, OnTheRight, true> operator*(const MatrixBase<Derived>& matrix, const Transpose& trPerm) { - return ei_permut_matrix_product_retval<PermutationType, Derived, OnTheRight, true>(trPerm.m_permutation, matrix.derived()); + return internal::permut_matrix_product_retval<PermutationType, Derived, OnTheRight, true>(trPerm.m_permutation, matrix.derived()); } /** \returns the matrix with the inverse permutation applied to the rows. */ template<typename Derived> - inline const ei_permut_matrix_product_retval<PermutationType, Derived, OnTheLeft, true> + inline const internal::permut_matrix_product_retval<PermutationType, Derived, OnTheLeft, true> operator*(const MatrixBase<Derived>& matrix) const { - return ei_permut_matrix_product_retval<PermutationType, Derived, OnTheLeft, true>(m_permutation, matrix.derived()); + return internal::permut_matrix_product_retval<PermutationType, Derived, OnTheLeft, true>(m_permutation, matrix.derived()); } const PermutationType& nestedPermutation() const { return m_permutation; } diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 3e2b36be9..0848475b3 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -32,24 +32,29 @@ # define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED #endif -template <typename Derived, typename OtherDerived = Derived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl; -template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct ei_matrix_swap_impl; +namespace internal { + +template <typename Derived, typename OtherDerived = Derived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct conservative_resize_like_impl; + +template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl; + +} // end namespace internal /** * \brief %Dense storage base class for matrices and arrays. * \sa \ref TopicClassHierarchy */ template<typename Derived> -class PlainObjectBase : public ei_dense_xpr_base<Derived>::type +class PlainObjectBase : public internal::dense_xpr_base<Derived>::type { public: - enum { Options = ei_traits<Derived>::Options }; - typedef typename ei_dense_xpr_base<Derived>::type Base; + enum { Options = internal::traits<Derived>::Options }; + typedef typename internal::dense_xpr_base<Derived>::type Base; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; using Base::RowsAtCompileTime; @@ -109,7 +114,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const { - return ei_ploadt<PacketScalar, LoadMode> + return internal::ploadt<PacketScalar, LoadMode> (m_storage.data() + (Flags & RowMajorBit ? col + row * m_storage.cols() : row + col * m_storage.rows())); @@ -118,13 +123,13 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index index) const { - return ei_ploadt<PacketScalar, LoadMode>(m_storage.data() + index); + return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index); } template<int StoreMode> EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, StoreMode> + internal::pstoret<Scalar, PacketScalar, StoreMode> (m_storage.data() + (Flags & RowMajorBit ? col + row * m_storage.cols() : row + col * m_storage.rows()), x); @@ -133,7 +138,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type template<int StoreMode> EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x); + internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x); } /** \returns a const pointer to the data array of this matrix */ @@ -186,7 +191,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type inline void resize(Index size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase) - ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size); + eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size); #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO bool size_changed = size != this->size(); #endif @@ -239,12 +244,12 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type const Index othersize = other.rows()*other.cols(); if(RowsAtCompileTime == 1) { - ei_assert(other.rows() == 1 || other.cols() == 1); + eigen_assert(other.rows() == 1 || other.cols() == 1); resize(1, othersize); } else if(ColsAtCompileTime == 1) { - ei_assert(other.rows() == 1 || other.cols() == 1); + eigen_assert(other.rows() == 1 || other.cols() == 1); resize(othersize, 1); } else resize(other.rows(), other.cols()); @@ -261,7 +266,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type */ EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols) { - ei_conservative_resize_like_impl<Derived>::run(*this, rows, cols); + internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols); } EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t) @@ -286,13 +291,13 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type */ EIGEN_STRONG_INLINE void conservativeResize(Index size) { - ei_conservative_resize_like_impl<Derived>::run(*this, size); + internal::conservative_resize_like_impl<Derived>::run(*this, size); } template<typename OtherDerived> EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other) { - ei_conservative_resize_like_impl<Derived,OtherDerived>::run(*this, other); + internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*this, other); } /** This is a special case of the templated operator=. Its purpose is to @@ -327,8 +332,8 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type #ifndef EIGEN_PARSED_BY_DOXYGEN // FIXME is it still needed ? /** \internal */ - PlainObjectBase(ei_constructor_without_unaligned_array_assert) - : m_storage(ei_constructor_without_unaligned_array_assert()) + PlainObjectBase(internal::constructor_without_unaligned_array_assert) + : m_storage(internal::constructor_without_unaligned_array_assert()) { // _check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } @@ -430,7 +435,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other) { #ifdef EIGEN_NO_AUTOMATIC_RESIZING - ei_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size()) + eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size()) : (rows() == other.rows() && cols() == other.cols()))) && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined"); #else @@ -455,15 +460,15 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type template<typename OtherDerived> EIGEN_STRONG_INLINE Derived& _set(const DenseBase<OtherDerived>& other) { - _set_selector(other.derived(), typename ei_meta_if<static_cast<bool>(int(OtherDerived::Flags) & EvalBeforeAssigningBit), ei_meta_true, ei_meta_false>::ret()); + _set_selector(other.derived(), typename internal::meta_if<static_cast<bool>(int(OtherDerived::Flags) & EvalBeforeAssigningBit), internal::meta_true, internal::meta_false>::ret()); return this->derived(); } template<typename OtherDerived> - EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_true&) { _set_noalias(other.eval()); } + EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const internal::meta_true&) { _set_noalias(other.eval()); } template<typename OtherDerived> - EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_false&) { _set_noalias(other); } + EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const internal::meta_false&) { _set_noalias(other); } /** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which * is the case when creating a new matrix) so one can enforce lazy evaluation. @@ -478,19 +483,19 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type //_resize_to_match(other); // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because // it wouldn't allow to copy a row-vector into a column-vector. - return ei_assign_selector<Derived,OtherDerived,false>::run(this->derived(), other.derived()); + return internal::assign_selector<Derived,OtherDerived,false>::run(this->derived(), other.derived()); } template<typename T0, typename T1> - EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename ei_enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0) + EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0) { - ei_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) + eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); m_storage.resize(rows*cols,rows,cols); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } template<typename T0, typename T1> - EIGEN_STRONG_INLINE void _init2(const Scalar& x, const Scalar& y, typename ei_enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0) + EIGEN_STRONG_INLINE void _init2(const Scalar& x, const Scalar& y, typename internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2) m_storage.data()[0] = x; @@ -498,7 +503,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type } template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> - friend struct ei_matrix_swap_impl; + friend struct internal::matrix_swap_impl; /** \internal generic implementation of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the * data pointers. @@ -506,8 +511,8 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type template<typename OtherDerived> void _swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { - enum { SwapPointers = ei_is_same_type<Derived, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic }; - ei_matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.const_cast_derived()); + enum { SwapPointers = internal::is_same_type<Derived, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic }; + internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.const_cast_derived()); } public: @@ -529,7 +534,7 @@ class PlainObjectBase : public ei_dense_xpr_base<Derived>::type }; template <typename Derived, typename OtherDerived, bool IsVector> -struct ei_conservative_resize_like_impl +struct internal::conservative_resize_like_impl { typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index rows, Index cols) @@ -588,8 +593,10 @@ struct ei_conservative_resize_like_impl } }; +namespace internal { + template <typename Derived, typename OtherDerived> -struct ei_conservative_resize_like_impl<Derived,OtherDerived,true> +struct conservative_resize_like_impl<Derived,OtherDerived,true> { typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index size) @@ -615,7 +622,7 @@ struct ei_conservative_resize_like_impl<Derived,OtherDerived,true> }; template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> -struct ei_matrix_swap_impl +struct matrix_swap_impl { static inline void run(MatrixTypeA& a, MatrixTypeB& b) { @@ -624,7 +631,7 @@ struct ei_matrix_swap_impl }; template<typename MatrixTypeA, typename MatrixTypeB> -struct ei_matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> +struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> { static inline void run(MatrixTypeA& a, MatrixTypeB& b) { @@ -632,4 +639,6 @@ struct ei_matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> } }; +} // end namespace internal + #endif // EIGEN_DENSESTORAGEBASE_H diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 57f7811c8..3bb73fa5f 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -45,20 +45,22 @@ * * \sa ProductReturnType, MatrixBase::operator*(const MatrixBase<OtherDerived>&) */ -template<typename Lhs, typename Rhs, int ProductType = ei_product_type<Lhs,Rhs>::value> +template<typename Lhs, typename Rhs, int ProductType = internal::product_type<Lhs,Rhs>::value> class GeneralProduct; -template<int Rows, int Cols, int Depth> struct ei_product_type_selector; - enum { Large = 2, Small = 3 }; -template<typename Lhs, typename Rhs> struct ei_product_type +namespace internal { + +template<int Rows, int Cols, int Depth> struct product_type_selector; + +template<typename Lhs, typename Rhs> struct product_type { - typedef typename ei_cleantype<Lhs>::type _Lhs; - typedef typename ei_cleantype<Rhs>::type _Rhs; + typedef typename cleantype<Lhs>::type _Lhs; + typedef typename cleantype<Rhs>::type _Rhs; enum { Rows = _Lhs::MaxRowsAtCompileTime, Cols = _Rhs::MaxColsAtCompileTime, @@ -73,11 +75,11 @@ private: cols_select = Cols == Dynamic || Cols >=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Cols==1 ? 1 : Small), depth_select = Depth == Dynamic || Depth>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Depth==1 ? 1 : Small) }; - typedef ei_product_type_selector<rows_select, cols_select, depth_select> product_type_selector; + typedef product_type_selector<rows_select, cols_select, depth_select> selector; public: enum { - value = product_type_selector::ret + value = selector::ret }; #ifdef EIGEN_DEBUG_PRODUCT static void debug() @@ -93,32 +95,35 @@ public: #endif }; + /* The following allows to select the kind of product at compile time * based on the three dimensions of the product. * This is a compile time mapping from {1,Small,Large}^3 -> {product types} */ // FIXME I'm not sure the current mapping is the ideal one. -template<int M, int N> struct ei_product_type_selector<M,N,1> { enum { ret = OuterProduct }; }; -template<int Depth> struct ei_product_type_selector<1, 1, Depth> { enum { ret = InnerProduct }; }; -template<> struct ei_product_type_selector<1, 1, 1> { enum { ret = InnerProduct }; }; -template<> struct ei_product_type_selector<Small,1, Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Small,Small,Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Small, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Small, Large, 1> { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Large, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<1, Large,Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<1, Large,Large> { enum { ret = GemvProduct }; }; -template<> struct ei_product_type_selector<1, Small,Large> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Large,1, Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Large,1, Large> { enum { ret = GemvProduct }; }; -template<> struct ei_product_type_selector<Small,1, Large> { enum { ret = CoeffBasedProductMode }; }; -template<> struct ei_product_type_selector<Small,Small,Large> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Large,Small,Large> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Small,Large,Large> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Large,Large,Large> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Large,Small,Small> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Small,Large,Small> { enum { ret = GemmProduct }; }; -template<> struct ei_product_type_selector<Large,Large,Small> { enum { ret = GemmProduct }; }; +template<int M, int N> struct product_type_selector<M,N,1> { enum { ret = OuterProduct }; }; +template<int Depth> struct product_type_selector<1, 1, Depth> { enum { ret = InnerProduct }; }; +template<> struct product_type_selector<1, 1, 1> { enum { ret = InnerProduct }; }; +template<> struct product_type_selector<Small,1, Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<Small,Small,Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<Small, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; }; +template<> struct product_type_selector<Small, Large, 1> { enum { ret = LazyCoeffBasedProductMode }; }; +template<> struct product_type_selector<Large, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; }; +template<> struct product_type_selector<1, Large,Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<1, Large,Large> { enum { ret = GemvProduct }; }; +template<> struct product_type_selector<1, Small,Large> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<Large,1, Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<Large,1, Large> { enum { ret = GemvProduct }; }; +template<> struct product_type_selector<Small,1, Large> { enum { ret = CoeffBasedProductMode }; }; +template<> struct product_type_selector<Small,Small,Large> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Large,Small,Large> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Small,Large,Large> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Large,Large,Large> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Large,Small,Small> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Small,Large,Small> { enum { ret = GemmProduct }; }; +template<> struct product_type_selector<Large,Large,Small> { enum { ret = GemmProduct }; }; + +} // end namespace internal /** \class ProductReturnType * \ingroup Core_Module @@ -127,7 +132,7 @@ template<> struct ei_product_type_selector<Large,Large,Small> { en * * \param Lhs the type of the left-hand side * \param Rhs the type of the right-hand side - * \param ProductMode the type of the product (determined automatically by ei_product_mode) + * \param ProductMode the type of the product (determined automatically by internal::product_mode) * * This class defines the typename Type representing the optimized product expression * between two matrix expressions. In practice, using ProductReturnType<Lhs,Rhs>::Type @@ -141,8 +146,8 @@ template<typename Lhs, typename Rhs, int ProductType> struct ProductReturnType { // TODO use the nested type to reduce instanciations ???? -// typedef typename ei_nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested; -// typedef typename ei_nested<Rhs,Lhs::RowsAtCompileTime>::type RhsNested; +// typedef typename internal::nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested; +// typedef typename internal::nested<Rhs,Lhs::RowsAtCompileTime>::type RhsNested; typedef GeneralProduct<Lhs/*Nested*/, Rhs/*Nested*/, ProductType> Type; }; @@ -150,16 +155,16 @@ struct ProductReturnType template<typename Lhs, typename Rhs> struct ProductReturnType<Lhs,Rhs,CoeffBasedProductMode> { - typedef typename ei_nested<Lhs, Rhs::ColsAtCompileTime, typename ei_plain_matrix_type<Lhs>::type >::type LhsNested; - typedef typename ei_nested<Rhs, Lhs::RowsAtCompileTime, typename ei_plain_matrix_type<Rhs>::type >::type RhsNested; + typedef typename internal::nested<Lhs, Rhs::ColsAtCompileTime, typename internal::plain_matrix_type<Lhs>::type >::type LhsNested; + typedef typename internal::nested<Rhs, Lhs::RowsAtCompileTime, typename internal::plain_matrix_type<Rhs>::type >::type RhsNested; typedef CoeffBasedProduct<LhsNested, RhsNested, EvalBeforeAssigningBit | EvalBeforeNestingBit> Type; }; template<typename Lhs, typename Rhs> struct ProductReturnType<Lhs,Rhs,LazyCoeffBasedProductMode> { - typedef typename ei_nested<Lhs, Rhs::ColsAtCompileTime, typename ei_plain_matrix_type<Lhs>::type >::type LhsNested; - typedef typename ei_nested<Rhs, Lhs::RowsAtCompileTime, typename ei_plain_matrix_type<Rhs>::type >::type RhsNested; + typedef typename internal::nested<Lhs, Rhs::ColsAtCompileTime, typename internal::plain_matrix_type<Lhs>::type >::type LhsNested; + typedef typename internal::nested<Rhs, Lhs::RowsAtCompileTime, typename internal::plain_matrix_type<Rhs>::type >::type RhsNested; typedef CoeffBasedProduct<LhsNested, RhsNested, NestByRefBit> Type; }; @@ -179,21 +184,25 @@ struct LazyProductReturnType : public ProductReturnType<Lhs,Rhs,LazyCoeffBasedPr // product ends up to a row-vector times col-vector product... To tackle this use // case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x); +namespace internal { + template<typename Lhs, typename Rhs> -struct ei_traits<GeneralProduct<Lhs,Rhs,InnerProduct> > - : ei_traits<Matrix<typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> > +struct traits<GeneralProduct<Lhs,Rhs,InnerProduct> > + : traits<Matrix<typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> > {}; +} + template<typename Lhs, typename Rhs> class GeneralProduct<Lhs, Rhs, InnerProduct> - : ei_no_assignment_operator, - public Matrix<typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> + : internal::no_assignment_operator, + public Matrix<typename internal::scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> { - typedef Matrix<typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> Base; + typedef Matrix<typename internal::scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> Base; public: GeneralProduct(const Lhs& lhs, const Rhs& rhs) { - EIGEN_STATIC_ASSERT((ei_is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) Base::coeffRef(0,0) = (lhs.transpose().cwiseProduct(rhs)).sum(); @@ -210,13 +219,17 @@ class GeneralProduct<Lhs, Rhs, InnerProduct> /*********************************************************************** * Implementation of Outer Vector Vector Product ***********************************************************************/ -template<int StorageOrder> struct ei_outer_product_selector; + +namespace internal { +template<int StorageOrder> struct outer_product_selector; template<typename Lhs, typename Rhs> -struct ei_traits<GeneralProduct<Lhs,Rhs,OuterProduct> > - : ei_traits<ProductBase<GeneralProduct<Lhs,Rhs,OuterProduct>, Lhs, Rhs> > +struct traits<GeneralProduct<Lhs,Rhs,OuterProduct> > + : traits<ProductBase<GeneralProduct<Lhs,Rhs,OuterProduct>, Lhs, Rhs> > {}; +} + template<typename Lhs, typename Rhs> class GeneralProduct<Lhs, Rhs, OuterProduct> : public ProductBase<GeneralProduct<Lhs,Rhs,OuterProduct>, Lhs, Rhs> @@ -226,17 +239,19 @@ class GeneralProduct<Lhs, Rhs, OuterProduct> GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) { - EIGEN_STATIC_ASSERT((ei_is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) } template<typename Dest> void scaleAndAddTo(Dest& dest, Scalar alpha) const { - ei_outer_product_selector<(int(Dest::Flags)&RowMajorBit) ? RowMajor : ColMajor>::run(*this, dest, alpha); + internal::outer_product_selector<(int(Dest::Flags)&RowMajorBit) ? RowMajor : ColMajor>::run(*this, dest, alpha); } }; -template<> struct ei_outer_product_selector<ColMajor> { +namespace internal { + +template<> struct outer_product_selector<ColMajor> { template<typename ProductType, typename Dest> static EIGEN_DONT_INLINE void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) { typedef typename Dest::Index Index; @@ -248,7 +263,7 @@ template<> struct ei_outer_product_selector<ColMajor> { } }; -template<> struct ei_outer_product_selector<RowMajor> { +template<> struct outer_product_selector<RowMajor> { template<typename ProductType, typename Dest> static EIGEN_DONT_INLINE void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) { typedef typename Dest::Index Index; @@ -260,6 +275,8 @@ template<> struct ei_outer_product_selector<RowMajor> { } }; +} // end namespace internal + /*********************************************************************** * Implementation of General Matrix Vector Product ***********************************************************************/ @@ -271,13 +288,17 @@ template<> struct ei_outer_product_selector<RowMajor> { * Therefore we need a lower level meta selector. * Furthermore, if the matrix is the rhs, then the product has to be transposed. */ +namespace internal { + template<typename Lhs, typename Rhs> -struct ei_traits<GeneralProduct<Lhs,Rhs,GemvProduct> > - : ei_traits<ProductBase<GeneralProduct<Lhs,Rhs,GemvProduct>, Lhs, Rhs> > +struct traits<GeneralProduct<Lhs,Rhs,GemvProduct> > + : traits<ProductBase<GeneralProduct<Lhs,Rhs,GemvProduct>, Lhs, Rhs> > {}; template<int Side, int StorageOrder, bool BlasCompatible> -struct ei_gemv_selector; +struct gemv_selector; + +} // end namespace internal template<typename Lhs, typename Rhs> class GeneralProduct<Lhs, Rhs, GemvProduct> @@ -291,37 +312,39 @@ class GeneralProduct<Lhs, Rhs, GemvProduct> GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) { -// EIGEN_STATIC_ASSERT((ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret), +// EIGEN_STATIC_ASSERT((internal::is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret), // YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) } enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight }; - typedef typename ei_meta_if<int(Side)==OnTheRight,_LhsNested,_RhsNested>::ret MatrixType; + typedef typename internal::meta_if<int(Side)==OnTheRight,_LhsNested,_RhsNested>::ret MatrixType; template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols()); - ei_gemv_selector<Side,(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor, - bool(ei_blas_traits<MatrixType>::HasUsableDirectAccess)>::run(*this, dst, alpha); + eigen_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols()); + internal::gemv_selector<Side,(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor, + bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess)>::run(*this, dst, alpha); } }; +namespace internal { + // The vector is on the left => transposition template<int StorageOrder, bool BlasCompatible> -struct ei_gemv_selector<OnTheLeft,StorageOrder,BlasCompatible> +struct gemv_selector<OnTheLeft,StorageOrder,BlasCompatible> { template<typename ProductType, typename Dest> static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) { Transpose<Dest> destT(dest); enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor }; - ei_gemv_selector<OnTheRight,OtherStorageOrder,BlasCompatible> + gemv_selector<OnTheRight,OtherStorageOrder,BlasCompatible> ::run(GeneralProduct<Transpose<typename ProductType::_RhsNested>,Transpose<typename ProductType::_LhsNested>, GemvProduct> (prod.rhs().transpose(), prod.lhs().transpose()), destT, alpha); } }; -template<> struct ei_gemv_selector<OnTheRight,ColMajor,true> +template<> struct gemv_selector<OnTheRight,ColMajor,true> { template<typename ProductType, typename Dest> static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) @@ -344,15 +367,15 @@ template<> struct ei_gemv_selector<OnTheRight,ColMajor,true> * RhsBlasTraits::extractScalarFactor(prod.rhs()); enum { - // FIXME find a way to allow an inner stride on the result if ei_packet_traits<Scalar>::size==1 + // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1 EvalToDestAtCompileTime = Dest::InnerStrideAtCompileTime==1, ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex) }; - bool alphaIsCompatible = (!ComplexByReal) || (ei_imag(actualAlpha)==RealScalar(0)); + bool alphaIsCompatible = (!ComplexByReal) || (imag(actualAlpha)==RealScalar(0)); bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; - RhsScalar compatibleAlpha = ei_get_factor<ResScalar,RhsScalar>::run(actualAlpha); + RhsScalar compatibleAlpha = get_factor<ResScalar,RhsScalar>::run(actualAlpha); ResScalar* actualDest; if (evalToDest) @@ -371,7 +394,7 @@ template<> struct ei_gemv_selector<OnTheRight,ColMajor,true> MappedDest(actualDest, dest.size()) = dest; } - ei_general_matrix_vector_product + general_matrix_vector_product <Index,LhsScalar,ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsBlasTraits::NeedToConjugate>::run( actualLhs.rows(), actualLhs.cols(), &actualLhs.const_cast_derived().coeffRef(0,0), actualLhs.outerStride(), @@ -390,7 +413,7 @@ template<> struct ei_gemv_selector<OnTheRight,ColMajor,true> } }; -template<> struct ei_gemv_selector<OnTheRight,RowMajor,true> +template<> struct gemv_selector<OnTheRight,RowMajor,true> { template<typename ProductType, typename Dest> static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) @@ -412,9 +435,9 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,true> * RhsBlasTraits::extractScalarFactor(prod.rhs()); enum { - // FIXME I think here we really have to check for ei_packet_traits<Scalar>::size==1 + // FIXME I think here we really have to check for packet_traits<Scalar>::size==1 // because in this case it is fine to have an inner stride - DirectlyUseRhs = ((ei_packet_traits<RhsScalar>::size==1) || (_ActualRhsType::Flags&ActualPacketAccessBit)) + DirectlyUseRhs = ((packet_traits<RhsScalar>::size==1) || (_ActualRhsType::Flags&ActualPacketAccessBit)) && (!(_ActualRhsType::Flags & RowMajorBit)) }; @@ -427,7 +450,7 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,true> Map<typename _ActualRhsType::PlainObject>(rhs_data, actualRhs.size()) = actualRhs; } - ei_general_matrix_vector_product + general_matrix_vector_product <Index,LhsScalar,RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsBlasTraits::NeedToConjugate>::run( actualLhs.rows(), actualLhs.cols(), &actualLhs.const_cast_derived().coeffRef(0,0), actualLhs.outerStride(), @@ -439,7 +462,7 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,true> } }; -template<> struct ei_gemv_selector<OnTheRight,ColMajor,false> +template<> struct gemv_selector<OnTheRight,ColMajor,false> { template<typename ProductType, typename Dest> static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) @@ -452,7 +475,7 @@ template<> struct ei_gemv_selector<OnTheRight,ColMajor,false> } }; -template<> struct ei_gemv_selector<OnTheRight,RowMajor,false> +template<> struct gemv_selector<OnTheRight,RowMajor,false> { template<typename ProductType, typename Dest> static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) @@ -465,6 +488,8 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,false> } }; +} // end namespace internal + /*************************************************************************** * Implementation of matrix base methods ***************************************************************************/ @@ -500,7 +525,7 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION) EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT) #ifdef EIGEN_DEBUG_PRODUCT - ei_product_type<Derived,OtherDerived>::debug(); + internal::product_type<Derived,OtherDerived>::debug(); #endif return typename ProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived()); } diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index bc2a0f743..87702f4db 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -29,29 +29,32 @@ * \ingroup Core_Module * */ + +namespace internal { template<typename Derived, typename _Lhs, typename _Rhs> -struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > +struct traits<ProductBase<Derived,_Lhs,_Rhs> > { typedef MatrixXpr XprKind; - typedef typename ei_cleantype<_Lhs>::type Lhs; - typedef typename ei_cleantype<_Rhs>::type Rhs; - typedef typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; - typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageKind, - typename ei_traits<Rhs>::StorageKind>::ret StorageKind; - typedef typename ei_promote_index_type<typename ei_traits<Lhs>::Index, - typename ei_traits<Rhs>::Index>::type Index; + typedef typename cleantype<_Lhs>::type Lhs; + typedef typename cleantype<_Rhs>::type Rhs; + typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; + typedef typename promote_storage_type<typename traits<Lhs>::StorageKind, + typename traits<Rhs>::StorageKind>::ret StorageKind; + typedef typename promote_index_type<typename traits<Lhs>::Index, + typename traits<Rhs>::Index>::type Index; enum { - RowsAtCompileTime = ei_traits<Lhs>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime, - MaxRowsAtCompileTime = ei_traits<Lhs>::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ei_traits<Rhs>::MaxColsAtCompileTime, + RowsAtCompileTime = traits<Lhs>::RowsAtCompileTime, + ColsAtCompileTime = traits<Rhs>::ColsAtCompileTime, + MaxRowsAtCompileTime = traits<Lhs>::MaxRowsAtCompileTime, + MaxColsAtCompileTime = traits<Rhs>::MaxColsAtCompileTime, Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0) | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, // Note that EvalBeforeNestingBit and NestByRefBit - // are not used in practice because ei_nested is overloaded for products + // are not used in practice because nested is overloaded for products CoeffReadCost = 0 // FIXME why is it needed ? }; }; +} #define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ typedef ProductBase<Derived, Lhs, Rhs > Base; \ @@ -77,16 +80,16 @@ class ProductBase : public MatrixBase<Derived> EIGEN_DENSE_PUBLIC_INTERFACE(ProductBase) protected: typedef typename Lhs::Nested LhsNested; - typedef typename ei_cleantype<LhsNested>::type _LhsNested; - typedef ei_blas_traits<_LhsNested> LhsBlasTraits; + typedef typename internal::cleantype<LhsNested>::type _LhsNested; + typedef internal::blas_traits<_LhsNested> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; - typedef typename ei_cleantype<ActualLhsType>::type _ActualLhsType; + typedef typename internal::cleantype<ActualLhsType>::type _ActualLhsType; typedef typename Rhs::Nested RhsNested; - typedef typename ei_cleantype<RhsNested>::type _RhsNested; - typedef ei_blas_traits<_RhsNested> RhsBlasTraits; + typedef typename internal::cleantype<RhsNested>::type _RhsNested; + typedef internal::blas_traits<_RhsNested> RhsBlasTraits; typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; - typedef typename ei_cleantype<ActualRhsType>::type _ActualRhsType; + typedef typename internal::cleantype<ActualRhsType>::type _ActualRhsType; // Diagonal of a product: no need to evaluate the arguments because they are going to be evaluated only once typedef CoeffBasedProduct<LhsNested, RhsNested, 0> FullyLazyCoeffBaseProductType; @@ -98,7 +101,7 @@ class ProductBase : public MatrixBase<Derived> ProductBase(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { - ei_assert(lhs.cols() == rhs.rows() + eigen_assert(lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); } @@ -157,11 +160,13 @@ class ProductBase : public MatrixBase<Derived> // here we need to overload the nested rule for products // such that the nested type is a const reference to a plain matrix +namespace internal { template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject> -struct ei_nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject> +struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject> { typedef PlainObject const& type; }; +} template<typename NestedProduct> class ScaledProduct; @@ -178,7 +183,7 @@ operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::Scalar x) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> -typename ei_enable_if<!ei_is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, +typename internal::enable_if<!internal::is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, const ScaledProduct<Derived> >::type operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::RealScalar x) { return ScaledProduct<Derived>(prod.derived(), x); } @@ -190,20 +195,21 @@ operator*(typename Derived::Scalar x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> -typename ei_enable_if<!ei_is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, +typename internal::enable_if<!internal::is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, const ScaledProduct<Derived> >::type operator*(typename Derived::RealScalar x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } - +namespace internal { template<typename NestedProduct> -struct ei_traits<ScaledProduct<NestedProduct> > - : ei_traits<ProductBase<ScaledProduct<NestedProduct>, +struct traits<ScaledProduct<NestedProduct> > + : traits<ProductBase<ScaledProduct<NestedProduct>, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested> > { - typedef typename ei_traits<NestedProduct>::StorageKind StorageKind; + typedef typename traits<NestedProduct>::StorageKind StorageKind; }; +} template<typename NestedProduct> class ScaledProduct diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index 3c3dc45ab..b7d90103a 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -25,15 +25,20 @@ #ifndef EIGEN_RANDOM_H #define EIGEN_RANDOM_H -template<typename Scalar> struct ei_scalar_random_op { - EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_random_op) +namespace internal { + +template<typename Scalar> struct scalar_random_op { + EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op) template<typename Index> - inline const Scalar operator() (Index, Index = 0) const { return ei_random<Scalar>(); } + inline const Scalar operator() (Index, Index = 0) const { return random<Scalar>(); } }; + template<typename Scalar> -struct ei_functor_traits<ei_scalar_random_op<Scalar> > +struct functor_traits<scalar_random_op<Scalar> > { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; }; +} // end namespace internal + /** \returns a random matrix expression * * The parameters \a rows and \a cols are the number of rows and of columns of @@ -53,10 +58,10 @@ struct ei_functor_traits<ei_scalar_random_op<Scalar> > * \sa MatrixBase::setRandom(), MatrixBase::Random(Index), MatrixBase::Random() */ template<typename Derived> -inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> +inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> DenseBase<Derived>::Random(Index rows, Index cols) { - return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>()); + return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>()); } /** \returns a random vector expression @@ -80,10 +85,10 @@ DenseBase<Derived>::Random(Index rows, Index cols) * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random() */ template<typename Derived> -inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> +inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> DenseBase<Derived>::Random(Index size) { - return NullaryExpr(size, ei_scalar_random_op<Scalar>()); + return NullaryExpr(size, internal::scalar_random_op<Scalar>()); } /** \returns a fixed-size random matrix or vector expression @@ -101,10 +106,10 @@ DenseBase<Derived>::Random(Index size) * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random(Index) */ template<typename Derived> -inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> +inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> DenseBase<Derived>::Random() { - return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>()); + return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>()); } /** Sets all coefficients in this expression to random values. diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 504a51229..f5a584cd4 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -26,6 +26,8 @@ #ifndef EIGEN_REDUX_H #define EIGEN_REDUX_H +namespace internal { + // TODO // * implement other kind of vectorization // * factorize code @@ -35,11 +37,11 @@ ***************************************************************************/ template<typename Func, typename Derived> -struct ei_redux_traits +struct redux_traits { public: enum { - PacketSize = ei_packet_traits<typename Derived::Scalar>::size, + PacketSize = packet_traits<typename Derived::Scalar>::size, InnerMaxSize = int(Derived::IsRowMajor) ? Derived::MaxColsAtCompileTime : Derived::MaxRowsAtCompileTime @@ -47,7 +49,7 @@ public: enum { MightVectorize = (int(Derived::Flags)&ActualPacketAccessBit) - && (ei_functor_traits<Func>::PacketAccess), + && (functor_traits<Func>::PacketAccess), MayLinearVectorize = MightVectorize && (int(Derived::Flags)&LinearAccessBit), MaySliceVectorize = MightVectorize && int(InnerMaxSize)>=3*PacketSize }; @@ -63,10 +65,10 @@ public: enum { Cost = ( Derived::SizeAtCompileTime == Dynamic || Derived::CoeffReadCost == Dynamic - || (Derived::SizeAtCompileTime!=1 && ei_functor_traits<Func>::Cost == Dynamic) + || (Derived::SizeAtCompileTime!=1 && functor_traits<Func>::Cost == Dynamic) ) ? Dynamic : Derived::SizeAtCompileTime * Derived::CoeffReadCost - + (Derived::SizeAtCompileTime-1) * ei_functor_traits<Func>::Cost, + + (Derived::SizeAtCompileTime-1) * functor_traits<Func>::Cost, UnrollingLimit = EIGEN_UNROLLING_LIMIT * (int(Traversal) == int(DefaultTraversal) ? 1 : int(PacketSize)) }; @@ -85,7 +87,7 @@ public: /*** no vectorization ***/ template<typename Func, typename Derived, int Start, int Length> -struct ei_redux_novec_unroller +struct redux_novec_unroller { enum { HalfLength = Length/2 @@ -95,13 +97,13 @@ struct ei_redux_novec_unroller EIGEN_STRONG_INLINE static Scalar run(const Derived &mat, const Func& func) { - return func(ei_redux_novec_unroller<Func, Derived, Start, HalfLength>::run(mat,func), - ei_redux_novec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func)); + return func(redux_novec_unroller<Func, Derived, Start, HalfLength>::run(mat,func), + redux_novec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func)); } }; template<typename Func, typename Derived, int Start> -struct ei_redux_novec_unroller<Func, Derived, Start, 1> +struct redux_novec_unroller<Func, Derived, Start, 1> { enum { outer = Start / Derived::InnerSizeAtCompileTime, @@ -120,7 +122,7 @@ struct ei_redux_novec_unroller<Func, Derived, Start, 1> // to prevent false warnings regarding failed inlining though // for 0 length run() will never be called at all. template<typename Func, typename Derived, int Start> -struct ei_redux_novec_unroller<Func, Derived, Start, 0> +struct redux_novec_unroller<Func, Derived, Start, 0> { typedef typename Derived::Scalar Scalar; EIGEN_STRONG_INLINE static Scalar run(const Derived&, const Func&) { return Scalar(); } @@ -129,36 +131,36 @@ struct ei_redux_novec_unroller<Func, Derived, Start, 0> /*** vectorization ***/ template<typename Func, typename Derived, int Start, int Length> -struct ei_redux_vec_unroller +struct redux_vec_unroller { enum { - PacketSize = ei_packet_traits<typename Derived::Scalar>::size, + PacketSize = packet_traits<typename Derived::Scalar>::size, HalfLength = Length/2 }; typedef typename Derived::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename packet_traits<Scalar>::type PacketScalar; EIGEN_STRONG_INLINE static PacketScalar run(const Derived &mat, const Func& func) { return func.packetOp( - ei_redux_vec_unroller<Func, Derived, Start, HalfLength>::run(mat,func), - ei_redux_vec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func) ); + redux_vec_unroller<Func, Derived, Start, HalfLength>::run(mat,func), + redux_vec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func) ); } }; template<typename Func, typename Derived, int Start> -struct ei_redux_vec_unroller<Func, Derived, Start, 1> +struct redux_vec_unroller<Func, Derived, Start, 1> { enum { - index = Start * ei_packet_traits<typename Derived::Scalar>::size, + index = Start * packet_traits<typename Derived::Scalar>::size, outer = index / int(Derived::InnerSizeAtCompileTime), inner = index % int(Derived::InnerSizeAtCompileTime), alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned }; typedef typename Derived::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename packet_traits<Scalar>::type PacketScalar; EIGEN_STRONG_INLINE static PacketScalar run(const Derived &mat, const Func&) { @@ -171,19 +173,19 @@ struct ei_redux_vec_unroller<Func, Derived, Start, 1> ***************************************************************************/ template<typename Func, typename Derived, - int Traversal = ei_redux_traits<Func, Derived>::Traversal, - int Unrolling = ei_redux_traits<Func, Derived>::Unrolling + int Traversal = redux_traits<Func, Derived>::Traversal, + int Unrolling = redux_traits<Func, Derived>::Unrolling > -struct ei_redux_impl; +struct redux_impl; template<typename Func, typename Derived> -struct ei_redux_impl<Func, Derived, DefaultTraversal, NoUnrolling> +struct redux_impl<Func, Derived, DefaultTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; typedef typename Derived::Index Index; static EIGEN_STRONG_INLINE Scalar run(const Derived& mat, const Func& func) { - ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); + eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); Scalar res; res = mat.coeffByOuterInner(0, 0); for(Index i = 1; i < mat.innerSize(); ++i) @@ -196,23 +198,23 @@ struct ei_redux_impl<Func, Derived, DefaultTraversal, NoUnrolling> }; template<typename Func, typename Derived> -struct ei_redux_impl<Func,Derived, DefaultTraversal, CompleteUnrolling> - : public ei_redux_novec_unroller<Func,Derived, 0, Derived::SizeAtCompileTime> +struct redux_impl<Func,Derived, DefaultTraversal, CompleteUnrolling> + : public redux_novec_unroller<Func,Derived, 0, Derived::SizeAtCompileTime> {}; template<typename Func, typename Derived> -struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling> +struct redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename packet_traits<Scalar>::type PacketScalar; typedef typename Derived::Index Index; static Scalar run(const Derived& mat, const Func& func) { const Index size = mat.size(); - ei_assert(size && "you are using an empty matrix"); - const Index packetSize = ei_packet_traits<Scalar>::size; - const Index alignedStart = ei_first_aligned(mat); + eigen_assert(size && "you are using an empty matrix"); + const Index packetSize = packet_traits<Scalar>::size; + const Index alignedStart = first_aligned(mat); enum { alignment = (Derived::Flags & DirectAccessBit) || (Derived::Flags & AlignedBit) ? Aligned : Unaligned @@ -246,19 +248,19 @@ struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling> }; template<typename Func, typename Derived> -struct ei_redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling> +struct redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename packet_traits<Scalar>::type PacketScalar; typedef typename Derived::Index Index; static Scalar run(const Derived& mat, const Func& func) { - ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); + eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); const Index innerSize = mat.innerSize(); const Index outerSize = mat.outerSize(); enum { - packetSize = ei_packet_traits<Scalar>::size + packetSize = packet_traits<Scalar>::size }; const Index packetedInnerSize = ((innerSize)/packetSize)*packetSize; Scalar res; @@ -277,7 +279,7 @@ struct ei_redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling> else // too small to vectorize anything. // since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize. { - res = ei_redux_impl<Func, Derived, DefaultTraversal, NoUnrolling>::run(mat, func); + res = redux_impl<Func, Derived, DefaultTraversal, NoUnrolling>::run(mat, func); } return res; @@ -285,25 +287,31 @@ struct ei_redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling> }; template<typename Func, typename Derived> -struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, CompleteUnrolling> +struct redux_impl<Func, Derived, LinearVectorizedTraversal, CompleteUnrolling> { typedef typename Derived::Scalar Scalar; - typedef typename ei_packet_traits<Scalar>::type PacketScalar; + typedef typename packet_traits<Scalar>::type PacketScalar; enum { - PacketSize = ei_packet_traits<Scalar>::size, + PacketSize = packet_traits<Scalar>::size, Size = Derived::SizeAtCompileTime, VectorizedSize = (Size / PacketSize) * PacketSize }; EIGEN_STRONG_INLINE static Scalar run(const Derived& mat, const Func& func) { - ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); - Scalar res = func.predux(ei_redux_vec_unroller<Func, Derived, 0, Size / PacketSize>::run(mat,func)); + eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); + Scalar res = func.predux(redux_vec_unroller<Func, Derived, 0, Size / PacketSize>::run(mat,func)); if (VectorizedSize != Size) - res = func(res,ei_redux_novec_unroller<Func, Derived, VectorizedSize, Size-VectorizedSize>::run(mat,func)); + res = func(res,redux_novec_unroller<Func, Derived, VectorizedSize, Size-VectorizedSize>::run(mat,func)); return res; } }; +} // end namespace internal + +/*************************************************************************** +* Part 4 : public API +***************************************************************************/ + /** \returns the result of a full redux operation on the whole matrix or vector using \a func * @@ -314,30 +322,30 @@ struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, CompleteUnrolling */ template<typename Derived> template<typename Func> -EIGEN_STRONG_INLINE typename ei_result_of<Func(typename ei_traits<Derived>::Scalar)>::type +EIGEN_STRONG_INLINE typename internal::result_of<Func(typename internal::traits<Derived>::Scalar)>::type DenseBase<Derived>::redux(const Func& func) const { - typedef typename ei_cleantype<typename Derived::Nested>::type ThisNested; - return ei_redux_impl<Func, ThisNested> + typedef typename internal::cleantype<typename Derived::Nested>::type ThisNested; + return internal::redux_impl<Func, ThisNested> ::run(derived(), func); } /** \returns the minimum of all coefficients of *this */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar DenseBase<Derived>::minCoeff() const { - return this->redux(Eigen::ei_scalar_min_op<Scalar>()); + return this->redux(Eigen::internal::scalar_min_op<Scalar>()); } /** \returns the maximum of all coefficients of *this */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar DenseBase<Derived>::maxCoeff() const { - return this->redux(Eigen::ei_scalar_max_op<Scalar>()); + return this->redux(Eigen::internal::scalar_max_op<Scalar>()); } /** \returns the sum of all coefficients of *this @@ -345,12 +353,12 @@ DenseBase<Derived>::maxCoeff() const * \sa trace(), prod(), mean() */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar DenseBase<Derived>::sum() const { if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) return Scalar(0); - return this->redux(Eigen::ei_scalar_sum_op<Scalar>()); + return this->redux(Eigen::internal::scalar_sum_op<Scalar>()); } /** \returns the mean of all coefficients of *this @@ -358,10 +366,10 @@ DenseBase<Derived>::sum() const * \sa trace(), prod(), sum() */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar DenseBase<Derived>::mean() const { - return Scalar(this->redux(Eigen::ei_scalar_sum_op<Scalar>())) / Scalar(this->size()); + return Scalar(this->redux(Eigen::internal::scalar_sum_op<Scalar>())) / Scalar(this->size()); } /** \returns the product of all coefficients of *this @@ -372,12 +380,12 @@ DenseBase<Derived>::mean() const * \sa sum(), mean(), trace() */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar DenseBase<Derived>::prod() const { if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) return Scalar(1); - return this->redux(Eigen::ei_scalar_product_op<Scalar>()); + return this->redux(Eigen::internal::scalar_product_op<Scalar>()); } /** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal. @@ -387,7 +395,7 @@ DenseBase<Derived>::prod() const * \sa diagonal(), sum() */ template<typename Derived> -EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar +EIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar MatrixBase<Derived>::trace() const { return derived().diagonal().sum(); diff --git a/Eigen/src/Core/Replicate.h b/Eigen/src/Core/Replicate.h index 87dea0533..d5022c2cd 100644 --- a/Eigen/src/Core/Replicate.h +++ b/Eigen/src/Core/Replicate.h @@ -39,15 +39,17 @@ * * \sa DenseBase::replicate() */ + +namespace internal { template<typename MatrixType,int RowFactor,int ColFactor> -struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> > - : ei_traits<MatrixType> +struct traits<Replicate<MatrixType,RowFactor,ColFactor> > + : traits<MatrixType> { typedef typename MatrixType::Scalar Scalar; - typedef typename ei_traits<MatrixType>::StorageKind StorageKind; - typedef typename ei_traits<MatrixType>::XprKind XprKind; - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename traits<MatrixType>::StorageKind StorageKind; + typedef typename traits<MatrixType>::XprKind XprKind; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic ? Dynamic @@ -65,29 +67,30 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> > CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; +} template<typename MatrixType,int RowFactor,int ColFactor> class Replicate - : public ei_dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type + : public internal::dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type { public: - typedef typename ei_dense_xpr_base<Replicate>::type Base; + typedef typename internal::dense_xpr_base<Replicate>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Replicate) template<typename OriginalMatrixType> inline explicit Replicate(const OriginalMatrixType& matrix) : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor) { - EIGEN_STATIC_ASSERT((ei_is_same_type<MatrixType,OriginalMatrixType>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<MatrixType,OriginalMatrixType>::ret), THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) - ei_assert(RowFactor!=Dynamic && ColFactor!=Dynamic); + eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic); } template<typename OriginalMatrixType> inline Replicate(const OriginalMatrixType& matrix, int rowFactor, int colFactor) : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) { - EIGEN_STATIC_ASSERT((ei_is_same_type<MatrixType,OriginalMatrixType>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<MatrixType,OriginalMatrixType>::ret), THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) } @@ -97,10 +100,10 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate inline Scalar coeff(Index row, Index col) const { // try to avoid using modulo; this is a pure optimization strategy - const Index actual_row = ei_traits<MatrixType>::RowsAtCompileTime==1 ? 0 + const Index actual_row = internal::traits<MatrixType>::RowsAtCompileTime==1 ? 0 : RowFactor==1 ? row : row%m_matrix.rows(); - const Index actual_col = ei_traits<MatrixType>::ColsAtCompileTime==1 ? 0 + const Index actual_col = internal::traits<MatrixType>::ColsAtCompileTime==1 ? 0 : ColFactor==1 ? col : col%m_matrix.cols(); @@ -109,10 +112,10 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate template<int LoadMode> inline PacketScalar packet(Index row, Index col) const { - const Index actual_row = ei_traits<MatrixType>::RowsAtCompileTime==1 ? 0 + const Index actual_row = internal::traits<MatrixType>::RowsAtCompileTime==1 ? 0 : RowFactor==1 ? row : row%m_matrix.rows(); - const Index actual_col = ei_traits<MatrixType>::ColsAtCompileTime==1 ? 0 + const Index actual_col = internal::traits<MatrixType>::ColsAtCompileTime==1 ? 0 : ColFactor==1 ? col : col%m_matrix.cols(); @@ -122,8 +125,8 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate protected: const typename MatrixType::Nested m_matrix; - const ei_variable_if_dynamic<Index, RowFactor> m_rowFactor; - const ei_variable_if_dynamic<Index, ColFactor> m_colFactor; + const internal::variable_if_dynamic<Index, RowFactor> m_rowFactor; + const internal::variable_if_dynamic<Index, ColFactor> m_colFactor; }; /** diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h index 82f194b56..c0d65f5cb 100644 --- a/Eigen/src/Core/ReturnByValue.h +++ b/Eigen/src/Core/ReturnByValue.h @@ -30,36 +30,43 @@ * \ingroup Core_Module * */ + +namespace internal { + template<typename Derived> -struct ei_traits<ReturnByValue<Derived> > - : public ei_traits<typename ei_traits<Derived>::ReturnType> +struct traits<ReturnByValue<Derived> > + : public traits<typename traits<Derived>::ReturnType> { enum { // We're disabling the DirectAccess because e.g. the constructor of // the Block-with-DirectAccess expression requires to have a coeffRef method. // Also, we don't want to have to implement the stride stuff. - Flags = (ei_traits<typename ei_traits<Derived>::ReturnType>::Flags + Flags = (traits<typename traits<Derived>::ReturnType>::Flags | EvalBeforeNestingBit) & ~DirectAccessBit }; }; /* The ReturnByValue object doesn't even have a coeff() method. * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. - * So ei_nested always gives the plain return matrix type. + * So internal::nested always gives the plain return matrix type. + * + * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? */ template<typename Derived,int n,typename PlainObject> -struct ei_nested<ReturnByValue<Derived>, n, PlainObject> +struct nested<ReturnByValue<Derived>, n, PlainObject> { - typedef typename ei_traits<Derived>::ReturnType type; + typedef typename traits<Derived>::ReturnType type; }; +} // end namespace internal + template<typename Derived> class ReturnByValue - : public ei_dense_xpr_base< ReturnByValue<Derived> >::type + : public internal::dense_xpr_base< ReturnByValue<Derived> >::type { public: - typedef typename ei_traits<Derived>::ReturnType ReturnType; + typedef typename internal::traits<Derived>::ReturnType ReturnType; - typedef typename ei_dense_xpr_base<ReturnByValue>::type Base; + typedef typename internal::dense_xpr_base<ReturnByValue>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) template<typename Dest> diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h index abc44bde6..13fdc50a7 100644 --- a/Eigen/src/Core/Reverse.h +++ b/Eigen/src/Core/Reverse.h @@ -40,15 +40,18 @@ * * \sa MatrixBase::reverse(), VectorwiseOp::reverse() */ + +namespace internal { + template<typename MatrixType, int Direction> -struct ei_traits<Reverse<MatrixType, Direction> > - : ei_traits<MatrixType> +struct traits<Reverse<MatrixType, Direction> > + : traits<MatrixType> { typedef typename MatrixType::Scalar Scalar; - typedef typename ei_traits<MatrixType>::StorageKind StorageKind; - typedef typename ei_traits<MatrixType>::XprKind XprKind; - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename traits<MatrixType>::StorageKind StorageKind; + typedef typename traits<MatrixType>::XprKind XprKind; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, @@ -65,21 +68,24 @@ struct ei_traits<Reverse<MatrixType, Direction> > }; }; -template<typename PacketScalar, bool ReversePacket> struct ei_reverse_packet_cond +template<typename PacketScalar, bool ReversePacket> struct reverse_packet_cond { - static inline PacketScalar run(const PacketScalar& x) { return ei_preverse(x); } + static inline PacketScalar run(const PacketScalar& x) { return preverse(x); } }; -template<typename PacketScalar> struct ei_reverse_packet_cond<PacketScalar,false> + +template<typename PacketScalar> struct reverse_packet_cond<PacketScalar,false> { static inline PacketScalar run(const PacketScalar& x) { return x; } }; +} // end namespace internal + template<typename MatrixType, int Direction> class Reverse - : public ei_dense_xpr_base< Reverse<MatrixType, Direction> >::type + : public internal::dense_xpr_base< Reverse<MatrixType, Direction> >::type { public: - typedef typename ei_dense_xpr_base<Reverse>::type Base; + typedef typename internal::dense_xpr_base<Reverse>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Reverse) using Base::IsRowMajor; @@ -89,7 +95,7 @@ template<typename MatrixType, int Direction> class Reverse protected: enum { - PacketSize = ei_packet_traits<Scalar>::size, + PacketSize = internal::packet_traits<Scalar>::size, IsColMajor = !IsRowMajor, ReverseRow = (Direction == Vertical) || (Direction == BothDirections), ReverseCol = (Direction == Horizontal) || (Direction == BothDirections), @@ -99,7 +105,7 @@ template<typename MatrixType, int Direction> class Reverse || ((Direction == Vertical) && IsColMajor) || ((Direction == Horizontal) && IsRowMajor) }; - typedef ei_reverse_packet_cond<PacketScalar,ReversePacket> reverse_packet; + typedef internal::reverse_packet_cond<PacketScalar,ReversePacket> reverse_packet; public: inline Reverse(const MatrixType& matrix) : m_matrix(matrix) { } @@ -116,7 +122,7 @@ template<typename MatrixType, int Direction> class Reverse inline Scalar& operator()(Index row, Index col) { - ei_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); + eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return coeffRef(row, col); } @@ -144,7 +150,7 @@ template<typename MatrixType, int Direction> class Reverse inline Scalar& operator()(Index index) { - ei_assert(index >= 0 && index < m_matrix.size()); + eigen_assert(index >= 0 && index < m_matrix.size()); return coeffRef(index); } @@ -168,13 +174,13 @@ template<typename MatrixType, int Direction> class Reverse template<int LoadMode> inline const PacketScalar packet(Index index) const { - return ei_preverse(m_matrix.template packet<LoadMode>( m_matrix.size() - index - PacketSize )); + return internal::preverse(m_matrix.template packet<LoadMode>( m_matrix.size() - index - PacketSize )); } template<int LoadMode> inline void writePacket(Index index, const PacketScalar& x) { - m_matrix.const_cast_derived().template writePacket<LoadMode>(m_matrix.size() - index - PacketSize, ei_preverse(x)); + m_matrix.const_cast_derived().template writePacket<LoadMode>(m_matrix.size() - index - PacketSize, internal::preverse(x)); } protected: diff --git a/Eigen/src/Core/Select.h b/Eigen/src/Core/Select.h index 000c70905..bad6a74f9 100644 --- a/Eigen/src/Core/Select.h +++ b/Eigen/src/Core/Select.h @@ -40,13 +40,14 @@ * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const */ +namespace internal { template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> -struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > - : ei_traits<ThenMatrixType> +struct traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > + : traits<ThenMatrixType> { - typedef typename ei_traits<ThenMatrixType>::Scalar Scalar; + typedef typename traits<ThenMatrixType>::Scalar Scalar; typedef Dense StorageKind; - typedef typename ei_traits<ThenMatrixType>::XprKind XprKind; + typedef typename traits<ThenMatrixType>::XprKind XprKind; typedef typename ConditionMatrixType::Nested ConditionMatrixNested; typedef typename ThenMatrixType::Nested ThenMatrixNested; typedef typename ElseMatrixType::Nested ElseMatrixNested; @@ -56,19 +57,20 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime, Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits, - CoeffReadCost = ei_traits<typename ei_cleantype<ConditionMatrixNested>::type>::CoeffReadCost - + EIGEN_SIZE_MAX(ei_traits<typename ei_cleantype<ThenMatrixNested>::type>::CoeffReadCost, - ei_traits<typename ei_cleantype<ElseMatrixNested>::type>::CoeffReadCost) + CoeffReadCost = traits<typename cleantype<ConditionMatrixNested>::type>::CoeffReadCost + + EIGEN_SIZE_MAX(traits<typename cleantype<ThenMatrixNested>::type>::CoeffReadCost, + traits<typename cleantype<ElseMatrixNested>::type>::CoeffReadCost) }; }; +} template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> -class Select : ei_no_assignment_operator, - public ei_dense_xpr_base< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type +class Select : internal::no_assignment_operator, + public internal::dense_xpr_base< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type { public: - typedef typename ei_dense_xpr_base<Select>::type Base; + typedef typename internal::dense_xpr_base<Select>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Select) Select(const ConditionMatrixType& conditionMatrix, @@ -76,8 +78,8 @@ class Select : ei_no_assignment_operator, const ElseMatrixType& elseMatrix) : m_condition(conditionMatrix), m_then(thenMatrix), m_else(elseMatrix) { - ei_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows()); - ei_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols()); + eigen_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows()); + eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols()); } Index rows() const { return m_condition.rows(); } diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index d72a94e15..489240dd9 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -40,11 +40,13 @@ * * \sa class TriangularBase, MatrixBase::selfAdjointView() */ + +namespace internal { template<typename MatrixType, unsigned int UpLo> -struct ei_traits<SelfAdjointView<MatrixType, UpLo> > : ei_traits<MatrixType> +struct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType> { - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; typedef MatrixType ExpressionType; enum { Mode = UpLo | SelfAdjoint, @@ -53,6 +55,7 @@ struct ei_traits<SelfAdjointView<MatrixType, UpLo> > : ei_traits<MatrixType> CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; +} template <typename Lhs, int LhsMode, bool LhsIsVector, typename Rhs, int RhsMode, bool RhsIsVector> @@ -67,17 +70,17 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView typedef TriangularBase<SelfAdjointView> Base; /** \brief The type of coefficients in this matrix */ - typedef typename ei_traits<SelfAdjointView>::Scalar Scalar; + typedef typename internal::traits<SelfAdjointView>::Scalar Scalar; typedef typename MatrixType::Index Index; enum { - Mode = ei_traits<SelfAdjointView>::Mode + Mode = internal::traits<SelfAdjointView>::Mode }; typedef typename MatrixType::PlainObject PlainObject; inline SelfAdjointView(const MatrixType& matrix) : m_matrix(matrix) - { ei_assert(ei_are_flags_consistent<Mode>::ret); } + { eigen_assert(internal::are_flags_consistent<Mode>::ret); } inline Index rows() const { return m_matrix.rows(); } inline Index cols() const { return m_matrix.cols(); } @@ -164,7 +167,7 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView /** Real part of #Scalar */ typedef typename NumTraits<Scalar>::Real RealScalar; /** Return type of eigenvalues() */ - typedef Matrix<RealScalar, ei_traits<MatrixType>::ColsAtCompileTime, 1> EigenvaluesReturnType; + typedef Matrix<RealScalar, internal::traits<MatrixType>::ColsAtCompileTime, 1> EigenvaluesReturnType; EigenvaluesReturnType eigenvalues() const; RealScalar operatorNorm() const; @@ -175,16 +178,18 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView // template<typename OtherDerived, typename MatrixType, unsigned int UpLo> -// ei_selfadjoint_matrix_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> > +// internal::selfadjoint_matrix_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> > // operator*(const MatrixBase<OtherDerived>& lhs, const SelfAdjointView<MatrixType,UpLo>& rhs) // { -// return ei_matrix_selfadjoint_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >(lhs.derived(),rhs); +// return internal::matrix_selfadjoint_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >(lhs.derived(),rhs); // } // selfadjoint to dense matrix +namespace internal { + template<typename Derived1, typename Derived2, int UnrollCount, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper), UnrollCount, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper), UnrollCount, ClearOpposite> { enum { col = (UnrollCount-1) / Derived1::RowsAtCompileTime, @@ -193,23 +198,23 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper) inline static void run(Derived1 &dst, const Derived2 &src) { - ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper), UnrollCount-1, ClearOpposite>::run(dst, src); + triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper), UnrollCount-1, ClearOpposite>::run(dst, src); if(row == col) - dst.coeffRef(row, col) = ei_real(src.coeff(row, col)); + dst.coeffRef(row, col) = real(src.coeff(row, col)); else if(row < col) - dst.coeffRef(col, row) = ei_conj(dst.coeffRef(row, col) = src.coeff(row, col)); + dst.coeffRef(col, row) = conj(dst.coeffRef(row, col) = src.coeff(row, col)); } }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, 0, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, 0, ClearOpposite> { inline static void run(Derived1 &, const Derived2 &) {} }; template<typename Derived1, typename Derived2, int UnrollCount, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Lower), UnrollCount, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Lower), UnrollCount, ClearOpposite> { enum { col = (UnrollCount-1) / Derived1::RowsAtCompileTime, @@ -218,23 +223,23 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Lower) inline static void run(Derived1 &dst, const Derived2 &src) { - ei_triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Lower), UnrollCount-1, ClearOpposite>::run(dst, src); + triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Lower), UnrollCount-1, ClearOpposite>::run(dst, src); if(row == col) - dst.coeffRef(row, col) = ei_real(src.coeff(row, col)); + dst.coeffRef(row, col) = real(src.coeff(row, col)); else if(row > col) - dst.coeffRef(col, row) = ei_conj(dst.coeffRef(row, col) = src.coeff(row, col)); + dst.coeffRef(col, row) = conj(dst.coeffRef(row, col) = src.coeff(row, col)); } }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, 0, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, 0, ClearOpposite> { inline static void run(Derived1 &, const Derived2 &) {} }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -244,7 +249,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, for(Index i = 0; i < j; ++i) { dst.copyCoeff(i, j, src); - dst.coeffRef(j,i) = ei_conj(dst.coeff(i,j)); + dst.coeffRef(j,i) = conj(dst.coeff(i,j)); } dst.copyCoeff(j, j, src); } @@ -252,7 +257,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, Dynamic, ClearOpposite> { inline static void run(Derived1 &dst, const Derived2 &src) { @@ -262,13 +267,15 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, for(Index j = 0; j < i; ++j) { dst.copyCoeff(i, j, src); - dst.coeffRef(j,i) = ei_conj(dst.coeff(i,j)); + dst.coeffRef(j,i) = conj(dst.coeff(i,j)); } dst.copyCoeff(i, i, src); } } }; +} // end namespace internal + /*************************************************************************** * Implementation of MatrixBase methods ***************************************************************************/ diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index f77589747..9a649c1ee 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -39,28 +39,31 @@ * * \sa class SwapWrapper for a similar trick. */ + +namespace internal { template<typename BinaryOp, typename Lhs, typename Rhs> -struct ei_traits<SelfCwiseBinaryOp<BinaryOp,Lhs,Rhs> > - : ei_traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> > +struct traits<SelfCwiseBinaryOp<BinaryOp,Lhs,Rhs> > + : traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> > { enum { // Note that it is still a good idea to preserve the DirectAccessBit // so that assign can correctly align the data. - Flags = ei_traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> >::Flags | (Lhs::Flags&DirectAccessBit) | (Lhs::Flags&LvalueBit), + Flags = traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> >::Flags | (Lhs::Flags&DirectAccessBit) | (Lhs::Flags&LvalueBit), OuterStrideAtCompileTime = Lhs::OuterStrideAtCompileTime, InnerStrideAtCompileTime = Lhs::InnerStrideAtCompileTime }; }; +} template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp - : public ei_dense_xpr_base< SelfCwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type + : public internal::dense_xpr_base< SelfCwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type { public: - typedef typename ei_dense_xpr_base<SelfCwiseBinaryOp>::type Base; + typedef typename internal::dense_xpr_base<SelfCwiseBinaryOp>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp) - typedef typename ei_packet_traits<Scalar>::type Packet; + typedef typename internal::packet_traits<Scalar>::type Packet; inline SelfCwiseBinaryOp(Lhs& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {} @@ -88,7 +91,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp void copyCoeff(Index row, Index col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); Scalar& tmp = m_matrix.coeffRef(row,col); tmp = m_functor(tmp, _other.coeff(row,col)); @@ -98,7 +101,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp void copyCoeff(Index index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(index >= 0 && index < m_matrix.size()); + eigen_internal_assert(index >= 0 && index < m_matrix.size()); Scalar& tmp = m_matrix.coeffRef(index); tmp = m_functor(tmp, _other.coeff(index)); } @@ -107,7 +110,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp void copyPacket(Index row, Index col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); m_matrix.template writePacket<StoreMode>(row, col, m_functor.packetOp(m_matrix.template packet<StoreMode>(row, col),_other.template packet<LoadMode>(row, col)) ); @@ -117,7 +120,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp void copyPacket(Index index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(index >= 0 && index < m_matrix.size()); + eigen_internal_assert(index >= 0 && index < m_matrix.size()); m_matrix.template writePacket<StoreMode>(index, m_functor.packetOp(m_matrix.template packet<StoreMode>(index),_other.template packet<LoadMode>(index)) ); } @@ -131,10 +134,10 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename RhsDerived::Scalar); #ifdef EIGEN_DEBUG_ASSIGN - ei_assign_traits<SelfCwiseBinaryOp, RhsDerived>::debug(); + internal::assign_traits<SelfCwiseBinaryOp, RhsDerived>::debug(); #endif - ei_assert(rows() == rhs.rows() && cols() == rhs.cols()); - ei_assign_impl<SelfCwiseBinaryOp, RhsDerived>::run(*this,rhs.derived()); + eigen_assert(rows() == rhs.rows() && cols() == rhs.cols()); + internal::assign_impl<SelfCwiseBinaryOp, RhsDerived>::run(*this,rhs.derived()); #ifndef EIGEN_NO_DEBUG this->checkTransposeAliasing(rhs.derived()); #endif @@ -146,7 +149,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp // at first... SelfCwiseBinaryOp& operator=(const Rhs& _rhs) { - typename ei_nested<Rhs>::type rhs(_rhs); + typename internal::nested<Rhs>::type rhs(_rhs); return Base::operator=(rhs); } @@ -162,7 +165,7 @@ template<typename Derived> inline Derived& DenseBase<Derived>::operator*=(const Scalar& other) { typedef typename Derived::PlainObject PlainObject; - SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); + SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); tmp = PlainObject::Constant(rows(),cols(),other); return derived(); } @@ -170,9 +173,9 @@ inline Derived& DenseBase<Derived>::operator*=(const Scalar& other) template<typename Derived> inline Derived& DenseBase<Derived>::operator/=(const Scalar& other) { - typedef typename ei_meta_if<NumTraits<Scalar>::IsInteger, - ei_scalar_quotient_op<Scalar>, - ei_scalar_product_op<Scalar> >::ret BinOp; + typedef typename internal::meta_if<NumTraits<Scalar>::IsInteger, + internal::scalar_quotient_op<Scalar>, + internal::scalar_product_op<Scalar> >::ret BinOp; typedef typename Derived::PlainObject PlainObject; SelfCwiseBinaryOp<BinOp, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); tmp = PlainObject::Constant(rows(),cols(), NumTraits<Scalar>::IsInteger ? other : Scalar(1)/other); diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index 960da31f3..0b9d3db9d 100644 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -25,8 +25,10 @@ #ifndef EIGEN_SOLVETRIANGULAR_H #define EIGEN_SOLVETRIANGULAR_H +namespace internal { + template<typename Lhs, typename Rhs, int Side> -class ei_trsolve_traits +class trsolve_traits { private: enum { @@ -43,19 +45,19 @@ class ei_trsolve_traits template<typename Lhs, typename Rhs, int Side, // can be OnTheLeft/OnTheRight int Mode, // can be Upper/Lower | UnitDiag - int Unrolling = ei_trsolve_traits<Lhs,Rhs,Side>::Unrolling, + int Unrolling = trsolve_traits<Lhs,Rhs,Side>::Unrolling, int StorageOrder = (int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor, - int RhsVectors = ei_trsolve_traits<Lhs,Rhs,Side>::RhsVectors + int RhsVectors = trsolve_traits<Lhs,Rhs,Side>::RhsVectors > -struct ei_triangular_solver_selector; +struct triangular_solver_selector; // forward and backward substitution, row-major, rhs is a vector template<typename Lhs, typename Rhs, int Mode> -struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor,1> +struct triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor,1> { typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; - typedef ei_blas_traits<Lhs> LhsProductTraits; + typedef blas_traits<Lhs> LhsProductTraits; typedef typename LhsProductTraits::ExtractType ActualLhsType; typedef typename Lhs::Index Index; enum { @@ -82,7 +84,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor Index startRow = IsLower ? pi : pi-actualPanelWidth; Index startCol = IsLower ? 0 : pi; - ei_general_matrix_vector_product<Index,LhsScalar,RowMajor,LhsProductTraits::NeedToConjugate,RhsScalar,false>::run( + general_matrix_vector_product<Index,LhsScalar,RowMajor,LhsProductTraits::NeedToConjugate,RhsScalar,false>::run( actualPanelWidth, r, &(actualLhs.const_cast_derived().coeffRef(startRow,startCol)), actualLhs.outerStride(), &(other.coeffRef(startCol)), other.innerStride(), @@ -106,11 +108,11 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor // forward and backward substitution, column-major, rhs is a vector template<typename Lhs, typename Rhs, int Mode> -struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,ColMajor,1> +struct triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,ColMajor,1> { typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; - typedef ei_blas_traits<Lhs> LhsProductTraits; + typedef blas_traits<Lhs> LhsProductTraits; typedef typename LhsProductTraits::ExtractType ActualLhsType; typedef typename Lhs::Index Index; enum { @@ -148,7 +150,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,ColMajor // let's directly call the low level product function because: // 1 - it is faster to compile // 2 - it is slighlty faster at runtime - ei_general_matrix_vector_product<Index,LhsScalar,ColMajor,LhsProductTraits::NeedToConjugate,RhsScalar,false>::run( + general_matrix_vector_product<Index,LhsScalar,ColMajor,LhsProductTraits::NeedToConjugate,RhsScalar,false>::run( r, actualPanelWidth, &(actualLhs.const_cast_derived().coeffRef(endBlock,startBlock)), actualLhs.outerStride(), &other.coeff(startBlock), other.innerStride(), @@ -160,31 +162,31 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,ColMajor // transpose OnTheRight cases for vectors template<typename Lhs, typename Rhs, int Mode, int Unrolling, int StorageOrder> -struct ei_triangular_solver_selector<Lhs,Rhs,OnTheRight,Mode,Unrolling,StorageOrder,1> +struct triangular_solver_selector<Lhs,Rhs,OnTheRight,Mode,Unrolling,StorageOrder,1> { static void run(const Lhs& lhs, Rhs& rhs) { Transpose<Rhs> rhsTr(rhs); Transpose<Lhs> lhsTr(lhs); - ei_triangular_solver_selector<Transpose<Lhs>,Transpose<Rhs>,OnTheLeft,TriangularView<Lhs,Mode>::TransposeMode>::run(lhsTr,rhsTr); + triangular_solver_selector<Transpose<Lhs>,Transpose<Rhs>,OnTheLeft,TriangularView<Lhs,Mode>::TransposeMode>::run(lhsTr,rhsTr); } }; template <typename Scalar, typename Index, int Side, int Mode, bool Conjugate, int TriStorageOrder, int OtherStorageOrder> -struct ei_triangular_solve_matrix; +struct triangular_solve_matrix; // the rhs is a matrix template<typename Lhs, typename Rhs, int Side, int Mode, int StorageOrder> -struct ei_triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,StorageOrder,Dynamic> +struct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,StorageOrder,Dynamic> { typedef typename Rhs::Scalar Scalar; typedef typename Rhs::Index Index; - typedef ei_blas_traits<Lhs> LhsProductTraits; + typedef blas_traits<Lhs> LhsProductTraits; typedef typename LhsProductTraits::DirectLinearAccessType ActualLhsType; static void run(const Lhs& lhs, Rhs& rhs) { const ActualLhsType actualLhs = LhsProductTraits::extract(lhs); - ei_triangular_solve_matrix<Scalar,Index,Side,Mode,LhsProductTraits::NeedToConjugate,StorageOrder, + triangular_solve_matrix<Scalar,Index,Side,Mode,LhsProductTraits::NeedToConjugate,StorageOrder, (Rhs::Flags&RowMajorBit) ? RowMajor : ColMajor> ::run(lhs.rows(), Side==OnTheLeft? rhs.cols() : rhs.rows(), &actualLhs.coeff(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.outerStride()); } @@ -196,10 +198,10 @@ struct ei_triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,StorageOrder, template<typename Lhs, typename Rhs, int Mode, int Index, int Size, bool Stop = Index==Size> -struct ei_triangular_solver_unroller; +struct triangular_solver_unroller; template<typename Lhs, typename Rhs, int Mode, int Index, int Size> -struct ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> { +struct triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> { enum { IsLower = ((Mode&Lower)==Lower), I = IsLower ? Index : Size - Index - 1, @@ -213,21 +215,23 @@ struct ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> { if(!(Mode & UnitDiag)) rhs.coeffRef(I) /= lhs.coeff(I,I); - ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index+1,Size>::run(lhs,rhs); + triangular_solver_unroller<Lhs,Rhs,Mode,Index+1,Size>::run(lhs,rhs); } }; template<typename Lhs, typename Rhs, int Mode, int Index, int Size> -struct ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,true> { +struct triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,true> { static void run(const Lhs&, Rhs&) {} }; template<typename Lhs, typename Rhs, int Mode, int StorageOrder> -struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,CompleteUnrolling,StorageOrder,1> { +struct triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,CompleteUnrolling,StorageOrder,1> { static void run(const Lhs& lhs, Rhs& rhs) - { ei_triangular_solver_unroller<Lhs,Rhs,Mode,0,Rhs::SizeAtCompileTime>::run(lhs,rhs); } + { triangular_solver_unroller<Lhs,Rhs,Mode,0,Rhs::SizeAtCompileTime>::run(lhs,rhs); } }; +} // end namespace internal + /*************************************************************************** * TriangularView methods ***************************************************************************/ @@ -246,17 +250,17 @@ template<int Side, typename OtherDerived> void TriangularView<MatrixType,Mode>::solveInPlace(const MatrixBase<OtherDerived>& _other) const { OtherDerived& other = _other.const_cast_derived(); - ei_assert(cols() == rows()); - ei_assert( (Side==OnTheLeft && cols() == other.rows()) || (Side==OnTheRight && cols() == other.cols()) ); - ei_assert(!(Mode & ZeroDiag)); - ei_assert(Mode & (Upper|Lower)); - - enum { copy = ei_traits<OtherDerived>::Flags & RowMajorBit && OtherDerived::IsVectorAtCompileTime }; - typedef typename ei_meta_if<copy, - typename ei_plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::ret OtherCopy; + eigen_assert(cols() == rows()); + eigen_assert( (Side==OnTheLeft && cols() == other.rows()) || (Side==OnTheRight && cols() == other.cols()) ); + eigen_assert(!(Mode & ZeroDiag)); + eigen_assert(Mode & (Upper|Lower)); + + enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit && OtherDerived::IsVectorAtCompileTime }; + typedef typename internal::meta_if<copy, + typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::ret OtherCopy; OtherCopy otherCopy(other); - ei_triangular_solver_selector<MatrixType, typename ei_unref<OtherCopy>::type, + internal::triangular_solver_selector<MatrixType, typename internal::unref<OtherCopy>::type, Side, Mode>::run(nestedExpression(), otherCopy); if (copy) @@ -296,10 +300,10 @@ void TriangularView<MatrixType,Mode>::solveInPlace(const MatrixBase<OtherDerived */ template<typename Derived, unsigned int Mode> template<int Side, typename RhsDerived> -typename ei_plain_matrix_type_column_major<RhsDerived>::type +typename internal::plain_matrix_type_column_major<RhsDerived>::type TriangularView<Derived,Mode>::solve(const MatrixBase<RhsDerived>& rhs) const { - typename ei_plain_matrix_type_column_major<RhsDerived>::type res(rhs); + typename internal::plain_matrix_type_column_major<RhsDerived>::type res(rhs); solveInPlace<Side>(res); return res; } diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h index c3c230796..fdf113bfe 100644 --- a/Eigen/src/Core/StableNorm.h +++ b/Eigen/src/Core/StableNorm.h @@ -25,13 +25,14 @@ #ifndef EIGEN_STABLENORM_H #define EIGEN_STABLENORM_H +namespace internal { template<typename ExpressionType, typename Scalar> -inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale) +inline void stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale) { Scalar max = bl.cwiseAbs().maxCoeff(); if (max>scale) { - ssq = ssq * ei_abs2(scale/max); + ssq = ssq * abs2(scale/max); scale = max; invScale = Scalar(1)/scale; } @@ -39,6 +40,7 @@ inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& // then we can neglect this sub vector ssq += (bl*invScale).squaredNorm(); } +} /** \returns the \em l2 norm of \c *this avoiding underflow and overflow. * This version use a blockwise two passes algorithm: @@ -51,7 +53,7 @@ inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& * \sa norm(), blueNorm(), hypotNorm() */ template<typename Derived> -inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real +inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::stableNorm() const { const Index blockSize = 4096; @@ -62,12 +64,12 @@ MatrixBase<Derived>::stableNorm() const Alignment = (int(Flags)&DirectAccessBit) || (int(Flags)&AlignedBit) ? 1 : 0 }; Index n = size(); - Index bi = ei_first_aligned(derived()); + Index bi = internal::first_aligned(derived()); if (bi>0) - ei_stable_norm_kernel(this->head(bi), ssq, scale, invScale); + internal::stable_norm_kernel(this->head(bi), ssq, scale, invScale); for (; bi<n; bi+=blockSize) - ei_stable_norm_kernel(this->segment(bi,std::min(blockSize, n - bi)).template forceAlignedAccessIf<Alignment>(), ssq, scale, invScale); - return scale * ei_sqrt(ssq); + internal::stable_norm_kernel(this->segment(bi,std::min(blockSize, n - bi)).template forceAlignedAccessIf<Alignment>(), ssq, scale, invScale); + return scale * internal::sqrt(ssq); } /** \returns the \em l2 norm of \c *this using the Blue's algorithm. @@ -80,7 +82,7 @@ MatrixBase<Derived>::stableNorm() const * \sa norm(), stableNorm(), hypotNorm() */ template<typename Derived> -inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real +inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::blueNorm() const { static Index nmax = -1; @@ -116,7 +118,7 @@ MatrixBase<Derived>::blueNorm() const overfl = rbig*s2m; // overflow boundary for abig eps = RealScalar(std::pow(double(ibeta), 1-it)); - relerr = ei_sqrt(eps); // tolerance for neglecting asml + relerr = internal::sqrt(eps); // tolerance for neglecting asml abig = RealScalar(1.0/eps - 1.0); if (RealScalar(nbig)>abig) nmax = int(abig); // largest safe n else nmax = nbig; @@ -128,23 +130,23 @@ MatrixBase<Derived>::blueNorm() const RealScalar abig = RealScalar(0); for(Index j=0; j<n; ++j) { - RealScalar ax = ei_abs(coeff(j)); - if(ax > ab2) abig += ei_abs2(ax*s2m); - else if(ax < b1) asml += ei_abs2(ax*s1m); - else amed += ei_abs2(ax); + RealScalar ax = internal::abs(coeff(j)); + if(ax > ab2) abig += internal::abs2(ax*s2m); + else if(ax < b1) asml += internal::abs2(ax*s1m); + else amed += internal::abs2(ax); } if(abig > RealScalar(0)) { - abig = ei_sqrt(abig); + abig = internal::sqrt(abig); if(abig > overfl) { - ei_assert(false && "overflow"); + eigen_assert(false && "overflow"); return rbig; } if(amed > RealScalar(0)) { abig = abig/s2m; - amed = ei_sqrt(amed); + amed = internal::sqrt(amed); } else return abig/s2m; @@ -153,20 +155,20 @@ MatrixBase<Derived>::blueNorm() const { if (amed > RealScalar(0)) { - abig = ei_sqrt(amed); - amed = ei_sqrt(asml) / s1m; + abig = internal::sqrt(amed); + amed = internal::sqrt(asml) / s1m; } else - return ei_sqrt(asml)/s1m; + return internal::sqrt(asml)/s1m; } else - return ei_sqrt(amed); + return internal::sqrt(amed); asml = std::min(abig, amed); abig = std::max(abig, amed); if(asml <= abig*relerr) return abig; else - return abig * ei_sqrt(RealScalar(1) + ei_abs2(asml/abig)); + return abig * internal::sqrt(RealScalar(1) + internal::abs2(asml/abig)); } /** \returns the \em l2 norm of \c *this avoiding undeflow and overflow. @@ -175,10 +177,10 @@ MatrixBase<Derived>::blueNorm() const * \sa norm(), stableNorm() */ template<typename Derived> -inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real +inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::hypotNorm() const { - return this->cwiseAbs().redux(ei_scalar_hypot_op<RealScalar>()); + return this->cwiseAbs().redux(internal::scalar_hypot_op<RealScalar>()); } #endif // EIGEN_STABLENORM_H diff --git a/Eigen/src/Core/Stride.h b/Eigen/src/Core/Stride.h index 47515b548..9425253ec 100644 --- a/Eigen/src/Core/Stride.h +++ b/Eigen/src/Core/Stride.h @@ -67,14 +67,14 @@ class Stride Stride() : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) { - ei_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); + eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); } /** Constructor allowing to pass the strides at runtime */ Stride(Index outerStride, Index innerStride) : m_outer(outerStride), m_inner(innerStride) { - ei_assert(innerStride>=0 && outerStride>=0); + eigen_assert(innerStride>=0 && outerStride>=0); } /** Copy constructor */ @@ -88,8 +88,8 @@ class Stride inline Index inner() const { return m_inner.value(); } protected: - ei_variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer; - ei_variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner; + internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer; + internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner; }; /** \brief Convenience specialization of Stride to specify only an inner stride diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 086d7f32c..abbef4443 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -32,17 +32,19 @@ * * \brief Internal helper class for swapping two expressions */ +namespace internal { template<typename ExpressionType> -struct ei_traits<SwapWrapper<ExpressionType> > : ei_traits<ExpressionType> {}; +struct traits<SwapWrapper<ExpressionType> > : traits<ExpressionType> {}; +} template<typename ExpressionType> class SwapWrapper - : public ei_dense_xpr_base<SwapWrapper<ExpressionType> >::type + : public internal::dense_xpr_base<SwapWrapper<ExpressionType> >::type { public: - typedef typename ei_dense_xpr_base<SwapWrapper>::type Base; + typedef typename internal::dense_xpr_base<SwapWrapper>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(SwapWrapper) - typedef typename ei_packet_traits<Scalar>::type Packet; + typedef typename internal::packet_traits<Scalar>::type Packet; inline SwapWrapper(ExpressionType& xpr) : m_expression(xpr) {} @@ -65,7 +67,7 @@ template<typename ExpressionType> class SwapWrapper void copyCoeff(Index row, Index col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); Scalar tmp = m_expression.coeff(row, col); m_expression.coeffRef(row, col) = _other.coeff(row, col); @@ -76,7 +78,7 @@ template<typename ExpressionType> class SwapWrapper void copyCoeff(Index index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(index >= 0 && index < m_expression.size()); + eigen_internal_assert(index >= 0 && index < m_expression.size()); Scalar tmp = m_expression.coeff(index); m_expression.coeffRef(index) = _other.coeff(index); _other.coeffRef(index) = tmp; @@ -86,7 +88,7 @@ template<typename ExpressionType> class SwapWrapper void copyPacket(Index row, Index col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(row >= 0 && row < rows() + eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); Packet tmp = m_expression.template packet<StoreMode>(row, col); m_expression.template writePacket<StoreMode>(row, col, @@ -99,7 +101,7 @@ template<typename ExpressionType> class SwapWrapper void copyPacket(Index index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); - ei_internal_assert(index >= 0 && index < m_expression.size()); + eigen_internal_assert(index >= 0 && index < m_expression.size()); Packet tmp = m_expression.template packet<StoreMode>(index); m_expression.template writePacket<StoreMode>(index, _other.template packet<LoadMode>(index) diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index de8ae0a5b..a011f7df3 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -39,14 +39,16 @@ * * \sa MatrixBase::transpose(), MatrixBase::adjoint() */ + +namespace internal { template<typename MatrixType> -struct ei_traits<Transpose<MatrixType> > : ei_traits<MatrixType> +struct traits<Transpose<MatrixType> > : traits<MatrixType> { typedef typename MatrixType::Scalar Scalar; - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; - typedef typename ei_traits<MatrixType>::StorageKind StorageKind; - typedef typename ei_traits<MatrixType>::XprKind XprKind; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename traits<MatrixType>::StorageKind StorageKind; + typedef typename traits<MatrixType>::XprKind XprKind; enum { RowsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -54,19 +56,20 @@ struct ei_traits<Transpose<MatrixType> > : ei_traits<MatrixType> MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime, Flags = int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit, CoeffReadCost = _MatrixTypeNested::CoeffReadCost, - InnerStrideAtCompileTime = ei_inner_stride_at_compile_time<MatrixType>::ret, - OuterStrideAtCompileTime = ei_outer_stride_at_compile_time<MatrixType>::ret + InnerStrideAtCompileTime = inner_stride_at_compile_time<MatrixType>::ret, + OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret }; }; +} template<typename MatrixType, typename StorageKind> class TransposeImpl; template<typename MatrixType> class Transpose - : public TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageKind> + : public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind> { public: - typedef typename TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageKind>::Base Base; + typedef typename TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose) inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {} @@ -77,35 +80,39 @@ template<typename MatrixType> class Transpose inline Index cols() const { return m_matrix.rows(); } /** \returns the nested expression */ - const typename ei_cleantype<typename MatrixType::Nested>::type& + const typename internal::cleantype<typename MatrixType::Nested>::type& nestedExpression() const { return m_matrix; } /** \returns the nested expression */ - typename ei_cleantype<typename MatrixType::Nested>::type& + typename internal::cleantype<typename MatrixType::Nested>::type& nestedExpression() { return m_matrix.const_cast_derived(); } protected: const typename MatrixType::Nested m_matrix; }; -template<typename MatrixType, bool HasDirectAccess = ei_has_direct_access<MatrixType>::ret> -struct ei_TransposeImpl_base +namespace internal { + +template<typename MatrixType, bool HasDirectAccess = has_direct_access<MatrixType>::ret> +struct TransposeImpl_base { - typedef typename ei_dense_xpr_base<Transpose<MatrixType> >::type type; + typedef typename dense_xpr_base<Transpose<MatrixType> >::type type; }; template<typename MatrixType> -struct ei_TransposeImpl_base<MatrixType, false> +struct TransposeImpl_base<MatrixType, false> { - typedef typename ei_dense_xpr_base<Transpose<MatrixType> >::type type; + typedef typename dense_xpr_base<Transpose<MatrixType> >::type type; }; +} // end namespace internal + template<typename MatrixType> class TransposeImpl<MatrixType,Dense> - : public ei_TransposeImpl_base<MatrixType>::type + : public internal::TransposeImpl_base<MatrixType>::type { public: - typedef typename ei_TransposeImpl_base<MatrixType>::type Base; + typedef typename internal::TransposeImpl_base<MatrixType>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>) inline Index innerStride() const { return derived().nestedExpression().innerStride(); } @@ -214,7 +221,7 @@ DenseBase<Derived>::transpose() const * m = m.adjoint().eval(); * \endcode * - * \sa adjointInPlace(), transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op */ + * \sa adjointInPlace(), transpose(), conjugate(), class Transpose, class internal::scalar_conjugate_op */ template<typename Derived> inline const typename MatrixBase<Derived>::AdjointReturnType MatrixBase<Derived>::adjoint() const @@ -226,19 +233,21 @@ MatrixBase<Derived>::adjoint() const * "in place" transpose implementation ***************************************************************************/ +namespace internal { + template<typename MatrixType, bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=Dynamic> -struct ei_inplace_transpose_selector; +struct inplace_transpose_selector; template<typename MatrixType> -struct ei_inplace_transpose_selector<MatrixType,true> { // square matrix +struct inplace_transpose_selector<MatrixType,true> { // square matrix static void run(MatrixType& m) { m.template triangularView<StrictlyUpper>().swap(m.transpose()); } }; template<typename MatrixType> -struct ei_inplace_transpose_selector<MatrixType,false> { // non square matrix +struct inplace_transpose_selector<MatrixType,false> { // non square matrix static void run(MatrixType& m) { if (m.rows()==m.cols()) m.template triangularView<StrictlyUpper>().swap(m.transpose()); @@ -247,6 +256,8 @@ struct ei_inplace_transpose_selector<MatrixType,false> { // non square matrix } }; +} // end namespace internal + /** This is the "in place" version of transpose(): it replaces \c *this by its own transpose. * Thus, doing * \code @@ -268,7 +279,7 @@ struct ei_inplace_transpose_selector<MatrixType,false> { // non square matrix template<typename Derived> inline void DenseBase<Derived>::transposeInPlace() { - ei_inplace_transpose_selector<Derived>::run(derived()); + internal::inplace_transpose_selector<Derived>::run(derived()); } /*************************************************************************** @@ -303,45 +314,47 @@ inline void MatrixBase<Derived>::adjointInPlace() // The following is to detect aliasing problems in most common cases. +namespace internal { + template<typename BinOp,typename NestedXpr,typename Rhs> -struct ei_blas_traits<SelfCwiseBinaryOp<BinOp,NestedXpr,Rhs> > - : ei_blas_traits<NestedXpr> +struct blas_traits<SelfCwiseBinaryOp<BinOp,NestedXpr,Rhs> > + : blas_traits<NestedXpr> { typedef SelfCwiseBinaryOp<BinOp,NestedXpr,Rhs> XprType; static inline const XprType extract(const XprType& x) { return x; } }; template<bool DestIsTransposed, typename OtherDerived> -struct ei_check_transpose_aliasing_compile_time_selector +struct check_transpose_aliasing_compile_time_selector { - enum { ret = ei_blas_traits<OtherDerived>::IsTransposed != DestIsTransposed + enum { ret = blas_traits<OtherDerived>::IsTransposed != DestIsTransposed }; }; template<bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB> -struct ei_check_transpose_aliasing_compile_time_selector<DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> > +struct check_transpose_aliasing_compile_time_selector<DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> > { - enum { ret = ei_blas_traits<DerivedA>::IsTransposed != DestIsTransposed - || ei_blas_traits<DerivedB>::IsTransposed != DestIsTransposed + enum { ret = blas_traits<DerivedA>::IsTransposed != DestIsTransposed + || blas_traits<DerivedB>::IsTransposed != DestIsTransposed }; }; template<typename Scalar, bool DestIsTransposed, typename OtherDerived> -struct ei_check_transpose_aliasing_run_time_selector +struct check_transpose_aliasing_run_time_selector { static bool run(const Scalar* dest, const OtherDerived& src) { - return (ei_blas_traits<OtherDerived>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)ei_extract_data(src)); + return (blas_traits<OtherDerived>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src)); } }; template<typename Scalar, bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB> -struct ei_check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> > +struct check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> > { static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src) { - return ((ei_blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)ei_extract_data(src.lhs()))) - || ((ei_blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)ei_extract_data(src.rhs()))); + return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src.lhs()))) + || ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src.rhs()))); } }; @@ -353,16 +366,16 @@ struct ei_check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,Cwi template<typename Derived, typename OtherDerived, bool MightHaveTransposeAliasing - = ei_check_transpose_aliasing_compile_time_selector - <ei_blas_traits<Derived>::IsTransposed,OtherDerived>::ret + = check_transpose_aliasing_compile_time_selector + <blas_traits<Derived>::IsTransposed,OtherDerived>::ret > struct checkTransposeAliasing_impl { static void run(const Derived& dst, const OtherDerived& other) { - ei_assert((!ei_check_transpose_aliasing_run_time_selector - <typename Derived::Scalar,ei_blas_traits<Derived>::IsTransposed,OtherDerived> - ::run(ei_extract_data(dst), other)) + eigen_assert((!check_transpose_aliasing_run_time_selector + <typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived> + ::run(extract_data(dst), other)) && "aliasing detected during tranposition, use transposeInPlace() " "or evaluate the rhs into a temporary using .eval()"); @@ -377,12 +390,13 @@ struct checkTransposeAliasing_impl<Derived, OtherDerived, false> } }; +} // end namespace internal template<typename Derived> template<typename OtherDerived> void DenseBase<Derived>::checkTransposeAliasing(const OtherDerived& other) const { - checkTransposeAliasing_impl<Derived, OtherDerived>::run(derived(), other); + internal::checkTransposeAliasing_impl<Derived, OtherDerived>::run(derived(), other); } #endif diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h index 6703b1e58..b7c3c339f 100644 --- a/Eigen/src/Core/Transpositions.h +++ b/Eigen/src/Core/Transpositions.h @@ -53,7 +53,10 @@ * * \sa class PermutationMatrix */ -template<typename TranspositionType, typename MatrixType, int Side, bool Transposed=false> struct ei_transposition_matrix_product_retval; + +namespace internal { +template<typename TranspositionType, typename MatrixType, int Side, bool Transposed=false> struct transposition_matrix_product_retval; +} template<int SizeAtCompileTime, int MaxSizeAtCompileTime> class Transpositions @@ -188,11 +191,11 @@ class Transpositions /** \returns the \a matrix with the \a transpositions applied to the columns. */ template<typename Derived, int SizeAtCompileTime, int MaxSizeAtCompileTime> -inline const ei_transposition_matrix_product_retval<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> +inline const internal::transposition_matrix_product_retval<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> operator*(const MatrixBase<Derived>& matrix, const Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime> &transpositions) { - return ei_transposition_matrix_product_retval + return internal::transposition_matrix_product_retval <Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheRight> (transpositions, matrix.derived()); } @@ -200,30 +203,32 @@ operator*(const MatrixBase<Derived>& matrix, /** \returns the \a matrix with the \a transpositions applied to the rows. */ template<typename Derived, int SizeAtCompileTime, int MaxSizeAtCompileTime> -inline const ei_transposition_matrix_product_retval +inline const internal::transposition_matrix_product_retval <Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheLeft> operator*(const Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime> &transpositions, const MatrixBase<Derived>& matrix) { - return ei_transposition_matrix_product_retval + return internal::transposition_matrix_product_retval <Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime>, Derived, OnTheLeft> (transpositions, matrix.derived()); } +namespace internal { + template<typename TranspositionType, typename MatrixType, int Side, bool Transposed> -struct ei_traits<ei_transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> > +struct traits<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> > { typedef typename MatrixType::PlainObject ReturnType; }; template<typename TranspositionType, typename MatrixType, int Side, bool Transposed> -struct ei_transposition_matrix_product_retval - : public ReturnByValue<ei_transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> > +struct transposition_matrix_product_retval + : public ReturnByValue<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> > { - typedef typename ei_cleantype<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; + typedef typename cleantype<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; typedef typename TranspositionType::Index Index; - ei_transposition_matrix_product_retval(const TranspositionType& tr, const MatrixType& matrix) + transposition_matrix_product_retval(const TranspositionType& tr, const MatrixType& matrix) : m_transpositions(tr), m_matrix(matrix) {} @@ -235,7 +240,7 @@ struct ei_transposition_matrix_product_retval const int size = m_transpositions.size(); Index j = 0; - if(!(ei_is_same_type<MatrixTypeNestedCleaned,Dest>::ret && ei_extract_data(dst) == ei_extract_data(m_matrix))) + if(!(is_same_type<MatrixTypeNestedCleaned,Dest>::ret && extract_data(dst) == extract_data(m_matrix))) dst = m_matrix; for(int k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k) @@ -253,6 +258,8 @@ struct ei_transposition_matrix_product_retval const typename MatrixType::Nested m_matrix; }; +} // end namespace internal + /* Template partial specialization for transposed/inverse transpositions */ template<int SizeAtCompileTime, int MaxSizeAtCompileTime> @@ -269,19 +276,19 @@ class Transpose<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime> > /** \returns the \a matrix with the inverse transpositions applied to the columns. */ template<typename Derived> friend - inline const ei_transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true> + inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true> operator*(const MatrixBase<Derived>& matrix, const Transpose& trt) { - return ei_transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>(trt.m_transpositions, matrix.derived()); + return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>(trt.m_transpositions, matrix.derived()); } /** \returns the \a matrix with the inverse transpositions applied to the rows. */ template<typename Derived> - inline const ei_transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true> + inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true> operator*(const MatrixBase<Derived>& matrix) const { - return ei_transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>(m_transpositions, matrix.derived()); + return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>(m_transpositions, matrix.derived()); } const TranspositionType& nestedTranspositions() const { return m_transpositions; } diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 6e4e5b2cc..dc540f9bc 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -38,18 +38,18 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived> public: enum { - Mode = ei_traits<Derived>::Mode, - CoeffReadCost = ei_traits<Derived>::CoeffReadCost, - RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, - MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime + Mode = internal::traits<Derived>::Mode, + CoeffReadCost = internal::traits<Derived>::CoeffReadCost, + RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime, + ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime, + MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime, + MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime }; - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::traits<Derived>::Index Index; - inline TriangularBase() { ei_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); } + inline TriangularBase() { eigen_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); } inline Index rows() const { return derived().rows(); } inline Index cols() const { return derived().cols(); } @@ -94,8 +94,8 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived> { EIGEN_ONLY_USED_FOR_DEBUG(row); EIGEN_ONLY_USED_FOR_DEBUG(col); - ei_assert(col>=0 && col<cols() && row>=0 && row<rows()); - ei_assert( (Mode==Upper && col>=row) + eigen_assert(col>=0 && col<cols() && row>=0 && row<rows()); + eigen_assert( (Mode==Upper && col>=row) || (Mode==Lower && col<=row) || ((Mode==StrictlyUpper || Mode==UnitUpper) && col>row) || ((Mode==StrictlyLower || Mode==UnitLower) && col<row)); @@ -129,11 +129,12 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived> * * \sa MatrixBase::triangularView() */ +namespace internal { template<typename MatrixType, unsigned int _Mode> -struct ei_traits<TriangularView<MatrixType, _Mode> > : ei_traits<MatrixType> +struct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType> { - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested; typedef MatrixType ExpressionType; enum { Mode = _Mode, @@ -141,6 +142,7 @@ struct ei_traits<TriangularView<MatrixType, _Mode> > : ei_traits<MatrixType> CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; +} template<int Mode, bool LhsIsTriangular, typename Lhs, bool LhsIsVector, @@ -153,22 +155,22 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView public: typedef TriangularBase<TriangularView> Base; - typedef typename ei_traits<TriangularView>::Scalar Scalar; + typedef typename internal::traits<TriangularView>::Scalar Scalar; typedef _MatrixType MatrixType; typedef typename MatrixType::PlainObject DenseMatrixType; protected: typedef typename MatrixType::Nested MatrixTypeNested; - typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested; - typedef typename ei_cleantype<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType; + typedef typename internal::cleantype<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename internal::cleantype<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType; public: using Base::evalToLazy; - typedef typename ei_traits<TriangularView>::StorageKind StorageKind; - typedef typename ei_traits<TriangularView>::Index Index; + typedef typename internal::traits<TriangularView>::StorageKind StorageKind; + typedef typename internal::traits<TriangularView>::Index Index; enum { Mode = _Mode, @@ -179,7 +181,7 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView }; inline TriangularView(const MatrixType& matrix) : m_matrix(matrix) - { ei_assert(ei_are_flags_consistent<Mode>::ret); } + { eigen_assert(internal::are_flags_consistent<Mode>::ret); } inline Index rows() const { return m_matrix.rows(); } inline Index cols() const { return m_matrix.cols(); } @@ -191,9 +193,9 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView /** \sa MatrixBase::operator-=() */ template<typename Other> TriangularView& operator-=(const Other& other) { return *this = m_matrix - other; } /** \sa MatrixBase::operator*=() */ - TriangularView& operator*=(const typename ei_traits<MatrixType>::Scalar& other) { return *this = m_matrix * other; } + TriangularView& operator*=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = m_matrix * other; } /** \sa MatrixBase::operator/=() */ - TriangularView& operator/=(const typename ei_traits<MatrixType>::Scalar& other) { return *this = m_matrix / other; } + TriangularView& operator/=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = m_matrix / other; } /** \sa MatrixBase::fill() */ void fill(const Scalar& value) { setConstant(value); } @@ -292,14 +294,14 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView template<int Side, typename OtherDerived> - typename ei_plain_matrix_type_column_major<OtherDerived>::type + typename internal::plain_matrix_type_column_major<OtherDerived>::type solve(const MatrixBase<OtherDerived>& other) const; template<int Side, typename OtherDerived> void solveInPlace(const MatrixBase<OtherDerived>& other) const; template<typename OtherDerived> - typename ei_plain_matrix_type_column_major<OtherDerived>::type + typename internal::plain_matrix_type_column_major<OtherDerived>::type solve(const MatrixBase<OtherDerived>& other) const { return solve<OnTheLeft>(other); } @@ -349,8 +351,10 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView * Implementation of triangular evaluation/assignment ***************************************************************************/ +namespace internal { + template<typename Derived1, typename Derived2, unsigned int Mode, int UnrollCount, bool ClearOpposite> -struct ei_triangular_assignment_selector +struct triangular_assignment_selector { enum { col = (UnrollCount-1) / Derived1::RowsAtCompileTime, @@ -359,9 +363,9 @@ struct ei_triangular_assignment_selector inline static void run(Derived1 &dst, const Derived2 &src) { - ei_triangular_assignment_selector<Derived1, Derived2, Mode, UnrollCount-1, ClearOpposite>::run(dst, src); + triangular_assignment_selector<Derived1, Derived2, Mode, UnrollCount-1, ClearOpposite>::run(dst, src); - ei_assert( Mode == Upper || Mode == Lower + eigen_assert( Mode == Upper || Mode == Lower || Mode == StrictlyUpper || Mode == StrictlyLower || Mode == UnitUpper || Mode == UnitLower); if((Mode == Upper && row <= col) @@ -383,13 +387,13 @@ struct ei_triangular_assignment_selector // prevent buggy user code from causing an infinite recursion template<typename Derived1, typename Derived2, unsigned int Mode, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, Mode, 0, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, Mode, 0, ClearOpposite> { inline static void run(Derived1 &, const Derived2 &) {} }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, Upper, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, Upper, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -407,7 +411,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, Upper, Dynamic, Cle }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, Lower, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, Lower, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -425,7 +429,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, Lower, Dynamic, Cle }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, StrictlyUpper, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, StrictlyUpper, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -443,7 +447,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, StrictlyUpper, Dyna }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, StrictlyLower, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, StrictlyLower, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -461,7 +465,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, StrictlyLower, Dyna }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, UnitUpper, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, UnitUpper, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -481,7 +485,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, UnitUpper, Dynamic, } }; template<typename Derived1, typename Derived2, bool ClearOpposite> -struct ei_triangular_assignment_selector<Derived1, Derived2, UnitLower, Dynamic, ClearOpposite> +struct triangular_assignment_selector<Derived1, Derived2, UnitLower, Dynamic, ClearOpposite> { typedef typename Derived1::Index Index; inline static void run(Derived1 &dst, const Derived2 &src) @@ -501,6 +505,8 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, UnitLower, Dynamic, } }; +} // end namespace internal + // FIXME should we keep that possibility template<typename MatrixType, unsigned int Mode> template<typename OtherDerived> @@ -509,7 +515,7 @@ TriangularView<MatrixType, Mode>::operator=(const MatrixBase<OtherDerived>& othe { if(OtherDerived::Flags & EvalBeforeAssigningBit) { - typename ei_plain_matrix_type<OtherDerived>::type other_evaluated(other.rows(), other.cols()); + typename internal::plain_matrix_type<OtherDerived>::type other_evaluated(other.rows(), other.cols()); other_evaluated.template triangularView<Mode>().lazyAssign(other.derived()); lazyAssign(other_evaluated); } @@ -525,12 +531,12 @@ void TriangularView<MatrixType, Mode>::lazyAssign(const MatrixBase<OtherDerived> { enum { unroll = MatrixType::SizeAtCompileTime != Dynamic - && ei_traits<OtherDerived>::CoeffReadCost != Dynamic - && MatrixType::SizeAtCompileTime*ei_traits<OtherDerived>::CoeffReadCost/2 <= EIGEN_UNROLLING_LIMIT + && internal::traits<OtherDerived>::CoeffReadCost != Dynamic + && MatrixType::SizeAtCompileTime*internal::traits<OtherDerived>::CoeffReadCost/2 <= EIGEN_UNROLLING_LIMIT }; - ei_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols()); + eigen_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols()); - ei_triangular_assignment_selector + internal::triangular_assignment_selector <MatrixType, OtherDerived, int(Mode), unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic, false // do not change the opposite triangular part @@ -544,8 +550,8 @@ template<typename OtherDerived> inline TriangularView<MatrixType, Mode>& TriangularView<MatrixType, Mode>::operator=(const TriangularBase<OtherDerived>& other) { - ei_assert(Mode == int(OtherDerived::Mode)); - if(ei_traits<OtherDerived>::Flags & EvalBeforeAssigningBit) + eigen_assert(Mode == int(OtherDerived::Mode)); + if(internal::traits<OtherDerived>::Flags & EvalBeforeAssigningBit) { typename OtherDerived::DenseMatrixType other_evaluated(other.rows(), other.cols()); other_evaluated.template triangularView<Mode>().lazyAssign(other.derived().nestedExpression()); @@ -562,13 +568,13 @@ void TriangularView<MatrixType, Mode>::lazyAssign(const TriangularBase<OtherDeri { enum { unroll = MatrixType::SizeAtCompileTime != Dynamic - && ei_traits<OtherDerived>::CoeffReadCost != Dynamic - && MatrixType::SizeAtCompileTime * ei_traits<OtherDerived>::CoeffReadCost / 2 + && internal::traits<OtherDerived>::CoeffReadCost != Dynamic + && MatrixType::SizeAtCompileTime * internal::traits<OtherDerived>::CoeffReadCost / 2 <= EIGEN_UNROLLING_LIMIT }; - ei_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols()); + eigen_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols()); - ei_triangular_assignment_selector + internal::triangular_assignment_selector <MatrixType, OtherDerived, int(Mode), unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic, false // preserve the opposite triangular part @@ -585,9 +591,9 @@ template<typename Derived> template<typename DenseDerived> void TriangularBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const { - if(ei_traits<Derived>::Flags & EvalBeforeAssigningBit) + if(internal::traits<Derived>::Flags & EvalBeforeAssigningBit) { - typename ei_plain_matrix_type<Derived>::type other_evaluated(rows(), cols()); + typename internal::plain_matrix_type<Derived>::type other_evaluated(rows(), cols()); evalToLazy(other_evaluated); other.derived().swap(other_evaluated); } @@ -603,14 +609,14 @@ void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const { enum { unroll = DenseDerived::SizeAtCompileTime != Dynamic - && ei_traits<Derived>::CoeffReadCost != Dynamic - && DenseDerived::SizeAtCompileTime * ei_traits<Derived>::CoeffReadCost / 2 + && internal::traits<Derived>::CoeffReadCost != Dynamic + && DenseDerived::SizeAtCompileTime * internal::traits<Derived>::CoeffReadCost / 2 <= EIGEN_UNROLLING_LIMIT }; - ei_assert(this->rows() == other.rows() && this->cols() == other.cols()); + eigen_assert(this->rows() == other.rows() && this->cols() == other.cols()); - ei_triangular_assignment_selector - <DenseDerived, typename ei_traits<Derived>::ExpressionType, Derived::Mode, + internal::triangular_assignment_selector + <DenseDerived, typename internal::traits<Derived>::ExpressionType, Derived::Mode, unroll ? int(DenseDerived::SizeAtCompileTime) : Dynamic, true // clear the opposite triangular part >::run(other.derived(), derived().nestedExpression()); @@ -680,14 +686,14 @@ bool MatrixBase<Derived>::isUpperTriangular(RealScalar prec) const Index maxi = std::min(j, rows()-1); for(Index i = 0; i <= maxi; ++i) { - RealScalar absValue = ei_abs(coeff(i,j)); + RealScalar absValue = internal::abs(coeff(i,j)); if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue; } } RealScalar threshold = maxAbsOnUpperPart * prec; for(Index j = 0; j < cols(); ++j) for(Index i = j+1; i < rows(); ++i) - if(ei_abs(coeff(i, j)) > threshold) return false; + if(internal::abs(coeff(i, j)) > threshold) return false; return true; } @@ -703,7 +709,7 @@ bool MatrixBase<Derived>::isLowerTriangular(RealScalar prec) const for(Index j = 0; j < cols(); ++j) for(Index i = j; i < rows(); ++i) { - RealScalar absValue = ei_abs(coeff(i,j)); + RealScalar absValue = internal::abs(coeff(i,j)); if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue; } RealScalar threshold = maxAbsOnLowerPart * prec; @@ -711,7 +717,7 @@ bool MatrixBase<Derived>::isLowerTriangular(RealScalar prec) const { Index maxi = std::min(j, rows()-1); for(Index i = 0; i < maxi; ++i) - if(ei_abs(coeff(i, j)) > threshold) return false; + if(internal::abs(coeff(i, j)) > threshold) return false; } return true; } diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h index 84040bca1..912277633 100644 --- a/Eigen/src/Core/VectorBlock.h +++ b/Eigen/src/Core/VectorBlock.h @@ -56,24 +56,27 @@ * * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index) */ + +namespace internal { template<typename VectorType, int Size> -struct ei_traits<VectorBlock<VectorType, Size> > - : public ei_traits<Block<VectorType, - ei_traits<VectorType>::Flags & RowMajorBit ? 1 : Size, - ei_traits<VectorType>::Flags & RowMajorBit ? Size : 1> > +struct traits<VectorBlock<VectorType, Size> > + : public traits<Block<VectorType, + traits<VectorType>::Flags & RowMajorBit ? 1 : Size, + traits<VectorType>::Flags & RowMajorBit ? Size : 1> > { }; +} template<typename VectorType, int Size> class VectorBlock : public Block<VectorType, - ei_traits<VectorType>::Flags & RowMajorBit ? 1 : Size, - ei_traits<VectorType>::Flags & RowMajorBit ? Size : 1> + internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size, + internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> { typedef Block<VectorType, - ei_traits<VectorType>::Flags & RowMajorBit ? 1 : Size, - ei_traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base; + internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size, + internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base; enum { - IsColVector = !(ei_traits<VectorType>::Flags & RowMajorBit) + IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit) }; public: EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock) diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h index 7f7ab842e..4c794d5b5 100644 --- a/Eigen/src/Core/VectorwiseOp.h +++ b/Eigen/src/Core/VectorwiseOp.h @@ -45,16 +45,17 @@ template< typename MatrixType, typename MemberOp, int Direction> class PartialReduxExpr; +namespace internal { template<typename MatrixType, typename MemberOp, int Direction> -struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > - : ei_traits<MatrixType> +struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > + : traits<MatrixType> { typedef typename MemberOp::result_type Scalar; - typedef typename ei_traits<MatrixType>::StorageKind StorageKind; - typedef typename ei_traits<MatrixType>::XprKind XprKind; + typedef typename traits<MatrixType>::StorageKind StorageKind; + typedef typename traits<MatrixType>::XprKind XprKind; typedef typename MatrixType::Scalar InputScalar; - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested; + typedef typename nested<MatrixType>::type MatrixTypeNested; + typedef typename cleantype<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, @@ -70,20 +71,21 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > typedef typename MemberOp::template Cost<InputScalar,TraversalSize> CostOpType; #endif enum { - CoeffReadCost = TraversalSize * ei_traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value) + CoeffReadCost = TraversalSize * traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value) }; }; +} template< typename MatrixType, typename MemberOp, int Direction> -class PartialReduxExpr : ei_no_assignment_operator, - public ei_dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type +class PartialReduxExpr : internal::no_assignment_operator, + public internal::dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type { public: - typedef typename ei_dense_xpr_base<PartialReduxExpr>::type Base; + typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr) - typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested; - typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested; + typedef typename internal::traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested; + typedef typename internal::traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested; PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp()) : m_matrix(mat), m_functor(func) {} @@ -114,8 +116,8 @@ class PartialReduxExpr : ei_no_assignment_operator, #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \ template <typename ResultType> \ - struct ei_member_##MEMBER { \ - EIGEN_EMPTY_STRUCT_CTOR(ei_member_##MEMBER) \ + struct member_##MEMBER { \ + EIGEN_EMPTY_STRUCT_CTOR(member_##MEMBER) \ typedef ResultType result_type; \ template<typename Scalar, int Size> struct Cost \ { enum { value = COST }; }; \ @@ -124,11 +126,13 @@ class PartialReduxExpr : ei_no_assignment_operator, { return mat.MEMBER(); } \ } +namespace internal { + EIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost); EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost); EIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost); EIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost); -EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * ei_functor_traits<ei_scalar_hypot_op<Scalar> >::Cost ); +EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * functor_traits<scalar_hypot_op<Scalar> >::Cost ); EIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost); EIGEN_MEMBER_FUNCTOR(mean, (Size-1)*NumTraits<Scalar>::AddCost + NumTraits<Scalar>::MulCost); EIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost); @@ -139,20 +143,20 @@ EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost); EIGEN_MEMBER_FUNCTOR(prod, (Size-1)*NumTraits<Scalar>::MulCost); -/** \internal */ template <typename BinaryOp, typename Scalar> -struct ei_member_redux { - typedef typename ei_result_of< +struct member_redux { + typedef typename result_of< BinaryOp(Scalar) >::type result_type; template<typename _Scalar, int Size> struct Cost - { enum { value = (Size-1) * ei_functor_traits<BinaryOp>::Cost }; }; - ei_member_redux(const BinaryOp func) : m_functor(func) {} + { enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; }; + member_redux(const BinaryOp func) : m_functor(func) {} template<typename Derived> inline result_type operator()(const DenseBase<Derived>& mat) const { return mat.redux(m_functor); } const BinaryOp m_functor; }; +} /** \class VectorwiseOp * \ingroup Core_Module @@ -178,11 +182,11 @@ template<typename ExpressionType, int Direction> class VectorwiseOp typedef typename ExpressionType::Scalar Scalar; typedef typename ExpressionType::RealScalar RealScalar; typedef typename ExpressionType::Index Index; - typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret, + typedef typename internal::meta_if<internal::must_nest_by_value<ExpressionType>::ret, ExpressionType, const ExpressionType&>::ret ExpressionTypeNested; template<template<typename _Scalar> class Functor, - typename Scalar=typename ei_traits<ExpressionType>::Scalar> struct ReturnType + typename Scalar=typename internal::traits<ExpressionType>::Scalar> struct ReturnType { typedef PartialReduxExpr<ExpressionType, Functor<Scalar>, @@ -193,7 +197,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp template<typename BinaryOp> struct ReduxReturnType { typedef PartialReduxExpr<ExpressionType, - ei_member_redux<BinaryOp,typename ei_traits<ExpressionType>::Scalar>, + internal::member_redux<BinaryOp,typename internal::traits<ExpressionType>::Scalar>, Direction > Type; }; @@ -207,7 +211,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp /** \internal * \returns the i-th subvector according to the \c Direction */ - typedef typename ei_meta_if<Direction==Vertical, + typedef typename internal::meta_if<Direction==Vertical, typename ExpressionType::ColXpr, typename ExpressionType::RowXpr>::ret SubVector; SubVector subVector(Index i) @@ -265,7 +269,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_minCoeff.out * * \sa DenseBase::minCoeff() */ - const typename ReturnType<ei_member_minCoeff>::Type minCoeff() const + const typename ReturnType<internal::member_minCoeff>::Type minCoeff() const { return _expression(); } /** \returns a row (or column) vector expression of the largest coefficient @@ -275,7 +279,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_maxCoeff.out * * \sa DenseBase::maxCoeff() */ - const typename ReturnType<ei_member_maxCoeff>::Type maxCoeff() const + const typename ReturnType<internal::member_maxCoeff>::Type maxCoeff() const { return _expression(); } /** \returns a row (or column) vector expression of the squared norm @@ -285,7 +289,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_squaredNorm.out * * \sa DenseBase::squaredNorm() */ - const typename ReturnType<ei_member_squaredNorm,RealScalar>::Type squaredNorm() const + const typename ReturnType<internal::member_squaredNorm,RealScalar>::Type squaredNorm() const { return _expression(); } /** \returns a row (or column) vector expression of the norm @@ -295,7 +299,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_norm.out * * \sa DenseBase::norm() */ - const typename ReturnType<ei_member_norm,RealScalar>::Type norm() const + const typename ReturnType<internal::member_norm,RealScalar>::Type norm() const { return _expression(); } @@ -304,7 +308,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * blue's algorithm. * * \sa DenseBase::blueNorm() */ - const typename ReturnType<ei_member_blueNorm,RealScalar>::Type blueNorm() const + const typename ReturnType<internal::member_blueNorm,RealScalar>::Type blueNorm() const { return _expression(); } @@ -313,7 +317,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * underflow and overflow. * * \sa DenseBase::stableNorm() */ - const typename ReturnType<ei_member_stableNorm,RealScalar>::Type stableNorm() const + const typename ReturnType<internal::member_stableNorm,RealScalar>::Type stableNorm() const { return _expression(); } @@ -322,7 +326,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * underflow and overflow using a concatenation of hypot() calls. * * \sa DenseBase::hypotNorm() */ - const typename ReturnType<ei_member_hypotNorm,RealScalar>::Type hypotNorm() const + const typename ReturnType<internal::member_hypotNorm,RealScalar>::Type hypotNorm() const { return _expression(); } /** \returns a row (or column) vector expression of the sum @@ -332,28 +336,28 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_sum.out * * \sa DenseBase::sum() */ - const typename ReturnType<ei_member_sum>::Type sum() const + const typename ReturnType<internal::member_sum>::Type sum() const { return _expression(); } /** \returns a row (or column) vector expression of the mean * of each column (or row) of the referenced expression. * * \sa DenseBase::mean() */ - const typename ReturnType<ei_member_mean>::Type mean() const + const typename ReturnType<internal::member_mean>::Type mean() const { return _expression(); } /** \returns a row (or column) vector expression representing * whether \b all coefficients of each respective column (or row) are \c true. * * \sa DenseBase::all() */ - const typename ReturnType<ei_member_all>::Type all() const + const typename ReturnType<internal::member_all>::Type all() const { return _expression(); } /** \returns a row (or column) vector expression representing * whether \b at \b least one coefficient of each respective column (or row) is \c true. * * \sa DenseBase::any() */ - const typename ReturnType<ei_member_any>::Type any() const + const typename ReturnType<internal::member_any>::Type any() const { return _expression(); } /** \returns a row (or column) vector expression representing @@ -363,7 +367,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_count.out * * \sa DenseBase::count() */ - const PartialReduxExpr<ExpressionType, ei_member_count<Index>, Direction> count() const + const PartialReduxExpr<ExpressionType, internal::member_count<Index>, Direction> count() const { return _expression(); } /** \returns a row (or column) vector expression of the product @@ -373,7 +377,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * Output: \verbinclude PartialRedux_prod.out * * \sa DenseBase::prod() */ - const typename ReturnType<ei_member_prod>::Type prod() const + const typename ReturnType<internal::member_prod>::Type prod() const { return _expression(); } @@ -413,7 +417,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp ExpressionType& operator=(const DenseBase<OtherDerived>& other) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) - //ei_assert((m_matrix.isNull()) == (other.isNull())); FIXME + //eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME for(Index j=0; j<subVectors(); ++j) subVector(j) = other; return const_cast<ExpressionType&>(m_matrix); @@ -441,7 +445,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp /** Returns the expression of the sum of the vector \a other to each subvector of \c *this */ template<typename OtherDerived> EIGEN_STRONG_INLINE - CwiseBinaryOp<ei_scalar_sum_op<Scalar>, + CwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, typename ExtendedType<OtherDerived>::Type> operator+(const DenseBase<OtherDerived>& other) const @@ -452,7 +456,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp /** Returns the expression of the difference between each subvector of \c *this and the vector \a other */ template<typename OtherDerived> - CwiseBinaryOp<ei_scalar_difference_op<Scalar>, + CwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, typename ExtendedType<OtherDerived>::Type> operator-(const DenseBase<OtherDerived>& other) const @@ -470,21 +474,21 @@ template<typename ExpressionType, int Direction> class VectorwiseOp const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const; enum { - HNormalized_Size = Direction==Vertical ? ei_traits<ExpressionType>::RowsAtCompileTime - : ei_traits<ExpressionType>::ColsAtCompileTime, + HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime + : internal::traits<ExpressionType>::ColsAtCompileTime, HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1 }; typedef Block<ExpressionType, Direction==Vertical ? int(HNormalized_SizeMinusOne) - : int(ei_traits<ExpressionType>::RowsAtCompileTime), + : int(internal::traits<ExpressionType>::RowsAtCompileTime), Direction==Horizontal ? int(HNormalized_SizeMinusOne) - : int(ei_traits<ExpressionType>::ColsAtCompileTime)> + : int(internal::traits<ExpressionType>::ColsAtCompileTime)> HNormalized_Block; typedef Block<ExpressionType, - Direction==Vertical ? 1 : int(ei_traits<ExpressionType>::RowsAtCompileTime), - Direction==Horizontal ? 1 : int(ei_traits<ExpressionType>::ColsAtCompileTime)> + Direction==Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime), + Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)> HNormalized_Factors; - typedef CwiseBinaryOp<ei_scalar_quotient_op<typename ei_traits<ExpressionType>::Scalar>, + typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>, HNormalized_Block, Replicate<HNormalized_Factors, Direction==Vertical ? HNormalized_SizeMinusOne : 1, diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index db6fac4b1..6b3b3bfb4 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -25,8 +25,10 @@ #ifndef EIGEN_VISITOR_H #define EIGEN_VISITOR_H +namespace internal { + template<typename Visitor, typename Derived, int UnrollCount> -struct ei_visitor_impl +struct visitor_impl { enum { col = (UnrollCount-1) / Derived::RowsAtCompileTime, @@ -35,13 +37,13 @@ struct ei_visitor_impl inline static void run(const Derived &mat, Visitor& visitor) { - ei_visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor); + visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor); visitor(mat.coeff(row, col), row, col); } }; template<typename Visitor, typename Derived> -struct ei_visitor_impl<Visitor, Derived, 1> +struct visitor_impl<Visitor, Derived, 1> { inline static void run(const Derived &mat, Visitor& visitor) { @@ -50,7 +52,7 @@ struct ei_visitor_impl<Visitor, Derived, 1> }; template<typename Visitor, typename Derived> -struct ei_visitor_impl<Visitor, Derived, Dynamic> +struct visitor_impl<Visitor, Derived, Dynamic> { typedef typename Derived::Index Index; inline static void run(const Derived& mat, Visitor& visitor) @@ -64,6 +66,7 @@ struct ei_visitor_impl<Visitor, Derived, Dynamic> } }; +} // end namespace internal /** Applies the visitor \a visitor to the whole coefficients of the matrix or vector. * @@ -88,19 +91,21 @@ void DenseBase<Derived>::visit(Visitor& visitor) const { enum { unroll = SizeAtCompileTime != Dynamic && CoeffReadCost != Dynamic - && (SizeAtCompileTime == 1 || ei_functor_traits<Visitor>::Cost != Dynamic) - && SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * ei_functor_traits<Visitor>::Cost + && (SizeAtCompileTime == 1 || internal::functor_traits<Visitor>::Cost != Dynamic) + && SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits<Visitor>::Cost <= EIGEN_UNROLLING_LIMIT }; - return ei_visitor_impl<Visitor, Derived, + return internal::visitor_impl<Visitor, Derived, unroll ? int(SizeAtCompileTime) : Dynamic >::run(derived(), visitor); } +namespace internal { + /** \internal * \brief Base class to implement min and max visitors */ template <typename Derived> -struct ei_coeff_visitor +struct coeff_visitor { typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; @@ -120,7 +125,7 @@ struct ei_coeff_visitor * \sa DenseBase::minCoeff(Index*, Index*) */ template <typename Derived> -struct ei_min_coeff_visitor : ei_coeff_visitor<Derived> +struct min_coeff_visitor : coeff_visitor<Derived> { typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; @@ -136,7 +141,7 @@ struct ei_min_coeff_visitor : ei_coeff_visitor<Derived> }; template<typename Scalar> -struct ei_functor_traits<ei_min_coeff_visitor<Scalar> > { +struct functor_traits<min_coeff_visitor<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost }; @@ -148,7 +153,7 @@ struct ei_functor_traits<ei_min_coeff_visitor<Scalar> > { * \sa DenseBase::maxCoeff(Index*, Index*) */ template <typename Derived> -struct ei_max_coeff_visitor : ei_coeff_visitor<Derived> +struct max_coeff_visitor : coeff_visitor<Derived> { typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; @@ -164,22 +169,24 @@ struct ei_max_coeff_visitor : ei_coeff_visitor<Derived> }; template<typename Scalar> -struct ei_functor_traits<ei_max_coeff_visitor<Scalar> > { +struct functor_traits<max_coeff_visitor<Scalar> > { enum { Cost = NumTraits<Scalar>::AddCost }; }; +} // end namespace internal + /** \returns the minimum of all coefficients of *this * and puts in *row and *col its location. * * \sa DenseBase::minCoeff(Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::minCoeff() */ template<typename Derived> -typename ei_traits<Derived>::Scalar +typename internal::traits<Derived>::Scalar DenseBase<Derived>::minCoeff(Index* row, Index* col) const { - ei_min_coeff_visitor<Derived> minVisitor; + internal::min_coeff_visitor<Derived> minVisitor; this->visit(minVisitor); *row = minVisitor.row; if (col) *col = minVisitor.col; @@ -192,11 +199,11 @@ DenseBase<Derived>::minCoeff(Index* row, Index* col) const * \sa DenseBase::minCoeff(Index*,Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::minCoeff() */ template<typename Derived> -typename ei_traits<Derived>::Scalar +typename internal::traits<Derived>::Scalar DenseBase<Derived>::minCoeff(Index* index) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - ei_min_coeff_visitor<Derived> minVisitor; + internal::min_coeff_visitor<Derived> minVisitor; this->visit(minVisitor); *index = (RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row; return minVisitor.res; @@ -208,10 +215,10 @@ DenseBase<Derived>::minCoeff(Index* index) const * \sa DenseBase::minCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::maxCoeff() */ template<typename Derived> -typename ei_traits<Derived>::Scalar +typename internal::traits<Derived>::Scalar DenseBase<Derived>::maxCoeff(Index* row, Index* col) const { - ei_max_coeff_visitor<Derived> maxVisitor; + internal::max_coeff_visitor<Derived> maxVisitor; this->visit(maxVisitor); *row = maxVisitor.row; if (col) *col = maxVisitor.col; @@ -224,11 +231,11 @@ DenseBase<Derived>::maxCoeff(Index* row, Index* col) const * \sa DenseBase::maxCoeff(Index*,Index*), DenseBase::minCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::maxCoeff() */ template<typename Derived> -typename ei_traits<Derived>::Scalar +typename internal::traits<Derived>::Scalar DenseBase<Derived>::maxCoeff(Index* index) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - ei_max_coeff_visitor<Derived> maxVisitor; + internal::max_coeff_visitor<Derived> maxVisitor; this->visit(maxVisitor); *index = (RowsAtCompileTime==1) ? maxVisitor.col : maxVisitor.row; return maxVisitor.res; diff --git a/Eigen/src/Core/arch/AltiVec/Complex.h b/Eigen/src/Core/arch/AltiVec/Complex.h index ecada02f4..cf5ed512a 100644 --- a/Eigen/src/Core/arch/AltiVec/Complex.h +++ b/Eigen/src/Core/arch/AltiVec/Complex.h @@ -25,13 +25,15 @@ #ifndef EIGEN_COMPLEX_ALTIVEC_H #define EIGEN_COMPLEX_ALTIVEC_H -static Packet4ui ei_p4ui_CONJ_XOR = vec_mergeh((Packet4ui)ei_p4i_ZERO, (Packet4ui)ei_p4f_ZERO_);//{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 }; -static Packet16uc ei_p16uc_COMPLEX_RE = vec_sld((Packet16uc) vec_splat((Packet4ui)ei_p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)ei_p16uc_FORWARD, 2), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 }; -static Packet16uc ei_p16uc_COMPLEX_IM = vec_sld((Packet16uc) vec_splat((Packet4ui)ei_p16uc_FORWARD, 1), (Packet16uc) vec_splat((Packet4ui)ei_p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 }; -static Packet16uc ei_p16uc_COMPLEX_REV = vec_sld(ei_p16uc_REVERSE, ei_p16uc_REVERSE, 8);//{ 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11 }; -static Packet16uc ei_p16uc_COMPLEX_REV2 = vec_sld(ei_p16uc_FORWARD, ei_p16uc_FORWARD, 8);//{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 }; -static Packet16uc ei_p16uc_PSET_HI = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)ei_p16uc_FORWARD, 0), (Packet4ui) vec_splat((Packet4ui)ei_p16uc_FORWARD, 1));//{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 }; -static Packet16uc ei_p16uc_PSET_LO = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)ei_p16uc_FORWARD, 2), (Packet4ui) vec_splat((Packet4ui)ei_p16uc_FORWARD, 3));//{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 }; +namespace internal { + +static Packet4ui p4ui_CONJ_XOR = vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_ZERO_);//{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 }; +static Packet16uc p16uc_COMPLEX_RE = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 2), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 }; +static Packet16uc p16uc_COMPLEX_IM = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 1), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 }; +static Packet16uc p16uc_COMPLEX_REV = vec_sld(p16uc_REVERSE, p16uc_REVERSE, 8);//{ 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11 }; +static Packet16uc p16uc_COMPLEX_REV2 = vec_sld(p16uc_FORWARD, p16uc_FORWARD, 8);//{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 }; +static Packet16uc p16uc_PSET_HI = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 1));//{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 }; +static Packet16uc p16uc_PSET_LO = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 2), (Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 3));//{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 }; //---------- float ---------- struct Packet2cf @@ -41,7 +43,7 @@ struct Packet2cf Packet4f v; }; -template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_traits +template<> struct packet_traits<std::complex<float> > : default_packet_traits { typedef Packet2cf type; enum { @@ -61,106 +63,106 @@ template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_tr }; }; -template<> struct ei_unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; +template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_pset1<Packet2cf>(const std::complex<float>& from) +template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from) { Packet2cf res; /* On AltiVec we cannot load 64-bit registers, so wa have to take care of alignment */ if ((ptrdiff_t)&from % 16 == 0) { - res.v = ei_pload((const float *)&from); - res.v = vec_perm(res.v, res.v, ei_p16uc_PSET_HI); + res.v = pload((const float *)&from); + res.v = vec_perm(res.v, res.v, p16uc_PSET_HI); } else { - res.v = ei_ploadu((const float *)&from); - res.v = vec_perm(res.v, res.v, ei_p16uc_PSET_LO); + res.v = ploadu((const float *)&from); + res.v = vec_perm(res.v, res.v, p16uc_PSET_LO); } return res; } -template<> EIGEN_STRONG_INLINE Packet2cf ei_padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_add(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_sub(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pnegate(const Packet2cf& a) { return Packet2cf(ei_psub<Packet4f>(ei_p4f_ZERO, a.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pconj(const Packet2cf& a) { return Packet2cf((Packet4f)vec_xor((Packet4ui)a.v, ei_p4ui_CONJ_XOR)); } +template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_add(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_sub(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(psub<Packet4f>(p4f_ZERO, a.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a) { return Packet2cf((Packet4f)vec_xor((Packet4ui)a.v, p4ui_CONJ_XOR)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { Packet4f v1, v2; // Permute and multiply the real parts of a and b - v1 = vec_perm(a.v, a.v, ei_p16uc_COMPLEX_RE); + v1 = vec_perm(a.v, a.v, p16uc_COMPLEX_RE); // Get the imaginary parts of a - v2 = vec_perm(a.v, a.v, ei_p16uc_COMPLEX_IM); + v2 = vec_perm(a.v, a.v, p16uc_COMPLEX_IM); // multiply a_re * b - v1 = vec_madd(v1, b.v, ei_p4f_ZERO); + v1 = vec_madd(v1, b.v, p4f_ZERO); // multiply a_im * b and get the conjugate result - v2 = vec_madd(v2, b.v, ei_p4f_ZERO); - v2 = (Packet4f) vec_xor((Packet4ui)v2, ei_p4ui_CONJ_XOR); + v2 = vec_madd(v2, b.v, p4f_ZERO); + v2 = (Packet4f) vec_xor((Packet4ui)v2, p4ui_CONJ_XOR); // permute back to a proper order - v2 = vec_perm(v2, v2, ei_p16uc_COMPLEX_REV); + v2 = vec_perm(v2, v2, p16uc_COMPLEX_REV); return Packet2cf(vec_add(v1, v2)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_and(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_or(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_xor(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_and(a.v, vec_nor(b.v,b.v))); } +template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_and(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_or(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_xor(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vec_and(a.v, vec_nor(b.v,b.v))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pload <std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(ei_pload((const float*)from)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_ploadu<std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ei_ploadu((const float*)from)); } +template<> EIGEN_STRONG_INLINE Packet2cf pload <std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload((const float*)from)); } +template<> EIGEN_STRONG_INLINE Packet2cf ploadu<std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu((const float*)from)); } -template<> EIGEN_STRONG_INLINE void ei_pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE ei_pstore((float*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((float*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<std::complex<float> >(const std::complex<float> * addr) { vec_dstt((float *)addr, DST_CTRL(2,2,32), DST_CHAN); } +template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { vec_dstt((float *)addr, DST_CTRL(2,2,32), DST_CHAN); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_pfirst<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a) { std::complex<float> EIGEN_ALIGN16 res[2]; - ei_pstore((float *)&res, a.v); + pstore((float *)&res, a.v); return res[0]; } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preverse(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { Packet4f rev_a; - rev_a = vec_perm(a.v, a.v, ei_p16uc_COMPLEX_REV2); + rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX_REV2); return Packet2cf(rev_a); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a) { Packet4f b; b = (Packet4f) vec_sld(a.v, a.v, 8); - b = ei_padd(a.v, b); - return ei_pfirst(Packet2cf(sum)); + b = padd(a.v, b); + return pfirst(Packet2cf(sum)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preduxp<Packet2cf>(const Packet2cf* vecs) +template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs) { Packet4f b1, b2; b1 = (Packet4f) vec_sld(vecs[0].v, vecs[1].v, 8); b2 = (Packet4f) vec_sld(vecs[1].v, vecs[0].v, 8); b2 = (Packet4f) vec_sld(b2, b2, 8); - b2 = ei_padd(b1, b2); + b2 = padd(b1, b2); return Packet2cf(b2); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux_mul<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a) { Packet4f b; Packet2cf prod; b = (Packet4f) vec_sld(a.v, a.v, 8); - prod = ei_pmul(a, Packet2cf(b)); + prod = pmul(a, Packet2cf(b)); - return ei_pfirst(prod); + return pfirst(prod); } template<int Offset> -struct ei_palign_impl<Offset,Packet2cf> +struct palign_impl<Offset,Packet2cf> { EIGEN_STRONG_INLINE static void run(Packet2cf& first, const Packet2cf& second) { @@ -171,45 +173,47 @@ struct ei_palign_impl<Offset,Packet2cf> } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, false,true> +template<> struct conj_helper<Packet2cf, Packet2cf, false,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pmul(a, ei_pconj(b)); + return pmul(a, pconj(b)); } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,false> +template<> struct conj_helper<Packet2cf, Packet2cf, true,false> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pmul(ei_pconj(a), b); + return pmul(pconj(a), b); } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,true> +template<> struct conj_helper<Packet2cf, Packet2cf, true,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pconj(ei_pmul(a, b)); + return pconj(pmul(a, b)); } }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { // TODO optimize it for AltiVec - Packet2cf res = ei_conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); - Packet4f s = vec_madd(b.v, b.v, ei_p4f_ZERO); - return Packet2cf(ei_pdiv(res.v, vec_add(s,vec_perm(s, s, ei_p16uc_COMPLEX_REV)))); + Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); + Packet4f s = vec_madd(b.v, b.v, p4f_ZERO); + return Packet2cf(pdiv(res.v, vec_add(s,vec_perm(s, s, p16uc_COMPLEX_REV)))); } +} // end namespace internal + #endif // EIGEN_COMPLEX_ALTIVEC_H diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h index 8205beae5..88a8e3669 100644 --- a/Eigen/src/Core/arch/AltiVec/PacketMath.h +++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h @@ -25,6 +25,8 @@ #ifndef EIGEN_PACKET_MATH_ALTIVEC_H #define EIGEN_PACKET_MATH_ALTIVEC_H +namespace internal { + #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4 #endif @@ -53,38 +55,38 @@ typedef __vector unsigned char Packet16uc; // and it doesn't really work to declare them global, so we define macros instead #define _EIGEN_DECLARE_CONST_FAST_Packet4f(NAME,X) \ - Packet4f ei_p4f_##NAME = (Packet4f) vec_splat_s32(X) + Packet4f p4f_##NAME = (Packet4f) vec_splat_s32(X) #define _EIGEN_DECLARE_CONST_FAST_Packet4i(NAME,X) \ - Packet4i ei_p4i_##NAME = vec_splat_s32(X) + Packet4i p4i_##NAME = vec_splat_s32(X) #define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \ - Packet4f ei_p4f_##NAME = ei_pset1<Packet4f>(X) + Packet4f p4f_##NAME = pset1<Packet4f>(X) #define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \ - Packet4f ei_p4f_##NAME = vreinterpretq_f32_u32(ei_pset1<int>(X)) + Packet4f p4f_##NAME = vreinterpretq_f32_u32(pset1<int>(X)) #define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \ - Packet4i ei_p4i_##NAME = ei_pset1<Packet4i>(X) + Packet4i p4i_##NAME = pset1<Packet4i>(X) #define DST_CHAN 1 #define DST_CTRL(size, count, stride) (((size) << 24) | ((count) << 16) | (stride)) // Define global static constants: -static Packet4f ei_p4f_COUNTDOWN = { 3.0, 2.0, 1.0, 0.0 }; -static Packet4i ei_p4i_COUNTDOWN = { 3, 2, 1, 0 }; -static Packet16uc ei_p16uc_REVERSE = {12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3}; -static Packet16uc ei_p16uc_FORWARD = vec_lvsl(0, (float*)0); +static Packet4f p4f_COUNTDOWN = { 3.0, 2.0, 1.0, 0.0 }; +static Packet4i p4i_COUNTDOWN = { 3, 2, 1, 0 }; +static Packet16uc p16uc_REVERSE = {12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3}; +static Packet16uc p16uc_FORWARD = vec_lvsl(0, (float*)0); static _EIGEN_DECLARE_CONST_FAST_Packet4f(ZERO, 0); static _EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0); static _EIGEN_DECLARE_CONST_FAST_Packet4i(ONE,1); static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS16,-16); static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS1,-1); -static Packet4f ei_p4f_ONE = vec_ctf(ei_p4i_ONE, 0); -static Packet4f ei_p4f_ZERO_ = (Packet4f) vec_sl((Packet4ui)ei_p4i_MINUS1, (Packet4ui)ei_p4i_MINUS1); +static Packet4f p4f_ONE = vec_ctf(p4i_ONE, 0); +static Packet4f p4f_ZERO_ = (Packet4f) vec_sl((Packet4ui)p4i_MINUS1, (Packet4ui)p4i_MINUS1); -template<> struct ei_packet_traits<float> : ei_default_packet_traits +template<> struct packet_traits<float> : default_packet_traits { typedef Packet4f type; enum { @@ -100,7 +102,7 @@ template<> struct ei_packet_traits<float> : ei_default_packet_traits HasSqrt = 0 }; }; -template<> struct ei_packet_traits<int> : ei_default_packet_traits +template<> struct packet_traits<int> : default_packet_traits { typedef Packet4i type; enum { @@ -111,8 +113,8 @@ template<> struct ei_packet_traits<int> : ei_default_packet_traits }; }; -template<> struct ei_unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; -template<> struct ei_unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; +template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; +template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; /* inline std::ostream & operator <<(std::ostream & s, const Packet4f & v) { @@ -158,7 +160,7 @@ inline std::ostream & operator <<(std::ostream & s, const Packetbi & v) return s; } */ -template<> EIGEN_STRONG_INLINE Packet4f ei_pset1<Packet4f>(const float& from) { +template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float& from) { // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html float EIGEN_ALIGN16 af[4]; af[0] = from; @@ -167,7 +169,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_pset1<Packet4f>(const float& from) { return vc; } -template<> EIGEN_STRONG_INLINE Packet4i ei_pset1<Packet4i>(const int& from) { +template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int& from) { int EIGEN_ALIGN16 ai[4]; ai[0] = from; Packet4i vc = vec_ld(0, ai); @@ -175,22 +177,22 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_pset1<Packet4i>(const int& from) return vc; } -template<> EIGEN_STRONG_INLINE Packet4f ei_plset<float>(const float& a) { return vec_add(ei_pset1<Packet4f>(a), ei_p4f_COUNTDOWN); } -template<> EIGEN_STRONG_INLINE Packet4i ei_plset<int>(const int& a) { return vec_add(ei_pset1<Packet4i>(a), ei_p4i_COUNTDOWN); } +template<> EIGEN_STRONG_INLINE Packet4f plset<float>(const float& a) { return vec_add(pset1<Packet4f>(a), p4f_COUNTDOWN); } +template<> EIGEN_STRONG_INLINE Packet4i plset<int>(const int& a) { return vec_add(pset1<Packet4i>(a), p4i_COUNTDOWN); } -template<> EIGEN_STRONG_INLINE Packet4f ei_padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_add(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_add(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_add(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_add(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_sub(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_sub(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_sub(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_sub(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pnegate(const Packet4f& a) { return ei_psub<Packet4f>(ei_p4f_ZERO, a); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pnegate(const Packet4i& a) { return ei_psub<Packet4i>(ei_p4i_ZERO, a); } +template<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { return psub<Packet4f>(p4f_ZERO, a); } +template<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return psub<Packet4i>(p4i_ZERO, a); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_madd(a,b,ei_p4f_ZERO); } +template<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_madd(a,b,p4f_ZERO); } /* Commented out: it's actually slower than processing it scalar * -template<> EIGEN_STRONG_INLINE Packet4i ei_pmul<Packet4i>(const Packet4i& a, const Packet4i& b) +template<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { // Detailed in: http://freevec.org/content/32bit_signed_integer_multiplication_altivec //Set up constants, variables @@ -201,21 +203,21 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_pmul<Packet4i>(const Packet4i& a, con b1 = vec_abs(b); // Get the signs using xor - Packet4bi sgn = (Packet4bi) vec_cmplt(vec_xor(a, b), ei_p4i_ZERO); + Packet4bi sgn = (Packet4bi) vec_cmplt(vec_xor(a, b), p4i_ZERO); // Do the multiplication for the asbolute values. - bswap = (Packet4i) vec_rl((Packet4ui) b1, (Packet4ui) ei_p4i_MINUS16 ); + bswap = (Packet4i) vec_rl((Packet4ui) b1, (Packet4ui) p4i_MINUS16 ); low_prod = vec_mulo((Packet8i) a1, (Packet8i)b1); - high_prod = vec_msum((Packet8i) a1, (Packet8i) bswap, ei_p4i_ZERO); - high_prod = (Packet4i) vec_sl((Packet4ui) high_prod, (Packet4ui) ei_p4i_MINUS16); + high_prod = vec_msum((Packet8i) a1, (Packet8i) bswap, p4i_ZERO); + high_prod = (Packet4i) vec_sl((Packet4ui) high_prod, (Packet4ui) p4i_MINUS16); prod = vec_add( low_prod, high_prod ); // NOR the product and select only the negative elements according to the sign mask prod_ = vec_nor(prod, prod); - prod_ = vec_sel(ei_p4i_ZERO, prod_, sgn); + prod_ = vec_sel(p4i_ZERO, prod_, sgn); // Add 1 to the result to get the negative numbers - v1sel = vec_sel(ei_p4i_ZERO, ei_p4i_ONE, sgn); + v1sel = vec_sel(p4i_ZERO, p4i_ONE, sgn); prod_ = vec_add(prod_, v1sel); // Merge the results back to the final vector. @@ -224,7 +226,7 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_pmul<Packet4i>(const Packet4i& a, con return prod; } */ -template<> EIGEN_STRONG_INLINE Packet4f ei_pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) { Packet4f t, y_0, y_1, res; @@ -232,45 +234,45 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_pdiv<Packet4f>(const Packet4f& a, con y_0 = vec_re(b); // Do one Newton-Raphson iteration to get the needed accuracy - t = vec_nmsub(y_0, b, ei_p4f_ONE); + t = vec_nmsub(y_0, b, p4f_ONE); y_1 = vec_madd(y_0, t, y_0); - res = vec_madd(a, y_1, ei_p4f_ZERO); + res = vec_madd(a, y_1, p4f_ZERO); return res; } -template<> EIGEN_STRONG_INLINE Packet4i ei_pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) -{ ei_assert(false && "packet integer division are not supported by AltiVec"); - return ei_pset1<Packet4i>(0); +template<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) +{ eigen_assert(false && "packet integer division are not supported by AltiVec"); + return pset1<Packet4i>(0); } // for some weird raisons, it has to be overloaded for packet of integers -template<> EIGEN_STRONG_INLINE Packet4f ei_pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) { return vec_madd(a, b, c); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return ei_padd(ei_pmul(a,b), c); } +template<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) { return vec_madd(a, b, c); } +template<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return padd(pmul(a,b), c); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_min(a, b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_min(a, b); } +template<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_min(a, b); } +template<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_min(a, b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_max(a, b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_max(a, b); } +template<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_max(a, b); } +template<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_max(a, b); } // Logical Operations are not supported for float, so we have to reinterpret casts using NEON intrinsics -template<> EIGEN_STRONG_INLINE Packet4f ei_pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, b); } +template<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, b); } +template<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_por<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_or(a, b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_or(a, b); } +template<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_or(a, b); } +template<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_or(a, b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_xor(a, b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_xor(a, b); } +template<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_xor(a, b); } +template<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_xor(a, b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, vec_nor(b, b)); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, vec_nor(b, b)); } +template<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, vec_nor(b, b)); } +template<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, vec_nor(b, b)); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pload<Packet4f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return vec_ld(0, from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pload<Packet4i>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return vec_ld(0, from); } +template<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return vec_ld(0, from); } +template<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return vec_ld(0, from); } -template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu<Packet4f>(const float* from) +template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html @@ -282,7 +284,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu<Packet4f>(const float* from) return (Packet4f) vec_perm(MSQ, LSQ, mask); // align the data } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<Packet4i>(const int* from) +template<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html @@ -294,10 +296,10 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<Packet4i>(const int* from) return (Packet4i) vec_perm(MSQ, LSQ, mask); // align the data } -template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE vec_st(from, 0, to); } -template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE vec_st(from, 0, to); } +template<> EIGEN_STRONG_INLINE void pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE vec_st(from, 0, to); } +template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE vec_st(from, 0, to); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f& from) +template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html @@ -315,7 +317,7 @@ template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f vec_st( LSQ, 15, (unsigned char *)to ); // Store the LSQ part first vec_st( MSQ, 0, (unsigned char *)to ); // Store the MSQ part } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i& from) +template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html @@ -334,29 +336,29 @@ template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i vec_st( MSQ, 0, (unsigned char *)to ); // Store the MSQ part } -template<> EIGEN_STRONG_INLINE void ei_prefetch<float>(const float* addr) { vec_dstt(addr, DST_CTRL(2,2,32), DST_CHAN); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<int>(const int* addr) { vec_dstt(addr, DST_CTRL(2,2,32), DST_CHAN); } +template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { vec_dstt(addr, DST_CTRL(2,2,32), DST_CHAN); } +template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { vec_dstt(addr, DST_CTRL(2,2,32), DST_CHAN); } -template<> EIGEN_STRONG_INLINE float ei_pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x[4]; vec_st(a, 0, x); return x[0]; } -template<> EIGEN_STRONG_INLINE int ei_pfirst<Packet4i>(const Packet4i& a) { int EIGEN_ALIGN16 x[4]; vec_st(a, 0, x); return x[0]; } +template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x[4]; vec_st(a, 0, x); return x[0]; } +template<> EIGEN_STRONG_INLINE int pfirst<Packet4i>(const Packet4i& a) { int EIGEN_ALIGN16 x[4]; vec_st(a, 0, x); return x[0]; } -template<> EIGEN_STRONG_INLINE Packet4f ei_preverse(const Packet4f& a) { return (Packet4f)vec_perm((Packet16uc)a,(Packet16uc)a, ei_p16uc_REVERSE); } -template<> EIGEN_STRONG_INLINE Packet4i ei_preverse(const Packet4i& a) { return (Packet4i)vec_perm((Packet16uc)a,(Packet16uc)a, ei_p16uc_REVERSE); } +template<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a) { return (Packet4f)vec_perm((Packet16uc)a,(Packet16uc)a, p16uc_REVERSE); } +template<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a) { return (Packet4i)vec_perm((Packet16uc)a,(Packet16uc)a, p16uc_REVERSE); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pabs(const Packet4f& a) { return vec_abs(a); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pabs(const Packet4i& a) { return vec_abs(a); } +template<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a) { return vec_abs(a); } +template<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a) { return vec_abs(a); } -template<> EIGEN_STRONG_INLINE float ei_predux<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a) { Packet4f b, sum; b = (Packet4f) vec_sld(a, a, 8); sum = vec_add(a, b); b = (Packet4f) vec_sld(sum, sum, 4); sum = vec_add(sum, b); - return ei_pfirst(sum); + return pfirst(sum); } -template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vecs) +template<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs) { Packet4f v[4], sum[4]; @@ -384,15 +386,15 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vec return sum[0]; } -template<> EIGEN_STRONG_INLINE int ei_predux<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a) { Packet4i sum; - sum = vec_sums(a, ei_p4i_ZERO); - sum = vec_sld(sum, ei_p4i_ZERO, 12); - return ei_pfirst(sum); + sum = vec_sums(a, p4i_ZERO); + sum = vec_sld(sum, p4i_ZERO, 12); + return pfirst(sum); } -template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vecs) +template<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs) { Packet4i v[4], sum[4]; @@ -422,56 +424,56 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vec // Other reduction functions: // mul -template<> EIGEN_STRONG_INLINE float ei_predux_mul<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a) { Packet4f prod; - prod = ei_pmul(a, (Packet4f)vec_sld(a, a, 8)); - return ei_pfirst(ei_pmul(prod, (Packet4f)vec_sld(prod, prod, 4))); + prod = pmul(a, (Packet4f)vec_sld(a, a, 8)); + return pfirst(pmul(prod, (Packet4f)vec_sld(prod, prod, 4))); } -template<> EIGEN_STRONG_INLINE int ei_predux_mul<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a) { EIGEN_ALIGN16 int aux[4]; - ei_pstore(aux, a); + pstore(aux, a); return aux[0] * aux[1] * aux[2] * aux[3]; } // min -template<> EIGEN_STRONG_INLINE float ei_predux_min<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a) { Packet4f b, res; b = vec_min(a, vec_sld(a, a, 8)); res = vec_min(b, vec_sld(b, b, 4)); - return ei_pfirst(res); + return pfirst(res); } -template<> EIGEN_STRONG_INLINE int ei_predux_min<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a) { Packet4i b, res; b = vec_min(a, vec_sld(a, a, 8)); res = vec_min(b, vec_sld(b, b, 4)); - return ei_pfirst(res); + return pfirst(res); } // max -template<> EIGEN_STRONG_INLINE float ei_predux_max<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a) { Packet4f b, res; b = vec_max(a, vec_sld(a, a, 8)); res = vec_max(b, vec_sld(b, b, 4)); - return ei_pfirst(res); + return pfirst(res); } -template<> EIGEN_STRONG_INLINE int ei_predux_max<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a) { Packet4i b, res; b = vec_max(a, vec_sld(a, a, 8)); res = vec_max(b, vec_sld(b, b, 4)); - return ei_pfirst(res); + return pfirst(res); } template<int Offset> -struct ei_palign_impl<Offset,Packet4f> +struct palign_impl<Offset,Packet4f> { EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second) { @@ -481,7 +483,7 @@ struct ei_palign_impl<Offset,Packet4f> }; template<int Offset> -struct ei_palign_impl<Offset,Packet4i> +struct palign_impl<Offset,Packet4i> { EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second) { @@ -489,4 +491,7 @@ struct ei_palign_impl<Offset,Packet4i> first = vec_sld(first, second, Offset*4); } }; + +} // end namespace internal + #endif // EIGEN_PACKET_MATH_ALTIVEC_H diff --git a/Eigen/src/Core/arch/NEON/Complex.h b/Eigen/src/Core/arch/NEON/Complex.h index 9678040e7..d1943ba3b 100644 --- a/Eigen/src/Core/arch/NEON/Complex.h +++ b/Eigen/src/Core/arch/NEON/Complex.h @@ -22,11 +22,13 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. -#ifndef EIGEN_COMPLEX_ALTIVEC_H -#define EIGEN_COMPLEX_ALTIVEC_H +#ifndef EIGEN_COMPLEX_NEON_H +#define EIGEN_COMPLEX_NEON_H -static uint32x4_t ei_p4ui_CONJ_XOR = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 }; -static uint32x2_t ei_p2ui_CONJ_XOR = { 0x00000000, 0x80000000 }; +namespace internal { + +static uint32x4_t p4ui_CONJ_XOR = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 }; +static uint32x2_t p2ui_CONJ_XOR = { 0x00000000, 0x80000000 }; //---------- float ---------- struct Packet2cf @@ -36,7 +38,7 @@ struct Packet2cf Packet4f v; }; -template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_traits +template<> struct packet_traits<std::complex<float> > : default_packet_traits { typedef Packet2cf type; enum { @@ -56,9 +58,9 @@ template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_tr }; }; -template<> struct ei_unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; +template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_pset1<Packet2cf>(const std::complex<float>& from) +template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from) { float32x2_t r64; r64 = vld1_f32((float *)&from); @@ -66,15 +68,15 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_pset1<Packet2cf>(const std::complex< return Packet2cf(vcombine_f32(r64, r64)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(ei_padd<Packet4f>(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(ei_psub<Packet4f>(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pnegate(const Packet2cf& a) { return Packet2cf(ei_pnegate<Packet4f>(a.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pconj(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(padd<Packet4f>(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(psub<Packet4f>(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(pnegate<Packet4f>(a.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a) { - return Packet2cf(vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a.v), ei_p4ui_CONJ_XOR))); + return Packet2cf(vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a.v), p4ui_CONJ_XOR))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { Packet4f v1, v2; float32x2_t a_lo, a_hi; @@ -88,7 +90,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_pmul<Packet2cf>(const Packet2cf& a, // Multiply the imag a with b v2 = vmulq_f32(v2, b.v); // Conjugate v2 - v2 = vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(v2), ei_p4ui_CONJ_XOR)); + v2 = vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(v2), p4ui_CONJ_XOR)); // Swap real/imag elements in v2. a_lo = vrev64_f32(vget_low_f32(v2)); a_hi = vrev64_f32(vget_high_f32(v2)); @@ -97,39 +99,39 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_pmul<Packet2cf>(const Packet2cf& a, return Packet2cf(vaddq_f32(v1, v2)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v)))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v)))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v)))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v)))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pload <std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(ei_pload((const float*)from)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_ploadu<std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ei_ploadu((const float*)from)); } +template<> EIGEN_STRONG_INLINE Packet2cf pload <std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload((const float*)from)); } +template<> EIGEN_STRONG_INLINE Packet2cf ploadu<std::complex<float> >(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu((const float*)from)); } -template<> EIGEN_STRONG_INLINE void ei_pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE ei_pstore((float*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((float*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<std::complex<float> >(const std::complex<float> * addr) { __pld((float *)addr); } +template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { __pld((float *)addr); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_pfirst<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a) { std::complex<float> EIGEN_ALIGN16 x[2]; vst1q_f32((float *)x, a.v); return x[0]; } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preverse(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { float32x2_t a_lo, a_hi; Packet4f a_r128; @@ -141,12 +143,12 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_preverse(const Packet2cf& a) return Packet2cf(a_r128); } -EIGEN_STRONG_INLINE Packet2cf ei_pcplxflip/*<Packet2cf>*/(const Packet2cf& x) +EIGEN_STRONG_INLINE Packet2cf pcplxflip/*<Packet2cf>*/(const Packet2cf& x) { return Packet2cf(vrev64q_f32(a.v)); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a) { float32x2_t a1, a2; std::complex<float> s; @@ -159,7 +161,7 @@ template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux<Packet2cf>(const Pa return s; } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preduxp<Packet2cf>(const Packet2cf* vecs) +template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs) { Packet4f sum1, sum2, sum; @@ -171,7 +173,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_preduxp<Packet2cf>(const Packet2cf* return Packet2cf(sum); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux_mul<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a) { float32x2_t a1, a2, v1, v2, prod; std::complex<float> s; @@ -187,7 +189,7 @@ template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux_mul<Packet2cf>(cons // Multiply the imag a with b v2 = vmul_f32(v2, a2); // Conjugate v2 - v2 = vreinterpret_f32_u32(veor_u32(vreinterpret_u32_f32(v2), ei_p2ui_CONJ_XOR)); + v2 = vreinterpret_f32_u32(veor_u32(vreinterpret_u32_f32(v2), p2ui_CONJ_XOR)); // Swap real/imag elements in v2. v2 = vrev64_f32(v2); // Add v1, v2 @@ -199,7 +201,7 @@ template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux_mul<Packet2cf>(cons } template<int Offset> -struct ei_palign_impl<Offset,Packet2cf> +struct palign_impl<Offset,Packet2cf> { EIGEN_STRONG_INLINE static void run(Packet2cf& first, const Packet2cf& second) { @@ -210,43 +212,43 @@ struct ei_palign_impl<Offset,Packet2cf> } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, false,true> +template<> struct conj_helper<Packet2cf, Packet2cf, false,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pmul(a, ei_pconj(b)); + return pmul(a, pconj(b)); } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,false> +template<> struct conj_helper<Packet2cf, Packet2cf, true,false> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pmul(ei_pconj(a), b); + return pmul(pconj(a), b); } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,true> +template<> struct conj_helper<Packet2cf, Packet2cf, true,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { - return ei_pconj(ei_pmul(a, b)); + return pconj(pmul(a, b)); } }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { // TODO optimize it for AltiVec - Packet2cf res = ei_conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); + Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); Packet4f s, rev_s; float32x2_t a_lo, a_hi; @@ -256,7 +258,9 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_pdiv<Packet2cf>(const Packet2cf& a, a_hi = vrev64_f32(vget_high_f32(s)); rev_s = vcombine_f32(a_lo, a_hi); - return Packet2cf(ei_pdiv(res.v, vaddq_f32(s,rev_s))); + return Packet2cf(pdiv(res.v, vaddq_f32(s,rev_s))); } -#endif // EIGEN_COMPLEX_ALTIVEC_H +} // end namespace internal + +#endif // EIGEN_COMPLEX_NEON_H diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h index 8220ed07c..cae35d737 100644 --- a/Eigen/src/Core/arch/NEON/PacketMath.h +++ b/Eigen/src/Core/arch/NEON/PacketMath.h @@ -27,6 +27,8 @@ #ifndef EIGEN_PACKET_MATH_NEON_H #define EIGEN_PACKET_MATH_NEON_H +namespace internal { + #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 #endif @@ -45,19 +47,19 @@ typedef float32x4_t Packet4f; typedef int32x4_t Packet4i; #define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \ - const Packet4f ei_p4f_##NAME = ei_pset1<Packet4f>(X) + const Packet4f p4f_##NAME = pset1<Packet4f>(X) #define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \ - const Packet4f ei_p4f_##NAME = vreinterpretq_f32_u32(ei_pset1<int>(X)) + const Packet4f p4f_##NAME = vreinterpretq_f32_u32(pset1<int>(X)) #define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \ - const Packet4i ei_p4i_##NAME = ei_pset1<Packet4i>(X) + const Packet4i p4i_##NAME = pset1<Packet4i>(X) #ifndef __pld #define __pld(x) asm volatile ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" ); #endif -template<> struct ei_packet_traits<float> : ei_default_packet_traits +template<> struct packet_traits<float> : default_packet_traits { typedef Packet4f type; enum { @@ -74,7 +76,7 @@ template<> struct ei_packet_traits<float> : ei_default_packet_traits HasSqrt = 0 }; }; -template<> struct ei_packet_traits<int> : ei_default_packet_traits +template<> struct packet_traits<int> : default_packet_traits { typedef Packet4i type; enum { @@ -85,36 +87,36 @@ template<> struct ei_packet_traits<int> : ei_default_packet_traits }; }; -template<> struct ei_unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; -template<> struct ei_unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; +template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; +template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; -template<> EIGEN_STRONG_INLINE Packet4f ei_pset1<Packet4f>(const float& from) { return vdupq_n_f32(from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pset1<Packet4i>(const int& from) { return vdupq_n_s32(from); } +template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float& from) { return vdupq_n_f32(from); } +template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int& from) { return vdupq_n_s32(from); } -template<> EIGEN_STRONG_INLINE Packet4f ei_plset<float>(const float& a) +template<> EIGEN_STRONG_INLINE Packet4f plset<float>(const float& a) { Packet4f countdown = { 3, 2, 1, 0 }; - return vaddq_f32(ei_pset1<Packet4f>(a), countdown); + return vaddq_f32(pset1<Packet4f>(a), countdown); } -template<> EIGEN_STRONG_INLINE Packet4i ei_plset<int>(const int& a) +template<> EIGEN_STRONG_INLINE Packet4i plset<int>(const int& a) { Packet4i countdown = { 3, 2, 1, 0 }; - return vaddq_s32(ei_pset1<Packet4i>(a), countdown); + return vaddq_s32(pset1<Packet4i>(a), countdown); } -template<> EIGEN_STRONG_INLINE Packet4f ei_padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return vaddq_f32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return vaddq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return vaddq_f32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return vaddq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return vsubq_f32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return vsubq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return vsubq_f32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return vsubq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pnegate(const Packet4f& a) { return vnegq_f32(a); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pnegate(const Packet4i& a) { return vnegq_s32(a); } +template<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { return vnegq_f32(a); } +template<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return vnegq_s32(a); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmulq_f32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmulq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmulq_f32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmulq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) { Packet4f inv, restep, div; @@ -135,59 +137,59 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_pdiv<Packet4f>(const Packet4f& a, con return div; } -template<> EIGEN_STRONG_INLINE Packet4i ei_pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) -{ ei_assert(false && "packet integer division are not supported by NEON"); - return ei_pset1<Packet4i>(0); +template<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) +{ eigen_assert(false && "packet integer division are not supported by NEON"); + return pset1<Packet4i>(0); } // for some weird raisons, it has to be overloaded for packet of integers -template<> EIGEN_STRONG_INLINE Packet4i ei_pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return ei_padd(ei_pmul(a,b), c); } +template<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return padd(pmul(a,b), c); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vminq_f32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vminq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vminq_f32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vminq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmaxq_f32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmaxq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmaxq_f32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmaxq_s32(a,b); } // Logical Operations are not supported for float, so we have to reinterpret casts using NEON intrinsics -template<> EIGEN_STRONG_INLINE Packet4f ei_pand<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b))); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vandq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vandq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_por<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b) { return vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b))); } -template<> EIGEN_STRONG_INLINE Packet4i ei_por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vorrq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vorrq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pxor<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b))); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return veorq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return veorq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) +template<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b))); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vbicq_s32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vbicq_s32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pload<float>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_f32(from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pload<int>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_s32(from); } +template<> EIGEN_STRONG_INLINE Packet4f pload<float>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_f32(from); } +template<> EIGEN_STRONG_INLINE Packet4i pload<int>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_s32(from); } -template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_f32(from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_s32(from); } +template<> EIGEN_STRONG_INLINE Packet4f ploadu(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_f32(from); } +template<> EIGEN_STRONG_INLINE Packet4i ploadu(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_s32(from); } -template<> EIGEN_STRONG_INLINE Packet4f ei_ploaddup<Packet4f>(const float* from) +template<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float* from) { float32x2_t lo, ho; lo = vdup_n_f32(*from); hi = vdup_n_f32(*from); return vcombine_f32(lo, hi); } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploaddup<Packet4i>(const float* from) +template<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const float* from) { int32x2_t lo, ho; lo = vdup_n_s32(*from); @@ -195,20 +197,20 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_ploaddup<Packet4i>(const float* from) return vcombine_s32(lo, hi); } -template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_f32(to, from); } -template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_s32(to, from); } +template<> EIGEN_STRONG_INLINE void pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_f32(to, from); } +template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_s32(to, from); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); } +template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); } +template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<float>(const float* addr) { __pld(addr); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<int>(const int* addr) { __pld(addr); } +template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { __pld(addr); } +template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { __pld(addr); } // FIXME only store the 2 first elements ? -template<> EIGEN_STRONG_INLINE float ei_pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x[4]; vst1q_f32(x, a); return x[0]; } -template<> EIGEN_STRONG_INLINE int ei_pfirst<Packet4i>(const Packet4i& a) { int EIGEN_ALIGN16 x[4]; vst1q_s32(x, a); return x[0]; } +template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x[4]; vst1q_f32(x, a); return x[0]; } +template<> EIGEN_STRONG_INLINE int pfirst<Packet4i>(const Packet4i& a) { int EIGEN_ALIGN16 x[4]; vst1q_s32(x, a); return x[0]; } -template<> EIGEN_STRONG_INLINE Packet4f ei_preverse(const Packet4f& a) { +template<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a) { float32x2_t a_lo, a_hi; Packet4f a_r64; @@ -217,7 +219,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_preverse(const Packet4f& a) { a_hi = vget_high_f32(a_r64); return vcombine_f32(a_hi, a_lo); } -template<> EIGEN_STRONG_INLINE Packet4i ei_preverse(const Packet4i& a) { +template<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a) { int32x2_t a_lo, a_hi; Packet4i a_r64; @@ -226,10 +228,10 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_preverse(const Packet4i& a) { a_hi = vget_high_s32(a_r64); return vcombine_s32(a_hi, a_lo); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pabs(const Packet4f& a) { return vabsq_f32(a); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pabs(const Packet4i& a) { return vabsq_s32(a); } +template<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a) { return vabsq_f32(a); } +template<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a) { return vabsq_s32(a); } -template<> EIGEN_STRONG_INLINE float ei_predux<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a) { float32x2_t a_lo, a_hi, sum; float s[2]; @@ -243,7 +245,7 @@ template<> EIGEN_STRONG_INLINE float ei_predux<Packet4f>(const Packet4f& a) return s[0]; } -template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vecs) +template<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs) { float32x4x2_t vtrn1, vtrn2, res1, res2; Packet4f sum1, sum2, sum; @@ -263,7 +265,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vec return sum; } -template<> EIGEN_STRONG_INLINE int ei_predux<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a) { int32x2_t a_lo, a_hi, sum; int32_t s[2]; @@ -277,7 +279,7 @@ template<> EIGEN_STRONG_INLINE int ei_predux<Packet4i>(const Packet4i& a) return s[0]; } -template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vecs) +template<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs) { int32x4x2_t vtrn1, vtrn2, res1, res2; Packet4i sum1, sum2, sum; @@ -299,7 +301,7 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vec // Other reduction functions: // mul -template<> EIGEN_STRONG_INLINE float ei_predux_mul<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a) { float32x2_t a_lo, a_hi, prod; float s[2]; @@ -315,7 +317,7 @@ template<> EIGEN_STRONG_INLINE float ei_predux_mul<Packet4f>(const Packet4f& a) return s[0]; } -template<> EIGEN_STRONG_INLINE int ei_predux_mul<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a) { int32x2_t a_lo, a_hi, prod; int32_t s[2]; @@ -333,7 +335,7 @@ template<> EIGEN_STRONG_INLINE int ei_predux_mul<Packet4i>(const Packet4i& a) } // min -template<> EIGEN_STRONG_INLINE float ei_predux_min<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a) { float32x2_t a_lo, a_hi, min; float s[2]; @@ -346,7 +348,7 @@ template<> EIGEN_STRONG_INLINE float ei_predux_min<Packet4f>(const Packet4f& a) return s[0]; } -template<> EIGEN_STRONG_INLINE int ei_predux_min<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a) { int32x2_t a_lo, a_hi, min; int32_t s[2]; @@ -361,7 +363,7 @@ template<> EIGEN_STRONG_INLINE int ei_predux_min<Packet4i>(const Packet4i& a) } // max -template<> EIGEN_STRONG_INLINE float ei_predux_max<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a) { float32x2_t a_lo, a_hi, max; float s[2]; @@ -374,7 +376,7 @@ template<> EIGEN_STRONG_INLINE float ei_predux_max<Packet4f>(const Packet4f& a) return s[0]; } -template<> EIGEN_STRONG_INLINE int ei_predux_max<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a) { int32x2_t a_lo, a_hi, max; int32_t s[2]; @@ -389,7 +391,7 @@ template<> EIGEN_STRONG_INLINE int ei_predux_max<Packet4i>(const Packet4i& a) } template<int Offset> -struct ei_palign_impl<Offset,Packet4f> +struct palign_impl<Offset,Packet4f> { EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second) { @@ -399,7 +401,7 @@ struct ei_palign_impl<Offset,Packet4f> }; template<int Offset> -struct ei_palign_impl<Offset,Packet4i> +struct palign_impl<Offset,Packet4i> { EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second) { @@ -407,4 +409,7 @@ struct ei_palign_impl<Offset,Packet4i> first = vextq_s32(first, second, Offset); } }; + +} // end namespace internal + #endif // EIGEN_PACKET_MATH_NEON_H diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h index 819d59364..cc686fc84 100644 --- a/Eigen/src/Core/arch/SSE/Complex.h +++ b/Eigen/src/Core/arch/SSE/Complex.h @@ -25,6 +25,8 @@ #ifndef EIGEN_COMPLEX_SSE_H #define EIGEN_COMPLEX_SSE_H +namespace internal { + //---------- float ---------- struct Packet2cf { @@ -33,7 +35,7 @@ struct Packet2cf __m128 v; }; -template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_traits +template<> struct packet_traits<std::complex<float> > : default_packet_traits { typedef Packet2cf type; enum { @@ -54,85 +56,85 @@ template<> struct ei_packet_traits<std::complex<float> > : ei_default_packet_tr }; }; -template<> struct ei_unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; +template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_add_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_sub_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pnegate(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_add_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_sub_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000)); return Packet2cf(_mm_xor_ps(a.v,mask)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pconj(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a) { const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000)); return Packet2cf(_mm_xor_ps(a.v,mask)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { // TODO optimize it for SSE3 and 4 #ifdef EIGEN_VECTORIZE_SSE3 return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(a.v), b.v), _mm_mul_ps(_mm_movehdup_ps(a.v), - ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)))); -// return Packet2cf(_mm_addsub_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), -// _mm_mul_ps(ei_vec4f_swizzle1(a.v, 1, 1, 3, 3), -// ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)))); + vec4f_swizzle1(b.v, 1, 0, 3, 2)))); +// return Packet2cf(_mm_addsub_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), +// _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3), +// vec4f_swizzle1(b.v, 1, 0, 3, 2)))); #else const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000)); - return Packet2cf(_mm_add_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), - _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 1, 1, 3, 3), - ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask))); + return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), + _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3), + vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask))); #endif } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_and_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_or_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_xor_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_andnot_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_and_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_or_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_xor_ps(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_andnot_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pload <Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(ei_pload<Packet4f>(&ei_real_ref(*from))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ei_ploadu<Packet4f>(&ei_real_ref(*from))); } +template<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>(&real_ref(*from))); } +template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>(&real_ref(*from))); } -template<> EIGEN_STRONG_INLINE void ei_pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE ei_pstore(&ei_real_ref(*to), from.v); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu(&ei_real_ref(*to), from.v); } +template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&real_ref(*to), from.v); } +template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&real_ref(*to), from.v); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<std::complex<float> >(const std::complex<float> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } +template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_pset1<Packet2cf>(const std::complex<float>& from) +template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from) { Packet2cf res; res.v = _mm_loadl_pi(res.v, (const __m64*)&from); return Packet2cf(_mm_movelh_ps(res.v,res.v)); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_pfirst<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a) { std::complex<float> res; _mm_storel_pi((__m64*)&res, a.v); return res; } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(ei_preverse(_mm_castps_pd(a.v)))); } +template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(preverse(_mm_castps_pd(a.v)))); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a) { - return ei_pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v)))); + return pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v)))); } -template<> EIGEN_STRONG_INLINE Packet2cf ei_preduxp<Packet2cf>(const Packet2cf* vecs) +template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs) { return Packet2cf(_mm_add_ps(_mm_movelh_ps(vecs[0].v,vecs[1].v), _mm_movehl_ps(vecs[1].v,vecs[0].v))); } -template<> EIGEN_STRONG_INLINE std::complex<float> ei_predux_mul<Packet2cf>(const Packet2cf& a) +template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a) { - return ei_pfirst(ei_pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v)))); + return pfirst(pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v)))); } template<int Offset> -struct ei_palign_impl<Offset,Packet2cf> +struct palign_impl<Offset,Packet2cf> { EIGEN_STRONG_INLINE static void run(Packet2cf& first, const Packet2cf& second) { @@ -144,89 +146,89 @@ struct ei_palign_impl<Offset,Packet2cf> } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, false,true> +template<> struct conj_helper<Packet2cf, Packet2cf, false,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pmul(a, ei_pconj(b)); + return pmul(a, pconj(b)); #else const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000)); - return Packet2cf(_mm_add_ps(_mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask), - _mm_mul_ps(ei_vec4f_swizzle1(a.v, 1, 1, 3, 3), - ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)))); + return Packet2cf(_mm_add_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask), + _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3), + vec4f_swizzle1(b.v, 1, 0, 3, 2)))); #endif } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,false> +template<> struct conj_helper<Packet2cf, Packet2cf, true,false> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pmul(ei_pconj(a), b); + return pmul(pconj(a), b); #else const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000)); - return Packet2cf(_mm_add_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), - _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 1, 1, 3, 3), - ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask))); + return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), + _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3), + vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask))); #endif } }; -template<> struct ei_conj_helper<Packet2cf, Packet2cf, true,true> +template<> struct conj_helper<Packet2cf, Packet2cf, true,true> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pconj(ei_pmul(a, b)); + return pconj(pmul(a, b)); #else const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000)); - return Packet2cf(_mm_sub_ps(_mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask), - _mm_mul_ps(ei_vec4f_swizzle1(a.v, 1, 1, 3, 3), - ei_vec4f_swizzle1(b.v, 1, 0, 3, 2)))); + return Packet2cf(_mm_sub_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask), + _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3), + vec4f_swizzle1(b.v, 1, 0, 3, 2)))); #endif } }; -template<> struct ei_conj_helper<Packet4f, Packet2cf, false,false> +template<> struct conj_helper<Packet4f, Packet2cf, false,false> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet4f& x, const Packet2cf& y, const Packet2cf& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet4f& x, const Packet2cf& y) const - { return Packet2cf(ei_pmul(x, y.v)); } + { return Packet2cf(Eigen::internal::pmul(x, y.v)); } }; -template<> struct ei_conj_helper<Packet2cf, Packet4f, false,false> +template<> struct conj_helper<Packet2cf, Packet4f, false,false> { EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet4f& y, const Packet2cf& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& x, const Packet4f& y) const - { return Packet2cf(ei_pmul(x.v, y)); } + { return Packet2cf(Eigen::internal::pmul(x.v, y)); } }; -template<> EIGEN_STRONG_INLINE Packet2cf ei_pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) +template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { // TODO optimize it for SSE3 and 4 - Packet2cf res = ei_conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); + Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b); __m128 s = _mm_mul_ps(b.v,b.v); return Packet2cf(_mm_div_ps(res.v,_mm_add_ps(s,_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(s), 0xb1))))); } -EIGEN_STRONG_INLINE Packet2cf ei_pcplxflip/*<Packet2cf>*/(const Packet2cf& x) +EIGEN_STRONG_INLINE Packet2cf pcplxflip/*<Packet2cf>*/(const Packet2cf& x) { - return Packet2cf(ei_vec4f_swizzle1(x.v, 1, 0, 3, 2)); + return Packet2cf(vec4f_swizzle1(x.v, 1, 0, 3, 2)); } @@ -238,7 +240,7 @@ struct Packet1cd __m128d v; }; -template<> struct ei_packet_traits<std::complex<double> > : ei_default_packet_traits +template<> struct packet_traits<std::complex<double> > : default_packet_traits { typedef Packet1cd type; enum { @@ -259,77 +261,77 @@ template<> struct ei_packet_traits<std::complex<double> > : ei_default_packet_t }; }; -template<> struct ei_unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1}; }; +template<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1}; }; -template<> EIGEN_STRONG_INLINE Packet1cd ei_padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_add_pd(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_sub_pd(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pnegate(const Packet1cd& a) { return Packet1cd(ei_pnegate(a.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pconj(const Packet1cd& a) +template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_add_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_sub_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate(a.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0)); return Packet1cd(_mm_xor_pd(a.v,mask)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b) +template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { // TODO optimize it for SSE3 and 4 #ifdef EIGEN_VECTORIZE_SSE3 - return Packet1cd(_mm_addsub_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 0, 0), b.v), - _mm_mul_pd(ei_vec2d_swizzle1(a.v, 1, 1), - ei_vec2d_swizzle1(b.v, 1, 0)))); + return Packet1cd(_mm_addsub_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), + _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1), + vec2d_swizzle1(b.v, 1, 0)))); #else const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0)); - return Packet1cd(_mm_add_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 0, 0), b.v), - _mm_xor_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 1, 1), - ei_vec2d_swizzle1(b.v, 1, 0)), mask))); + return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), + _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1), + vec2d_swizzle1(b.v, 1, 0)), mask))); #endif } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pand <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_and_pd(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_por <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_or_pd(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pxor <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_xor_pd(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_andnot_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_and_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_or_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_xor_pd(a.v,b.v)); } +template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_andnot_pd(a.v,b.v)); } // FIXME force unaligned load, this is a temporary fix -template<> EIGEN_STRONG_INLINE Packet1cd ei_pload <Packet1cd>(const std::complex<double>* from) -{ EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(ei_pload<Packet2d>((const double*)from)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_ploadu<Packet1cd>(const std::complex<double>* from) -{ EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ei_ploadu<Packet2d>((const double*)from)); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_pset1<Packet1cd>(const std::complex<double>& from) -{ /* here we really have to use unaligned loads :( */ return ei_ploadu<Packet1cd>(&from); } +template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(const std::complex<double>* from) +{ EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); } +template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) +{ EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); } +template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>& from) +{ /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); } // FIXME force unaligned store, this is a temporary fix -template<> EIGEN_STRONG_INLINE void ei_pstore <std::complex<double> >(std::complex<double> * to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE ei_pstore((double*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<std::complex<double> >(std::complex<double> * to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((double*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> * to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); } +template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> * to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<std::complex<double> >(const std::complex<double> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } +template<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } -template<> EIGEN_STRONG_INLINE std::complex<double> ei_pfirst<Packet1cd>(const Packet1cd& a) +template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(const Packet1cd& a) { EIGEN_ALIGN16 double res[2]; _mm_store_pd(res, a.v); return std::complex<double>(res[0],res[1]); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_preverse(const Packet1cd& a) { return a; } +template<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; } -template<> EIGEN_STRONG_INLINE std::complex<double> ei_predux<Packet1cd>(const Packet1cd& a) +template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a) { - return ei_pfirst(a); + return pfirst(a); } -template<> EIGEN_STRONG_INLINE Packet1cd ei_preduxp<Packet1cd>(const Packet1cd* vecs) +template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs) { return vecs[0]; } -template<> EIGEN_STRONG_INLINE std::complex<double> ei_predux_mul<Packet1cd>(const Packet1cd& a) +template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a) { - return ei_pfirst(a); + return pfirst(a); } template<int Offset> -struct ei_palign_impl<Offset,Packet1cd> +struct palign_impl<Offset,Packet1cd> { EIGEN_STRONG_INLINE static void run(Packet1cd& /*first*/, const Packet1cd& /*second*/) { @@ -338,89 +340,91 @@ struct ei_palign_impl<Offset,Packet1cd> } }; -template<> struct ei_conj_helper<Packet1cd, Packet1cd, false,true> +template<> struct conj_helper<Packet1cd, Packet1cd, false,true> { EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pmul(a, ei_pconj(b)); + return pmul(a, pconj(b)); #else const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0)); - return Packet1cd(_mm_add_pd(_mm_xor_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 0, 0), b.v), mask), - _mm_mul_pd(ei_vec2d_swizzle1(a.v, 1, 1), - ei_vec2d_swizzle1(b.v, 1, 0)))); + return Packet1cd(_mm_add_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask), + _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1), + vec2d_swizzle1(b.v, 1, 0)))); #endif } }; -template<> struct ei_conj_helper<Packet1cd, Packet1cd, true,false> +template<> struct conj_helper<Packet1cd, Packet1cd, true,false> { EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pmul(ei_pconj(a), b); + return pmul(pconj(a), b); #else const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0)); - return Packet1cd(_mm_add_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 0, 0), b.v), - _mm_xor_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 1, 1), - ei_vec2d_swizzle1(b.v, 1, 0)), mask))); + return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), + _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1), + vec2d_swizzle1(b.v, 1, 0)), mask))); #endif } }; -template<> struct ei_conj_helper<Packet1cd, Packet1cd, true,true> +template<> struct conj_helper<Packet1cd, Packet1cd, true,true> { EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const - { return ei_padd(pmul(x,y),c); } + { return padd(pmul(x,y),c); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const { #ifdef EIGEN_VECTORIZE_SSE3 - return ei_pconj(ei_pmul(a, b)); + return pconj(pmul(a, b)); #else const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0)); - return Packet1cd(_mm_sub_pd(_mm_xor_pd(_mm_mul_pd(ei_vec2d_swizzle1(a.v, 0, 0), b.v), mask), - _mm_mul_pd(ei_vec2d_swizzle1(a.v, 1, 1), - ei_vec2d_swizzle1(b.v, 1, 0)))); + return Packet1cd(_mm_sub_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask), + _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1), + vec2d_swizzle1(b.v, 1, 0)))); #endif } }; -template<> struct ei_conj_helper<Packet2d, Packet1cd, false,false> +template<> struct conj_helper<Packet2d, Packet1cd, false,false> { EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet2d& x, const Packet1cd& y, const Packet1cd& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet2d& x, const Packet1cd& y) const - { return Packet1cd(ei_pmul(x, y.v)); } + { return Packet1cd(Eigen::internal::pmul(x, y.v)); } }; -template<> struct ei_conj_helper<Packet1cd, Packet2d, false,false> +template<> struct conj_helper<Packet1cd, Packet2d, false,false> { EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet2d& y, const Packet1cd& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& x, const Packet2d& y) const - { return Packet1cd(ei_pmul(x.v, y)); } + { return Packet1cd(Eigen::internal::pmul(x.v, y)); } }; -template<> EIGEN_STRONG_INLINE Packet1cd ei_pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b) +template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { // TODO optimize it for SSE3 and 4 - Packet1cd res = ei_conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b); + Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b); __m128d s = _mm_mul_pd(b.v,b.v); return Packet1cd(_mm_div_pd(res.v, _mm_add_pd(s,_mm_shuffle_pd(s, s, 0x1)))); } -EIGEN_STRONG_INLINE Packet1cd ei_pcplxflip/*<Packet1cd>*/(const Packet1cd& x) +EIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x) { - return Packet1cd(ei_preverse(x.v)); + return Packet1cd(preverse(x.v)); } +} // end namespace internal + #endif // EIGEN_COMPLEX_SSE_H diff --git a/Eigen/src/Core/arch/SSE/MathFunctions.h b/Eigen/src/Core/arch/SSE/MathFunctions.h index cb73fd205..9d56d8218 100644 --- a/Eigen/src/Core/arch/SSE/MathFunctions.h +++ b/Eigen/src/Core/arch/SSE/MathFunctions.h @@ -30,8 +30,10 @@ #ifndef EIGEN_MATH_FUNCTIONS_SSE_H #define EIGEN_MATH_FUNCTIONS_SSE_H +namespace internal { + template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED -Packet4f ei_plog<Packet4f>(const Packet4f& _x) +Packet4f plog<Packet4f>(const Packet4f& _x) { Packet4f x = _x; _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f); @@ -64,15 +66,15 @@ Packet4f ei_plog<Packet4f>(const Packet4f& _x) Packet4f invalid_mask = _mm_cmple_ps(x, _mm_setzero_ps()); - x = ei_pmax(x, ei_p4f_min_norm_pos); /* cut off denormalized stuff */ + x = pmax(x, p4f_min_norm_pos); /* cut off denormalized stuff */ emm0 = _mm_srli_epi32(_mm_castps_si128(x), 23); /* keep only the fractional part */ - x = _mm_and_ps(x, ei_p4f_inv_mant_mask); - x = _mm_or_ps(x, ei_p4f_half); + x = _mm_and_ps(x, p4f_inv_mant_mask); + x = _mm_or_ps(x, p4f_half); - emm0 = _mm_sub_epi32(emm0, ei_p4i_0x7f); - Packet4f e = ei_padd(_mm_cvtepi32_ps(emm0), ei_p4f_1); + emm0 = _mm_sub_epi32(emm0, p4i_0x7f); + Packet4f e = padd(_mm_cvtepi32_ps(emm0), p4f_1); /* part2: if( x < SQRTHF ) { @@ -80,38 +82,38 @@ Packet4f ei_plog<Packet4f>(const Packet4f& _x) x = x + x - 1.0; } else { x = x - 1.0; } */ - Packet4f mask = _mm_cmplt_ps(x, ei_p4f_cephes_SQRTHF); + Packet4f mask = _mm_cmplt_ps(x, p4f_cephes_SQRTHF); Packet4f tmp = _mm_and_ps(x, mask); - x = ei_psub(x, ei_p4f_1); - e = ei_psub(e, _mm_and_ps(ei_p4f_1, mask)); - x = ei_padd(x, tmp); + x = psub(x, p4f_1); + e = psub(e, _mm_and_ps(p4f_1, mask)); + x = padd(x, tmp); - Packet4f x2 = ei_pmul(x,x); - Packet4f x3 = ei_pmul(x2,x); + Packet4f x2 = pmul(x,x); + Packet4f x3 = pmul(x2,x); Packet4f y, y1, y2; - y = ei_pmadd(ei_p4f_cephes_log_p0, x, ei_p4f_cephes_log_p1); - y1 = ei_pmadd(ei_p4f_cephes_log_p3, x, ei_p4f_cephes_log_p4); - y2 = ei_pmadd(ei_p4f_cephes_log_p6, x, ei_p4f_cephes_log_p7); - y = ei_pmadd(y , x, ei_p4f_cephes_log_p2); - y1 = ei_pmadd(y1, x, ei_p4f_cephes_log_p5); - y2 = ei_pmadd(y2, x, ei_p4f_cephes_log_p8); - y = ei_pmadd(y, x3, y1); - y = ei_pmadd(y, x3, y2); - y = ei_pmul(y, x3); - - y1 = ei_pmul(e, ei_p4f_cephes_log_q1); - tmp = ei_pmul(x2, ei_p4f_half); - y = ei_padd(y, y1); - x = ei_psub(x, tmp); - y2 = ei_pmul(e, ei_p4f_cephes_log_q2); - x = ei_padd(x, y); - x = ei_padd(x, y2); + y = pmadd(p4f_cephes_log_p0, x, p4f_cephes_log_p1); + y1 = pmadd(p4f_cephes_log_p3, x, p4f_cephes_log_p4); + y2 = pmadd(p4f_cephes_log_p6, x, p4f_cephes_log_p7); + y = pmadd(y , x, p4f_cephes_log_p2); + y1 = pmadd(y1, x, p4f_cephes_log_p5); + y2 = pmadd(y2, x, p4f_cephes_log_p8); + y = pmadd(y, x3, y1); + y = pmadd(y, x3, y2); + y = pmul(y, x3); + + y1 = pmul(e, p4f_cephes_log_q1); + tmp = pmul(x2, p4f_half); + y = padd(y, y1); + x = psub(x, tmp); + y2 = pmul(e, p4f_cephes_log_q2); + x = padd(x, y); + x = padd(x, y2); return _mm_or_ps(x, invalid_mask); // negative arg will be NAN } template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED -Packet4f ei_pexp<Packet4f>(const Packet4f& _x) +Packet4f pexp<Packet4f>(const Packet4f& _x) { Packet4f x = _x; _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f); @@ -137,40 +139,40 @@ Packet4f ei_pexp<Packet4f>(const Packet4f& _x) Packet4i emm0; // clamp x - x = ei_pmax(ei_pmin(x, ei_p4f_exp_hi), ei_p4f_exp_lo); + x = pmax(pmin(x, p4f_exp_hi), p4f_exp_lo); /* express exp(x) as exp(g + n*log(2)) */ - fx = ei_pmadd(x, ei_p4f_cephes_LOG2EF, ei_p4f_half); + fx = pmadd(x, p4f_cephes_LOG2EF, p4f_half); /* how to perform a floorf with SSE: just below */ emm0 = _mm_cvttps_epi32(fx); tmp = _mm_cvtepi32_ps(emm0); /* if greater, substract 1 */ Packet4f mask = _mm_cmpgt_ps(tmp, fx); - mask = _mm_and_ps(mask, ei_p4f_1); - fx = ei_psub(tmp, mask); + mask = _mm_and_ps(mask, p4f_1); + fx = psub(tmp, mask); - tmp = ei_pmul(fx, ei_p4f_cephes_exp_C1); - Packet4f z = ei_pmul(fx, ei_p4f_cephes_exp_C2); - x = ei_psub(x, tmp); - x = ei_psub(x, z); + tmp = pmul(fx, p4f_cephes_exp_C1); + Packet4f z = pmul(fx, p4f_cephes_exp_C2); + x = psub(x, tmp); + x = psub(x, z); - z = ei_pmul(x,x); + z = pmul(x,x); - Packet4f y = ei_p4f_cephes_exp_p0; - y = ei_pmadd(y, x, ei_p4f_cephes_exp_p1); - y = ei_pmadd(y, x, ei_p4f_cephes_exp_p2); - y = ei_pmadd(y, x, ei_p4f_cephes_exp_p3); - y = ei_pmadd(y, x, ei_p4f_cephes_exp_p4); - y = ei_pmadd(y, x, ei_p4f_cephes_exp_p5); - y = ei_pmadd(y, z, x); - y = ei_padd(y, ei_p4f_1); + Packet4f y = p4f_cephes_exp_p0; + y = pmadd(y, x, p4f_cephes_exp_p1); + y = pmadd(y, x, p4f_cephes_exp_p2); + y = pmadd(y, x, p4f_cephes_exp_p3); + y = pmadd(y, x, p4f_cephes_exp_p4); + y = pmadd(y, x, p4f_cephes_exp_p5); + y = pmadd(y, z, x); + y = padd(y, p4f_1); /* build 2^n */ emm0 = _mm_cvttps_epi32(fx); - emm0 = _mm_add_epi32(emm0, ei_p4i_0x7f); + emm0 = _mm_add_epi32(emm0, p4i_0x7f); emm0 = _mm_slli_epi32(emm0, 23); - return ei_pmul(y, _mm_castsi128_ps(emm0)); + return pmul(y, _mm_castsi128_ps(emm0)); } /* evaluation of 4 sines at onces, using SSE2 intrinsics. @@ -186,7 +188,7 @@ Packet4f ei_pexp<Packet4f>(const Packet4f& _x) */ template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED -Packet4f ei_psin<Packet4f>(const Packet4f& _x) +Packet4f psin<Packet4f>(const Packet4f& _x) { Packet4f x = _x; _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f); @@ -215,24 +217,24 @@ Packet4f ei_psin<Packet4f>(const Packet4f& _x) Packet4i emm0, emm2; sign_bit = x; /* take the absolute value */ - x = ei_pabs(x); + x = pabs(x); /* take the modulo */ /* extract the sign bit (upper one) */ - sign_bit = _mm_and_ps(sign_bit, ei_p4f_sign_mask); + sign_bit = _mm_and_ps(sign_bit, p4f_sign_mask); /* scale by 4/Pi */ - y = ei_pmul(x, ei_p4f_cephes_FOPI); + y = pmul(x, p4f_cephes_FOPI); /* store the integer part of y in mm0 */ emm2 = _mm_cvttps_epi32(y); /* j=(j+1) & (~1) (see the cephes sources) */ - emm2 = _mm_add_epi32(emm2, ei_p4i_1); - emm2 = _mm_and_si128(emm2, ei_p4i_not1); + emm2 = _mm_add_epi32(emm2, p4i_1); + emm2 = _mm_and_si128(emm2, p4i_not1); y = _mm_cvtepi32_ps(emm2); /* get the swap sign flag */ - emm0 = _mm_and_si128(emm2, ei_p4i_4); + emm0 = _mm_and_si128(emm2, p4i_4); emm0 = _mm_slli_epi32(emm0, 29); /* get the polynom selection mask there is one polynom for 0 <= x <= Pi/4 @@ -240,7 +242,7 @@ Packet4f ei_psin<Packet4f>(const Packet4f& _x) Both branches will be computed. */ - emm2 = _mm_and_si128(emm2, ei_p4i_2); + emm2 = _mm_and_si128(emm2, p4i_2); emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128()); Packet4f swap_sign_bit = _mm_castsi128_ps(emm0); @@ -249,33 +251,33 @@ Packet4f ei_psin<Packet4f>(const Packet4f& _x) /* The magic pass: "Extended precision modular arithmetic" x = ((x - y * DP1) - y * DP2) - y * DP3; */ - xmm1 = ei_pmul(y, ei_p4f_minus_cephes_DP1); - xmm2 = ei_pmul(y, ei_p4f_minus_cephes_DP2); - xmm3 = ei_pmul(y, ei_p4f_minus_cephes_DP3); - x = ei_padd(x, xmm1); - x = ei_padd(x, xmm2); - x = ei_padd(x, xmm3); + xmm1 = pmul(y, p4f_minus_cephes_DP1); + xmm2 = pmul(y, p4f_minus_cephes_DP2); + xmm3 = pmul(y, p4f_minus_cephes_DP3); + x = padd(x, xmm1); + x = padd(x, xmm2); + x = padd(x, xmm3); /* Evaluate the first polynom (0 <= x <= Pi/4) */ - y = ei_p4f_coscof_p0; + y = p4f_coscof_p0; Packet4f z = _mm_mul_ps(x,x); - y = ei_pmadd(y, z, ei_p4f_coscof_p1); - y = ei_pmadd(y, z, ei_p4f_coscof_p2); - y = ei_pmul(y, z); - y = ei_pmul(y, z); - Packet4f tmp = ei_pmul(z, ei_p4f_half); - y = ei_psub(y, tmp); - y = ei_padd(y, ei_p4f_1); + y = pmadd(y, z, p4f_coscof_p1); + y = pmadd(y, z, p4f_coscof_p2); + y = pmul(y, z); + y = pmul(y, z); + Packet4f tmp = pmul(z, p4f_half); + y = psub(y, tmp); + y = padd(y, p4f_1); /* Evaluate the second polynom (Pi/4 <= x <= 0) */ - Packet4f y2 = ei_p4f_sincof_p0; - y2 = ei_pmadd(y2, z, ei_p4f_sincof_p1); - y2 = ei_pmadd(y2, z, ei_p4f_sincof_p2); - y2 = ei_pmul(y2, z); - y2 = ei_pmul(y2, x); - y2 = ei_padd(y2, x); + Packet4f y2 = p4f_sincof_p0; + y2 = pmadd(y2, z, p4f_sincof_p1); + y2 = pmadd(y2, z, p4f_sincof_p2); + y2 = pmul(y2, z); + y2 = pmul(y2, x); + y2 = padd(y2, x); /* select the correct result from the two polynoms */ y2 = _mm_and_ps(poly_mask, y2); @@ -285,9 +287,9 @@ Packet4f ei_psin<Packet4f>(const Packet4f& _x) return _mm_xor_ps(y, sign_bit); } -/* almost the same as ei_psin */ +/* almost the same as psin */ template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED -Packet4f ei_pcos<Packet4f>(const Packet4f& _x) +Packet4f pcos<Packet4f>(const Packet4f& _x) { Packet4f x = _x; _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f); @@ -312,25 +314,25 @@ Packet4f ei_pcos<Packet4f>(const Packet4f& _x) Packet4f xmm1, xmm2 = _mm_setzero_ps(), xmm3, y; Packet4i emm0, emm2; - x = ei_pabs(x); + x = pabs(x); /* scale by 4/Pi */ - y = ei_pmul(x, ei_p4f_cephes_FOPI); + y = pmul(x, p4f_cephes_FOPI); /* get the integer part of y */ emm2 = _mm_cvttps_epi32(y); /* j=(j+1) & (~1) (see the cephes sources) */ - emm2 = _mm_add_epi32(emm2, ei_p4i_1); - emm2 = _mm_and_si128(emm2, ei_p4i_not1); + emm2 = _mm_add_epi32(emm2, p4i_1); + emm2 = _mm_and_si128(emm2, p4i_not1); y = _mm_cvtepi32_ps(emm2); - emm2 = _mm_sub_epi32(emm2, ei_p4i_2); + emm2 = _mm_sub_epi32(emm2, p4i_2); /* get the swap sign flag */ - emm0 = _mm_andnot_si128(emm2, ei_p4i_4); + emm0 = _mm_andnot_si128(emm2, p4i_4); emm0 = _mm_slli_epi32(emm0, 29); /* get the polynom selection mask */ - emm2 = _mm_and_si128(emm2, ei_p4i_2); + emm2 = _mm_and_si128(emm2, p4i_2); emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128()); Packet4f sign_bit = _mm_castsi128_ps(emm0); @@ -338,31 +340,31 @@ Packet4f ei_pcos<Packet4f>(const Packet4f& _x) /* The magic pass: "Extended precision modular arithmetic" x = ((x - y * DP1) - y * DP2) - y * DP3; */ - xmm1 = ei_pmul(y, ei_p4f_minus_cephes_DP1); - xmm2 = ei_pmul(y, ei_p4f_minus_cephes_DP2); - xmm3 = ei_pmul(y, ei_p4f_minus_cephes_DP3); - x = ei_padd(x, xmm1); - x = ei_padd(x, xmm2); - x = ei_padd(x, xmm3); + xmm1 = pmul(y, p4f_minus_cephes_DP1); + xmm2 = pmul(y, p4f_minus_cephes_DP2); + xmm3 = pmul(y, p4f_minus_cephes_DP3); + x = padd(x, xmm1); + x = padd(x, xmm2); + x = padd(x, xmm3); /* Evaluate the first polynom (0 <= x <= Pi/4) */ - y = ei_p4f_coscof_p0; - Packet4f z = ei_pmul(x,x); + y = p4f_coscof_p0; + Packet4f z = pmul(x,x); - y = ei_pmadd(y,z,ei_p4f_coscof_p1); - y = ei_pmadd(y,z,ei_p4f_coscof_p2); - y = ei_pmul(y, z); - y = ei_pmul(y, z); - Packet4f tmp = _mm_mul_ps(z, ei_p4f_half); - y = ei_psub(y, tmp); - y = ei_padd(y, ei_p4f_1); + y = pmadd(y,z,p4f_coscof_p1); + y = pmadd(y,z,p4f_coscof_p2); + y = pmul(y, z); + y = pmul(y, z); + Packet4f tmp = _mm_mul_ps(z, p4f_half); + y = psub(y, tmp); + y = padd(y, p4f_1); /* Evaluate the second polynom (Pi/4 <= x <= 0) */ - Packet4f y2 = ei_p4f_sincof_p0; - y2 = ei_pmadd(y2, z, ei_p4f_sincof_p1); - y2 = ei_pmadd(y2, z, ei_p4f_sincof_p2); - y2 = ei_pmul(y2, z); - y2 = ei_pmadd(y2, x, x); + Packet4f y2 = p4f_sincof_p0; + y2 = pmadd(y2, z, p4f_sincof_p1); + y2 = pmadd(y2, z, p4f_sincof_p2); + y2 = pmul(y2, z); + y2 = pmadd(y2, x, x); /* select the correct result from the two polynoms */ y2 = _mm_and_ps(poly_mask, y2); @@ -376,16 +378,18 @@ Packet4f ei_pcos<Packet4f>(const Packet4f& _x) // This is based on Quake3's fast inverse square root. // For detail see here: http://www.beyond3d.com/content/articles/8/ template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED -Packet4f ei_psqrt<Packet4f>(const Packet4f& _x) +Packet4f psqrt<Packet4f>(const Packet4f& _x) { - Packet4f half = ei_pmul(_x, ei_pset1<Packet4f>(.5f)); + Packet4f half = pmul(_x, pset1<Packet4f>(.5f)); /* select only the inverse sqrt of non-zero inputs */ - Packet4f non_zero_mask = _mm_cmpgt_ps(_x, ei_pset1<Packet4f>(std::numeric_limits<float>::epsilon())); + Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1<Packet4f>(std::numeric_limits<float>::epsilon())); Packet4f x = _mm_and_ps(non_zero_mask, _mm_rsqrt_ps(_x)); - x = ei_pmul(x, ei_psub(ei_pset1<Packet4f>(1.5f), ei_pmul(half, ei_pmul(x,x)))); - return ei_pmul(_x,x); + x = pmul(x, psub(pset1<Packet4f>(1.5f), pmul(half, pmul(x,x)))); + return pmul(_x,x); } +} // end namespace internal + #endif // EIGEN_MATH_FUNCTIONS_SSE_H diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index a7206e77d..98a5a3426 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -25,6 +25,8 @@ #ifndef EIGEN_PACKET_MATH_SSE_H #define EIGEN_PACKET_MATH_SSE_H +namespace internal { + #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 #endif @@ -37,36 +39,36 @@ typedef __m128 Packet4f; typedef __m128i Packet4i; typedef __m128d Packet2d; -template<> struct ei_is_arithmetic<__m128> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<__m128i> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<__m128d> { enum { ret = true }; }; +template<> struct is_arithmetic<__m128> { enum { ret = true }; }; +template<> struct is_arithmetic<__m128i> { enum { ret = true }; }; +template<> struct is_arithmetic<__m128d> { enum { ret = true }; }; -#define ei_vec4f_swizzle1(v,p,q,r,s) \ +#define vec4f_swizzle1(v,p,q,r,s) \ (_mm_castsi128_ps(_mm_shuffle_epi32( _mm_castps_si128(v), ((s)<<6|(r)<<4|(q)<<2|(p))))) -#define ei_vec4i_swizzle1(v,p,q,r,s) \ +#define vec4i_swizzle1(v,p,q,r,s) \ (_mm_shuffle_epi32( v, ((s)<<6|(r)<<4|(q)<<2|(p)))) -#define ei_vec2d_swizzle1(v,p,q) \ +#define vec2d_swizzle1(v,p,q) \ (_mm_castsi128_pd(_mm_shuffle_epi32( _mm_castpd_si128(v), ((q*2+1)<<6|(q*2)<<4|(p*2+1)<<2|(p*2))))) -#define ei_vec4f_swizzle2(a,b,p,q,r,s) \ +#define vec4f_swizzle2(a,b,p,q,r,s) \ (_mm_shuffle_ps( (a), (b), ((s)<<6|(r)<<4|(q)<<2|(p)))) -#define ei_vec4i_swizzle2(a,b,p,q,r,s) \ +#define vec4i_swizzle2(a,b,p,q,r,s) \ (_mm_castps_si128( (_mm_shuffle_ps( _mm_castsi128_ps(a), _mm_castsi128_ps(b), ((s)<<6|(r)<<4|(q)<<2|(p)))))) #define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \ - const Packet4f ei_p4f_##NAME = ei_pset1<Packet4f>(X) + const Packet4f p4f_##NAME = pset1<Packet4f>(X) #define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \ - const Packet4f ei_p4f_##NAME = _mm_castsi128_ps(ei_pset1<Packet4i>(X)) + const Packet4f p4f_##NAME = _mm_castsi128_ps(pset1<Packet4i>(X)) #define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \ - const Packet4i ei_p4i_##NAME = ei_pset1<Packet4i>(X) + const Packet4i p4i_##NAME = pset1<Packet4i>(X) -template<> struct ei_packet_traits<float> : ei_default_packet_traits +template<> struct packet_traits<float> : default_packet_traits { typedef Packet4f type; enum { @@ -82,7 +84,7 @@ template<> struct ei_packet_traits<float> : ei_default_packet_traits HasSqrt = 1 }; }; -template<> struct ei_packet_traits<double> : ei_default_packet_traits +template<> struct packet_traits<double> : default_packet_traits { typedef Packet2d type; enum { @@ -93,7 +95,7 @@ template<> struct ei_packet_traits<double> : ei_default_packet_traits HasDiv = 1 }; }; -template<> struct ei_packet_traits<int> : ei_default_packet_traits +template<> struct packet_traits<int> : default_packet_traits { typedef Packet4i type; enum { @@ -104,125 +106,125 @@ template<> struct ei_packet_traits<int> : ei_default_packet_traits }; }; -template<> struct ei_unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; -template<> struct ei_unpacket_traits<Packet2d> { typedef double type; enum {size=2}; }; -template<> struct ei_unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; +template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4}; }; +template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2}; }; +template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4}; }; #ifdef __GNUC__ // Sometimes GCC implements _mm_set1_p* using multiple moves, -// that is inefficient :( (e.g., see ei_gemm_pack_rhs) -template<> EIGEN_STRONG_INLINE Packet4f ei_pset1<Packet4f>(const float& from) { +// that is inefficient :( (e.g., see gemm_pack_rhs) +template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float& from) { Packet4f res = _mm_set_ss(from); - return ei_vec4f_swizzle1(res,0,0,0,0); + return vec4f_swizzle1(res,0,0,0,0); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pset1<Packet2d>(const double& from) { +template<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { // NOTE the SSE3 intrinsic _mm_loaddup_pd is never faster but sometimes much slower Packet2d res = _mm_set_sd(from); - return ei_vec2d_swizzle1(res, 0, 0); + return vec2d_swizzle1(res, 0, 0); } #else -template<> EIGEN_STRONG_INLINE Packet4f ei_pset1<Packet4f>(const float& from) { return _mm_set1_ps(from); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pset1<Packet2d>(const double& from) { return _mm_set1_pd(from); } +template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float& from) { return _mm_set1_ps(from); } +template<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set1_pd(from); } #endif -template<> EIGEN_STRONG_INLINE Packet4i ei_pset1<Packet4i>(const int& from) { return _mm_set1_epi32(from); } +template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int& from) { return _mm_set1_epi32(from); } -template<> EIGEN_STRONG_INLINE Packet4f ei_plset<float>(const float& a) { return _mm_add_ps(ei_pset1<Packet4f>(a), _mm_set_ps(3,2,1,0)); } -template<> EIGEN_STRONG_INLINE Packet2d ei_plset<double>(const double& a) { return _mm_add_pd(ei_pset1<Packet2d>(a),_mm_set_pd(1,0)); } -template<> EIGEN_STRONG_INLINE Packet4i ei_plset<int>(const int& a) { return _mm_add_epi32(ei_pset1<Packet4i>(a),_mm_set_epi32(3,2,1,0)); } +template<> EIGEN_STRONG_INLINE Packet4f plset<float>(const float& a) { return _mm_add_ps(pset1<Packet4f>(a), _mm_set_ps(3,2,1,0)); } +template<> EIGEN_STRONG_INLINE Packet2d plset<double>(const double& a) { return _mm_add_pd(pset1<Packet2d>(a),_mm_set_pd(1,0)); } +template<> EIGEN_STRONG_INLINE Packet4i plset<int>(const int& a) { return _mm_add_epi32(pset1<Packet4i>(a),_mm_set_epi32(3,2,1,0)); } -template<> EIGEN_STRONG_INLINE Packet4f ei_padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_add_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_add_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_add_epi32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_add_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_add_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_add_epi32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_sub_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_sub_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_sub_epi32(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_sub_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_sub_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_sub_epi32(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pnegate(const Packet4f& a) +template<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { const Packet4f mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000)); return _mm_xor_ps(a,mask); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pnegate(const Packet2d& a) +template<> EIGEN_STRONG_INLINE Packet2d pnegate(const Packet2d& a) { const Packet2d mask = _mm_castsi128_pd(_mm_setr_epi32(0x0,0x80000000,0x0,0x80000000)); return _mm_xor_pd(a,mask); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pnegate(const Packet4i& a) +template<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { - return ei_psub(_mm_setr_epi32(0,0,0,0), a); + return psub(_mm_setr_epi32(0,0,0,0), a); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_mul_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_mul_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmul<Packet4i>(const Packet4i& a, const Packet4i& b) +template<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_mul_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_mul_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { #ifdef EIGEN_VECTORIZE_SSE4_1 return _mm_mullo_epi32(a,b); #else // this version is slightly faster than 4 scalar products - return ei_vec4i_swizzle1( - ei_vec4i_swizzle2( + return vec4i_swizzle1( + vec4i_swizzle2( _mm_mul_epu32(a,b), - _mm_mul_epu32(ei_vec4i_swizzle1(a,1,0,3,2), - ei_vec4i_swizzle1(b,1,0,3,2)), + _mm_mul_epu32(vec4i_swizzle1(a,1,0,3,2), + vec4i_swizzle1(b,1,0,3,2)), 0,2,0,2), 0,2,1,3); #endif } -template<> EIGEN_STRONG_INLINE Packet4f ei_pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_div_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_div_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) -{ ei_assert(false && "packet integer division are not supported by SSE"); - return ei_pset1<Packet4i>(0); +template<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_div_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_div_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/) +{ eigen_assert(false && "packet integer division are not supported by SSE"); + return pset1<Packet4i>(0); } // for some weird raisons, it has to be overloaded for packet of integers -template<> EIGEN_STRONG_INLINE Packet4i ei_pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return ei_padd(ei_pmul(a,b), c); } +template<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return padd(pmul(a,b), c); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_min_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_min_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmin<Packet4i>(const Packet4i& a, const Packet4i& b) +template<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_min_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_min_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { // after some bench, this version *is* faster than a scalar implementation Packet4i mask = _mm_cmplt_epi32(a,b); return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b)); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_max_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_max_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pmax<Packet4i>(const Packet4i& a, const Packet4i& b) +template<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_max_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_max_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { // after some bench, this version *is* faster than a scalar implementation Packet4i mask = _mm_cmpgt_epi32(a,b); return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b)); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_and_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pand<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_and_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_and_si128(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_and_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_and_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_and_si128(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_por<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_or_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_por<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_or_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_por<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_or_si128(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_or_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d por<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_or_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_or_si128(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_xor_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pxor<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_xor_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_xor_si128(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_xor_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_xor_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_xor_si128(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_andnot_ps(a,b); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_andnot_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_andnot_si128(a,b); } +template<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_andnot_ps(a,b); } +template<> EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_andnot_pd(a,b); } +template<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_andnot_si128(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pload<Packet4f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_ps(from); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pload<Packet2d>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_pd(from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pload<Packet4i>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); } +template<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_ps(from); } +template<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_pd(from); } +template<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); } #if defined(_MSC_VER) - template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu<Packet4f>(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_ps(from); } - template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<Packet2d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_pd(from); } - template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<Packet4i>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); } + template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_ps(from); } + template<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_pd(from); } + template<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); } #else // Fast unaligned loads. Note that here we cannot directly use intrinsics: this would // require pointer casting to incompatible pointer types and leads to invalid code @@ -230,7 +232,7 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_pload<Packet4i>(const int* from) // a correct instruction dependency. // TODO: do the same for MSVC (ICC is compatible) // NOTE: with the code below, MSVC's compiler crashes! -template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu<Packet4f>(const float* from) +template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD __m128d res; @@ -238,7 +240,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu<Packet4f>(const float* from) res = _mm_loadh_pd(res, (const double*)(from+2)) ; return _mm_castpd_ps(res); } -template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<Packet2d>(const double* from) +template<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD __m128d res; @@ -246,7 +248,7 @@ template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<Packet2d>(const double* from) res = _mm_loadh_pd(res,from+1); return res; } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<Packet4i>(const int* from) +template<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD __m128d res; @@ -256,71 +258,71 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<Packet4i>(const int* from) } #endif -template<> EIGEN_STRONG_INLINE Packet4f ei_ploaddup<Packet4f>(const float* from) +template<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float* from) { - return ei_vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd((const double*)from)), 0, 0, 1, 1); + return vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd((const double*)from)), 0, 0, 1, 1); } -template<> EIGEN_STRONG_INLINE Packet2d ei_ploaddup<Packet2d>(const double* from) -{ return ei_pset1<Packet2d>(from[0]); } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploaddup<Packet4i>(const int* from) +template<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double* from) +{ return pset1<Packet2d>(from[0]); } +template<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int* from) { Packet4i tmp; tmp = _mm_loadl_epi64(reinterpret_cast<const Packet4i*>(from)); - return ei_vec4i_swizzle1(tmp, 0, 0, 1, 1); + return vec4i_swizzle1(tmp, 0, 0, 1, 1); } -template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_ps(to, from); } -template<> EIGEN_STRONG_INLINE void ei_pstore<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_pd(to, from); } -template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<Packet4i*>(to), from); } +template<> EIGEN_STRONG_INLINE void pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_ps(to, from); } +template<> EIGEN_STRONG_INLINE void pstore<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_pd(to, from); } +template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<Packet4i*>(to), from); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<double>(double* to, const Packet2d& from) { +template<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm_storel_pd((to), from); _mm_storeh_pd((to+1), from); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((double*)to, _mm_castps_pd(from)); } -template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((double*)to, _mm_castsi128_pd(from)); } +template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, _mm_castps_pd(from)); } +template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, _mm_castsi128_pd(from)); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<float>(const float* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } -template<> EIGEN_STRONG_INLINE void ei_prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } +template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } +template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } +template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } #if defined(_MSC_VER) && (_MSC_VER <= 1500) && defined(_WIN64) && !defined(__INTEL_COMPILER) // The temporary variable fixes an internal compilation error. // Direct of the struct members fixed bug #62. -template<> EIGEN_STRONG_INLINE float ei_pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; } -template<> EIGEN_STRONG_INLINE double ei_pfirst<Packet2d>(const Packet2d& a) { return a.m128d_f64[0]; } -template<> EIGEN_STRONG_INLINE int ei_pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; } +template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; } +template<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { return a.m128d_f64[0]; } +template<> EIGEN_STRONG_INLINE int pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; } #elif defined(_MSC_VER) && (_MSC_VER <= 1500) && !defined(__INTEL_COMPILER) // The temporary variable fixes an internal compilation error. -template<> EIGEN_STRONG_INLINE float ei_pfirst<Packet4f>(const Packet4f& a) { float x = _mm_cvtss_f32(a); return x; } -template<> EIGEN_STRONG_INLINE double ei_pfirst<Packet2d>(const Packet2d& a) { double x = _mm_cvtsd_f64(a); return x; } -template<> EIGEN_STRONG_INLINE int ei_pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; } +template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { float x = _mm_cvtss_f32(a); return x; } +template<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { double x = _mm_cvtsd_f64(a); return x; } +template<> EIGEN_STRONG_INLINE int pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; } #else -template<> EIGEN_STRONG_INLINE float ei_pfirst<Packet4f>(const Packet4f& a) { return _mm_cvtss_f32(a); } -template<> EIGEN_STRONG_INLINE double ei_pfirst<Packet2d>(const Packet2d& a) { return _mm_cvtsd_f64(a); } -template<> EIGEN_STRONG_INLINE int ei_pfirst<Packet4i>(const Packet4i& a) { return _mm_cvtsi128_si32(a); } +template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return _mm_cvtss_f32(a); } +template<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { return _mm_cvtsd_f64(a); } +template<> EIGEN_STRONG_INLINE int pfirst<Packet4i>(const Packet4i& a) { return _mm_cvtsi128_si32(a); } #endif -template<> EIGEN_STRONG_INLINE Packet4f ei_preverse(const Packet4f& a) +template<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a) { return _mm_shuffle_ps(a,a,0x1B); } -template<> EIGEN_STRONG_INLINE Packet2d ei_preverse(const Packet2d& a) +template<> EIGEN_STRONG_INLINE Packet2d preverse(const Packet2d& a) { return _mm_shuffle_pd(a,a,0x1); } -template<> EIGEN_STRONG_INLINE Packet4i ei_preverse(const Packet4i& a) +template<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a) { return _mm_shuffle_epi32(a,0x1B); } -template<> EIGEN_STRONG_INLINE Packet4f ei_pabs(const Packet4f& a) +template<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a) { const Packet4f mask = _mm_castsi128_ps(_mm_setr_epi32(0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF)); return _mm_and_ps(a,mask); } -template<> EIGEN_STRONG_INLINE Packet2d ei_pabs(const Packet2d& a) +template<> EIGEN_STRONG_INLINE Packet2d pabs(const Packet2d& a) { const Packet2d mask = _mm_castsi128_pd(_mm_setr_epi32(0xFFFFFFFF,0x7FFFFFFF,0xFFFFFFFF,0x7FFFFFFF)); return _mm_and_pd(a,mask); } -template<> EIGEN_STRONG_INLINE Packet4i ei_pabs(const Packet4i& a) +template<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a) { #ifdef EIGEN_VECTORIZE_SSSE3 return _mm_abs_epi32(a); @@ -330,7 +332,7 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_pabs(const Packet4i& a) #endif } -EIGEN_STRONG_INLINE void ei_punpackp(Packet4f* vecs) +EIGEN_STRONG_INLINE void punpackp(Packet4f* vecs) { vecs[1] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0x55)); vecs[2] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0xAA)); @@ -340,47 +342,47 @@ EIGEN_STRONG_INLINE void ei_punpackp(Packet4f* vecs) #ifdef EIGEN_VECTORIZE_SSE3 // TODO implement SSE2 versions as well as integer versions -template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vecs) +template<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs) { return _mm_hadd_ps(_mm_hadd_ps(vecs[0], vecs[1]),_mm_hadd_ps(vecs[2], vecs[3])); } -template<> EIGEN_STRONG_INLINE Packet2d ei_preduxp<Packet2d>(const Packet2d* vecs) +template<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs) { return _mm_hadd_pd(vecs[0], vecs[1]); } // SSSE3 version: -// EIGEN_STRONG_INLINE Packet4i ei_preduxp(const Packet4i* vecs) +// EIGEN_STRONG_INLINE Packet4i preduxp(const Packet4i* vecs) // { // return _mm_hadd_epi32(_mm_hadd_epi32(vecs[0], vecs[1]),_mm_hadd_epi32(vecs[2], vecs[3])); // } -template<> EIGEN_STRONG_INLINE float ei_predux<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a) { Packet4f tmp0 = _mm_hadd_ps(a,a); - return ei_pfirst(_mm_hadd_ps(tmp0, tmp0)); + return pfirst(_mm_hadd_ps(tmp0, tmp0)); } -template<> EIGEN_STRONG_INLINE double ei_predux<Packet2d>(const Packet2d& a) { return ei_pfirst(_mm_hadd_pd(a, a)); } +template<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a) { return pfirst(_mm_hadd_pd(a, a)); } // SSSE3 version: -// EIGEN_STRONG_INLINE float ei_predux(const Packet4i& a) +// EIGEN_STRONG_INLINE float predux(const Packet4i& a) // { // Packet4i tmp0 = _mm_hadd_epi32(a,a); -// return ei_pfirst(_mm_hadd_epi32(tmp0, tmp0)); +// return pfirst(_mm_hadd_epi32(tmp0, tmp0)); // } #else // SSE2 versions -template<> EIGEN_STRONG_INLINE float ei_predux<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a) { Packet4f tmp = _mm_add_ps(a, _mm_movehl_ps(a,a)); - return ei_pfirst(_mm_add_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); + return pfirst(_mm_add_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); } -template<> EIGEN_STRONG_INLINE double ei_predux<Packet2d>(const Packet2d& a) +template<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a) { - return ei_pfirst(_mm_add_sd(a, _mm_unpackhi_pd(a,a))); + return pfirst(_mm_add_sd(a, _mm_unpackhi_pd(a,a))); } -template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vecs) +template<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs) { Packet4f tmp0, tmp1, tmp2; tmp0 = _mm_unpacklo_ps(vecs[0], vecs[1]); @@ -394,19 +396,19 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_preduxp<Packet4f>(const Packet4f* vec return _mm_add_ps(tmp0, tmp2); } -template<> EIGEN_STRONG_INLINE Packet2d ei_preduxp<Packet2d>(const Packet2d* vecs) +template<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs) { return _mm_add_pd(_mm_unpacklo_pd(vecs[0], vecs[1]), _mm_unpackhi_pd(vecs[0], vecs[1])); } #endif // SSE3 -template<> EIGEN_STRONG_INLINE int ei_predux<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a) { Packet4i tmp = _mm_add_epi32(a, _mm_unpackhi_epi64(a,a)); - return ei_pfirst(tmp) + ei_pfirst(_mm_shuffle_epi32(tmp, 1)); + return pfirst(tmp) + pfirst(_mm_shuffle_epi32(tmp, 1)); } -template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vecs) +template<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs) { Packet4i tmp0, tmp1, tmp2; tmp0 = _mm_unpacklo_epi32(vecs[0], vecs[1]); @@ -423,69 +425,69 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_preduxp<Packet4i>(const Packet4i* vec // Other reduction functions: // mul -template<> EIGEN_STRONG_INLINE float ei_predux_mul<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a) { Packet4f tmp = _mm_mul_ps(a, _mm_movehl_ps(a,a)); - return ei_pfirst(_mm_mul_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); + return pfirst(_mm_mul_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); } -template<> EIGEN_STRONG_INLINE double ei_predux_mul<Packet2d>(const Packet2d& a) +template<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a) { - return ei_pfirst(_mm_mul_sd(a, _mm_unpackhi_pd(a,a))); + return pfirst(_mm_mul_sd(a, _mm_unpackhi_pd(a,a))); } -template<> EIGEN_STRONG_INLINE int ei_predux_mul<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a) { // after some experiments, it is seems this is the fastest way to implement it - // for GCC (eg., reusing ei_pmul is very slow !) + // for GCC (eg., reusing pmul is very slow !) // TODO try to call _mm_mul_epu32 directly EIGEN_ALIGN16 int aux[4]; - ei_pstore(aux, a); + pstore(aux, a); return (aux[0] * aux[1]) * (aux[2] * aux[3]);; } // min -template<> EIGEN_STRONG_INLINE float ei_predux_min<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a) { Packet4f tmp = _mm_min_ps(a, _mm_movehl_ps(a,a)); - return ei_pfirst(_mm_min_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); + return pfirst(_mm_min_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); } -template<> EIGEN_STRONG_INLINE double ei_predux_min<Packet2d>(const Packet2d& a) +template<> EIGEN_STRONG_INLINE double predux_min<Packet2d>(const Packet2d& a) { - return ei_pfirst(_mm_min_sd(a, _mm_unpackhi_pd(a,a))); + return pfirst(_mm_min_sd(a, _mm_unpackhi_pd(a,a))); } -template<> EIGEN_STRONG_INLINE int ei_predux_min<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a) { // after some experiments, it is seems this is the fastest way to implement it - // for GCC (eg., it does not like using std::min after the ei_pstore !!) + // for GCC (eg., it does not like using std::min after the pstore !!) EIGEN_ALIGN16 int aux[4]; - ei_pstore(aux, a); + pstore(aux, a); register int aux0 = aux[0]<aux[1] ? aux[0] : aux[1]; register int aux2 = aux[2]<aux[3] ? aux[2] : aux[3]; return aux0<aux2 ? aux0 : aux2; } // max -template<> EIGEN_STRONG_INLINE float ei_predux_max<Packet4f>(const Packet4f& a) +template<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a) { Packet4f tmp = _mm_max_ps(a, _mm_movehl_ps(a,a)); - return ei_pfirst(_mm_max_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); + return pfirst(_mm_max_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1))); } -template<> EIGEN_STRONG_INLINE double ei_predux_max<Packet2d>(const Packet2d& a) +template<> EIGEN_STRONG_INLINE double predux_max<Packet2d>(const Packet2d& a) { - return ei_pfirst(_mm_max_sd(a, _mm_unpackhi_pd(a,a))); + return pfirst(_mm_max_sd(a, _mm_unpackhi_pd(a,a))); } -template<> EIGEN_STRONG_INLINE int ei_predux_max<Packet4i>(const Packet4i& a) +template<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a) { // after some experiments, it is seems this is the fastest way to implement it - // for GCC (eg., it does not like using std::min after the ei_pstore !!) + // for GCC (eg., it does not like using std::min after the pstore !!) EIGEN_ALIGN16 int aux[4]; - ei_pstore(aux, a); + pstore(aux, a); register int aux0 = aux[0]>aux[1] ? aux[0] : aux[1]; register int aux2 = aux[2]>aux[3] ? aux[2] : aux[3]; return aux0>aux2 ? aux0 : aux2; } #if (defined __GNUC__) -// template <> EIGEN_STRONG_INLINE Packet4f ei_pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) +// template <> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) // { // Packet4f res = b; // asm("mulps %[a], %[b] \n\taddps %[c], %[b]" : [b] "+x" (res) : [a] "x" (a), [c] "x" (c)); @@ -502,7 +504,7 @@ template<> EIGEN_STRONG_INLINE int ei_predux_max<Packet4i>(const Packet4i& a) #ifdef EIGEN_VECTORIZE_SSSE3 // SSSE3 versions template<int Offset> -struct ei_palign_impl<Offset,Packet4f> +struct palign_impl<Offset,Packet4f> { EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second) { @@ -512,7 +514,7 @@ struct ei_palign_impl<Offset,Packet4f> }; template<int Offset> -struct ei_palign_impl<Offset,Packet4i> +struct palign_impl<Offset,Packet4i> { EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second) { @@ -522,7 +524,7 @@ struct ei_palign_impl<Offset,Packet4i> }; template<int Offset> -struct ei_palign_impl<Offset,Packet2d> +struct palign_impl<Offset,Packet2d> { EIGEN_STRONG_INLINE static void run(Packet2d& first, const Packet2d& second) { @@ -533,7 +535,7 @@ struct ei_palign_impl<Offset,Packet2d> #else // SSE2 versions template<int Offset> -struct ei_palign_impl<Offset,Packet4f> +struct palign_impl<Offset,Packet4f> { EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second) { @@ -556,7 +558,7 @@ struct ei_palign_impl<Offset,Packet4f> }; template<int Offset> -struct ei_palign_impl<Offset,Packet4i> +struct palign_impl<Offset,Packet4i> { EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second) { @@ -579,7 +581,7 @@ struct ei_palign_impl<Offset,Packet4i> }; template<int Offset> -struct ei_palign_impl<Offset,Packet2d> +struct palign_impl<Offset,Packet2d> { EIGEN_STRONG_INLINE static void run(Packet2d& first, const Packet2d& second) { @@ -592,4 +594,6 @@ struct ei_palign_impl<Offset,Packet2d> }; #endif +} // end namespace internal + #endif // EIGEN_PACKET_MATH_SSE_H diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index d2e693861..e1f19d787 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -26,6 +26,8 @@ #ifndef EIGEN_COEFFBASED_PRODUCT_H #define EIGEN_COEFFBASED_PRODUCT_H +namespace internal { + /********************************************************************************* * Coefficient based product implementation. * It is designed for the following use cases: @@ -40,22 +42,22 @@ */ template<int Traversal, int UnrollingIndex, typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl; +struct product_coeff_impl; template<int StorageOrder, int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl; +struct product_packet_impl; template<typename LhsNested, typename RhsNested, int NestingFlags> -struct ei_traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> > +struct traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> > { typedef MatrixXpr XprKind; - typedef typename ei_cleantype<LhsNested>::type _LhsNested; - typedef typename ei_cleantype<RhsNested>::type _RhsNested; - typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar; - typedef typename ei_promote_storage_type<typename ei_traits<_LhsNested>::StorageKind, - typename ei_traits<_RhsNested>::StorageKind>::ret StorageKind; - typedef typename ei_promote_index_type<typename ei_traits<_LhsNested>::Index, - typename ei_traits<_RhsNested>::Index>::type Index; + typedef typename cleantype<LhsNested>::type _LhsNested; + typedef typename cleantype<RhsNested>::type _RhsNested; + typedef typename scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar; + typedef typename promote_storage_type<typename traits<_LhsNested>::StorageKind, + typename traits<_RhsNested>::StorageKind>::ret StorageKind; + typedef typename promote_index_type<typename traits<_LhsNested>::Index, + typename traits<_RhsNested>::Index>::type Index; enum { LhsCoeffReadCost = _LhsNested::CoeffReadCost, @@ -73,18 +75,18 @@ struct ei_traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> > LhsRowMajor = LhsFlags & RowMajorBit, RhsRowMajor = RhsFlags & RowMajorBit, - SameType = ei_is_same_type<typename _LhsNested::Scalar,typename _RhsNested::Scalar>::ret, + SameType = is_same_type<typename _LhsNested::Scalar,typename _RhsNested::Scalar>::ret, CanVectorizeRhs = RhsRowMajor && (RhsFlags & PacketAccessBit) && (ColsAtCompileTime == Dynamic - || ( (ColsAtCompileTime % ei_packet_traits<Scalar>::size) == 0 + || ( (ColsAtCompileTime % packet_traits<Scalar>::size) == 0 && (RhsFlags&AlignedBit) ) ), CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags & PacketAccessBit) && (RowsAtCompileTime == Dynamic - || ( (RowsAtCompileTime % ei_packet_traits<Scalar>::size) == 0 + || ( (RowsAtCompileTime % packet_traits<Scalar>::size) == 0 && (LhsFlags&AlignedBit) ) ), @@ -113,13 +115,15 @@ struct ei_traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> > && (!RhsRowMajor) && (LhsFlags & RhsFlags & ActualPacketAccessBit) && (LhsFlags & RhsFlags & AlignedBit) - && (InnerSize % ei_packet_traits<Scalar>::size == 0) + && (InnerSize % packet_traits<Scalar>::size == 0) }; }; +} // end namespace internal + template<typename LhsNested, typename RhsNested, int NestingFlags> class CoeffBasedProduct - : ei_no_assignment_operator, + : internal::no_assignment_operator, public MatrixBase<CoeffBasedProduct<LhsNested, RhsNested, NestingFlags> > { public: @@ -130,19 +134,19 @@ class CoeffBasedProduct private: - typedef typename ei_traits<CoeffBasedProduct>::_LhsNested _LhsNested; - typedef typename ei_traits<CoeffBasedProduct>::_RhsNested _RhsNested; + typedef typename internal::traits<CoeffBasedProduct>::_LhsNested _LhsNested; + typedef typename internal::traits<CoeffBasedProduct>::_RhsNested _RhsNested; enum { - PacketSize = ei_packet_traits<Scalar>::size, - InnerSize = ei_traits<CoeffBasedProduct>::InnerSize, + PacketSize = internal::packet_traits<Scalar>::size, + InnerSize = internal::traits<CoeffBasedProduct>::InnerSize, Unroll = CoeffReadCost != Dynamic && CoeffReadCost <= EIGEN_UNROLLING_LIMIT, - CanVectorizeInner = ei_traits<CoeffBasedProduct>::CanVectorizeInner + CanVectorizeInner = internal::traits<CoeffBasedProduct>::CanVectorizeInner }; - typedef ei_product_coeff_impl<CanVectorizeInner ? InnerVectorizedTraversal : DefaultTraversal, - Unroll ? InnerSize-1 : Dynamic, - _LhsNested, _RhsNested, Scalar> ScalarCoeffImpl; + typedef internal::product_coeff_impl<CanVectorizeInner ? InnerVectorizedTraversal : DefaultTraversal, + Unroll ? InnerSize-1 : Dynamic, + _LhsNested, _RhsNested, Scalar> ScalarCoeffImpl; typedef CoeffBasedProduct<LhsNested,RhsNested,NestByRefBit> LazyCoeffBasedProductType; @@ -158,9 +162,9 @@ class CoeffBasedProduct { // we don't allow taking products of matrices of different real types, as that wouldn't be vectorizable. // We still allow to mix T and complex<T>. - EIGEN_STATIC_ASSERT((ei_is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - ei_assert(lhs.cols() == rhs.rows() + eigen_assert(lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); } @@ -191,9 +195,9 @@ class CoeffBasedProduct EIGEN_STRONG_INLINE const PacketScalar packet(Index row, Index col) const { PacketScalar res; - ei_product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor, - Unroll ? InnerSize-1 : Dynamic, - _LhsNested, _RhsNested, PacketScalar, LoadMode> + internal::product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor, + Unroll ? InnerSize-1 : Dynamic, + _LhsNested, _RhsNested, PacketScalar, LoadMode> ::run(row, col, m_lhs, m_rhs, res); return res; } @@ -225,10 +229,12 @@ class CoeffBasedProduct mutable PlainObject m_result; }; +namespace internal { + // here we need to overload the nested rule for products // such that the nested type is a const reference to a plain matrix template<typename Lhs, typename Rhs, int N, typename PlainObject> -struct ei_nested<CoeffBasedProduct<Lhs,Rhs,EvalBeforeNestingBit|EvalBeforeAssigningBit>, N, PlainObject> +struct nested<CoeffBasedProduct<Lhs,Rhs,EvalBeforeNestingBit|EvalBeforeAssigningBit>, N, PlainObject> { typedef PlainObject const& type; }; @@ -242,18 +248,18 @@ struct ei_nested<CoeffBasedProduct<Lhs,Rhs,EvalBeforeNestingBit|EvalBeforeAssign **************************************/ template<int UnrollingIndex, typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl<DefaultTraversal, UnrollingIndex, Lhs, Rhs, RetScalar> +struct product_coeff_impl<DefaultTraversal, UnrollingIndex, Lhs, Rhs, RetScalar> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res) { - ei_product_coeff_impl<DefaultTraversal, UnrollingIndex-1, Lhs, Rhs, RetScalar>::run(row, col, lhs, rhs, res); + product_coeff_impl<DefaultTraversal, UnrollingIndex-1, Lhs, Rhs, RetScalar>::run(row, col, lhs, rhs, res); res += lhs.coeff(row, UnrollingIndex) * rhs.coeff(UnrollingIndex, col); } }; template<typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar> +struct product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res) @@ -263,12 +269,12 @@ struct ei_product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar> }; template<typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl<DefaultTraversal, Dynamic, Lhs, Rhs, RetScalar> +struct product_coeff_impl<DefaultTraversal, Dynamic, Lhs, Rhs, RetScalar> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar& res) { - ei_assert(lhs.cols()>0 && "you are using a non initialized matrix"); + eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix"); res = lhs.coeff(row, 0) * rhs.coeff(0, col); for(Index i = 1; i < lhs.cols(); ++i) res += lhs.coeff(row, i) * rhs.coeff(i, col); @@ -280,44 +286,44 @@ struct ei_product_coeff_impl<DefaultTraversal, Dynamic, Lhs, Rhs, RetScalar> *******************************************/ template<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet> -struct ei_product_coeff_vectorized_unroller +struct product_coeff_vectorized_unroller { typedef typename Lhs::Index Index; - enum { PacketSize = ei_packet_traits<typename Lhs::Scalar>::size }; + enum { PacketSize = packet_traits<typename Lhs::Scalar>::size }; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres) { - ei_product_coeff_vectorized_unroller<UnrollingIndex-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres); - pres = ei_padd(pres, ei_pmul( lhs.template packet<Aligned>(row, UnrollingIndex) , rhs.template packet<Aligned>(UnrollingIndex, col) )); + product_coeff_vectorized_unroller<UnrollingIndex-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres); + pres = padd(pres, pmul( lhs.template packet<Aligned>(row, UnrollingIndex) , rhs.template packet<Aligned>(UnrollingIndex, col) )); } }; template<typename Lhs, typename Rhs, typename Packet> -struct ei_product_coeff_vectorized_unroller<0, Lhs, Rhs, Packet> +struct product_coeff_vectorized_unroller<0, Lhs, Rhs, Packet> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres) { - pres = ei_pmul(lhs.template packet<Aligned>(row, 0) , rhs.template packet<Aligned>(0, col)); + pres = pmul(lhs.template packet<Aligned>(row, 0) , rhs.template packet<Aligned>(0, col)); } }; template<int UnrollingIndex, typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl<InnerVectorizedTraversal, UnrollingIndex, Lhs, Rhs, RetScalar> +struct product_coeff_impl<InnerVectorizedTraversal, UnrollingIndex, Lhs, Rhs, RetScalar> { typedef typename Lhs::PacketScalar Packet; typedef typename Lhs::Index Index; - enum { PacketSize = ei_packet_traits<typename Lhs::Scalar>::size }; + enum { PacketSize = packet_traits<typename Lhs::Scalar>::size }; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res) { Packet pres; - ei_product_coeff_vectorized_unroller<UnrollingIndex+1-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres); - ei_product_coeff_impl<DefaultTraversal,UnrollingIndex,Lhs,Rhs,RetScalar>::run(row, col, lhs, rhs, res); - res = ei_predux(pres); + product_coeff_vectorized_unroller<UnrollingIndex+1-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres); + product_coeff_impl<DefaultTraversal,UnrollingIndex,Lhs,Rhs,RetScalar>::run(row, col, lhs, rhs, res); + res = predux(pres); } }; template<typename Lhs, typename Rhs, int LhsRows = Lhs::RowsAtCompileTime, int RhsCols = Rhs::ColsAtCompileTime> -struct ei_product_coeff_vectorized_dyn_selector +struct product_coeff_vectorized_dyn_selector { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) @@ -329,7 +335,7 @@ struct ei_product_coeff_vectorized_dyn_selector // NOTE the 3 following specializations are because taking .col(0) on a vector is a bit slower // NOTE maybe they are now useless since we have a specialization for Block<Matrix> template<typename Lhs, typename Rhs, int RhsCols> -struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,RhsCols> +struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,RhsCols> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index /*row*/, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) @@ -339,7 +345,7 @@ struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,RhsCols> }; template<typename Lhs, typename Rhs, int LhsRows> -struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,LhsRows,1> +struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,LhsRows,1> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) @@ -349,7 +355,7 @@ struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,LhsRows,1> }; template<typename Lhs, typename Rhs> -struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,1> +struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,1> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index /*row*/, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) @@ -359,12 +365,12 @@ struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,1> }; template<typename Lhs, typename Rhs, typename RetScalar> -struct ei_product_coeff_impl<InnerVectorizedTraversal, Dynamic, Lhs, Rhs, RetScalar> +struct product_coeff_impl<InnerVectorizedTraversal, Dynamic, Lhs, Rhs, RetScalar> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) { - ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs>::run(row, col, lhs, rhs, res); + product_coeff_vectorized_dyn_selector<Lhs,Rhs>::run(row, col, lhs, rhs, res); } }; @@ -373,71 +379,73 @@ struct ei_product_coeff_impl<InnerVectorizedTraversal, Dynamic, Lhs, Rhs, RetSca *******************/ template<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res) { - ei_product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res); - res = ei_pmadd(ei_pset1<Packet>(lhs.coeff(row, UnrollingIndex)), rhs.template packet<LoadMode>(UnrollingIndex, col), res); + product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res); + res = pmadd(pset1<Packet>(lhs.coeff(row, UnrollingIndex)), rhs.template packet<LoadMode>(UnrollingIndex, col), res); } }; template<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res) { - ei_product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res); - res = ei_pmadd(lhs.template packet<LoadMode>(row, UnrollingIndex), ei_pset1<Packet>(rhs.coeff(UnrollingIndex, col)), res); + product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res); + res = pmadd(lhs.template packet<LoadMode>(row, UnrollingIndex), pset1<Packet>(rhs.coeff(UnrollingIndex, col)), res); } }; template<typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res) { - res = ei_pmul(ei_pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col)); + res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col)); } }; template<typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res) { - res = ei_pmul(lhs.template packet<LoadMode>(row, 0), ei_pset1<Packet>(rhs.coeff(0, col))); + res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col))); } }; template<typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res) { - ei_assert(lhs.cols()>0 && "you are using a non initialized matrix"); - res = ei_pmul(ei_pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col)); + eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix"); + res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col)); for(Index i = 1; i < lhs.cols(); ++i) - res = ei_pmadd(ei_pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode>(i, col), res); + res = pmadd(pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode>(i, col), res); } }; template<typename Lhs, typename Rhs, typename Packet, int LoadMode> -struct ei_product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> +struct product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> { typedef typename Lhs::Index Index; EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res) { - ei_assert(lhs.cols()>0 && "you are using a non initialized matrix"); - res = ei_pmul(lhs.template packet<LoadMode>(row, 0), ei_pset1<Packet>(rhs.coeff(0, col))); + eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix"); + res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col))); for(Index i = 1; i < lhs.cols(); ++i) - res = ei_pmadd(lhs.template packet<LoadMode>(row, i), ei_pset1<Packet>(rhs.coeff(i, col)), res); + res = pmadd(lhs.template packet<LoadMode>(row, i), pset1<Packet>(rhs.coeff(i, col)), res); } }; +} // end namespace internal + #endif // EIGEN_COEFFBASED_PRODUCT_H diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 7e2d496fe..94ed792f7 100644 --- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -25,18 +25,20 @@ #ifndef EIGEN_GENERAL_BLOCK_PANEL_H #define EIGEN_GENERAL_BLOCK_PANEL_H +namespace internal { + template<typename _LhsScalar, typename _RhsScalar, bool _ConjLhs=false, bool _ConjRhs=false> -class ei_gebp_traits; +class gebp_traits; /** \internal */ -inline void ei_manage_caching_sizes(Action action, std::ptrdiff_t* l1=0, std::ptrdiff_t* l2=0) +inline void manage_caching_sizes(Action action, std::ptrdiff_t* l1=0, std::ptrdiff_t* l2=0) { static std::ptrdiff_t m_l1CacheSize = 0; static std::ptrdiff_t m_l2CacheSize = 0; if(m_l1CacheSize==0) { - m_l1CacheSize = ei_queryL1CacheSize(); - m_l2CacheSize = ei_queryTopLevelCacheSize(); + m_l1CacheSize = queryL1CacheSize(); + m_l2CacheSize = queryTopLevelCacheSize(); if(m_l1CacheSize<=0) m_l1CacheSize = 8 * 1024; if(m_l2CacheSize<=0) m_l2CacheSize = 1 * 1024 * 1024; @@ -45,50 +47,22 @@ inline void ei_manage_caching_sizes(Action action, std::ptrdiff_t* l1=0, std::pt if(action==SetAction) { // set the cpu cache size and cache all block sizes from a global cache size in byte - ei_internal_assert(l1!=0 && l2!=0); + eigen_internal_assert(l1!=0 && l2!=0); m_l1CacheSize = *l1; m_l2CacheSize = *l2; } else if(action==GetAction) { - ei_internal_assert(l1!=0 && l2!=0); + eigen_internal_assert(l1!=0 && l2!=0); *l1 = m_l1CacheSize; *l2 = m_l2CacheSize; } else { - ei_internal_assert(false); + eigen_internal_assert(false); } } -/** \returns the currently set level 1 cpu cache size (in bytes) used to estimate the ideal blocking size parameters. - * \sa setCpuCacheSize */ -inline std::ptrdiff_t l1CacheSize() -{ - std::ptrdiff_t l1, l2; - ei_manage_caching_sizes(GetAction, &l1, &l2); - return l1; -} - -/** \returns the currently set level 2 cpu cache size (in bytes) used to estimate the ideal blocking size parameters. - * \sa setCpuCacheSize */ -inline std::ptrdiff_t l2CacheSize() -{ - std::ptrdiff_t l1, l2; - ei_manage_caching_sizes(GetAction, &l1, &l2); - return l2; -} - -/** Set the cpu L1 and L2 cache sizes (in bytes). - * These values are use to adjust the size of the blocks - * for the algorithms working per blocks. - * - * \sa computeProductBlockingSizes */ -inline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2) -{ - ei_manage_caching_sizes(SetAction, &l1, &l2); -} - /** \brief Computes the blocking parameters for a m x k times k x n matrix product * * \param[in,out] k Input: the third dimension of the product. Output: the blocking size along the same dimension. @@ -100,7 +74,7 @@ inline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2) * for matrix products and related algorithms. The blocking sizes depends on various * parameters: * - the L1 and L2 cache sizes, - * - the register level blocking sizes defined by ei_gebp_traits, + * - the register level blocking sizes defined by gebp_traits, * - the number of scalars that fit into a packet (when vectorization is enabled). * * \sa setCpuCacheSizes */ @@ -116,15 +90,15 @@ void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, std::ptrd // stay in L1 cache. std::ptrdiff_t l1, l2; - typedef ei_gebp_traits<LhsScalar,RhsScalar> Traits; + typedef gebp_traits<LhsScalar,RhsScalar> Traits; enum { kdiv = KcFactor * 2 * Traits::nr * Traits::RhsProgress * sizeof(RhsScalar), - mr = ei_gebp_traits<LhsScalar,RhsScalar>::mr, + mr = gebp_traits<LhsScalar,RhsScalar>::mr, mr_mask = (0xffffffff/mr)*mr }; - ei_manage_caching_sizes(GetAction, &l1, &l2); + manage_caching_sizes(GetAction, &l1, &l2); k = std::min<std::ptrdiff_t>(k, l1/kdiv); std::ptrdiff_t _m = k>0 ? l2/(4 * sizeof(LhsScalar) * k) : 0; if(_m<m) m = _m & mr_mask; @@ -143,28 +117,28 @@ inline void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, st // FIXME (a bit overkill maybe ?) - template<typename CJ, typename A, typename B, typename C, typename T> struct ei_gebp_madd_selector { + template<typename CJ, typename A, typename B, typename C, typename T> struct gebp_madd_selector { EIGEN_STRONG_INLINE EIGEN_ALWAYS_INLINE_ATTRIB static void run(const CJ& cj, A& a, B& b, C& c, T& /*t*/) { c = cj.pmadd(a,b,c); } }; - template<typename CJ, typename T> struct ei_gebp_madd_selector<CJ,T,T,T,T> { + template<typename CJ, typename T> struct gebp_madd_selector<CJ,T,T,T,T> { EIGEN_STRONG_INLINE EIGEN_ALWAYS_INLINE_ATTRIB static void run(const CJ& cj, T& a, T& b, T& c, T& t) { - t = b; t = cj.pmul(a,t); c = ei_padd(c,t); + t = b; t = cj.pmul(a,t); c = padd(c,t); } }; template<typename CJ, typename A, typename B, typename C, typename T> - EIGEN_STRONG_INLINE void ei_gebp_madd(const CJ& cj, A& a, B& b, C& c, T& t) + EIGEN_STRONG_INLINE void gebp_madd(const CJ& cj, A& a, B& b, C& c, T& t) { - ei_gebp_madd_selector<CJ,A,B,C,T>::run(cj,a,b,c,t); + gebp_madd_selector<CJ,A,B,C,T>::run(cj,a,b,c,t); } - #define MADD(CJ,A,B,C,T) ei_gebp_madd(CJ,A,B,C,T); -// #define MADD(CJ,A,B,C,T) T = B; T = CJ.pmul(A,T); C = ei_padd(C,T); + #define MADD(CJ,A,B,C,T) gebp_madd(CJ,A,B,C,T); +// #define MADD(CJ,A,B,C,T) T = B; T = CJ.pmul(A,T); C = padd(C,T); #endif /* Vectorization logic @@ -178,20 +152,20 @@ inline void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, st * real*cplx : load lhs as (a0,a0,a1,a1), and mul as usual */ template<typename _LhsScalar, typename _RhsScalar, bool _ConjLhs, bool _ConjRhs> -class ei_gebp_traits +class gebp_traits { public: typedef _LhsScalar LhsScalar; typedef _RhsScalar RhsScalar; - typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; + typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; enum { ConjLhs = _ConjLhs, ConjRhs = _ConjRhs, - Vectorizable = ei_packet_traits<LhsScalar>::Vectorizable && ei_packet_traits<RhsScalar>::Vectorizable, - LhsPacketSize = Vectorizable ? ei_packet_traits<LhsScalar>::size : 1, - RhsPacketSize = Vectorizable ? ei_packet_traits<RhsScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1, + Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable, + LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1, + RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1, NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS, @@ -207,67 +181,67 @@ public: RhsProgress = RhsPacketSize }; - typedef typename ei_packet_traits<LhsScalar>::type _LhsPacket; - typedef typename ei_packet_traits<RhsScalar>::type _RhsPacket; - typedef typename ei_packet_traits<ResScalar>::type _ResPacket; + typedef typename packet_traits<LhsScalar>::type _LhsPacket; + typedef typename packet_traits<RhsScalar>::type _RhsPacket; + typedef typename packet_traits<ResScalar>::type _ResPacket; - typedef typename ei_meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; - typedef typename ei_meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; - typedef typename ei_meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; + typedef typename meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; + typedef typename meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; + typedef typename meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; typedef ResPacket AccPacket; EIGEN_STRONG_INLINE void initAcc(AccPacket& p) { - p = ei_pset1<ResPacket>(ResScalar(0)); + p = pset1<ResPacket>(ResScalar(0)); } EIGEN_STRONG_INLINE void unpackRhs(DenseIndex n, const RhsScalar* rhs, RhsScalar* b) { for(DenseIndex k=0; k<n; k++) - ei_pstore(&b[k*RhsPacketSize], ei_pset1<RhsPacket>(rhs[k])); + pstore(&b[k*RhsPacketSize], pset1<RhsPacket>(rhs[k])); } EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacket& dest) const { - dest = ei_pload<RhsPacket>(b); + dest = pload<RhsPacket>(b); } EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const { - dest = ei_pload<LhsPacket>(a); + dest = pload<LhsPacket>(a); } EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, AccPacket& c, AccPacket& tmp) const { - tmp = b; tmp = ei_pmul(a,tmp); c = ei_padd(c,tmp); + tmp = b; tmp = pmul(a,tmp); c = padd(c,tmp); } EIGEN_STRONG_INLINE void acc(const AccPacket& c, const ResPacket& alpha, ResPacket& r) const { - r = ei_pmadd(c,alpha,r); + r = pmadd(c,alpha,r); } protected: -// ei_conj_helper<LhsScalar,RhsScalar,ConjLhs,ConjRhs> cj; -// ei_conj_helper<LhsPacket,RhsPacket,ConjLhs,ConjRhs> pcj; +// conj_helper<LhsScalar,RhsScalar,ConjLhs,ConjRhs> cj; +// conj_helper<LhsPacket,RhsPacket,ConjLhs,ConjRhs> pcj; }; template<typename RealScalar, bool _ConjLhs> -class ei_gebp_traits<std::complex<RealScalar>, RealScalar, _ConjLhs, false> +class gebp_traits<std::complex<RealScalar>, RealScalar, _ConjLhs, false> { public: typedef std::complex<RealScalar> LhsScalar; typedef RealScalar RhsScalar; - typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; + typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; enum { ConjLhs = _ConjLhs, ConjRhs = false, - Vectorizable = ei_packet_traits<LhsScalar>::Vectorizable && ei_packet_traits<RhsScalar>::Vectorizable, - LhsPacketSize = Vectorizable ? ei_packet_traits<LhsScalar>::size : 1, - RhsPacketSize = Vectorizable ? ei_packet_traits<RhsScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1, + Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable, + LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1, + RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1, NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS, nr = NumberOfRegisters/4, @@ -278,48 +252,48 @@ public: RhsProgress = RhsPacketSize }; - typedef typename ei_packet_traits<LhsScalar>::type _LhsPacket; - typedef typename ei_packet_traits<RhsScalar>::type _RhsPacket; - typedef typename ei_packet_traits<ResScalar>::type _ResPacket; + typedef typename packet_traits<LhsScalar>::type _LhsPacket; + typedef typename packet_traits<RhsScalar>::type _RhsPacket; + typedef typename packet_traits<ResScalar>::type _ResPacket; - typedef typename ei_meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; - typedef typename ei_meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; - typedef typename ei_meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; + typedef typename meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; + typedef typename meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; + typedef typename meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; typedef ResPacket AccPacket; EIGEN_STRONG_INLINE void initAcc(AccPacket& p) { - p = ei_pset1<ResPacket>(ResScalar(0)); + p = pset1<ResPacket>(ResScalar(0)); } EIGEN_STRONG_INLINE void unpackRhs(DenseIndex n, const RhsScalar* rhs, RhsScalar* b) { for(DenseIndex k=0; k<n; k++) - ei_pstore(&b[k*RhsPacketSize], ei_pset1<RhsPacket>(rhs[k])); + pstore(&b[k*RhsPacketSize], pset1<RhsPacket>(rhs[k])); } EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacket& dest) const { - dest = ei_pload<RhsPacket>(b); + dest = pload<RhsPacket>(b); } EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const { - dest = ei_pload<LhsPacket>(a); + dest = pload<LhsPacket>(a); } EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp) const { - madd_impl(a, b, c, tmp, typename ei_meta_if<Vectorizable,ei_meta_true,ei_meta_false>::ret()); + madd_impl(a, b, c, tmp, typename meta_if<Vectorizable,meta_true,meta_false>::ret()); } - EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const ei_meta_true&) const + EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const meta_true&) const { - tmp = b; tmp = ei_pmul(a.v,tmp); c.v = ei_padd(c.v,tmp); + tmp = b; tmp = pmul(a.v,tmp); c.v = padd(c.v,tmp); } - EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const ei_meta_false&) const + EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const meta_false&) const { c += a * b; } @@ -330,11 +304,11 @@ public: } protected: - ei_conj_helper<ResPacket,ResPacket,ConjLhs,false> cj; + conj_helper<ResPacket,ResPacket,ConjLhs,false> cj; }; template<typename RealScalar, bool _ConjLhs, bool _ConjRhs> -class ei_gebp_traits<std::complex<RealScalar>, std::complex<RealScalar>, _ConjLhs, _ConjRhs > +class gebp_traits<std::complex<RealScalar>, std::complex<RealScalar>, _ConjLhs, _ConjRhs > { public: typedef std::complex<RealScalar> Scalar; @@ -345,10 +319,10 @@ public: enum { ConjLhs = _ConjLhs, ConjRhs = _ConjRhs, - Vectorizable = ei_packet_traits<RealScalar>::Vectorizable - && ei_packet_traits<Scalar>::Vectorizable, - RealPacketSize = Vectorizable ? ei_packet_traits<RealScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1, + Vectorizable = packet_traits<RealScalar>::Vectorizable + && packet_traits<Scalar>::Vectorizable, + RealPacketSize = Vectorizable ? packet_traits<RealScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1, nr = 2, mr = 2 * ResPacketSize, @@ -358,25 +332,25 @@ public: RhsProgress = Vectorizable ? 2*ResPacketSize : 1 }; - typedef typename ei_packet_traits<RealScalar>::type RealPacket; - typedef typename ei_packet_traits<Scalar>::type ScalarPacket; + typedef typename packet_traits<RealScalar>::type RealPacket; + typedef typename packet_traits<Scalar>::type ScalarPacket; struct DoublePacket { RealPacket first; RealPacket second; }; - typedef typename ei_meta_if<Vectorizable,RealPacket, Scalar>::ret LhsPacket; - typedef typename ei_meta_if<Vectorizable,DoublePacket,Scalar>::ret RhsPacket; - typedef typename ei_meta_if<Vectorizable,ScalarPacket,Scalar>::ret ResPacket; - typedef typename ei_meta_if<Vectorizable,DoublePacket,Scalar>::ret AccPacket; + typedef typename meta_if<Vectorizable,RealPacket, Scalar>::ret LhsPacket; + typedef typename meta_if<Vectorizable,DoublePacket,Scalar>::ret RhsPacket; + typedef typename meta_if<Vectorizable,ScalarPacket,Scalar>::ret ResPacket; + typedef typename meta_if<Vectorizable,DoublePacket,Scalar>::ret AccPacket; EIGEN_STRONG_INLINE void initAcc(Scalar& p) { p = Scalar(0); } EIGEN_STRONG_INLINE void initAcc(DoublePacket& p) { - p.first = ei_pset1<RealPacket>(RealScalar(0)); - p.second = ei_pset1<RealPacket>(RealScalar(0)); + p.first = pset1<RealPacket>(RealScalar(0)); + p.second = pset1<RealPacket>(RealScalar(0)); } /* Unpack the rhs coeff such that each complex coefficient is spread into @@ -389,8 +363,8 @@ public: { if(Vectorizable) { - ei_pstore((RealScalar*)&b[k*ResPacketSize*2+0], ei_pset1<RealPacket>(ei_real(rhs[k]))); - ei_pstore((RealScalar*)&b[k*ResPacketSize*2+ResPacketSize], ei_pset1<RealPacket>(ei_imag(rhs[k]))); + pstore((RealScalar*)&b[k*ResPacketSize*2+0], pset1<RealPacket>(real(rhs[k]))); + pstore((RealScalar*)&b[k*ResPacketSize*2+ResPacketSize], pset1<RealPacket>(imag(rhs[k]))); } else b[k] = rhs[k]; @@ -401,20 +375,20 @@ public: EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, DoublePacket& dest) const { - dest.first = ei_pload<RealPacket>((const RealScalar*)b); - dest.second = ei_pload<RealPacket>((const RealScalar*)(b+ResPacketSize)); + dest.first = pload<RealPacket>((const RealScalar*)b); + dest.second = pload<RealPacket>((const RealScalar*)(b+ResPacketSize)); } // nothing special here EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const { - dest = ei_pload<LhsPacket>((const typename ei_unpacket_traits<LhsPacket>::type*)(a)); + dest = pload<LhsPacket>((const typename unpacket_traits<LhsPacket>::type*)(a)); } EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, DoublePacket& c, RhsPacket& /*tmp*/) const { - c.first = ei_padd(ei_pmul(a,b.first), c.first); - c.second = ei_padd(ei_pmul(a,b.second),c.second); + c.first = padd(pmul(a,b.first), c.first); + c.second = padd(pmul(a,b.second),c.second); } EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, ResPacket& c, RhsPacket& /*tmp*/) const @@ -430,34 +404,34 @@ public: ResPacket tmp; if((!ConjLhs)&&(!ConjRhs)) { - tmp = ei_pcplxflip(ei_pconj(ResPacket(c.second))); - tmp = ei_padd(ResPacket(c.first),tmp); + tmp = pcplxflip(pconj(ResPacket(c.second))); + tmp = padd(ResPacket(c.first),tmp); } else if((!ConjLhs)&&(ConjRhs)) { - tmp = ei_pconj(ei_pcplxflip(ResPacket(c.second))); - tmp = ei_padd(ResPacket(c.first),tmp); + tmp = pconj(pcplxflip(ResPacket(c.second))); + tmp = padd(ResPacket(c.first),tmp); } else if((ConjLhs)&&(!ConjRhs)) { - tmp = ei_pcplxflip(ResPacket(c.second)); - tmp = ei_padd(ei_pconj(ResPacket(c.first)),tmp); + tmp = pcplxflip(ResPacket(c.second)); + tmp = padd(pconj(ResPacket(c.first)),tmp); } else if((ConjLhs)&&(ConjRhs)) { - tmp = ei_pcplxflip(ResPacket(c.second)); - tmp = ei_psub(ei_pconj(ResPacket(c.first)),tmp); + tmp = pcplxflip(ResPacket(c.second)); + tmp = psub(pconj(ResPacket(c.first)),tmp); } - r = ei_pmadd(tmp,alpha,r); + r = pmadd(tmp,alpha,r); } protected: - ei_conj_helper<LhsScalar,RhsScalar,ConjLhs,ConjRhs> cj; + conj_helper<LhsScalar,RhsScalar,ConjLhs,ConjRhs> cj; }; template<typename RealScalar, bool _ConjRhs> -class ei_gebp_traits<RealScalar, std::complex<RealScalar>, false, _ConjRhs > +class gebp_traits<RealScalar, std::complex<RealScalar>, false, _ConjRhs > { public: typedef std::complex<RealScalar> Scalar; @@ -468,11 +442,11 @@ public: enum { ConjLhs = false, ConjRhs = _ConjRhs, - Vectorizable = ei_packet_traits<RealScalar>::Vectorizable - && ei_packet_traits<Scalar>::Vectorizable, - LhsPacketSize = Vectorizable ? ei_packet_traits<LhsScalar>::size : 1, - RhsPacketSize = Vectorizable ? ei_packet_traits<RhsScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1, + Vectorizable = packet_traits<RealScalar>::Vectorizable + && packet_traits<Scalar>::Vectorizable, + LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1, + RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1, NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS, nr = 4, @@ -483,48 +457,48 @@ public: RhsProgress = ResPacketSize }; - typedef typename ei_packet_traits<LhsScalar>::type _LhsPacket; - typedef typename ei_packet_traits<RhsScalar>::type _RhsPacket; - typedef typename ei_packet_traits<ResScalar>::type _ResPacket; + typedef typename packet_traits<LhsScalar>::type _LhsPacket; + typedef typename packet_traits<RhsScalar>::type _RhsPacket; + typedef typename packet_traits<ResScalar>::type _ResPacket; - typedef typename ei_meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; - typedef typename ei_meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; - typedef typename ei_meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; + typedef typename meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; + typedef typename meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; + typedef typename meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; typedef ResPacket AccPacket; EIGEN_STRONG_INLINE void initAcc(AccPacket& p) { - p = ei_pset1<ResPacket>(ResScalar(0)); + p = pset1<ResPacket>(ResScalar(0)); } EIGEN_STRONG_INLINE void unpackRhs(DenseIndex n, const RhsScalar* rhs, RhsScalar* b) { for(DenseIndex k=0; k<n; k++) - ei_pstore(&b[k*RhsPacketSize], ei_pset1<RhsPacket>(rhs[k])); + pstore(&b[k*RhsPacketSize], pset1<RhsPacket>(rhs[k])); } EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacket& dest) const { - dest = ei_pload<RhsPacket>(b); + dest = pload<RhsPacket>(b); } EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const { - dest = ei_ploaddup<LhsPacket>(a); + dest = ploaddup<LhsPacket>(a); } EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp) const { - madd_impl(a, b, c, tmp, typename ei_meta_if<Vectorizable,ei_meta_true,ei_meta_false>::ret()); + madd_impl(a, b, c, tmp, typename meta_if<Vectorizable,meta_true,meta_false>::ret()); } - EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const ei_meta_true&) const + EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const meta_true&) const { - tmp = b; tmp.v = ei_pmul(a,tmp.v); c = ei_padd(c,tmp); + tmp = b; tmp.v = pmul(a,tmp.v); c = padd(c,tmp); } - EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const ei_meta_false&) const + EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const meta_false&) const { c += a * b; } @@ -535,7 +509,7 @@ public: } protected: - ei_conj_helper<ResPacket,ResPacket,false,ConjRhs> cj; + conj_helper<ResPacket,ResPacket,false,ConjRhs> cj; }; /* optimized GEneral packed Block * packed Panel product kernel @@ -546,9 +520,9 @@ protected: * |cplx |real | easy vectorization */ template<typename LhsScalar, typename RhsScalar, typename Index, int mr, int nr, bool ConjugateLhs, bool ConjugateRhs> -struct ei_gebp_kernel +struct gebp_kernel { - typedef ei_gebp_traits<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> Traits; + typedef gebp_traits<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> Traits; typedef typename Traits::ResScalar ResScalar; typedef typename Traits::LhsPacket LhsPacket; typedef typename Traits::RhsPacket RhsPacket; @@ -570,8 +544,8 @@ struct ei_gebp_kernel if(strideA==-1) strideA = depth; if(strideB==-1) strideB = depth; - ei_conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; -// ei_conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; + conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; +// conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; Index packet_cols = (cols/nr) * nr; const Index peeled_mc = (rows/mr)*mr; // FIXME: @@ -592,7 +566,7 @@ struct ei_gebp_kernel for(Index i=0; i<peeled_mc; i+=mr) { const LhsScalar* blA = &blockA[i*strideA+offsetA*mr]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); // gets res block as register AccPacket C0, C1, C2, C3, C4, C5, C6, C7; @@ -610,10 +584,10 @@ struct ei_gebp_kernel ResScalar* r2 = r1 + resStride; ResScalar* r3 = r2 + resStride; - ei_prefetch(r0+16); - ei_prefetch(r1+16); - ei_prefetch(r2+16); - ei_prefetch(r3+16); + prefetch(r0+16); + prefetch(r1+16); + prefetch(r2+16); + prefetch(r3+16); // performs "inner" product // TODO let's check wether the folowing peeled loop could not be @@ -781,16 +755,16 @@ EIGEN_ASM_COMMENT("mybegin4"); } ResPacket R0, R1, R2, R3, R4, R5, R6, R7; - ResPacket alphav = ei_pset1<ResPacket>(alpha); + ResPacket alphav = pset1<ResPacket>(alpha); - R0 = ei_ploadu<ResPacket>(r0); - R1 = ei_ploadu<ResPacket>(r1); - if(nr==4) R2 = ei_ploadu<ResPacket>(r2); - if(nr==4) R3 = ei_ploadu<ResPacket>(r3); - R4 = ei_ploadu<ResPacket>(r0 + ResPacketSize); - R5 = ei_ploadu<ResPacket>(r1 + ResPacketSize); - if(nr==4) R6 = ei_ploadu<ResPacket>(r2 + ResPacketSize); - if(nr==4) R7 = ei_ploadu<ResPacket>(r3 + ResPacketSize); + R0 = ploadu<ResPacket>(r0); + R1 = ploadu<ResPacket>(r1); + if(nr==4) R2 = ploadu<ResPacket>(r2); + if(nr==4) R3 = ploadu<ResPacket>(r3); + R4 = ploadu<ResPacket>(r0 + ResPacketSize); + R5 = ploadu<ResPacket>(r1 + ResPacketSize); + if(nr==4) R6 = ploadu<ResPacket>(r2 + ResPacketSize); + if(nr==4) R7 = ploadu<ResPacket>(r3 + ResPacketSize); traits.acc(C0, alphav, R0); traits.acc(C1, alphav, R1); @@ -801,21 +775,21 @@ EIGEN_ASM_COMMENT("mybegin4"); if(nr==4) traits.acc(C6, alphav, R6); if(nr==4) traits.acc(C7, alphav, R7); - ei_pstoreu(r0, R0); - ei_pstoreu(r1, R1); - if(nr==4) ei_pstoreu(r2, R2); - if(nr==4) ei_pstoreu(r3, R3); - ei_pstoreu(r0 + ResPacketSize, R4); - ei_pstoreu(r1 + ResPacketSize, R5); - if(nr==4) ei_pstoreu(r2 + ResPacketSize, R6); - if(nr==4) ei_pstoreu(r3 + ResPacketSize, R7); + pstoreu(r0, R0); + pstoreu(r1, R1); + if(nr==4) pstoreu(r2, R2); + if(nr==4) pstoreu(r3, R3); + pstoreu(r0 + ResPacketSize, R4); + pstoreu(r1 + ResPacketSize, R5); + if(nr==4) pstoreu(r2 + ResPacketSize, R6); + if(nr==4) pstoreu(r3 + ResPacketSize, R7); } if(rows-peeled_mc>=LhsProgress) { Index i = peeled_mc; const LhsScalar* blA = &blockA[i*strideA+offsetA*LhsProgress]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); // gets res block as register AccPacket C0, C1, C2, C3; @@ -939,32 +913,32 @@ EIGEN_ASM_COMMENT("mybegin4"); } ResPacket R0, R1, R2, R3; - ResPacket alphav = ei_pset1<ResPacket>(alpha); + ResPacket alphav = pset1<ResPacket>(alpha); ResScalar* r0 = &res[(j2+0)*resStride + i]; ResScalar* r1 = r0 + resStride; ResScalar* r2 = r1 + resStride; ResScalar* r3 = r2 + resStride; - R0 = ei_ploadu<ResPacket>(r0); - R1 = ei_ploadu<ResPacket>(r1); - if(nr==4) R2 = ei_ploadu<ResPacket>(r2); - if(nr==4) R3 = ei_ploadu<ResPacket>(r3); + R0 = ploadu<ResPacket>(r0); + R1 = ploadu<ResPacket>(r1); + if(nr==4) R2 = ploadu<ResPacket>(r2); + if(nr==4) R3 = ploadu<ResPacket>(r3); traits.acc(C0, alphav, R0); traits.acc(C1, alphav, R1); if(nr==4) traits.acc(C2, alphav, R2); if(nr==4) traits.acc(C3, alphav, R3); - ei_pstoreu(r0, R0); - ei_pstoreu(r1, R1); - if(nr==4) ei_pstoreu(r2, R2); - if(nr==4) ei_pstoreu(r3, R3); + pstoreu(r0, R0); + pstoreu(r1, R1); + if(nr==4) pstoreu(r2, R2); + if(nr==4) pstoreu(r3, R3); } for(Index i=peeled_mc2; i<rows; i++) { const LhsScalar* blA = &blockA[i*strideA+offsetA]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); // gets a 1 x nr res block as registers ResScalar C0(0), C1(0), C2(0), C3(0); @@ -1017,13 +991,13 @@ EIGEN_ASM_COMMENT("mybegin4"); traits.unpackRhs(depth, &blockB[j2*strideB+offsetB], unpackedB); // const RhsScalar* blB = &blockB[j2*strideB+offsetB]; // for(Index k=0; k<depth; k++) -// ei_pstore(&unpackedB[k*RhsPacketSize], ei_pset1<RhsPacket>(blB[k])); +// pstore(&unpackedB[k*RhsPacketSize], pset1<RhsPacket>(blB[k])); } for(Index i=0; i<peeled_mc; i+=mr) { const LhsScalar* blA = &blockA[i*strideA+offsetA*mr]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); // TODO move the res loads to the stores @@ -1049,24 +1023,24 @@ EIGEN_ASM_COMMENT("mybegin4"); blA += 2*LhsProgress; } ResPacket R0, R4; - ResPacket alphav = ei_pset1<ResPacket>(alpha); + ResPacket alphav = pset1<ResPacket>(alpha); ResScalar* r0 = &res[(j2+0)*resStride + i]; - R0 = ei_ploadu<ResPacket>(r0); - R4 = ei_ploadu<ResPacket>(r0+ResPacketSize); + R0 = ploadu<ResPacket>(r0); + R4 = ploadu<ResPacket>(r0+ResPacketSize); traits.acc(C0, alphav, R0); traits.acc(C4, alphav, R4); - ei_pstoreu(r0, R0); - ei_pstoreu(r0+ResPacketSize, R4); + pstoreu(r0, R0); + pstoreu(r0+ResPacketSize, R4); } if(rows-peeled_mc>=LhsProgress) { Index i = peeled_mc; const LhsScalar* blA = &blockA[i*strideA+offsetA*LhsProgress]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); AccPacket C0; traits.initAcc(C0); @@ -1083,15 +1057,15 @@ EIGEN_ASM_COMMENT("mybegin4"); blA += LhsProgress; } - ResPacket alphav = ei_pset1<ResPacket>(alpha); - ResPacket R0 = ei_ploadu<ResPacket>(&res[(j2+0)*resStride + i]); + ResPacket alphav = pset1<ResPacket>(alpha); + ResPacket R0 = ploadu<ResPacket>(&res[(j2+0)*resStride + i]); traits.acc(C0, alphav, R0); - ei_pstoreu(&res[(j2+0)*resStride + i], R0); + pstoreu(&res[(j2+0)*resStride + i], R0); } for(Index i=peeled_mc2; i<rows; i++) { const LhsScalar* blA = &blockA[i*strideA+offsetA]; - ei_prefetch(&blA[0]); + prefetch(&blA[0]); // gets a 1 x 1 res block as registers ResScalar C0(0); @@ -1126,15 +1100,15 @@ EIGEN_ASM_COMMENT("mybegin4"); // 32 33 34 35 ... // 36 36 38 39 ... template<typename Scalar, typename Index, int Pack1, int Pack2, int StorageOrder, bool Conjugate, bool PanelMode> -struct ei_gemm_pack_lhs +struct gemm_pack_lhs { void operator()(Scalar* blockA, const Scalar* EIGEN_RESTRICT _lhs, Index lhsStride, Index depth, Index rows, Index stride=0, Index offset=0) { -// enum { PacketSize = ei_packet_traits<Scalar>::size }; - ei_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); - ei_conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; - ei_const_blas_data_mapper<Scalar, Index, StorageOrder> lhs(_lhs,lhsStride); +// enum { PacketSize = packet_traits<Scalar>::size }; + eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); + conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; + const_blas_data_mapper<Scalar, Index, StorageOrder> lhs(_lhs,lhsStride); Index count = 0; Index peeled_mc = (rows/Pack1)*Pack1; for(Index i=0; i<peeled_mc; i+=Pack1) @@ -1172,15 +1146,15 @@ struct ei_gemm_pack_lhs // 8 9 10 11 20 21 22 23 26 29 // . . . . . . . . . . template<typename Scalar, typename Index, int nr, bool Conjugate, bool PanelMode> -struct ei_gemm_pack_rhs<Scalar, Index, nr, ColMajor, Conjugate, PanelMode> +struct gemm_pack_rhs<Scalar, Index, nr, ColMajor, Conjugate, PanelMode> { - typedef typename ei_packet_traits<Scalar>::type Packet; - enum { PacketSize = ei_packet_traits<Scalar>::size }; + typedef typename packet_traits<Scalar>::type Packet; + enum { PacketSize = packet_traits<Scalar>::size }; void operator()(Scalar* blockB, const Scalar* rhs, Index rhsStride, Index depth, Index cols, Index stride=0, Index offset=0) { - ei_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); - ei_conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; + eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); + conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; for(Index j2=0; j2<packet_cols; j2+=nr) @@ -1220,14 +1194,14 @@ struct ei_gemm_pack_rhs<Scalar, Index, nr, ColMajor, Conjugate, PanelMode> // this version is optimized for row major matrices template<typename Scalar, typename Index, int nr, bool Conjugate, bool PanelMode> -struct ei_gemm_pack_rhs<Scalar, Index, nr, RowMajor, Conjugate, PanelMode> +struct gemm_pack_rhs<Scalar, Index, nr, RowMajor, Conjugate, PanelMode> { - enum { PacketSize = ei_packet_traits<Scalar>::size }; + enum { PacketSize = packet_traits<Scalar>::size }; void operator()(Scalar* blockB, const Scalar* rhs, Index rhsStride, Index depth, Index cols, Index stride=0, Index offset=0) { - ei_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); - ei_conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; + eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); + conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; for(Index j2=0; j2<packet_cols; j2+=nr) @@ -1261,4 +1235,34 @@ struct ei_gemm_pack_rhs<Scalar, Index, nr, RowMajor, Conjugate, PanelMode> } }; +} // end namespace internal + +/** \returns the currently set level 1 cpu cache size (in bytes) used to estimate the ideal blocking size parameters. + * \sa setCpuCacheSize */ +inline std::ptrdiff_t l1CacheSize() +{ + std::ptrdiff_t l1, l2; + internal::manage_caching_sizes(GetAction, &l1, &l2); + return l1; +} + +/** \returns the currently set level 2 cpu cache size (in bytes) used to estimate the ideal blocking size parameters. + * \sa setCpuCacheSize */ +inline std::ptrdiff_t l2CacheSize() +{ + std::ptrdiff_t l1, l2; + internal::manage_caching_sizes(GetAction, &l1, &l2); + return l2; +} + +/** Set the cpu L1 and L2 cache sizes (in bytes). + * These values are use to adjust the size of the blocks + * for the algorithms working per blocks. + * + * \sa computeProductBlockingSizes */ +inline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2) +{ + internal::manage_caching_sizes(SetAction, &l1, &l2); +} + #endif // EIGEN_GENERAL_BLOCK_PANEL_H diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h index 1cdfb84d1..39e65599d 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -25,27 +25,29 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_H #define EIGEN_GENERAL_MATRIX_MATRIX_H -template<typename _LhsScalar, typename _RhsScalar> class ei_level3_blocking; +namespace internal { + +template<typename _LhsScalar, typename _RhsScalar> class level3_blocking; /* Specialization for a row-major destination matrix => simple transposition of the product */ template< typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs> -struct ei_general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,RowMajor> +struct general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,RowMajor> { - typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; + typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; static EIGEN_STRONG_INLINE void run( Index rows, Index cols, Index depth, const LhsScalar* lhs, Index lhsStride, const RhsScalar* rhs, Index rhsStride, ResScalar* res, Index resStride, ResScalar alpha, - ei_level3_blocking<RhsScalar,LhsScalar>& blocking, + level3_blocking<RhsScalar,LhsScalar>& blocking, GemmParallelInfo<Index>* info = 0) { // transpose the product such that the result is column major - ei_general_matrix_matrix_product<Index, + general_matrix_matrix_product<Index, RhsScalar, RhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateRhs, LhsScalar, LhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateLhs, ColMajor> @@ -59,29 +61,29 @@ template< typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs> -struct ei_general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,ColMajor> +struct general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,ColMajor> { -typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; +typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; static void run(Index rows, Index cols, Index depth, const LhsScalar* _lhs, Index lhsStride, const RhsScalar* _rhs, Index rhsStride, ResScalar* res, Index resStride, ResScalar alpha, - ei_level3_blocking<LhsScalar,RhsScalar>& blocking, + level3_blocking<LhsScalar,RhsScalar>& blocking, GemmParallelInfo<Index>* info = 0) { - ei_const_blas_data_mapper<LhsScalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); - ei_const_blas_data_mapper<RhsScalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); + const_blas_data_mapper<LhsScalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<RhsScalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); - typedef ei_gebp_traits<LhsScalar,RhsScalar> Traits; + typedef gebp_traits<LhsScalar,RhsScalar> Traits; Index kc = blocking.kc(); // cache block size along the K direction Index mc = std::min(rows,blocking.mc()); // cache block size along the M direction //Index nc = blocking.nc(); // cache block size along the N direction - ei_gemm_pack_lhs<LhsScalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; - ei_gemm_pack_rhs<RhsScalar, Index, Traits::nr, RhsStorageOrder> pack_rhs; - ei_gebp_kernel<LhsScalar, RhsScalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp; + gemm_pack_lhs<LhsScalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; + gemm_pack_rhs<RhsScalar, Index, Traits::nr, RhsStorageOrder> pack_rhs; + gebp_kernel<LhsScalar, RhsScalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp; #ifdef EIGEN_HAS_OPENMP if(info) @@ -94,7 +96,7 @@ static void run(Index rows, Index cols, Index depth, std::size_t sizeW = kc*Traits::WorkSpaceFactor; RhsScalar* w = ei_aligned_stack_new(RhsScalar, sizeW); RhsScalar* blockB = blocking.blockB(); - ei_internal_assert(blockB!=0); + eigen_internal_assert(blockB!=0); // For each horizontal panel of the rhs, and corresponding vertical panel of the lhs... for(Index k=0; k<depth; k+=kc) @@ -208,18 +210,18 @@ static void run(Index rows, Index cols, Index depth, /********************************************************************************* * Specialization of GeneralProduct<> for "large" GEMM, i.e., -* implementation of the high level wrapper to ei_general_matrix_matrix_product +* implementation of the high level wrapper to general_matrix_matrix_product **********************************************************************************/ template<typename Lhs, typename Rhs> -struct ei_traits<GeneralProduct<Lhs,Rhs,GemmProduct> > - : ei_traits<ProductBase<GeneralProduct<Lhs,Rhs,GemmProduct>, Lhs, Rhs> > +struct traits<GeneralProduct<Lhs,Rhs,GemmProduct> > + : traits<ProductBase<GeneralProduct<Lhs,Rhs,GemmProduct>, Lhs, Rhs> > {}; template<typename Scalar, typename Index, typename Gemm, typename Lhs, typename Rhs, typename Dest, typename BlockingType> -struct ei_gemm_functor +struct gemm_functor { - ei_gemm_functor(const Lhs& lhs, const Rhs& rhs, Dest& dest, Scalar actualAlpha, + gemm_functor(const Lhs& lhs, const Rhs& rhs, Dest& dest, Scalar actualAlpha, BlockingType& blocking) : m_lhs(lhs), m_rhs(rhs), m_dest(dest), m_actualAlpha(actualAlpha), m_blocking(blocking) {} @@ -250,10 +252,10 @@ struct ei_gemm_functor }; template<int StorageOrder, typename LhsScalar, typename RhsScalar, int MaxRows, int MaxCols, int MaxDepth, -bool FiniteAtCompileTime = MaxRows!=Dynamic && MaxCols!=Dynamic && MaxDepth != Dynamic> class ei_gemm_blocking_space; +bool FiniteAtCompileTime = MaxRows!=Dynamic && MaxCols!=Dynamic && MaxDepth != Dynamic> class gemm_blocking_space; template<typename _LhsScalar, typename _RhsScalar> -class ei_level3_blocking +class level3_blocking { typedef _LhsScalar LhsScalar; typedef _RhsScalar RhsScalar; @@ -269,7 +271,7 @@ class ei_level3_blocking public: - ei_level3_blocking() + level3_blocking() : m_blockA(0), m_blockB(0), m_blockW(0), m_mc(0), m_nc(0), m_kc(0) {} @@ -283,19 +285,19 @@ class ei_level3_blocking }; template<int StorageOrder, typename _LhsScalar, typename _RhsScalar, int MaxRows, int MaxCols, int MaxDepth> -class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, true> - : public ei_level3_blocking< - typename ei_meta_if<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::ret, - typename ei_meta_if<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::ret> +class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, true> + : public level3_blocking< + typename meta_if<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::ret, + typename meta_if<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::ret> { enum { Transpose = StorageOrder==RowMajor, ActualRows = Transpose ? MaxCols : MaxRows, ActualCols = Transpose ? MaxRows : MaxCols }; - typedef typename ei_meta_if<Transpose,_RhsScalar,_LhsScalar>::ret LhsScalar; - typedef typename ei_meta_if<Transpose,_LhsScalar,_RhsScalar>::ret RhsScalar; - typedef ei_gebp_traits<LhsScalar,RhsScalar> Traits; + typedef typename meta_if<Transpose,_RhsScalar,_LhsScalar>::ret LhsScalar; + typedef typename meta_if<Transpose,_LhsScalar,_RhsScalar>::ret RhsScalar; + typedef gebp_traits<LhsScalar,RhsScalar> Traits; enum { SizeA = ActualRows * MaxDepth, SizeB = ActualCols * MaxDepth, @@ -308,7 +310,7 @@ class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols public: - ei_gemm_blocking_space(DenseIndex /*rows*/, DenseIndex /*cols*/, DenseIndex /*depth*/) + gemm_blocking_space(DenseIndex /*rows*/, DenseIndex /*cols*/, DenseIndex /*depth*/) { this->m_mc = ActualRows; this->m_nc = ActualCols; @@ -325,17 +327,17 @@ class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols }; template<int StorageOrder, typename _LhsScalar, typename _RhsScalar, int MaxRows, int MaxCols, int MaxDepth> -class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, false> - : public ei_level3_blocking< - typename ei_meta_if<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::ret, - typename ei_meta_if<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::ret> +class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, false> + : public level3_blocking< + typename meta_if<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::ret, + typename meta_if<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::ret> { enum { Transpose = StorageOrder==RowMajor }; - typedef typename ei_meta_if<Transpose,_RhsScalar,_LhsScalar>::ret LhsScalar; - typedef typename ei_meta_if<Transpose,_LhsScalar,_RhsScalar>::ret RhsScalar; - typedef ei_gebp_traits<LhsScalar,RhsScalar> Traits; + typedef typename meta_if<Transpose,_RhsScalar,_LhsScalar>::ret LhsScalar; + typedef typename meta_if<Transpose,_LhsScalar,_RhsScalar>::ret RhsScalar; + typedef gebp_traits<LhsScalar,RhsScalar> Traits; DenseIndex m_sizeA; DenseIndex m_sizeB; @@ -343,7 +345,7 @@ class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols public: - ei_gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth) + gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth) { this->m_mc = Transpose ? cols : rows; this->m_nc = Transpose ? rows : cols; @@ -358,19 +360,19 @@ class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols void allocateA() { if(this->m_blockA==0) - this->m_blockA = ei_aligned_new<LhsScalar>(m_sizeA); + this->m_blockA = aligned_new<LhsScalar>(m_sizeA); } void allocateB() { if(this->m_blockB==0) - this->m_blockB = ei_aligned_new<RhsScalar>(m_sizeB); + this->m_blockB = aligned_new<RhsScalar>(m_sizeB); } void allocateW() { if(this->m_blockW==0) - this->m_blockW = ei_aligned_new<RhsScalar>(m_sizeW); + this->m_blockW = aligned_new<RhsScalar>(m_sizeW); } void allocateAll() @@ -380,14 +382,16 @@ class ei_gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols allocateW(); } - ~ei_gemm_blocking_space() + ~gemm_blocking_space() { - ei_aligned_delete(this->m_blockA, m_sizeA); - ei_aligned_delete(this->m_blockB, m_sizeB); - ei_aligned_delete(this->m_blockW, m_sizeW); + aligned_delete(this->m_blockA, m_sizeA); + aligned_delete(this->m_blockB, m_sizeB); + aligned_delete(this->m_blockW, m_sizeW); } }; +} // end namespace internal + template<typename Lhs, typename Rhs> class GeneralProduct<Lhs, Rhs, GemmProduct> : public ProductBase<GeneralProduct<Lhs,Rhs,GemmProduct>, Lhs, Rhs> @@ -404,13 +408,13 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) { - typedef ei_scalar_product_op<LhsScalar,RhsScalar> BinOp; + typedef internal::scalar_product_op<LhsScalar,RhsScalar> BinOp; EIGEN_CHECK_BINARY_COMPATIBILIY(BinOp,LhsScalar,RhsScalar); } template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -418,12 +422,12 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - typedef ei_gemm_blocking_space<(Dest::Flags&RowMajorBit) ? RowMajor : ColMajor,LhsScalar,RhsScalar, + typedef internal::gemm_blocking_space<(Dest::Flags&RowMajorBit) ? RowMajor : ColMajor,LhsScalar,RhsScalar, Dest::MaxRowsAtCompileTime,Dest::MaxColsAtCompileTime,MaxDepthAtCompileTime> BlockingType; - typedef ei_gemm_functor< + typedef internal::gemm_functor< Scalar, Index, - ei_general_matrix_matrix_product< + internal::general_matrix_matrix_product< Index, LhsScalar, (_ActualLhsType::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(LhsBlasTraits::NeedToConjugate), RhsScalar, (_ActualRhsType::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(RhsBlasTraits::NeedToConjugate), @@ -432,7 +436,7 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> BlockingType blocking(dst.rows(), dst.cols(), lhs.cols()); - ei_parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>(GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), this->rows(), this->cols(), Dest::Flags&RowMajorBit); + internal::parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>(GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), this->rows(), this->cols(), Dest::Flags&RowMajorBit); } }; diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index 96a038b05..41df6170c 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -25,6 +25,8 @@ #ifndef EIGEN_GENERAL_MATRIX_VECTOR_H #define EIGEN_GENERAL_MATRIX_VECTOR_H +namespace internal { + /* Optimized col-major matrix * vector product: * This algorithm processes 4 columns at onces that allows to both reduce * the number of load/stores of the result by a factor 4 and to reduce @@ -39,25 +41,25 @@ * |cplx |real |real | optimal case, vectorization possible via real-cplx mul */ template<typename Index, typename LhsScalar, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs> -struct ei_general_matrix_vector_product<Index,LhsScalar,ColMajor,ConjugateLhs,RhsScalar,ConjugateRhs> +struct general_matrix_vector_product<Index,LhsScalar,ColMajor,ConjugateLhs,RhsScalar,ConjugateRhs> { -typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; +typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; enum { - Vectorizable = ei_packet_traits<LhsScalar>::Vectorizable && ei_packet_traits<RhsScalar>::Vectorizable - && int(ei_packet_traits<LhsScalar>::size)==int(ei_packet_traits<RhsScalar>::size), - LhsPacketSize = Vectorizable ? ei_packet_traits<LhsScalar>::size : 1, - RhsPacketSize = Vectorizable ? ei_packet_traits<RhsScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1 + Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable + && int(packet_traits<LhsScalar>::size)==int(packet_traits<RhsScalar>::size), + LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1, + RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1 }; -typedef typename ei_packet_traits<LhsScalar>::type _LhsPacket; -typedef typename ei_packet_traits<RhsScalar>::type _RhsPacket; -typedef typename ei_packet_traits<ResScalar>::type _ResPacket; +typedef typename packet_traits<LhsScalar>::type _LhsPacket; +typedef typename packet_traits<RhsScalar>::type _RhsPacket; +typedef typename packet_traits<ResScalar>::type _ResPacket; -typedef typename ei_meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; -typedef typename ei_meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; -typedef typename ei_meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; +typedef typename meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; +typedef typename meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; +typedef typename meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; EIGEN_DONT_INLINE static void run( Index rows, Index cols, @@ -69,23 +71,23 @@ EIGEN_DONT_INLINE static void run( #endif , RhsScalar alpha) { - ei_internal_assert(resIncr==1); + eigen_internal_assert(resIncr==1); #ifdef _EIGEN_ACCUMULATE_PACKETS #error _EIGEN_ACCUMULATE_PACKETS has already been defined #endif #define _EIGEN_ACCUMULATE_PACKETS(A0,A13,A2) \ - ei_pstore(&res[j], \ - ei_padd(ei_pload<ResPacket>(&res[j]), \ - ei_padd( \ - ei_padd(pcj.pmul(EIGEN_CAT(ei_ploa , A0)<LhsPacket>(&lhs0[j]), ptmp0), \ - pcj.pmul(EIGEN_CAT(ei_ploa , A13)<LhsPacket>(&lhs1[j]), ptmp1)), \ - ei_padd(pcj.pmul(EIGEN_CAT(ei_ploa , A2)<LhsPacket>(&lhs2[j]), ptmp2), \ - pcj.pmul(EIGEN_CAT(ei_ploa , A13)<LhsPacket>(&lhs3[j]), ptmp3)) ))) - - ei_conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; - ei_conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; + pstore(&res[j], \ + padd(pload<ResPacket>(&res[j]), \ + padd( \ + padd(pcj.pmul(EIGEN_CAT(ploa , A0)<LhsPacket>(&lhs0[j]), ptmp0), \ + pcj.pmul(EIGEN_CAT(ploa , A13)<LhsPacket>(&lhs1[j]), ptmp1)), \ + padd(pcj.pmul(EIGEN_CAT(ploa , A2)<LhsPacket>(&lhs2[j]), ptmp2), \ + pcj.pmul(EIGEN_CAT(ploa , A13)<LhsPacket>(&lhs3[j]), ptmp3)) ))) + + conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; + conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; if(ConjugateRhs) - alpha = ei_conj(alpha); + alpha = conj(alpha); enum { AllAligned = 0, EvenAligned, FirstAligned, NoneAligned }; const Index columnsAtOnce = 4; @@ -97,7 +99,7 @@ EIGEN_DONT_INLINE static void run( // How many coeffs of the result do we have to skip to be aligned. // Here we assume data are at least aligned on the base scalar type. - Index alignedStart = ei_first_aligned(res,size); + Index alignedStart = first_aligned(res,size); Index alignedSize = ResPacketSize>1 ? alignedStart + ((size-alignedStart) & ~ResPacketAlignedMask) : 0; const Index peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart; @@ -107,7 +109,7 @@ EIGEN_DONT_INLINE static void run( : FirstAligned; // we cannot assume the first element is aligned because of sub-matrices - const Index lhsAlignmentOffset = ei_first_aligned(lhs,size); + const Index lhsAlignmentOffset = first_aligned(lhs,size); // find how many columns do we have to skip to be aligned with the result (if possible) Index skipColumns = 0; @@ -119,7 +121,7 @@ EIGEN_DONT_INLINE static void run( } else if (LhsPacketSize>1) { - ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0 || size<LhsPacketSize); + eigen_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0 || size<LhsPacketSize); while (skipColumns<LhsPacketSize && alignedStart != ((lhsAlignmentOffset + alignmentStep*skipColumns)%LhsPacketSize)) @@ -136,7 +138,7 @@ EIGEN_DONT_INLINE static void run( // note that the skiped columns are processed later. } - ei_internal_assert( (alignmentPattern==NoneAligned) + eigen_internal_assert( (alignmentPattern==NoneAligned) || (skipColumns + columnsAtOnce >= cols) || LhsPacketSize > size || (size_t(lhs+alignedStart+lhsStride*skipColumns)%sizeof(LhsPacket))==0); @@ -154,10 +156,10 @@ EIGEN_DONT_INLINE static void run( Index columnBound = ((cols-skipColumns)/columnsAtOnce)*columnsAtOnce + skipColumns; for (Index i=skipColumns; i<columnBound; i+=columnsAtOnce) { - RhsPacket ptmp0 = ei_pset1<RhsPacket>(alpha*rhs[i*rhsIncr]), - ptmp1 = ei_pset1<RhsPacket>(alpha*rhs[(i+offset1)*rhsIncr]), - ptmp2 = ei_pset1<RhsPacket>(alpha*rhs[(i+2)*rhsIncr]), - ptmp3 = ei_pset1<RhsPacket>(alpha*rhs[(i+offset3)*rhsIncr]); + RhsPacket ptmp0 = pset1<RhsPacket>(alpha*rhs[i*rhsIncr]), + ptmp1 = pset1<RhsPacket>(alpha*rhs[(i+offset1)*rhsIncr]), + ptmp2 = pset1<RhsPacket>(alpha*rhs[(i+2)*rhsIncr]), + ptmp3 = pset1<RhsPacket>(alpha*rhs[(i+offset3)*rhsIncr]); // this helps a lot generating better binary code const LhsScalar *lhs0 = lhs + i*lhsStride, *lhs1 = lhs + (i+offset1)*lhsStride, @@ -169,10 +171,10 @@ EIGEN_DONT_INLINE static void run( // process initial unaligned coeffs for (Index j=0; j<alignedStart; ++j) { - res[j] = cj.pmadd(lhs0[j], ei_pfirst(ptmp0), res[j]); - res[j] = cj.pmadd(lhs1[j], ei_pfirst(ptmp1), res[j]); - res[j] = cj.pmadd(lhs2[j], ei_pfirst(ptmp2), res[j]); - res[j] = cj.pmadd(lhs3[j], ei_pfirst(ptmp3), res[j]); + res[j] = cj.pmadd(lhs0[j], pfirst(ptmp0), res[j]); + res[j] = cj.pmadd(lhs1[j], pfirst(ptmp1), res[j]); + res[j] = cj.pmadd(lhs2[j], pfirst(ptmp2), res[j]); + res[j] = cj.pmadd(lhs3[j], pfirst(ptmp3), res[j]); } if (alignedSize>alignedStart) @@ -193,32 +195,32 @@ EIGEN_DONT_INLINE static void run( LhsPacket A00, A01, A02, A03, A10, A11, A12, A13; ResPacket T0, T1; - A01 = ei_pload<LhsPacket>(&lhs1[alignedStart-1]); - A02 = ei_pload<LhsPacket>(&lhs2[alignedStart-2]); - A03 = ei_pload<LhsPacket>(&lhs3[alignedStart-3]); + A01 = pload<LhsPacket>(&lhs1[alignedStart-1]); + A02 = pload<LhsPacket>(&lhs2[alignedStart-2]); + A03 = pload<LhsPacket>(&lhs3[alignedStart-3]); for (Index j = alignedStart; j<peeledSize; j+=peels*ResPacketSize) { - A11 = ei_pload<LhsPacket>(&lhs1[j-1+LhsPacketSize]); ei_palign<1>(A01,A11); - A12 = ei_pload<LhsPacket>(&lhs2[j-2+LhsPacketSize]); ei_palign<2>(A02,A12); - A13 = ei_pload<LhsPacket>(&lhs3[j-3+LhsPacketSize]); ei_palign<3>(A03,A13); + A11 = pload<LhsPacket>(&lhs1[j-1+LhsPacketSize]); palign<1>(A01,A11); + A12 = pload<LhsPacket>(&lhs2[j-2+LhsPacketSize]); palign<2>(A02,A12); + A13 = pload<LhsPacket>(&lhs3[j-3+LhsPacketSize]); palign<3>(A03,A13); - A00 = ei_pload<LhsPacket>(&lhs0[j]); - A10 = ei_pload<LhsPacket>(&lhs0[j+LhsPacketSize]); - T0 = pcj.pmadd(A00, ptmp0, ei_pload<ResPacket>(&res[j])); - T1 = pcj.pmadd(A10, ptmp0, ei_pload<ResPacket>(&res[j+ResPacketSize])); + A00 = pload<LhsPacket>(&lhs0[j]); + A10 = pload<LhsPacket>(&lhs0[j+LhsPacketSize]); + T0 = pcj.pmadd(A00, ptmp0, pload<ResPacket>(&res[j])); + T1 = pcj.pmadd(A10, ptmp0, pload<ResPacket>(&res[j+ResPacketSize])); T0 = pcj.pmadd(A01, ptmp1, T0); - A01 = ei_pload<LhsPacket>(&lhs1[j-1+2*LhsPacketSize]); ei_palign<1>(A11,A01); + A01 = pload<LhsPacket>(&lhs1[j-1+2*LhsPacketSize]); palign<1>(A11,A01); T0 = pcj.pmadd(A02, ptmp2, T0); - A02 = ei_pload<LhsPacket>(&lhs2[j-2+2*LhsPacketSize]); ei_palign<2>(A12,A02); + A02 = pload<LhsPacket>(&lhs2[j-2+2*LhsPacketSize]); palign<2>(A12,A02); T0 = pcj.pmadd(A03, ptmp3, T0); - ei_pstore(&res[j],T0); - A03 = ei_pload<LhsPacket>(&lhs3[j-3+2*LhsPacketSize]); ei_palign<3>(A13,A03); + pstore(&res[j],T0); + A03 = pload<LhsPacket>(&lhs3[j-3+2*LhsPacketSize]); palign<3>(A13,A03); T1 = pcj.pmadd(A11, ptmp1, T1); T1 = pcj.pmadd(A12, ptmp2, T1); T1 = pcj.pmadd(A13, ptmp3, T1); - ei_pstore(&res[j+ResPacketSize],T1); + pstore(&res[j+ResPacketSize],T1); } } for (Index j = peeledSize; j<alignedSize; j+=ResPacketSize) @@ -235,10 +237,10 @@ EIGEN_DONT_INLINE static void run( /* process remaining coeffs (or all if there is no explicit vectorization) */ for (Index j=alignedSize; j<size; ++j) { - res[j] = cj.pmadd(lhs0[j], ei_pfirst(ptmp0), res[j]); - res[j] = cj.pmadd(lhs1[j], ei_pfirst(ptmp1), res[j]); - res[j] = cj.pmadd(lhs2[j], ei_pfirst(ptmp2), res[j]); - res[j] = cj.pmadd(lhs3[j], ei_pfirst(ptmp3), res[j]); + res[j] = cj.pmadd(lhs0[j], pfirst(ptmp0), res[j]); + res[j] = cj.pmadd(lhs1[j], pfirst(ptmp1), res[j]); + res[j] = cj.pmadd(lhs2[j], pfirst(ptmp2), res[j]); + res[j] = cj.pmadd(lhs3[j], pfirst(ptmp3), res[j]); } } @@ -249,7 +251,7 @@ EIGEN_DONT_INLINE static void run( { for (Index k=start; k<end; ++k) { - RhsPacket ptmp0 = ei_pset1<RhsPacket>(alpha*rhs[k*rhsIncr]); + RhsPacket ptmp0 = pset1<RhsPacket>(alpha*rhs[k*rhsIncr]); const LhsScalar* lhs0 = lhs + k*lhsStride; if (Vectorizable) @@ -257,19 +259,19 @@ EIGEN_DONT_INLINE static void run( /* explicit vectorization */ // process first unaligned result's coeffs for (Index j=0; j<alignedStart; ++j) - res[j] += cj.pmul(lhs0[j], ei_pfirst(ptmp0)); + res[j] += cj.pmul(lhs0[j], pfirst(ptmp0)); // process aligned result's coeffs if ((size_t(lhs0+alignedStart)%sizeof(LhsPacket))==0) for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize) - ei_pstore(&res[i], pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[i]), ptmp0, ei_pload<ResPacket>(&res[i]))); + pstore(&res[i], pcj.pmadd(ploadu<LhsPacket>(&lhs0[i]), ptmp0, pload<ResPacket>(&res[i]))); else for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize) - ei_pstore(&res[i], pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[i]), ptmp0, ei_pload<ResPacket>(&res[i]))); + pstore(&res[i], pcj.pmadd(ploadu<LhsPacket>(&lhs0[i]), ptmp0, pload<ResPacket>(&res[i]))); } // process remaining scalars (or all if no explicit vectorization) for (Index i=alignedSize; i<size; ++i) - res[i] += cj.pmul(lhs0[i], ei_pfirst(ptmp0)); + res[i] += cj.pmul(lhs0[i], pfirst(ptmp0)); } if (skipColumns) { @@ -295,25 +297,25 @@ EIGEN_DONT_INLINE static void run( * - no vectorization */ template<typename Index, typename LhsScalar, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs> -struct ei_general_matrix_vector_product<Index,LhsScalar,RowMajor,ConjugateLhs,RhsScalar,ConjugateRhs> +struct general_matrix_vector_product<Index,LhsScalar,RowMajor,ConjugateLhs,RhsScalar,ConjugateRhs> { -typedef typename ei_scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; +typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar; enum { - Vectorizable = ei_packet_traits<LhsScalar>::Vectorizable && ei_packet_traits<RhsScalar>::Vectorizable - && int(ei_packet_traits<LhsScalar>::size)==int(ei_packet_traits<RhsScalar>::size), - LhsPacketSize = Vectorizable ? ei_packet_traits<LhsScalar>::size : 1, - RhsPacketSize = Vectorizable ? ei_packet_traits<RhsScalar>::size : 1, - ResPacketSize = Vectorizable ? ei_packet_traits<ResScalar>::size : 1 + Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable + && int(packet_traits<LhsScalar>::size)==int(packet_traits<RhsScalar>::size), + LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1, + RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1, + ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1 }; -typedef typename ei_packet_traits<LhsScalar>::type _LhsPacket; -typedef typename ei_packet_traits<RhsScalar>::type _RhsPacket; -typedef typename ei_packet_traits<ResScalar>::type _ResPacket; +typedef typename packet_traits<LhsScalar>::type _LhsPacket; +typedef typename packet_traits<RhsScalar>::type _RhsPacket; +typedef typename packet_traits<ResScalar>::type _ResPacket; -typedef typename ei_meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; -typedef typename ei_meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; -typedef typename ei_meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; +typedef typename meta_if<Vectorizable,_LhsPacket,LhsScalar>::ret LhsPacket; +typedef typename meta_if<Vectorizable,_RhsPacket,RhsScalar>::ret RhsPacket; +typedef typename meta_if<Vectorizable,_ResPacket,ResScalar>::ret ResPacket; EIGEN_DONT_INLINE static void run( Index rows, Index cols, @@ -323,20 +325,20 @@ EIGEN_DONT_INLINE static void run( ResScalar alpha) { EIGEN_UNUSED_VARIABLE(rhsIncr); - ei_internal_assert(rhsIncr==1); + eigen_internal_assert(rhsIncr==1); #ifdef _EIGEN_ACCUMULATE_PACKETS #error _EIGEN_ACCUMULATE_PACKETS has already been defined #endif #define _EIGEN_ACCUMULATE_PACKETS(A0,A13,A2) {\ - RhsPacket b = ei_pload<RhsPacket>(&rhs[j]); \ - ptmp0 = pcj.pmadd(EIGEN_CAT(ei_ploa,A0) <LhsPacket>(&lhs0[j]), b, ptmp0); \ - ptmp1 = pcj.pmadd(EIGEN_CAT(ei_ploa,A13)<LhsPacket>(&lhs1[j]), b, ptmp1); \ - ptmp2 = pcj.pmadd(EIGEN_CAT(ei_ploa,A2) <LhsPacket>(&lhs2[j]), b, ptmp2); \ - ptmp3 = pcj.pmadd(EIGEN_CAT(ei_ploa,A13)<LhsPacket>(&lhs3[j]), b, ptmp3); } + RhsPacket b = pload<RhsPacket>(&rhs[j]); \ + ptmp0 = pcj.pmadd(EIGEN_CAT(ploa,A0) <LhsPacket>(&lhs0[j]), b, ptmp0); \ + ptmp1 = pcj.pmadd(EIGEN_CAT(ploa,A13)<LhsPacket>(&lhs1[j]), b, ptmp1); \ + ptmp2 = pcj.pmadd(EIGEN_CAT(ploa,A2) <LhsPacket>(&lhs2[j]), b, ptmp2); \ + ptmp3 = pcj.pmadd(EIGEN_CAT(ploa,A13)<LhsPacket>(&lhs3[j]), b, ptmp3); } - ei_conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; - ei_conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; + conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj; + conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj; enum { AllAligned=0, EvenAligned=1, FirstAligned=2, NoneAligned=3 }; const Index rowsAtOnce = 4; @@ -349,7 +351,7 @@ EIGEN_DONT_INLINE static void run( // How many coeffs of the result do we have to skip to be aligned. // Here we assume data are at least aligned on the base scalar type // if that's not the case then vectorization is discarded, see below. - Index alignedStart = ei_first_aligned(rhs, depth); + Index alignedStart = first_aligned(rhs, depth); Index alignedSize = RhsPacketSize>1 ? alignedStart + ((depth-alignedStart) & ~RhsPacketAlignedMask) : 0; const Index peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart; @@ -359,7 +361,7 @@ EIGEN_DONT_INLINE static void run( : FirstAligned; // we cannot assume the first element is aligned because of sub-matrices - const Index lhsAlignmentOffset = ei_first_aligned(lhs,depth); + const Index lhsAlignmentOffset = first_aligned(lhs,depth); // find how many rows do we have to skip to be aligned with rhs (if possible) Index skipRows = 0; @@ -371,7 +373,7 @@ EIGEN_DONT_INLINE static void run( } else if (LhsPacketSize>1) { - ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0 || depth<LhsPacketSize); + eigen_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0 || depth<LhsPacketSize); while (skipRows<LhsPacketSize && alignedStart != ((lhsAlignmentOffset + alignmentStep*skipRows)%LhsPacketSize)) @@ -387,7 +389,7 @@ EIGEN_DONT_INLINE static void run( skipRows = std::min(skipRows,Index(rows)); // note that the skiped columns are processed later. } - ei_internal_assert( alignmentPattern==NoneAligned + eigen_internal_assert( alignmentPattern==NoneAligned || LhsPacketSize==1 || (skipRows + rowsAtOnce >= rows) || LhsPacketSize > depth @@ -416,8 +418,8 @@ EIGEN_DONT_INLINE static void run( if (Vectorizable) { /* explicit vectorization */ - ResPacket ptmp0 = ei_pset1<ResPacket>(ResScalar(0)), ptmp1 = ei_pset1<ResPacket>(ResScalar(0)), - ptmp2 = ei_pset1<ResPacket>(ResScalar(0)), ptmp3 = ei_pset1<ResPacket>(ResScalar(0)); + ResPacket ptmp0 = pset1<ResPacket>(ResScalar(0)), ptmp1 = pset1<ResPacket>(ResScalar(0)), + ptmp2 = pset1<ResPacket>(ResScalar(0)), ptmp3 = pset1<ResPacket>(ResScalar(0)); // process initial unaligned coeffs // FIXME this loop get vectorized by the compiler ! @@ -450,27 +452,27 @@ EIGEN_DONT_INLINE static void run( * than basic unaligned loads. */ LhsPacket A01, A02, A03, A11, A12, A13; - A01 = ei_pload<LhsPacket>(&lhs1[alignedStart-1]); - A02 = ei_pload<LhsPacket>(&lhs2[alignedStart-2]); - A03 = ei_pload<LhsPacket>(&lhs3[alignedStart-3]); + A01 = pload<LhsPacket>(&lhs1[alignedStart-1]); + A02 = pload<LhsPacket>(&lhs2[alignedStart-2]); + A03 = pload<LhsPacket>(&lhs3[alignedStart-3]); for (Index j = alignedStart; j<peeledSize; j+=peels*RhsPacketSize) { - RhsPacket b = ei_pload<RhsPacket>(&rhs[j]); - A11 = ei_pload<LhsPacket>(&lhs1[j-1+LhsPacketSize]); ei_palign<1>(A01,A11); - A12 = ei_pload<LhsPacket>(&lhs2[j-2+LhsPacketSize]); ei_palign<2>(A02,A12); - A13 = ei_pload<LhsPacket>(&lhs3[j-3+LhsPacketSize]); ei_palign<3>(A03,A13); + RhsPacket b = pload<RhsPacket>(&rhs[j]); + A11 = pload<LhsPacket>(&lhs1[j-1+LhsPacketSize]); palign<1>(A01,A11); + A12 = pload<LhsPacket>(&lhs2[j-2+LhsPacketSize]); palign<2>(A02,A12); + A13 = pload<LhsPacket>(&lhs3[j-3+LhsPacketSize]); palign<3>(A03,A13); - ptmp0 = pcj.pmadd(ei_pload<LhsPacket>(&lhs0[j]), b, ptmp0); + ptmp0 = pcj.pmadd(pload<LhsPacket>(&lhs0[j]), b, ptmp0); ptmp1 = pcj.pmadd(A01, b, ptmp1); - A01 = ei_pload<LhsPacket>(&lhs1[j-1+2*LhsPacketSize]); ei_palign<1>(A11,A01); + A01 = pload<LhsPacket>(&lhs1[j-1+2*LhsPacketSize]); palign<1>(A11,A01); ptmp2 = pcj.pmadd(A02, b, ptmp2); - A02 = ei_pload<LhsPacket>(&lhs2[j-2+2*LhsPacketSize]); ei_palign<2>(A12,A02); + A02 = pload<LhsPacket>(&lhs2[j-2+2*LhsPacketSize]); palign<2>(A12,A02); ptmp3 = pcj.pmadd(A03, b, ptmp3); - A03 = ei_pload<LhsPacket>(&lhs3[j-3+2*LhsPacketSize]); ei_palign<3>(A13,A03); + A03 = pload<LhsPacket>(&lhs3[j-3+2*LhsPacketSize]); palign<3>(A13,A03); - b = ei_pload<RhsPacket>(&rhs[j+RhsPacketSize]); - ptmp0 = pcj.pmadd(ei_pload<LhsPacket>(&lhs0[j+LhsPacketSize]), b, ptmp0); + b = pload<RhsPacket>(&rhs[j+RhsPacketSize]); + ptmp0 = pcj.pmadd(pload<LhsPacket>(&lhs0[j+LhsPacketSize]), b, ptmp0); ptmp1 = pcj.pmadd(A11, b, ptmp1); ptmp2 = pcj.pmadd(A12, b, ptmp2); ptmp3 = pcj.pmadd(A13, b, ptmp3); @@ -484,10 +486,10 @@ EIGEN_DONT_INLINE static void run( _EIGEN_ACCUMULATE_PACKETS(du,du,du); break; } - tmp0 += ei_predux(ptmp0); - tmp1 += ei_predux(ptmp1); - tmp2 += ei_predux(ptmp2); - tmp3 += ei_predux(ptmp3); + tmp0 += predux(ptmp0); + tmp1 += predux(ptmp1); + tmp2 += predux(ptmp2); + tmp3 += predux(ptmp3); } } // end explicit vectorization @@ -513,7 +515,7 @@ EIGEN_DONT_INLINE static void run( for (Index i=start; i<end; ++i) { EIGEN_ALIGN16 ResScalar tmp0 = ResScalar(0); - ResPacket ptmp0 = ei_pset1<ResPacket>(tmp0); + ResPacket ptmp0 = pset1<ResPacket>(tmp0); const LhsScalar* lhs0 = lhs + i*lhsStride; // process first unaligned result's coeffs // FIXME this loop get vectorized by the compiler ! @@ -525,11 +527,11 @@ EIGEN_DONT_INLINE static void run( // process aligned rhs coeffs if ((size_t(lhs0+alignedStart)%sizeof(LhsPacket))==0) for (Index j = alignedStart;j<alignedSize;j+=RhsPacketSize) - ptmp0 = pcj.pmadd(ei_pload<LhsPacket>(&lhs0[j]), ei_pload<RhsPacket>(&rhs[j]), ptmp0); + ptmp0 = pcj.pmadd(pload<LhsPacket>(&lhs0[j]), pload<RhsPacket>(&rhs[j]), ptmp0); else for (Index j = alignedStart;j<alignedSize;j+=RhsPacketSize) - ptmp0 = pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[j]), ei_pload<RhsPacket>(&rhs[j]), ptmp0); - tmp0 += ei_predux(ptmp0); + ptmp0 = pcj.pmadd(ploadu<LhsPacket>(&lhs0[j]), pload<RhsPacket>(&rhs[j]), ptmp0); + tmp0 += predux(ptmp0); } // process remaining scalars @@ -552,4 +554,6 @@ EIGEN_DONT_INLINE static void run( } }; +} // end namespace internal + #endif // EIGEN_GENERAL_MATRIX_VECTOR_H diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h index b13c0706e..677504ecc 100644 --- a/Eigen/src/Core/products/Parallelizer.h +++ b/Eigen/src/Core/products/Parallelizer.h @@ -25,19 +25,21 @@ #ifndef EIGEN_PARALLELIZER_H #define EIGEN_PARALLELIZER_H +namespace internal { + /** \internal */ -inline void ei_manage_multi_threading(Action action, int* v) +inline void manage_multi_threading(Action action, int* v) { static int m_maxThreads = -1; if(action==SetAction) { - ei_internal_assert(v!=0); + eigen_internal_assert(v!=0); m_maxThreads = *v; } else if(action==GetAction) { - ei_internal_assert(v!=0); + eigen_internal_assert(v!=0); #ifdef EIGEN_HAS_OPENMP if(m_maxThreads>0) *v = m_maxThreads; @@ -49,7 +51,7 @@ inline void ei_manage_multi_threading(Action action, int* v) } else { - ei_internal_assert(false); + eigen_internal_assert(false); } } @@ -58,7 +60,7 @@ inline void ei_manage_multi_threading(Action action, int* v) inline int nbThreads() { int ret; - ei_manage_multi_threading(GetAction, &ret); + manage_multi_threading(GetAction, &ret); return ret; } @@ -66,7 +68,7 @@ inline int nbThreads() * \sa nbThreads */ inline void setNbThreads(int v) { - ei_manage_multi_threading(SetAction, &v); + manage_multi_threading(SetAction, &v); } template<typename Index> struct GemmParallelInfo @@ -81,7 +83,7 @@ template<typename Index> struct GemmParallelInfo }; template<bool Condition, typename Functor, typename Index> -void ei_parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpose) +void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpose) { #ifndef EIGEN_HAS_OPENMP // FIXME the transpose variable is only needed to properly split @@ -147,4 +149,6 @@ void ei_parallelize_gemm(const Functor& func, Index rows, Index cols, bool trans #endif } +} // end namespace internal + #endif // EIGEN_PARALLELIZER_H diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index ede8b77bf..741c5f630 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -25,12 +25,14 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_H #define EIGEN_SELFADJOINT_MATRIX_MATRIX_H +namespace internal { + // pack a selfadjoint block diagonal for use with the gebp_kernel template<typename Scalar, typename Index, int Pack1, int Pack2, int StorageOrder> -struct ei_symm_pack_lhs +struct symm_pack_lhs { template<int BlockRows> inline - void pack(Scalar* blockA, const ei_const_blas_data_mapper<Scalar,Index,StorageOrder>& lhs, Index cols, Index i, Index& count) + void pack(Scalar* blockA, const const_blas_data_mapper<Scalar,Index,StorageOrder>& lhs, Index cols, Index i, Index& count) { // normal copy for(Index k=0; k<i; k++) @@ -41,9 +43,9 @@ struct ei_symm_pack_lhs for(Index k=i; k<i+BlockRows; k++) { for(Index w=0; w<h; w++) - blockA[count++] = ei_conj(lhs(k, i+w)); // transposed + blockA[count++] = conj(lhs(k, i+w)); // transposed - blockA[count++] = ei_real(lhs(k,k)); // real (diagonal) + blockA[count++] = real(lhs(k,k)); // real (diagonal) for(Index w=h+1; w<BlockRows; w++) blockA[count++] = lhs(i+w, k); // normal @@ -52,11 +54,11 @@ struct ei_symm_pack_lhs // transposed copy for(Index k=i+BlockRows; k<cols; k++) for(Index w=0; w<BlockRows; w++) - blockA[count++] = ei_conj(lhs(k, i+w)); // transposed + blockA[count++] = conj(lhs(k, i+w)); // transposed } void operator()(Scalar* blockA, const Scalar* _lhs, Index lhsStride, Index cols, Index rows) { - ei_const_blas_data_mapper<Scalar,Index,StorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<Scalar,Index,StorageOrder> lhs(_lhs,lhsStride); Index count = 0; Index peeled_mc = (rows/Pack1)*Pack1; for(Index i=0; i<peeled_mc; i+=Pack1) @@ -76,23 +78,23 @@ struct ei_symm_pack_lhs for(Index k=0; k<i; k++) blockA[count++] = lhs(i, k); // normal - blockA[count++] = ei_real(lhs(i, i)); // real (diagonal) + blockA[count++] = real(lhs(i, i)); // real (diagonal) for(Index k=i+1; k<cols; k++) - blockA[count++] = ei_conj(lhs(k, i)); // transposed + blockA[count++] = conj(lhs(k, i)); // transposed } } }; template<typename Scalar, typename Index, int nr, int StorageOrder> -struct ei_symm_pack_rhs +struct symm_pack_rhs { - enum { PacketSize = ei_packet_traits<Scalar>::size }; + enum { PacketSize = packet_traits<Scalar>::size }; void operator()(Scalar* blockB, const Scalar* _rhs, Index rhsStride, Index rows, Index cols, Index k2) { Index end_k = k2 + rows; Index count = 0; - ei_const_blas_data_mapper<Scalar,Index,StorageOrder> rhs(_rhs,rhsStride); + const_blas_data_mapper<Scalar,Index,StorageOrder> rhs(_rhs,rhsStride); Index packet_cols = (cols/nr)*nr; // first part: normal case @@ -118,12 +120,12 @@ struct ei_symm_pack_rhs // transpose for(Index k=k2; k<j2; k++) { - blockB[count+0] = ei_conj(rhs(j2+0,k)); - blockB[count+1] = ei_conj(rhs(j2+1,k)); + blockB[count+0] = conj(rhs(j2+0,k)); + blockB[count+1] = conj(rhs(j2+1,k)); if (nr==4) { - blockB[count+2] = ei_conj(rhs(j2+2,k)); - blockB[count+3] = ei_conj(rhs(j2+3,k)); + blockB[count+2] = conj(rhs(j2+2,k)); + blockB[count+3] = conj(rhs(j2+3,k)); } count += nr; } @@ -135,11 +137,11 @@ struct ei_symm_pack_rhs for (Index w=0 ; w<h; ++w) blockB[count+w] = rhs(k,j2+w); - blockB[count+h] = ei_real(rhs(k,k)); + blockB[count+h] = real(rhs(k,k)); // transpose for (Index w=h+1 ; w<nr; ++w) - blockB[count+w] = ei_conj(rhs(j2+w,k)); + blockB[count+w] = conj(rhs(j2+w,k)); count += nr; ++h; } @@ -162,12 +164,12 @@ struct ei_symm_pack_rhs { for(Index k=k2; k<end_k; k++) { - blockB[count+0] = ei_conj(rhs(j2+0,k)); - blockB[count+1] = ei_conj(rhs(j2+1,k)); + blockB[count+0] = conj(rhs(j2+0,k)); + blockB[count+1] = conj(rhs(j2+1,k)); if (nr==4) { - blockB[count+2] = ei_conj(rhs(j2+2,k)); - blockB[count+3] = ei_conj(rhs(j2+3,k)); + blockB[count+2] = conj(rhs(j2+2,k)); + blockB[count+3] = conj(rhs(j2+3,k)); } count += nr; } @@ -180,13 +182,13 @@ struct ei_symm_pack_rhs Index half = std::min(end_k,j2); for(Index k=k2; k<half; k++) { - blockB[count] = ei_conj(rhs(j2,k)); + blockB[count] = conj(rhs(j2,k)); count += 1; } if(half==j2 && half<k2+rows) { - blockB[count] = ei_real(rhs(j2,j2)); + blockB[count] = real(rhs(j2,j2)); count += 1; } else @@ -209,12 +211,12 @@ template <typename Scalar, typename Index, int LhsStorageOrder, bool LhsSelfAdjoint, bool ConjugateLhs, int RhsStorageOrder, bool RhsSelfAdjoint, bool ConjugateRhs, int ResStorageOrder> -struct ei_product_selfadjoint_matrix; +struct product_selfadjoint_matrix; template <typename Scalar, typename Index, int LhsStorageOrder, bool LhsSelfAdjoint, bool ConjugateLhs, int RhsStorageOrder, bool RhsSelfAdjoint, bool ConjugateRhs> -struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,LhsSelfAdjoint,ConjugateLhs, RhsStorageOrder,RhsSelfAdjoint,ConjugateRhs,RowMajor> +struct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,LhsSelfAdjoint,ConjugateLhs, RhsStorageOrder,RhsSelfAdjoint,ConjugateRhs,RowMajor> { static EIGEN_STRONG_INLINE void run( @@ -224,7 +226,7 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,LhsSelfAdjoint Scalar* res, Index resStride, Scalar alpha) { - ei_product_selfadjoint_matrix<Scalar, Index, + product_selfadjoint_matrix<Scalar, Index, EIGEN_LOGICAL_XOR(RhsSelfAdjoint,RhsStorageOrder==RowMajor) ? ColMajor : RowMajor, RhsSelfAdjoint, NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(RhsSelfAdjoint,ConjugateRhs), EIGEN_LOGICAL_XOR(LhsSelfAdjoint,LhsStorageOrder==RowMajor) ? ColMajor : RowMajor, @@ -237,7 +239,7 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,LhsSelfAdjoint template <typename Scalar, typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> -struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,ConjugateLhs, RhsStorageOrder,false,ConjugateRhs,ColMajor> +struct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,ConjugateLhs, RhsStorageOrder,false,ConjugateRhs,ColMajor> { static EIGEN_DONT_INLINE void run( @@ -249,10 +251,10 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,Conjugate { Index size = rows; - ei_const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); - ei_const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); + const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; Index kc = size; // cache block size along the K direction Index mc = rows; // cache block size along the M direction @@ -267,10 +269,10 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,Conjugate Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); Scalar* blockB = allocatedBlockB + sizeW; - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; - ei_symm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder==RowMajor?ColMajor:RowMajor, true> pack_lhs_transposed; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; + symm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder==RowMajor?ColMajor:RowMajor, true> pack_lhs_transposed; for(Index k2=0; k2<size; k2+=kc) { @@ -305,7 +307,7 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,Conjugate for(Index i2=k2+kc; i2<size; i2+=mc) { const Index actual_mc = std::min(i2+mc,size)-i2; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder,false>() + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder,false>() (blockA, &lhs(i2, k2), lhsStride, actual_kc, actual_mc); gebp_kernel(res+i2, resStride, blockA, blockB, actual_mc, actual_kc, cols, alpha); @@ -321,7 +323,7 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,Conjugate template <typename Scalar, typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> -struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,ConjugateLhs, RhsStorageOrder,true,ConjugateRhs,ColMajor> +struct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,ConjugateLhs, RhsStorageOrder,true,ConjugateRhs,ColMajor> { static EIGEN_DONT_INLINE void run( @@ -333,9 +335,9 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,Conjugat { Index size = cols; - ei_const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; Index kc = size; // cache block size along the K direction Index mc = rows; // cache block size along the M direction @@ -348,9 +350,9 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,Conjugat Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); Scalar* blockB = allocatedBlockB + sizeW; - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; - ei_symm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; + symm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; for(Index k2=0; k2<size; k2+=kc) { @@ -373,14 +375,18 @@ struct ei_product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,Conjugat } }; +} // end namespace internal + /*************************************************************************** -* Wrapper to ei_product_selfadjoint_matrix +* Wrapper to product_selfadjoint_matrix ***************************************************************************/ +namespace internal { template<typename Lhs, int LhsMode, typename Rhs, int RhsMode> -struct ei_traits<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> > - : ei_traits<ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false>, Lhs, Rhs> > +struct traits<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> > + : traits<ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false>, Lhs, Rhs> > {}; +} template<typename Lhs, int LhsMode, typename Rhs, int RhsMode> struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> @@ -399,7 +405,7 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -407,14 +413,14 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_product_selfadjoint_matrix<Scalar, Index, + internal::product_selfadjoint_matrix<Scalar, Index, EIGEN_LOGICAL_XOR(LhsIsUpper, - ei_traits<Lhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, LhsIsSelfAdjoint, + internal::traits<Lhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, LhsIsSelfAdjoint, NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(LhsIsUpper,bool(LhsBlasTraits::NeedToConjugate)), EIGEN_LOGICAL_XOR(RhsIsUpper, - ei_traits<Rhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, RhsIsSelfAdjoint, + internal::traits<Rhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, RhsIsSelfAdjoint, NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(RhsIsUpper,bool(RhsBlasTraits::NeedToConjugate)), - ei_traits<Dest>::Flags&RowMajorBit ? RowMajor : ColMajor> + internal::traits<Dest>::Flags&RowMajorBit ? RowMajor : ColMajor> ::run( lhs.rows(), rhs.cols(), // sizes &lhs.coeff(0,0), lhs.outerStride(), // lhs info diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index df7509f9a..57f4b7da3 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -25,19 +25,21 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_H #define EIGEN_SELFADJOINT_MATRIX_VECTOR_H +namespace internal { + /* Optimized selfadjoint matrix * vector product: * This algorithm processes 2 columns at onces that allows to both reduce * the number of load/stores of the result by a factor 2 and to reduce * the instruction dependency. */ template<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> -static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( +static EIGEN_DONT_INLINE void product_selfadjoint_vector( Index size, const Scalar* lhs, Index lhsStride, const Scalar* _rhs, Index rhsIncr, Scalar* res, Scalar alpha) { - typedef typename ei_packet_traits<Scalar>::type Packet; + typedef typename packet_traits<Scalar>::type Packet; const Index PacketSize = sizeof(Packet)/sizeof(Scalar); enum { @@ -46,13 +48,13 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( FirstTriangular = IsRowMajor == IsLower }; - ei_conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, IsRowMajor), ConjugateRhs> cj0; - ei_conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> cj1; + conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, IsRowMajor), ConjugateRhs> cj0; + conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> cj1; - ei_conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, IsRowMajor), ConjugateRhs> pcj0; - ei_conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> pcj1; + conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, IsRowMajor), ConjugateRhs> pcj0; + conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> pcj1; - Scalar cjAlpha = ConjugateRhs ? ei_conj(alpha) : alpha; + Scalar cjAlpha = ConjugateRhs ? conj(alpha) : alpha; // if the rhs is not sequentially stored in memory we copy it to a temporary buffer, // this is because we need to extract packets @@ -77,19 +79,19 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( register const Scalar* EIGEN_RESTRICT A1 = lhs + (j+1)*lhsStride; Scalar t0 = cjAlpha * rhs[j]; - Packet ptmp0 = ei_pset1<Packet>(t0); + Packet ptmp0 = pset1<Packet>(t0); Scalar t1 = cjAlpha * rhs[j+1]; - Packet ptmp1 = ei_pset1<Packet>(t1); + Packet ptmp1 = pset1<Packet>(t1); Scalar t2 = 0; - Packet ptmp2 = ei_pset1<Packet>(t2); + Packet ptmp2 = pset1<Packet>(t2); Scalar t3 = 0; - Packet ptmp3 = ei_pset1<Packet>(t3); + Packet ptmp3 = pset1<Packet>(t3); size_t starti = FirstTriangular ? 0 : j+2; size_t endi = FirstTriangular ? j : size; size_t alignedEnd = starti; - size_t alignedStart = (starti) + ei_first_aligned(&res[starti], endi-starti); + size_t alignedStart = (starti) + first_aligned(&res[starti], endi-starti); alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize); res[j] += cj0.pmul(A0[j], t0); @@ -108,8 +110,8 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( for (size_t i=starti; i<alignedStart; ++i) { res[i] += t0 * A0[i] + t1 * A1[i]; - t2 += ei_conj(A0[i]) * rhs[i]; - t3 += ei_conj(A1[i]) * rhs[i]; + t2 += conj(A0[i]) * rhs[i]; + t3 += conj(A1[i]) * rhs[i]; } // Yes this an optimization for gcc 4.3 and 4.4 (=> huge speed up) // gcc 4.2 does this optimization automatically. @@ -119,15 +121,15 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( Scalar* EIGEN_RESTRICT resIt = res + alignedStart; for (size_t i=alignedStart; i<alignedEnd; i+=PacketSize) { - Packet A0i = ei_ploadu<Packet>(a0It); a0It += PacketSize; - Packet A1i = ei_ploadu<Packet>(a1It); a1It += PacketSize; - Packet Bi = ei_ploadu<Packet>(rhsIt); rhsIt += PacketSize; // FIXME should be aligned in most cases - Packet Xi = ei_pload <Packet>(resIt); + Packet A0i = ploadu<Packet>(a0It); a0It += PacketSize; + Packet A1i = ploadu<Packet>(a1It); a1It += PacketSize; + Packet Bi = ploadu<Packet>(rhsIt); rhsIt += PacketSize; // FIXME should be aligned in most cases + Packet Xi = pload <Packet>(resIt); Xi = pcj0.pmadd(A0i,ptmp0, pcj0.pmadd(A1i,ptmp1,Xi)); ptmp2 = pcj1.pmadd(A0i, Bi, ptmp2); ptmp3 = pcj1.pmadd(A1i, Bi, ptmp3); - ei_pstore(resIt,Xi); resIt += PacketSize; + pstore(resIt,Xi); resIt += PacketSize; } for (size_t i=alignedEnd; i<endi; i++) { @@ -136,8 +138,8 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( t3 += cj1.pmul(A1[i], rhs[i]); } - res[j] += alpha * (t2 + ei_predux(ptmp2)); - res[j+1] += alpha * (t3 + ei_predux(ptmp3)); + res[j] += alpha * (t2 + predux(ptmp2)); + res[j+1] += alpha * (t3 + predux(ptmp3)); } for (Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound : size);j++) { @@ -157,14 +159,18 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( ei_aligned_stack_delete(Scalar, const_cast<Scalar*>(rhs), size); } +} // end namespace internal + /*************************************************************************** -* Wrapper to ei_product_selfadjoint_vector +* Wrapper to product_selfadjoint_vector ***************************************************************************/ +namespace internal { template<typename Lhs, int LhsMode, typename Rhs> -struct ei_traits<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> > - : ei_traits<ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>, Lhs, Rhs> > +struct traits<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> > + : traits<ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>, Lhs, Rhs> > {}; +} template<typename Lhs, int LhsMode, typename Rhs> struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> @@ -180,7 +186,7 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -188,9 +194,9 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_assert(dst.innerStride()==1 && "not implemented yet"); + eigen_assert(dst.innerStride()==1 && "not implemented yet"); - ei_product_selfadjoint_vector<Scalar, Index, (ei_traits<_ActualLhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)> + internal::product_selfadjoint_vector<Scalar, Index, (internal::traits<_ActualLhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)> ( lhs.rows(), // size &lhs.coeff(0,0), lhs.outerStride(), // lhs info @@ -201,10 +207,12 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true> } }; +namespace internal { template<typename Lhs, typename Rhs, int RhsMode> -struct ei_traits<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false> > - : ei_traits<ProductBase<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false>, Lhs, Rhs> > +struct traits<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false> > + : traits<ProductBase<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false>, Lhs, Rhs> > {}; +} template<typename Lhs, typename Rhs, int RhsMode> struct SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false> @@ -220,7 +228,7 @@ struct SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false> template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -228,10 +236,10 @@ struct SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_assert(dst.innerStride()==1 && "not implemented yet"); + eigen_assert(dst.innerStride()==1 && "not implemented yet"); // transpose the product - ei_product_selfadjoint_vector<Scalar, Index, (ei_traits<_ActualRhsType>::Flags&RowMajorBit) ? ColMajor : RowMajor, int(RhsUpLo)==Upper ? Lower : Upper, + internal::product_selfadjoint_vector<Scalar, Index, (internal::traits<_ActualRhsType>::Flags&RowMajorBit) ? ColMajor : RowMajor, int(RhsUpLo)==Upper ? Lower : Upper, bool(RhsBlasTraits::NeedToConjugate), bool(LhsBlasTraits::NeedToConjugate)> ( rhs.rows(), // size diff --git a/Eigen/src/Core/products/SelfadjointProduct.h b/Eigen/src/Core/products/SelfadjointProduct.h index 8f431c2e4..26aa65cca 100644 --- a/Eigen/src/Core/products/SelfadjointProduct.h +++ b/Eigen/src/Core/products/SelfadjointProduct.h @@ -25,6 +25,8 @@ #ifndef EIGEN_SELFADJOINT_PRODUCT_H #define EIGEN_SELFADJOINT_PRODUCT_H +namespace internal { + /********************************************************************** * This file implements a self adjoint product: C += A A^T updating only * half of the selfadjoint matrix C. @@ -33,28 +35,28 @@ // forward declarations (defined at the end of this file) template<typename Scalar, typename Index, int mr, int nr, bool ConjLhs, bool ConjRhs, int UpLo> -struct ei_sybb_kernel; +struct sybb_kernel; /* Optimized selfadjoint product (_SYRK) */ template <typename Scalar, typename Index, int RhsStorageOrder, int ResStorageOrder, bool AAT, int UpLo> -struct ei_selfadjoint_product; +struct selfadjoint_product; // as usual if the result is row major => we transpose the product template <typename Scalar, typename Index, int MatStorageOrder, bool AAT, int UpLo> -struct ei_selfadjoint_product<Scalar, Index, MatStorageOrder, RowMajor, AAT, UpLo> +struct selfadjoint_product<Scalar, Index, MatStorageOrder, RowMajor, AAT, UpLo> { static EIGEN_STRONG_INLINE void run(Index size, Index depth, const Scalar* mat, Index matStride, Scalar* res, Index resStride, Scalar alpha) { - ei_selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, !AAT, UpLo==Lower?Upper:Lower> + selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, !AAT, UpLo==Lower?Upper:Lower> ::run(size, depth, mat, matStride, res, resStride, alpha); } }; template <typename Scalar, typename Index, int MatStorageOrder, bool AAT, int UpLo> -struct ei_selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, AAT, UpLo> +struct selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, AAT, UpLo> { static EIGEN_DONT_INLINE void run( @@ -63,12 +65,12 @@ struct ei_selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, AAT, UpL Scalar* res, Index resStride, Scalar alpha) { - ei_const_blas_data_mapper<Scalar, Index, MatStorageOrder> mat(_mat,matStride); + const_blas_data_mapper<Scalar, Index, MatStorageOrder> mat(_mat,matStride); // if(AAT) -// alpha = ei_conj(alpha); +// alpha = conj(alpha); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; Index kc = depth; // cache block size along the K direction Index mc = size; // cache block size along the M direction @@ -90,10 +92,10 @@ struct ei_selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, AAT, UpL ConjRhs = NumTraits<Scalar>::IsComplex && AAT }; - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjLhs, ConjRhs> gebp_kernel; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,MatStorageOrder==RowMajor ? ColMajor : RowMajor> pack_rhs; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, MatStorageOrder, false> pack_lhs; - ei_sybb_kernel<Scalar, Index, Traits::mr, Traits::nr, ConjLhs, ConjRhs, UpLo> sybb; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjLhs, ConjRhs> gebp_kernel; + gemm_pack_rhs<Scalar, Index, Traits::nr,MatStorageOrder==RowMajor ? ColMajor : RowMajor> pack_rhs; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, MatStorageOrder, false> pack_lhs; + sybb_kernel<Scalar, Index, Traits::mr, Traits::nr, ConjLhs, ConjRhs, UpLo> sybb; for(Index k2=0; k2<depth; k2+=kc) { @@ -131,33 +133,6 @@ struct ei_selfadjoint_product<Scalar, Index, MatStorageOrder, ColMajor, AAT, UpL } }; -// high level API - -template<typename MatrixType, unsigned int UpLo> -template<typename DerivedU> -SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> -::rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha) -{ - typedef ei_blas_traits<DerivedU> UBlasTraits; - typedef typename UBlasTraits::DirectLinearAccessType ActualUType; - typedef typename ei_cleantype<ActualUType>::type _ActualUType; - const ActualUType actualU = UBlasTraits::extract(u.derived()); - - Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()); - - enum { IsRowMajor = (ei_traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; - - ei_selfadjoint_product<Scalar, Index, - _ActualUType::Flags&RowMajorBit ? RowMajor : ColMajor, - MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor, - !UBlasTraits::NeedToConjugate, UpLo> - ::run(_expression().cols(), actualU.cols(), &actualU.coeff(0,0), actualU.outerStride(), - const_cast<Scalar*>(_expression().data()), _expression().outerStride(), actualAlpha); - - return *this; -} - - // Optimized SYmmetric packed Block * packed Block product kernel. // This kernel is built on top of the gebp kernel: // - the current selfadjoint block (res) is processed per panel of actual_mc x BlockSize @@ -168,15 +143,15 @@ SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> // small temporary buffer which is then accumulated into the result using a // triangular traversal. template<typename Scalar, typename Index, int mr, int nr, bool ConjLhs, bool ConjRhs, int UpLo> -struct ei_sybb_kernel +struct sybb_kernel { enum { - PacketSize = ei_packet_traits<Scalar>::size, + PacketSize = packet_traits<Scalar>::size, BlockSize = EIGEN_PLAIN_ENUM_MAX(mr,nr) }; void operator()(Scalar* res, Index resStride, const Scalar* blockA, const Scalar* blockB, Index size, Index depth, Scalar alpha, Scalar* workspace) { - ei_gebp_kernel<Scalar, Scalar, Index, mr, nr, ConjLhs, ConjRhs> gebp_kernel; + gebp_kernel<Scalar, Scalar, Index, mr, nr, ConjLhs, ConjRhs> gebp_kernel; Matrix<Scalar,BlockSize,BlockSize,ColMajor> buffer; // let's process the block per panel of actual_mc x BlockSize, @@ -217,4 +192,32 @@ struct ei_sybb_kernel } }; +} // end namespace internal + +// high level API + +template<typename MatrixType, unsigned int UpLo> +template<typename DerivedU> +SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> +::rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha) +{ + typedef internal::blas_traits<DerivedU> UBlasTraits; + typedef typename UBlasTraits::DirectLinearAccessType ActualUType; + typedef typename internal::cleantype<ActualUType>::type _ActualUType; + const ActualUType actualU = UBlasTraits::extract(u.derived()); + + Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()); + + enum { IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; + + internal::selfadjoint_product<Scalar, Index, + _ActualUType::Flags&RowMajorBit ? RowMajor : ColMajor, + MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor, + !UBlasTraits::NeedToConjugate, UpLo> + ::run(_expression().cols(), actualU.cols(), &actualU.coeff(0,0), actualU.outerStride(), + const_cast<Scalar*>(_expression().data()), _expression().outerStride(), actualAlpha); + + return *this; +} + #endif // EIGEN_SELFADJOINT_PRODUCT_H diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index a617f1cc6..13b088031 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -25,15 +25,17 @@ #ifndef EIGEN_SELFADJOINTRANK2UPTADE_H #define EIGEN_SELFADJOINTRANK2UPTADE_H +namespace internal { + /* Optimized selfadjoint matrix += alpha * uv' + vu' * It corresponds to the Level2 syr2 BLAS routine */ template<typename Scalar, typename Index, typename UType, typename VType, int UpLo> -struct ei_selfadjoint_rank2_update_selector; +struct selfadjoint_rank2_update_selector; template<typename Scalar, typename Index, typename UType, typename VType> -struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> +struct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> { static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) { @@ -41,52 +43,53 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> for (Index i=0; i<size; ++i) { Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+i, size-i) += - (alpha * ei_conj(u.coeff(i))) * v.tail(size-i) - + (alpha * ei_conj(v.coeff(i))) * u.tail(size-i); + (alpha * conj(u.coeff(i))) * v.tail(size-i) + + (alpha * conj(v.coeff(i))) * u.tail(size-i); } } }; template<typename Scalar, typename Index, typename UType, typename VType> -struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Upper> +struct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Upper> { static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) { const Index size = u.size(); for (Index i=0; i<size; ++i) Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i, i+1) += - (alpha * ei_conj(u.coeff(i))) * v.head(i+1) - + (alpha * ei_conj(v.coeff(i))) * u.head(i+1); + (alpha * conj(u.coeff(i))) * v.head(i+1) + + (alpha * conj(v.coeff(i))) * u.head(i+1); } }; -template<bool Cond, typename T> struct ei_conj_expr_if - : ei_meta_if<!Cond, const T&, - CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<T>::Scalar>,T> > {}; +template<bool Cond, typename T> struct conj_expr_if + : meta_if<!Cond, const T&, + CwiseUnaryOp<scalar_conjugate_op<typename traits<T>::Scalar>,T> > {}; +} // end namespace internal template<typename MatrixType, unsigned int UpLo> template<typename DerivedU, typename DerivedV> SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> ::rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha) { - typedef ei_blas_traits<DerivedU> UBlasTraits; + typedef internal::blas_traits<DerivedU> UBlasTraits; typedef typename UBlasTraits::DirectLinearAccessType ActualUType; - typedef typename ei_cleantype<ActualUType>::type _ActualUType; + typedef typename internal::cleantype<ActualUType>::type _ActualUType; const ActualUType actualU = UBlasTraits::extract(u.derived()); - typedef ei_blas_traits<DerivedV> VBlasTraits; + typedef internal::blas_traits<DerivedV> VBlasTraits; typedef typename VBlasTraits::DirectLinearAccessType ActualVType; - typedef typename ei_cleantype<ActualVType>::type _ActualVType; + typedef typename internal::cleantype<ActualVType>::type _ActualVType; const ActualVType actualV = VBlasTraits::extract(v.derived()); Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) * VBlasTraits::extractScalarFactor(v.derived()); - enum { IsRowMajor = (ei_traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; - ei_selfadjoint_rank2_update_selector<Scalar, Index, - typename ei_cleantype<typename ei_conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::ret>::type, - typename ei_cleantype<typename ei_conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::ret>::type, + enum { IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; + internal::selfadjoint_rank2_update_selector<Scalar, Index, + typename internal::cleantype<typename internal::conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::ret>::type, + typename internal::cleantype<typename internal::conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::ret>::type, (IsRowMajor ? int(UpLo==Upper ? Lower : Upper) : UpLo)> ::run(const_cast<Scalar*>(_expression().data()),_expression().outerStride(),actualU,actualV,actualAlpha); diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix.h b/Eigen/src/Core/products/TriangularMatrixMatrix.h index cef5eeba1..e35399243 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix.h @@ -25,14 +25,16 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_H #define EIGEN_TRIANGULAR_MATRIX_MATRIX_H +namespace internal { + // template<typename Scalar, int mr, int StorageOrder, bool Conjugate, int Mode> -// struct ei_gemm_pack_lhs_triangular +// struct gemm_pack_lhs_triangular // { // Matrix<Scalar,mr,mr, // void operator()(Scalar* blockA, const EIGEN_RESTRICT Scalar* _lhs, int lhsStride, int depth, int rows) // { -// ei_conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; -// ei_const_blas_data_mapper<Scalar, StorageOrder> lhs(_lhs,lhsStride); +// conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj; +// const_blas_data_mapper<Scalar, StorageOrder> lhs(_lhs,lhsStride); // int count = 0; // const int peeled_mc = (rows/mr)*mr; // for(int i=0; i<peeled_mc; i+=mr) @@ -57,13 +59,13 @@ template <typename Scalar, typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs, int ResStorageOrder> -struct ei_product_triangular_matrix_matrix; +struct product_triangular_matrix_matrix; template <typename Scalar, typename Index, int Mode, bool LhsIsTriangular, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> -struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,LhsIsTriangular, +struct product_triangular_matrix_matrix<Scalar,Index,Mode,LhsIsTriangular, LhsStorageOrder,ConjugateLhs, RhsStorageOrder,ConjugateRhs,RowMajor> { @@ -74,7 +76,7 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,LhsIsTriangular, Scalar* res, Index resStride, Scalar alpha) { - ei_product_triangular_matrix_matrix<Scalar, Index, + product_triangular_matrix_matrix<Scalar, Index, (Mode&(UnitDiag|ZeroDiag)) | ((Mode&Upper) ? Lower : Upper), (!LhsIsTriangular), RhsStorageOrder==RowMajor ? ColMajor : RowMajor, @@ -90,7 +92,7 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,LhsIsTriangular, template <typename Scalar, typename Index, int Mode, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> -struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,true, +struct product_triangular_matrix_matrix<Scalar,Index,Mode,true, LhsStorageOrder,ConjugateLhs, RhsStorageOrder,ConjugateRhs,ColMajor> { @@ -102,10 +104,10 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,true, Scalar* res, Index resStride, Scalar alpha) { - ei_const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); - ei_const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); + const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; enum { SmallPanelWidth = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr), IsLower = (Mode&Lower) == Lower, @@ -130,9 +132,9 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,true, else triangularBuffer.diagonal().setOnes(); - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; for(Index k2=IsLower ? depth : 0; IsLower ? k2>0 : k2<depth; @@ -199,7 +201,7 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,true, for(Index i2=start; i2<end; i2+=mc) { const Index actual_mc = std::min(i2+mc,end)-i2; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr,Traits::LhsProgress, LhsStorageOrder,false>() + gemm_pack_lhs<Scalar, Index, Traits::mr,Traits::LhsProgress, LhsStorageOrder,false>() (blockA, &lhs(i2, actual_k2), lhsStride, actual_kc, actual_mc); gebp_kernel(res+i2, resStride, blockA, blockB, actual_mc, actual_kc, cols, alpha); @@ -217,7 +219,7 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,true, template <typename Scalar, typename Index, int Mode, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> -struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,false, +struct product_triangular_matrix_matrix<Scalar,Index,Mode,false, LhsStorageOrder,ConjugateLhs, RhsStorageOrder,ConjugateRhs,ColMajor> { @@ -229,10 +231,10 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,false, Scalar* res, Index resStride, Scalar alpha) { - ei_const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); - ei_const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); + const_blas_data_mapper<Scalar, Index, LhsStorageOrder> lhs(_lhs,lhsStride); + const_blas_data_mapper<Scalar, Index, RhsStorageOrder> rhs(_rhs,rhsStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; enum { SmallPanelWidth = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr), IsLower = (Mode&Lower) == Lower, @@ -257,10 +259,10 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,false, else triangularBuffer.diagonal().setOnes(); - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder,false,true> pack_rhs_panel; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder,false,true> pack_rhs_panel; for(Index k2=IsLower ? 0 : depth; IsLower ? k2<depth : k2>0; @@ -352,14 +354,16 @@ struct ei_product_triangular_matrix_matrix<Scalar,Index,Mode,false, }; /*************************************************************************** -* Wrapper to ei_product_triangular_matrix_matrix +* Wrapper to product_triangular_matrix_matrix ***************************************************************************/ template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs> -struct ei_traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> > - : ei_traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false>, Lhs, Rhs> > +struct traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> > + : traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false>, Lhs, Rhs> > {}; +} // end namespace internal + template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs> struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> : public ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false>, Lhs, Rhs > @@ -376,11 +380,11 @@ struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_product_triangular_matrix_matrix<Scalar, Index, + internal::product_triangular_matrix_matrix<Scalar, Index, Mode, LhsIsTriangular, - (ei_traits<_ActualLhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, LhsBlasTraits::NeedToConjugate, - (ei_traits<_ActualRhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, RhsBlasTraits::NeedToConjugate, - (ei_traits<Dest >::Flags&RowMajorBit) ? RowMajor : ColMajor> + (internal::traits<_ActualLhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, LhsBlasTraits::NeedToConjugate, + (internal::traits<_ActualRhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, RhsBlasTraits::NeedToConjugate, + (internal::traits<Dest >::Flags&RowMajorBit) ? RowMajor : ColMajor> ::run( lhs.rows(), rhs.cols(), lhs.cols(),// LhsIsTriangular ? rhs.cols() : lhs.rows(), // sizes &lhs.coeff(0,0), lhs.outerStride(), // lhs info @@ -391,4 +395,5 @@ struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> } }; + #endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_H diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h index 67c131ab2..4c1cfc492 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector.h +++ b/Eigen/src/Core/products/TriangularMatrixVector.h @@ -25,26 +25,28 @@ #ifndef EIGEN_TRIANGULARMATRIXVECTOR_H #define EIGEN_TRIANGULARMATRIXVECTOR_H +namespace internal { + template<bool LhsIsTriangular, typename Lhs, typename Rhs, typename Result, int Mode, bool ConjLhs, bool ConjRhs, int StorageOrder> -struct ei_product_triangular_vector_selector; +struct product_triangular_vector_selector; template<typename Lhs, typename Rhs, typename Result, int Mode, bool ConjLhs, bool ConjRhs, int StorageOrder> -struct ei_product_triangular_vector_selector<false,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,StorageOrder> +struct product_triangular_vector_selector<false,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,StorageOrder> { - static EIGEN_DONT_INLINE void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename ei_traits<Lhs>::Scalar alpha) + static EIGEN_DONT_INLINE void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename traits<Lhs>::Scalar alpha) { typedef Transpose<Rhs> TrRhs; TrRhs trRhs(rhs); typedef Transpose<Lhs> TrLhs; TrLhs trLhs(lhs); typedef Transpose<Result> TrRes; TrRes trRes(res); - ei_product_triangular_vector_selector<true,TrRhs,TrLhs,TrRes, + product_triangular_vector_selector<true,TrRhs,TrLhs,TrRes, (Mode & UnitDiag) | (Mode & Lower) ? Upper : Lower, ConjRhs, ConjLhs, StorageOrder==RowMajor ? ColMajor : RowMajor> ::run(trRhs,trLhs,trRes,alpha); } }; template<typename Lhs, typename Rhs, typename Result, int Mode, bool ConjLhs, bool ConjRhs> -struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,ColMajor> +struct product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,ColMajor> { typedef typename Rhs::Scalar Scalar; typedef typename Rhs::Index Index; @@ -52,11 +54,11 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co IsLower = ((Mode&Lower)==Lower), HasUnitDiag = (Mode & UnitDiag)==UnitDiag }; - static EIGEN_DONT_INLINE void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename ei_traits<Lhs>::Scalar alpha) + static EIGEN_DONT_INLINE void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename traits<Lhs>::Scalar alpha) { static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH; - typename ei_conj_expr_if<ConjLhs,Lhs>::ret cjLhs(lhs); - typename ei_conj_expr_if<ConjRhs,Rhs>::ret cjRhs(rhs); + typename conj_expr_if<ConjLhs,Lhs>::ret cjLhs(lhs); + typename conj_expr_if<ConjRhs,Rhs>::ret cjRhs(rhs); Index size = lhs.cols(); for (Index pi=0; pi<size; pi+=PanelWidth) @@ -76,7 +78,7 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co if (r>0) { Index s = IsLower ? pi+actualPanelWidth : 0; - ei_general_matrix_vector_product<Index,Scalar,ColMajor,ConjLhs,Scalar,ConjRhs>::run( + general_matrix_vector_product<Index,Scalar,ColMajor,ConjLhs,Scalar,ConjRhs>::run( r, actualPanelWidth, &(lhs.const_cast_derived().coeffRef(s,pi)), lhs.outerStride(), &rhs.coeff(pi), rhs.innerStride(), @@ -87,7 +89,7 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co }; template<typename Lhs, typename Rhs, typename Result, int Mode, bool ConjLhs, bool ConjRhs> -struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,RowMajor> +struct product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs,RowMajor> { typedef typename Rhs::Scalar Scalar; typedef typename Rhs::Index Index; @@ -95,11 +97,11 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co IsLower = ((Mode&Lower)==Lower), HasUnitDiag = (Mode & UnitDiag)==UnitDiag }; - static void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename ei_traits<Lhs>::Scalar alpha) + static void run(const Lhs& lhs, const Rhs& rhs, Result& res, typename traits<Lhs>::Scalar alpha) { static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH; - typename ei_conj_expr_if<ConjLhs,Lhs>::ret cjLhs(lhs); - typename ei_conj_expr_if<ConjRhs,Rhs>::ret cjRhs(rhs); + typename conj_expr_if<ConjLhs,Lhs>::ret cjLhs(lhs); + typename conj_expr_if<ConjRhs,Rhs>::ret cjRhs(rhs); Index size = lhs.cols(); for (Index pi=0; pi<size; pi+=PanelWidth) { @@ -118,7 +120,7 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co if (r>0) { Index s = IsLower ? 0 : pi + actualPanelWidth; - ei_general_matrix_vector_product<Index,Scalar,RowMajor,ConjLhs,Scalar,ConjRhs>::run( + general_matrix_vector_product<Index,Scalar,RowMajor,ConjLhs,Scalar,ConjRhs>::run( actualPanelWidth, r, &(lhs.const_cast_derived().coeffRef(pi,s)), lhs.outerStride(), &(rhs.const_cast_derived().coeffRef(s)), 1, @@ -129,19 +131,21 @@ struct ei_product_triangular_vector_selector<true,Lhs,Rhs,Result,Mode,ConjLhs,Co }; /*************************************************************************** -* Wrapper to ei_product_triangular_vector +* Wrapper to product_triangular_vector ***************************************************************************/ template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs> -struct ei_traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,true> > - : ei_traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,true>, Lhs, Rhs> > +struct traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,true> > + : traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,true>, Lhs, Rhs> > {}; template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs> -struct ei_traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,true,Rhs,false> > - : ei_traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,true,Rhs,false>, Lhs, Rhs> > +struct traits<TriangularProduct<Mode,LhsIsTriangular,Lhs,true,Rhs,false> > + : traits<ProductBase<TriangularProduct<Mode,LhsIsTriangular,Lhs,true,Rhs,false>, Lhs, Rhs> > {}; +} // end namespace internal + template<int Mode, typename Lhs, typename Rhs> struct TriangularProduct<Mode,true,Lhs,false,Rhs,true> : public ProductBase<TriangularProduct<Mode,true,Lhs,false,Rhs,true>, Lhs, Rhs > @@ -152,7 +156,7 @@ struct TriangularProduct<Mode,true,Lhs,false,Rhs,true> template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -160,12 +164,12 @@ struct TriangularProduct<Mode,true,Lhs,false,Rhs,true> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_product_triangular_vector_selector + internal::product_triangular_vector_selector <true,_ActualLhsType,_ActualRhsType,Dest, Mode, LhsBlasTraits::NeedToConjugate, RhsBlasTraits::NeedToConjugate, - (int(ei_traits<Lhs>::Flags)&RowMajorBit) ? RowMajor : ColMajor> + (int(internal::traits<Lhs>::Flags)&RowMajorBit) ? RowMajor : ColMajor> ::run(lhs,rhs,dst,actualAlpha); } }; @@ -181,7 +185,7 @@ struct TriangularProduct<Mode,false,Lhs,true,Rhs,false> template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const { - ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + eigen_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); @@ -189,12 +193,12 @@ struct TriangularProduct<Mode,false,Lhs,true,Rhs,false> Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); - ei_product_triangular_vector_selector + internal::product_triangular_vector_selector <false,_ActualLhsType,_ActualRhsType,Dest, Mode, LhsBlasTraits::NeedToConjugate, RhsBlasTraits::NeedToConjugate, - (int(ei_traits<Rhs>::Flags)&RowMajorBit) ? RowMajor : ColMajor> + (int(internal::traits<Rhs>::Flags)&RowMajorBit) ? RowMajor : ColMajor> ::run(lhs,rhs,dst,actualAlpha); } }; diff --git a/Eigen/src/Core/products/TriangularSolverMatrix.h b/Eigen/src/Core/products/TriangularSolverMatrix.h index 7163a800a..8b9143c2b 100644 --- a/Eigen/src/Core/products/TriangularSolverMatrix.h +++ b/Eigen/src/Core/products/TriangularSolverMatrix.h @@ -25,16 +25,18 @@ #ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_H #define EIGEN_TRIANGULAR_SOLVER_MATRIX_H +namespace internal { + // if the rhs is row major, let's transpose the product template <typename Scalar, typename Index, int Side, int Mode, bool Conjugate, int TriStorageOrder> -struct ei_triangular_solve_matrix<Scalar,Index,Side,Mode,Conjugate,TriStorageOrder,RowMajor> +struct triangular_solve_matrix<Scalar,Index,Side,Mode,Conjugate,TriStorageOrder,RowMajor> { static EIGEN_DONT_INLINE void run( Index size, Index cols, const Scalar* tri, Index triStride, Scalar* _other, Index otherStride) { - ei_triangular_solve_matrix< + triangular_solve_matrix< Scalar, Index, Side==OnTheLeft?OnTheRight:OnTheLeft, (Mode&UnitDiag) | ((Mode&Upper) ? Lower : Upper), NumTraits<Scalar>::IsComplex && Conjugate, @@ -46,7 +48,7 @@ struct ei_triangular_solve_matrix<Scalar,Index,Side,Mode,Conjugate,TriStorageOrd /* Optimized triangular solver with multiple right hand side and the triangular matrix on the left */ template <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder> -struct ei_triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor> +struct triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor> { static EIGEN_DONT_INLINE void run( Index size, Index otherSize, @@ -54,10 +56,10 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStora Scalar* _other, Index otherStride) { Index cols = otherSize; - ei_const_blas_data_mapper<Scalar, Index, TriStorageOrder> tri(_tri,triStride); - ei_blas_data_mapper<Scalar, Index, ColMajor> other(_other,otherStride); + const_blas_data_mapper<Scalar, Index, TriStorageOrder> tri(_tri,triStride); + blas_data_mapper<Scalar, Index, ColMajor> other(_other,otherStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; enum { SmallPanelWidth = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr), IsLower = (Mode&Lower) == Lower @@ -74,10 +76,10 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStora Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); Scalar* blockB = allocatedBlockB + sizeW; - ei_conj_if<Conjugate> conj; - ei_gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, Conjugate, false> gebp_kernel; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, TriStorageOrder> pack_lhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr, ColMajor, false, true> pack_rhs; + conj_if<Conjugate> conj; + gebp_kernel<Scalar, Scalar, Index, Traits::mr, Traits::nr, Conjugate, false> gebp_kernel; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, TriStorageOrder> pack_lhs; + gemm_pack_rhs<Scalar, Index, Traits::nr, ColMajor, false, true> pack_rhs; for(Index k2=IsLower ? 0 : size; IsLower ? k2<size : k2>0; @@ -181,7 +183,7 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStora /* Optimized triangular solver with multiple left hand sides and the trinagular matrix on the right */ template <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder> -struct ei_triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor> +struct triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor> { static EIGEN_DONT_INLINE void run( Index size, Index otherSize, @@ -189,10 +191,10 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStor Scalar* _other, Index otherStride) { Index rows = otherSize; - ei_const_blas_data_mapper<Scalar, Index, TriStorageOrder> rhs(_tri,triStride); - ei_blas_data_mapper<Scalar, Index, ColMajor> lhs(_other,otherStride); + const_blas_data_mapper<Scalar, Index, TriStorageOrder> rhs(_tri,triStride); + blas_data_mapper<Scalar, Index, ColMajor> lhs(_other,otherStride); - typedef ei_gebp_traits<Scalar,Scalar> Traits; + typedef gebp_traits<Scalar,Scalar> Traits; enum { RhsStorageOrder = TriStorageOrder, SmallPanelWidth = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr), @@ -213,11 +215,11 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStor Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); Scalar* blockB = allocatedBlockB + sizeW; - ei_conj_if<Conjugate> conj; - ei_gebp_kernel<Scalar,Scalar, Index, Traits::mr, Traits::nr, false, Conjugate> gebp_kernel; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; - ei_gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder,false,true> pack_rhs_panel; - ei_gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, ColMajor, false, true> pack_lhs_panel; + conj_if<Conjugate> conj; + gebp_kernel<Scalar,Scalar, Index, Traits::mr, Traits::nr, false, Conjugate> gebp_kernel; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs; + gemm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder,false,true> pack_rhs_panel; + gemm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, ColMajor, false, true> pack_lhs_panel; for(Index k2=IsLower ? size : 0; IsLower ? k2>0 : k2<size; @@ -318,4 +320,6 @@ struct ei_triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStor } }; +} // end namespace internal + #endif // EIGEN_TRIANGULAR_SOLVER_MATRIX_H diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index 972814dc9..7c976a5bc 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -28,109 +28,111 @@ // This file contains many lightweight helper classes used to // implement and control fast level 2 and level 3 BLAS-like routines. +namespace internal { + // forward declarations template<typename LhsScalar, typename RhsScalar, typename Index, int mr, int nr, bool ConjugateLhs=false, bool ConjugateRhs=false> -struct ei_gebp_kernel; +struct gebp_kernel; template<typename Scalar, typename Index, int nr, int StorageOrder, bool Conjugate = false, bool PanelMode=false> -struct ei_gemm_pack_rhs; +struct gemm_pack_rhs; template<typename Scalar, typename Index, int Pack1, int Pack2, int StorageOrder, bool Conjugate = false, bool PanelMode = false> -struct ei_gemm_pack_lhs; +struct gemm_pack_lhs; template< typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs, int ResStorageOrder> -struct ei_general_matrix_matrix_product; +struct general_matrix_matrix_product; template<typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs> -struct ei_general_matrix_vector_product; +struct general_matrix_vector_product; -template<bool Conjugate> struct ei_conj_if; +template<bool Conjugate> struct conj_if; -template<> struct ei_conj_if<true> { +template<> struct conj_if<true> { template<typename T> - inline T operator()(const T& x) { return ei_conj(x); } + inline T operator()(const T& x) { return conj(x); } }; -template<> struct ei_conj_if<false> { +template<> struct conj_if<false> { template<typename T> inline const T& operator()(const T& x) { return x; } }; -template<typename Scalar> struct ei_conj_helper<Scalar,Scalar,false,false> +template<typename Scalar> struct conj_helper<Scalar,Scalar,false,false> { - EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return ei_pmadd(x,y,c); } - EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const { return ei_pmul(x,y); } + EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return internal::pmadd(x,y,c); } + EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const { return internal::pmul(x,y); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, false,true> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, false,true> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) + ei_imag(x)*ei_imag(y), ei_imag(x)*ei_real(y) - ei_real(x)*ei_imag(y)); } + { return Scalar(real(x)*real(y) + imag(x)*imag(y), imag(x)*real(y) - real(x)*imag(y)); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,false> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,false> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) + ei_imag(x)*ei_imag(y), ei_real(x)*ei_imag(y) - ei_imag(x)*ei_real(y)); } + { return Scalar(real(x)*real(y) + imag(x)*imag(y), real(x)*imag(y) - imag(x)*real(y)); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,true> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,true> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) - ei_imag(x)*ei_imag(y), - ei_real(x)*ei_imag(y) - ei_imag(x)*ei_real(y)); } + { return Scalar(real(x)*real(y) - imag(x)*imag(y), - real(x)*imag(y) - imag(x)*real(y)); } }; -template<typename RealScalar,bool Conj> struct ei_conj_helper<std::complex<RealScalar>, RealScalar, Conj,false> +template<typename RealScalar,bool Conj> struct conj_helper<std::complex<RealScalar>, RealScalar, Conj,false> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const RealScalar& y, const Scalar& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const RealScalar& y) const - { return ei_conj_if<Conj>()(x)*y; } + { return conj_if<Conj>()(x)*y; } }; -template<typename RealScalar,bool Conj> struct ei_conj_helper<RealScalar, std::complex<RealScalar>, false,Conj> +template<typename RealScalar,bool Conj> struct conj_helper<RealScalar, std::complex<RealScalar>, false,Conj> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const RealScalar& x, const Scalar& y, const Scalar& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Scalar pmul(const RealScalar& x, const Scalar& y) const - { return x*ei_conj_if<Conj>()(y); } + { return x*conj_if<Conj>()(y); } }; -template<typename From,typename To> struct ei_get_factor { +template<typename From,typename To> struct get_factor { EIGEN_STRONG_INLINE static To run(const From& x) { return x; } }; -template<typename Scalar> struct ei_get_factor<Scalar,typename NumTraits<Scalar>::Real> { - EIGEN_STRONG_INLINE static typename NumTraits<Scalar>::Real run(const Scalar& x) { return ei_real(x); } +template<typename Scalar> struct get_factor<Scalar,typename NumTraits<Scalar>::Real> { + EIGEN_STRONG_INLINE static typename NumTraits<Scalar>::Real run(const Scalar& x) { return real(x); } }; // Lightweight helper class to access matrix coefficients. // Yes, this is somehow redundant with Map<>, but this version is much much lighter, // and so I hope better compilation performance (time and code quality). template<typename Scalar, typename Index, int StorageOrder> -class ei_blas_data_mapper +class blas_data_mapper { public: - ei_blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {} + blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {} EIGEN_STRONG_INLINE Scalar& operator()(Index i, Index j) { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; } protected: @@ -140,10 +142,10 @@ class ei_blas_data_mapper // lightweight helper class to access matrix coefficients (const version) template<typename Scalar, typename Index, int StorageOrder> -class ei_const_blas_data_mapper +class const_blas_data_mapper { public: - ei_const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {} + const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {} EIGEN_STRONG_INLINE const Scalar& operator()(Index i, Index j) const { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; } protected: @@ -155,9 +157,9 @@ class ei_const_blas_data_mapper /* Helper class to analyze the factors of a Product expression. * In particular it allows to pop out operator-, scalar multiples, * and conjugate */ -template<typename XprType> struct ei_blas_traits +template<typename XprType> struct blas_traits { - typedef typename ei_traits<XprType>::Scalar Scalar; + typedef typename traits<XprType>::Scalar Scalar; typedef const XprType& ExtractType; typedef XprType _ExtractType; enum { @@ -168,10 +170,10 @@ template<typename XprType> struct ei_blas_traits && ( /* Uncomment this when the low-level matrix-vector product functions support strided vectors bool(XprType::IsVectorAtCompileTime) || */ - int(ei_inner_stride_at_compile_time<XprType>::ret) == 1) + int(inner_stride_at_compile_time<XprType>::ret) == 1) ) ? 1 : 0 }; - typedef typename ei_meta_if<bool(HasUsableDirectAccess), + typedef typename meta_if<bool(HasUsableDirectAccess), ExtractType, typename _ExtractType::PlainObject >::ret DirectLinearAccessType; @@ -181,11 +183,11 @@ template<typename XprType> struct ei_blas_traits // pop conjugate template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; enum { @@ -193,16 +195,16 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> > NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex }; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } - static inline Scalar extractScalarFactor(const XprType& x) { return ei_conj(Base::extractScalarFactor(x.nestedExpression())); } + static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); } }; // pop scalar multiple template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) @@ -211,11 +213,11 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> > // pop opposite template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) @@ -224,15 +226,15 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> > // pop/push transpose template<typename NestedXpr> -struct ei_blas_traits<Transpose<NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<Transpose<NestedXpr> > + : blas_traits<NestedXpr> { typedef typename NestedXpr::Scalar Scalar; - typedef ei_blas_traits<NestedXpr> Base; + typedef blas_traits<NestedXpr> Base; typedef Transpose<NestedXpr> XprType; typedef Transpose<typename Base::_ExtractType> ExtractType; typedef Transpose<typename Base::_ExtractType> _ExtractType; - typedef typename ei_meta_if<bool(Base::HasUsableDirectAccess), + typedef typename meta_if<bool(Base::HasUsableDirectAccess), ExtractType, typename ExtractType::PlainObject >::ret DirectLinearAccessType; @@ -243,22 +245,24 @@ struct ei_blas_traits<Transpose<NestedXpr> > static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); } }; -template<typename T, bool HasUsableDirectAccess=ei_blas_traits<T>::HasUsableDirectAccess> -struct ei_extract_data_selector { +template<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess> +struct extract_data_selector { static const typename T::Scalar* run(const T& m) { - return &ei_blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data() + return &blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data() } }; template<typename T> -struct ei_extract_data_selector<T,false> { +struct extract_data_selector<T,false> { static typename T::Scalar* run(const T&) { return 0; } }; -template<typename T> const typename T::Scalar* ei_extract_data(const T& m) +template<typename T> const typename T::Scalar* extract_data(const T& m) { - return ei_extract_data_selector<T>::run(m); + return extract_data_selector<T>::run(m); } +} // end namespace internal + #endif // EIGEN_BLASUTIL_H diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 4b1740c82..0d0b905ea 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -26,19 +26,22 @@ #ifndef EIGEN_FORWARDDECLARATIONS_H #define EIGEN_FORWARDDECLARATIONS_H -template<typename T> struct ei_traits; -template<typename T> struct NumTraits; +namespace internal { +template<typename T> struct traits; -template<typename Derived> struct ei_has_direct_access +template<typename Derived> struct has_direct_access { - enum { ret = (ei_traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 }; + enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 }; }; +} // end namespace internal + +template<typename T> struct NumTraits; template<typename Derived> struct EigenBase; template<typename Derived> class DenseBase; template<typename Derived, - AccessorLevels Level = (ei_traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors - : (ei_traits<Derived>::Flags & LvalueBit) ? WriteAccessors + AccessorLevels Level = (internal::traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors + : (internal::traits<Derived>::Flags & LvalueBit) ? WriteAccessors : ReadOnlyAccessors> class DenseCoeffsBase; @@ -61,7 +64,7 @@ template<typename ExpressionType> class ForceAlignedAccess; template<typename ExpressionType> class SwapWrapper; template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false, - bool HasDirectAccess = ei_has_direct_access<XprType>::ret> class Block; + bool HasDirectAccess = internal::has_direct_access<XprType>::ret> class Block; template<typename MatrixType, int Size=Dynamic> class VectorBlock; template<typename MatrixType> class Transpose; @@ -95,58 +98,67 @@ template<typename MatrixType> struct CommaInitializer; template<typename Derived> class ReturnByValue; template<typename ExpressionType> class ArrayWrapper; -template<typename DecompositionType, typename Rhs> struct ei_solve_retval_base; -template<typename DecompositionType, typename Rhs> struct ei_solve_retval; -template<typename DecompositionType> struct ei_kernel_retval_base; -template<typename DecompositionType> struct ei_kernel_retval; -template<typename DecompositionType> struct ei_image_retval_base; -template<typename DecompositionType> struct ei_image_retval; +namespace internal { +template<typename DecompositionType, typename Rhs> struct solve_retval_base; +template<typename DecompositionType, typename Rhs> struct solve_retval; +template<typename DecompositionType> struct kernel_retval_base; +template<typename DecompositionType> struct kernel_retval; +template<typename DecompositionType> struct image_retval_base; +template<typename DecompositionType> struct image_retval; +} // end namespace internal template<typename _Scalar, int Rows=Dynamic, int Cols=Dynamic, int Supers=Dynamic, int Subs=Dynamic, int Options=0> class BandMatrix; -template<typename Lhs, typename Rhs> struct ei_product_type; +namespace internal { +template<typename Lhs, typename Rhs> struct product_type; +} + template<typename Lhs, typename Rhs, - int ProductType = ei_product_type<Lhs,Rhs>::value> + int ProductType = internal::product_type<Lhs,Rhs>::value> struct ProductReturnType; // this is a workaround for sun CC template<typename Lhs, typename Rhs> struct LazyProductReturnType; +namespace internal { + // Provides scalar/packet-wise product and product with accumulation // with optional conjugation of the arguments. -template<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct ei_conj_helper; - -template<typename Scalar> struct ei_scalar_sum_op; -template<typename Scalar> struct ei_scalar_difference_op; -template<typename Scalar> struct ei_scalar_conj_product_op; -template<typename Scalar> struct ei_scalar_quotient_op; -template<typename Scalar> struct ei_scalar_opposite_op; -template<typename Scalar> struct ei_scalar_conjugate_op; -template<typename Scalar> struct ei_scalar_real_op; -template<typename Scalar> struct ei_scalar_imag_op; -template<typename Scalar> struct ei_scalar_abs_op; -template<typename Scalar> struct ei_scalar_abs2_op; -template<typename Scalar> struct ei_scalar_sqrt_op; -template<typename Scalar> struct ei_scalar_exp_op; -template<typename Scalar> struct ei_scalar_log_op; -template<typename Scalar> struct ei_scalar_cos_op; -template<typename Scalar> struct ei_scalar_sin_op; -template<typename Scalar> struct ei_scalar_pow_op; -template<typename Scalar> struct ei_scalar_inverse_op; -template<typename Scalar> struct ei_scalar_square_op; -template<typename Scalar> struct ei_scalar_cube_op; -template<typename Scalar, typename NewType> struct ei_scalar_cast_op; -template<typename Scalar> struct ei_scalar_multiple_op; -template<typename Scalar> struct ei_scalar_quotient1_op; -template<typename Scalar> struct ei_scalar_min_op; -template<typename Scalar> struct ei_scalar_max_op; -template<typename Scalar> struct ei_scalar_random_op; -template<typename Scalar> struct ei_scalar_add_op; -template<typename Scalar> struct ei_scalar_constant_op; -template<typename Scalar> struct ei_scalar_identity_op; - -template<typename LhsScalar,typename RhsScalar=LhsScalar> struct ei_scalar_product_op; -template<typename LhsScalar,typename RhsScalar> struct ei_scalar_multiple2_op; +template<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct conj_helper; + +template<typename Scalar> struct scalar_sum_op; +template<typename Scalar> struct scalar_difference_op; +template<typename Scalar> struct scalar_conj_product_op; +template<typename Scalar> struct scalar_quotient_op; +template<typename Scalar> struct scalar_opposite_op; +template<typename Scalar> struct scalar_conjugate_op; +template<typename Scalar> struct scalar_real_op; +template<typename Scalar> struct scalar_imag_op; +template<typename Scalar> struct scalar_abs_op; +template<typename Scalar> struct scalar_abs2_op; +template<typename Scalar> struct scalar_sqrt_op; +template<typename Scalar> struct scalar_exp_op; +template<typename Scalar> struct scalar_log_op; +template<typename Scalar> struct scalar_cos_op; +template<typename Scalar> struct scalar_sin_op; +template<typename Scalar> struct scalar_pow_op; +template<typename Scalar> struct scalar_inverse_op; +template<typename Scalar> struct scalar_square_op; +template<typename Scalar> struct scalar_cube_op; +template<typename Scalar, typename NewType> struct scalar_cast_op; +template<typename Scalar> struct scalar_multiple_op; +template<typename Scalar> struct scalar_quotient1_op; +template<typename Scalar> struct scalar_min_op; +template<typename Scalar> struct scalar_max_op; +template<typename Scalar> struct scalar_random_op; +template<typename Scalar> struct scalar_add_op; +template<typename Scalar> struct scalar_constant_op; +template<typename Scalar> struct scalar_identity_op; + +template<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_product_op; +template<typename LhsScalar,typename RhsScalar> struct scalar_multiple2_op; + +} // end namespace internal struct IOFormat; @@ -165,7 +177,9 @@ template<typename MatrixType, int Direction = BothDirections> class Reverse; template<typename MatrixType> class FullPivLU; template<typename MatrixType> class PartialPivLU; -template<typename MatrixType> struct ei_inverse_impl; +namespace internal { +template<typename MatrixType> struct inverse_impl; +} template<typename MatrixType> class HouseholderQR; template<typename MatrixType> class ColPivHouseholderQR; template<typename MatrixType> class FullPivHouseholderQR; @@ -192,12 +206,15 @@ template<typename MatrixType,int Direction> class Homogeneous; // MatrixFunctions module template<typename Derived> struct MatrixExponentialReturnValue; template<typename Derived> class MatrixFunctionReturnValue; + +namespace internal { template <typename Scalar> -struct ei_stem_function +struct stem_function { typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar; typedef ComplexScalar type(ComplexScalar, int); }; +} #ifdef EIGEN2_SUPPORT diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 2bf509f8f..0cea94852 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -128,18 +128,18 @@ # endif #endif -#ifndef ei_assert +#ifndef eigen_assert #ifdef EIGEN_NO_DEBUG -#define ei_assert(x) +#define eigen_assert(x) #else -#define ei_assert(x) assert(x) +#define eigen_assert(x) assert(x) #endif #endif #ifdef EIGEN_INTERNAL_DEBUGGING -#define ei_internal_assert(x) ei_assert(x) +#define eigen_internal_assert(x) eigen_assert(x) #else -#define ei_internal_assert(x) +#define eigen_internal_assert(x) #endif #ifdef EIGEN_NO_DEBUG @@ -295,35 +295,35 @@ **/ #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ + typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::ei_nested<Derived>::type Nested; \ - typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::ei_traits<Derived>::Index Index; \ - enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \ - Flags = Eigen::ei_traits<Derived>::Flags, \ - CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \ + typedef typename Eigen::internal::nested<Derived>::type Nested; \ + typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ + typedef typename Eigen::internal::traits<Derived>::Index Index; \ + enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ + ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ + Flags = Eigen::internal::traits<Derived>::Flags, \ + CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ + typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ typedef typename Base::PacketScalar PacketScalar; \ typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::ei_nested<Derived>::type Nested; \ - typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::ei_traits<Derived>::Index Index; \ - enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \ - MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \ - MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \ - Flags = Eigen::ei_traits<Derived>::Flags, \ - CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \ + typedef typename Eigen::internal::nested<Derived>::type Nested; \ + typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ + typedef typename Eigen::internal::traits<Derived>::Index Index; \ + enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ + ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ + MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \ + MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \ + Flags = Eigen::internal::traits<Derived>::Flags, \ + CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ @@ -371,9 +371,9 @@ // the expression type of a cwise product #define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \ CwiseBinaryOp< \ - ei_scalar_product_op< \ - typename ei_traits<LHS>::Scalar, \ - typename ei_traits<RHS>::Scalar \ + internal::scalar_product_op< \ + typename internal::traits<LHS>::Scalar, \ + typename internal::traits<RHS>::Scalar \ >, \ LHS, \ RHS \ diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 362ccf18e..51ec78f1a 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -80,6 +80,8 @@ #define EIGEN_HAS_MM_MALLOC 0 #endif +namespace internal { + /***************************************************************************** *** Implementation of handmade aligned functions *** *****************************************************************************/ @@ -89,7 +91,7 @@ /** \internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. * Fast, but wastes 16 additional bytes of memory. Does not throw any exception. */ -inline void* ei_handmade_aligned_malloc(size_t size) +inline void* handmade_aligned_malloc(size_t size) { void *original = std::malloc(size+16); if (original == 0) return 0; @@ -98,8 +100,8 @@ inline void* ei_handmade_aligned_malloc(size_t size) return aligned; } -/** \internal Frees memory allocated with ei_handmade_aligned_malloc */ -inline void ei_handmade_aligned_free(void *ptr) +/** \internal Frees memory allocated with handmade_aligned_malloc */ +inline void handmade_aligned_free(void *ptr) { if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); } @@ -109,9 +111,9 @@ inline void ei_handmade_aligned_free(void *ptr) * Since we know that our handmade version is based on std::realloc * we can use std::realloc to implement efficient reallocation. */ -inline void* ei_handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) +inline void* handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) { - if (ptr == 0) return ei_handmade_aligned_malloc(size); + if (ptr == 0) return handmade_aligned_malloc(size); void *original = *(reinterpret_cast<void**>(ptr) - 1); original = std::realloc(original,size+16); if (original == 0) return 0; @@ -124,26 +126,26 @@ inline void* ei_handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) *** Implementation of generic aligned realloc (when no realloc can be used)*** *****************************************************************************/ -void* ei_aligned_malloc(size_t size); -void ei_aligned_free(void *ptr); +void* aligned_malloc(size_t size); +void aligned_free(void *ptr); /** \internal * \brief Reallocates aligned memory. * Allows reallocation with aligned ptr types. This implementation will * always create a new memory chunk and copy the old data. */ -inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) +inline void* generic_aligned_realloc(void* ptr, size_t size, size_t old_size) { if (ptr==0) - return ei_aligned_malloc(size); + return aligned_malloc(size); if (size==0) { - ei_aligned_free(ptr); + aligned_free(ptr); return 0; } - void* newptr = ei_aligned_malloc(size); + void* newptr = aligned_malloc(size); if (newptr == 0) { #ifdef EIGEN_HAS_ERRNO @@ -155,7 +157,7 @@ inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) if (ptr != 0) { std::memcpy(newptr, ptr, std::min(size,old_size)); - ei_aligned_free(ptr); + aligned_free(ptr); } return newptr; @@ -168,10 +170,10 @@ inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) /** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 bytes alignment. * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. */ -inline void* ei_aligned_malloc(size_t size) +inline void* aligned_malloc(size_t size) { #ifdef EIGEN_NO_MALLOC - ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); + eigen_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); #endif void *result; @@ -186,7 +188,7 @@ inline void* ei_aligned_malloc(size_t size) #elif (defined _MSC_VER) result = _aligned_malloc(size, 16); #else - result = ei_handmade_aligned_malloc(size); + result = handmade_aligned_malloc(size); #endif #ifdef EIGEN_EXCEPTIONS @@ -196,8 +198,8 @@ inline void* ei_aligned_malloc(size_t size) return result; } -/** \internal Frees memory allocated with ei_aligned_malloc. */ -inline void ei_aligned_free(void *ptr) +/** \internal Frees memory allocated with aligned_malloc. */ +inline void aligned_free(void *ptr) { #if !EIGEN_ALIGN std::free(ptr); @@ -210,7 +212,7 @@ inline void ei_aligned_free(void *ptr) #elif defined(_MSC_VER) _aligned_free(ptr); #else - ei_handmade_aligned_free(ptr); + handmade_aligned_free(ptr); #endif } @@ -219,7 +221,7 @@ inline void ei_aligned_free(void *ptr) * \brief Reallocates an aligned block of memory. * \throws std::bad_alloc if EIGEN_EXCEPTIONS are defined. **/ -inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) +inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) { EIGEN_UNUSED_VARIABLE(old_size); @@ -229,7 +231,7 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) #elif EIGEN_MALLOC_ALREADY_ALIGNED result = std::realloc(ptr,new_size); #elif EIGEN_HAS_POSIX_MEMALIGN - result = ei_generic_aligned_realloc(ptr,new_size,old_size); + result = generic_aligned_realloc(ptr,new_size,old_size); #elif EIGEN_HAS_MM_MALLOC // The defined(_mm_free) is just here to verify that this MSVC version // implements _mm_malloc/_mm_free based on the corresponding _aligned_ @@ -237,12 +239,12 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) #if defined(_MSC_VER) && defined(_mm_free) result = _aligned_realloc(ptr,new_size,16); #else - result = ei_generic_aligned_realloc(ptr,new_size,old_size); + result = generic_aligned_realloc(ptr,new_size,old_size); #endif #elif defined(_MSC_VER) result = _aligned_realloc(ptr,new_size,16); #else - result = ei_handmade_aligned_realloc(ptr,new_size,old_size); + result = handmade_aligned_realloc(ptr,new_size,old_size); #endif #ifdef EIGEN_EXCEPTIONS @@ -259,15 +261,15 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) /** \internal Allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned. * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. */ -template<bool Align> inline void* ei_conditional_aligned_malloc(size_t size) +template<bool Align> inline void* conditional_aligned_malloc(size_t size) { - return ei_aligned_malloc(size); + return aligned_malloc(size); } -template<> inline void* ei_conditional_aligned_malloc<false>(size_t size) +template<> inline void* conditional_aligned_malloc<false>(size_t size) { #ifdef EIGEN_NO_MALLOC - ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); + eigen_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); #endif void *result = std::malloc(size); @@ -277,23 +279,23 @@ template<> inline void* ei_conditional_aligned_malloc<false>(size_t size) return result; } -/** \internal Frees memory allocated with ei_conditional_aligned_malloc */ -template<bool Align> inline void ei_conditional_aligned_free(void *ptr) +/** \internal Frees memory allocated with conditional_aligned_malloc */ +template<bool Align> inline void conditional_aligned_free(void *ptr) { - ei_aligned_free(ptr); + aligned_free(ptr); } -template<> inline void ei_conditional_aligned_free<false>(void *ptr) +template<> inline void conditional_aligned_free<false>(void *ptr) { std::free(ptr); } -template<bool Align> inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) +template<bool Align> inline void* conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) { - return ei_aligned_realloc(ptr, new_size, old_size); + return aligned_realloc(ptr, new_size, old_size); } -template<> inline void* ei_conditional_aligned_realloc<false>(void* ptr, size_t new_size, size_t) +template<> inline void* conditional_aligned_realloc<false>(void* ptr, size_t new_size, size_t) { return std::realloc(ptr, new_size); } @@ -305,7 +307,7 @@ template<> inline void* ei_conditional_aligned_realloc<false>(void* ptr, size_t /** \internal Constructs the elements of an array. * The \a size parameter tells on how many objects to call the constructor of T. */ -template<typename T> inline T* ei_construct_elements_of_array(T *ptr, size_t size) +template<typename T> inline T* construct_elements_of_array(T *ptr, size_t size) { for (size_t i=0; i < size; ++i) ::new (ptr + i) T; return ptr; @@ -314,7 +316,7 @@ template<typename T> inline T* ei_construct_elements_of_array(T *ptr, size_t siz /** \internal Destructs the elements of an array. * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T> inline void ei_destruct_elements_of_array(T *ptr, size_t size) +template<typename T> inline void destruct_elements_of_array(T *ptr, size_t size) { // always destruct an array starting from the end. if(ptr) @@ -329,41 +331,41 @@ template<typename T> inline void ei_destruct_elements_of_array(T *ptr, size_t si * On allocation error, the returned pointer is undefined, but if exceptions are enabled then a std::bad_alloc is thrown. * The default constructor of T is called. */ -template<typename T> inline T* ei_aligned_new(size_t size) +template<typename T> inline T* aligned_new(size_t size) { - T *result = reinterpret_cast<T*>(ei_aligned_malloc(sizeof(T)*size)); - return ei_construct_elements_of_array(result, size); + T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size)); + return construct_elements_of_array(result, size); } -template<typename T, bool Align> inline T* ei_conditional_aligned_new(size_t size) +template<typename T, bool Align> inline T* conditional_aligned_new(size_t size) { - T *result = reinterpret_cast<T*>(ei_conditional_aligned_malloc<Align>(sizeof(T)*size)); - return ei_construct_elements_of_array(result, size); + T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size)); + return construct_elements_of_array(result, size); } -/** \internal Deletes objects constructed with ei_aligned_new +/** \internal Deletes objects constructed with aligned_new * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T> inline void ei_aligned_delete(T *ptr, size_t size) +template<typename T> inline void aligned_delete(T *ptr, size_t size) { - ei_destruct_elements_of_array<T>(ptr, size); - ei_aligned_free(ptr); + destruct_elements_of_array<T>(ptr, size); + aligned_free(ptr); } -/** \internal Deletes objects constructed with ei_conditional_aligned_new +/** \internal Deletes objects constructed with conditional_aligned_new * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T, bool Align> inline void ei_conditional_aligned_delete(T *ptr, size_t size) +template<typename T, bool Align> inline void conditional_aligned_delete(T *ptr, size_t size) { - ei_destruct_elements_of_array<T>(ptr, size); - ei_conditional_aligned_free<Align>(ptr); + destruct_elements_of_array<T>(ptr, size); + conditional_aligned_free<Align>(ptr); } -template<typename T, bool Align> inline T* ei_conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) +template<typename T, bool Align> inline T* conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) { - T *result = reinterpret_cast<T*>(ei_conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size)); + T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size)); if (new_size > old_size) - ei_construct_elements_of_array(result+old_size, new_size-old_size); + construct_elements_of_array(result+old_size, new_size-old_size); return result; } @@ -383,13 +385,13 @@ template<typename T, bool Align> inline T* ei_conditional_aligned_realloc_new(T* * other hand, we do not assume that the array address is a multiple of sizeof(Scalar), as that fails for * example with Scalar=double on certain 32-bit platforms, see bug #79. * - * There is also the variant ei_first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h. + * There is also the variant first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h. */ template<typename Scalar, typename Index> -inline static Index ei_first_aligned(const Scalar* array, Index size) +inline static Index first_aligned(const Scalar* array, Index size) { - typedef typename ei_packet_traits<Scalar>::type Packet; - enum { PacketSize = ei_packet_traits<Scalar>::size, + typedef typename packet_traits<Scalar>::type Packet; + enum { PacketSize = packet_traits<Scalar>::size, PacketAlignedMask = PacketSize-1 }; @@ -412,6 +414,8 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) } } +} // end namespace internal + /***************************************************************************** *** Implementation of runtime stack allocation (falling back to malloc) *** *****************************************************************************/ @@ -431,20 +435,20 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) #if (defined __linux__) #define ei_aligned_stack_alloc(SIZE) (SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) \ ? alloca(SIZE) \ - : ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) ei_aligned_free(PTR) + : Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) Eigen::internal::aligned_free(PTR) #elif defined(_MSC_VER) #define ei_aligned_stack_alloc(SIZE) (SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) \ ? _alloca(SIZE) \ - : ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) ei_aligned_free(PTR) + : Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) Eigen::internal::aligned_free(PTR) #else - #define ei_aligned_stack_alloc(SIZE) ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) ei_aligned_free(PTR) + #define ei_aligned_stack_alloc(SIZE) Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) Eigen::internal::aligned_free(PTR) #endif -#define ei_aligned_stack_new(TYPE,SIZE) ei_construct_elements_of_array(reinterpret_cast<TYPE*>(ei_aligned_stack_alloc(sizeof(TYPE)*SIZE)), SIZE) -#define ei_aligned_stack_delete(TYPE,PTR,SIZE) do {ei_destruct_elements_of_array<TYPE>(PTR, SIZE); \ +#define ei_aligned_stack_new(TYPE,SIZE) Eigen::internal::construct_elements_of_array(reinterpret_cast<TYPE*>(ei_aligned_stack_alloc(sizeof(TYPE)*SIZE)), SIZE) +#define ei_aligned_stack_delete(TYPE,PTR,SIZE) do {Eigen::internal::destruct_elements_of_array<TYPE>(PTR, SIZE); \ ei_aligned_stack_free(PTR,sizeof(TYPE)*SIZE);} while(0) @@ -456,26 +460,26 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) #ifdef EIGEN_EXCEPTIONS #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void* operator new(size_t size, const std::nothrow_t&) throw() { \ - try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \ + try { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \ catch (...) { return 0; } \ return 0; \ } #else #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void* operator new(size_t size, const std::nothrow_t&) throw() { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } #endif #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ void *operator new(size_t size) { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } \ void *operator new[](size_t size) { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } \ - void operator delete(void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \ - void operator delete[](void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ /* in-place new and delete. since (at least afaik) there is no actual */ \ /* memory allocated we can safely let the default implementation handle */ \ /* this particular case. */ \ @@ -484,9 +488,9 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) /* nothrow-new (returns zero instead of std::bad_alloc) */ \ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void operator delete(void *ptr, const std::nothrow_t&) throw() { \ - Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); \ + Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); \ } \ - typedef void ei_operator_new_marker_type; + typedef void eigen_aligned_operator_new_marker_type; #else #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) #endif @@ -564,7 +568,7 @@ public: pointer allocate( size_type num, const_pointer* hint = 0 ) { static_cast<void>( hint ); // suppress unused variable warning - return static_cast<pointer>( ei_aligned_malloc( num * sizeof(T) ) ); + return static_cast<pointer>( internal::aligned_malloc( num * sizeof(T) ) ); } void construct( pointer p, const T& value ) @@ -579,7 +583,7 @@ public: void deallocate( pointer p, size_type /*num*/ ) { - ei_aligned_free( p ); + internal::aligned_free( p ); } bool operator!=(const aligned_allocator<T>& ) const @@ -605,13 +609,16 @@ public: # endif #endif +namespace internal { + #ifdef EIGEN_CPUID -inline bool ei_cpuid_is_vendor(int abcd[4], const char* vendor) + +inline bool cpuid_is_vendor(int abcd[4], const char* vendor) { return abcd[1]==((int*)(vendor))[0] && abcd[3]==((int*)(vendor))[1] && abcd[2]==((int*)(vendor))[2]; } -inline void ei_queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) +inline void queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) { int abcd[4]; l1 = l2 = l3 = 0; @@ -643,7 +650,7 @@ inline void ei_queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) } while(cache_type>0 && cache_id<16); } -inline void ei_queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) +inline void queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) { int abcd[4]; abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0; @@ -723,15 +730,15 @@ inline void ei_queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) l3 *= 1024; } -inline void ei_queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs) +inline void queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs) { if(max_std_funcs>=4) - ei_queryCacheSizes_intel_direct(l1,l2,l3); + queryCacheSizes_intel_direct(l1,l2,l3); else - ei_queryCacheSizes_intel_codes(l1,l2,l3); + queryCacheSizes_intel_codes(l1,l2,l3); } -inline void ei_queryCacheSizes_amd(int& l1, int& l2, int& l3) +inline void queryCacheSizes_amd(int& l1, int& l2, int& l3) { int abcd[4]; abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0; @@ -746,7 +753,7 @@ inline void ei_queryCacheSizes_amd(int& l1, int& l2, int& l3) /** \internal * Queries and returns the cache sizes in Bytes of the L1, L2, and L3 data caches respectively */ -inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) +inline void queryCacheSizes(int& l1, int& l2, int& l3) { #ifdef EIGEN_CPUID int abcd[4]; @@ -754,27 +761,27 @@ inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) // identify the CPU vendor EIGEN_CPUID(abcd,0x0,0); int max_std_funcs = abcd[1]; - if(ei_cpuid_is_vendor(abcd,"GenuineIntel")) - ei_queryCacheSizes_intel(l1,l2,l3,max_std_funcs); - else if(ei_cpuid_is_vendor(abcd,"AuthenticAMD") || ei_cpuid_is_vendor(abcd,"AMDisbetter!")) - ei_queryCacheSizes_amd(l1,l2,l3); + if(cpuid_is_vendor(abcd,"GenuineIntel")) + queryCacheSizes_intel(l1,l2,l3,max_std_funcs); + else if(cpuid_is_vendor(abcd,"AuthenticAMD") || cpuid_is_vendor(abcd,"AMDisbetter!")) + queryCacheSizes_amd(l1,l2,l3); else // by default let's use Intel's API - ei_queryCacheSizes_intel(l1,l2,l3,max_std_funcs); + queryCacheSizes_intel(l1,l2,l3,max_std_funcs); // here is the list of other vendors: -// ||ei_cpuid_is_vendor(abcd,"VIA VIA VIA ") -// ||ei_cpuid_is_vendor(abcd,"CyrixInstead") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") -// ||ei_cpuid_is_vendor(abcd,"GenuineTMx86") -// ||ei_cpuid_is_vendor(abcd,"TransmetaCPU") -// ||ei_cpuid_is_vendor(abcd,"RiseRiseRise") -// ||ei_cpuid_is_vendor(abcd,"Geode by NSC") -// ||ei_cpuid_is_vendor(abcd,"SiS SiS SiS ") -// ||ei_cpuid_is_vendor(abcd,"UMC UMC UMC ") -// ||ei_cpuid_is_vendor(abcd,"NexGenDriven") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"VIA VIA VIA ") +// ||cpuid_is_vendor(abcd,"CyrixInstead") +// ||cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"GenuineTMx86") +// ||cpuid_is_vendor(abcd,"TransmetaCPU") +// ||cpuid_is_vendor(abcd,"RiseRiseRise") +// ||cpuid_is_vendor(abcd,"Geode by NSC") +// ||cpuid_is_vendor(abcd,"SiS SiS SiS ") +// ||cpuid_is_vendor(abcd,"UMC UMC UMC ") +// ||cpuid_is_vendor(abcd,"NexGenDriven") +// ||cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"CentaurHauls") #else l1 = l2 = l3 = -1; #endif @@ -782,20 +789,22 @@ inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) /** \internal * \returns the size in Bytes of the L1 data cache */ -inline int ei_queryL1CacheSize() +inline int queryL1CacheSize() { int l1(-1), l2, l3; - ei_queryCacheSizes(l1,l2,l3); + queryCacheSizes(l1,l2,l3); return l1; } /** \internal * \returns the size in Bytes of the L2 or L3 cache if this later is present */ -inline int ei_queryTopLevelCacheSize() +inline int queryTopLevelCacheSize() { int l1, l2(-1), l3(-1); - ei_queryCacheSizes(l1,l2,l3); + queryCacheSizes(l1,l2,l3); return std::max(l2,l3); } +} // end namespace internal + #endif // EIGEN_MEMORY_H diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 3d28680b6..56330db9b 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -26,6 +26,8 @@ #ifndef EIGEN_META_H #define EIGEN_META_H +namespace internal { + /** \internal * \file Meta.h * This file contains generic metaprogramming classes which are not specifically related to Eigen. @@ -33,72 +35,72 @@ * we however don't want to add a dependency to Boost. */ -struct ei_meta_true { enum { ret = 1 }; }; -struct ei_meta_false { enum { ret = 0 }; }; +struct meta_true { enum { ret = 1 }; }; +struct meta_false { enum { ret = 0 }; }; template<bool Condition, typename Then, typename Else> -struct ei_meta_if { typedef Then ret; }; +struct 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; }; - -template<typename T> struct ei_is_arithmetic { enum { ret = false }; }; -template<> struct ei_is_arithmetic<float> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<double> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<long double> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<bool> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed short> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned short>{ enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed int> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned int> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed long long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned long long> { enum { ret = true }; }; - -template<typename T> struct ei_makeconst { typedef const T type; }; -template<typename T> struct ei_makeconst<const T> { typedef const T type; }; -template<typename T> struct ei_makeconst<T&> { typedef const T& type; }; -template<typename T> struct ei_makeconst<const T&> { typedef const T& type; }; -template<typename T> struct ei_makeconst<T*> { typedef const T* type; }; -template<typename T> struct ei_makeconst<const T*> { typedef const T* type; }; - -template<typename T> struct ei_makeconst_return_type +struct meta_if <false, Then, Else> { typedef Else ret; }; + +template<typename T, typename U> struct is_same_type { enum { ret = 0 }; }; +template<typename T> struct is_same_type<T,T> { enum { ret = 1 }; }; + +template<typename T> struct unref { typedef T type; }; +template<typename T> struct unref<T&> { typedef T type; }; + +template<typename T> struct unpointer { typedef T type; }; +template<typename T> struct unpointer<T*> { typedef T type; }; +template<typename T> struct unpointer<T*const> { typedef T type; }; + +template<typename T> struct unconst { typedef T type; }; +template<typename T> struct unconst<const T> { typedef T type; }; +template<typename T> struct unconst<T const &> { typedef T & type; }; +template<typename T> struct unconst<T const *> { typedef T * type; }; + +template<typename T> struct cleantype { typedef T type; }; +template<typename T> struct cleantype<const T> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<const T&> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<T&> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<const T*> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<T*> { typedef typename cleantype<T>::type type; }; + +template<typename T> struct is_arithmetic { enum { ret = false }; }; +template<> struct is_arithmetic<float> { enum { ret = true }; }; +template<> struct is_arithmetic<double> { enum { ret = true }; }; +template<> struct is_arithmetic<long double> { enum { ret = true }; }; +template<> struct is_arithmetic<bool> { enum { ret = true }; }; +template<> struct is_arithmetic<char> { enum { ret = true }; }; +template<> struct is_arithmetic<signed char> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned char> { enum { ret = true }; }; +template<> struct is_arithmetic<signed short> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned short>{ enum { ret = true }; }; +template<> struct is_arithmetic<signed int> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned int> { enum { ret = true }; }; +template<> struct is_arithmetic<signed long> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned long> { enum { ret = true }; }; +template<> struct is_arithmetic<signed long long> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned long long> { enum { ret = true }; }; + +template<typename T> struct makeconst { typedef const T type; }; +template<typename T> struct makeconst<const T> { typedef const T type; }; +template<typename T> struct makeconst<T&> { typedef const T& type; }; +template<typename T> struct makeconst<const T&> { typedef const T& type; }; +template<typename T> struct makeconst<T*> { typedef const T* type; }; +template<typename T> struct makeconst<const T*> { typedef const T* type; }; + +template<typename T> struct makeconst_return_type { - typedef typename ei_meta_if<ei_is_arithmetic<T>::ret, T, typename ei_makeconst<T>::type>::ret type; + typedef typename meta_if<is_arithmetic<T>::ret, T, typename makeconst<T>::type>::ret type; }; /** \internal Allows to enable/disable an overload * according to a compile time condition. */ -template<bool Condition, typename T> struct ei_enable_if; +template<bool Condition, typename T> struct enable_if; -template<typename T> struct ei_enable_if<true,T> +template<typename T> struct enable_if<true,T> { typedef T type; }; /** \internal @@ -108,67 +110,67 @@ template<typename T> struct ei_enable_if<true,T> * upcoming next STL generation (using a templated result member). * If none of these members is provided, then the type of the first argument is returned. FIXME, that behavior is a pretty bad hack. */ -template<typename T> struct ei_result_of {}; +template<typename T> struct result_of {}; -struct ei_has_none {int a[1];}; -struct ei_has_std_result_type {int a[2];}; -struct ei_has_tr1_result {int a[3];}; +struct has_none {int a[1];}; +struct has_std_result_type {int a[2];}; +struct has_tr1_result {int a[3];}; -template<typename Func, typename ArgType, int SizeOf=sizeof(ei_has_none)> -struct ei_unary_result_of_select {typedef ArgType type;}; +template<typename Func, typename ArgType, int SizeOf=sizeof(has_none)> +struct unary_result_of_select {typedef ArgType type;}; template<typename Func, typename ArgType> -struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_std_result_type)> {typedef typename Func::result_type type;}; +struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typedef typename Func::result_type type;}; template<typename Func, typename ArgType> -struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;}; +struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;}; template<typename Func, typename ArgType> -struct ei_result_of<Func(ArgType)> { +struct result_of<Func(ArgType)> { template<typename T> - static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); + static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template<typename T> - static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0); - static ei_has_none testFunctor(...); + static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0); + static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; - typedef typename ei_unary_result_of_select<Func, ArgType, FunctorType>::type type; + typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type; }; -template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(ei_has_none)> -struct ei_binary_result_of_select {typedef ArgType0 type;}; +template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(has_none)> +struct binary_result_of_select {typedef ArgType0 type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_std_result_type)> +struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)> {typedef typename Func::result_type type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_tr1_result)> +struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_result_of<Func(ArgType0,ArgType1)> { +struct result_of<Func(ArgType0,ArgType1)> { template<typename T> - static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); + static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template<typename T> - static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0); - static ei_has_none testFunctor(...); + static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0); + static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; - typedef typename ei_binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type; + typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::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 + * Usage example: \code 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 +class meta_sqrt { enum { MidX = (InfX+SupX)/2, @@ -177,49 +179,51 @@ class ei_meta_sqrt NewSup = int(TakeInf) ? int(MidX) : SupX }; public: - enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret }; + enum { ret = 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 }; }; +class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; /** \internal determines whether the product of two numeric types is allowed and what the return type is */ -template<typename T, typename U> struct ei_scalar_product_traits; +template<typename T, typename U> struct scalar_product_traits; -template<typename T> struct ei_scalar_product_traits<T,T> +template<typename T> struct scalar_product_traits<T,T> { //enum { Cost = NumTraits<T>::MulCost }; typedef T ReturnType; }; -template<typename T> struct ei_scalar_product_traits<T,std::complex<T> > +template<typename T> struct scalar_product_traits<T,std::complex<T> > { //enum { Cost = 2*NumTraits<T>::MulCost }; typedef std::complex<T> ReturnType; }; -template<typename T> struct ei_scalar_product_traits<std::complex<T>, T> +template<typename T> struct scalar_product_traits<std::complex<T>, T> { //enum { Cost = 2*NumTraits<T>::MulCost }; typedef std::complex<T> ReturnType; }; -// FIXME quick workaround around current limitation of ei_result_of +// FIXME quick workaround around current limitation of result_of // template<typename Scalar, typename ArgType0, typename ArgType1> -// struct ei_result_of<ei_scalar_product_op<Scalar>(ArgType0,ArgType1)> { -// typedef typename ei_scalar_product_traits<typename ei_cleantype<ArgType0>::type, typename ei_cleantype<ArgType1>::type>::ReturnType type; +// struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> { +// typedef typename scalar_product_traits<typename cleantype<ArgType0>::type, typename cleantype<ArgType1>::type>::ReturnType type; // }; -template<typename T> struct ei_is_diagonal +template<typename T> struct is_diagonal { enum { ret = false }; }; -template<typename T> struct ei_is_diagonal<DiagonalBase<T> > +template<typename T> struct is_diagonal<DiagonalBase<T> > { enum { ret = true }; }; -template<typename T> struct ei_is_diagonal<DiagonalWrapper<T> > +template<typename T> struct is_diagonal<DiagonalWrapper<T> > { enum { ret = true }; }; -template<typename T, int S> struct ei_is_diagonal<DiagonalMatrix<T,S> > +template<typename T, int S> struct is_diagonal<DiagonalMatrix<T,S> > { enum { ret = true }; }; +} // end namespace internal + #endif // EIGEN_META_H diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 323273e6a..71e8eef1b 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -29,11 +29,11 @@ /* Some notes on Eigen's static assertion mechanism: * * - in EIGEN_STATIC_ASSERT(CONDITION,MSG) the parameter CONDITION must be a compile time boolean - * expression, and MSG an enum listed in struct ei_static_assert<true> + * expression, and MSG an enum listed in struct internal::static_assertion<true> * * - define EIGEN_NO_STATIC_ASSERT to disable them (and save compilation time) * in that case, the static assertion is converted to the following runtime assert: - * ei_assert(CONDITION && "MSG") + * eigen_assert(CONDITION && "MSG") * * - currently EIGEN_STATIC_ASSERT can only be used in function scope * @@ -48,11 +48,13 @@ #else // not CXX0X + namespace internal { + template<bool condition> - struct ei_static_assert {}; + struct static_assertion {}; template<> - struct ei_static_assert<true> + struct static_assertion<true> { enum { YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX, @@ -94,18 +96,20 @@ }; }; + } // end namespace internal + // Specialized implementation for MSVC to avoid "conditional // expression is constant" warnings. This implementation doesn't // appear to work under GCC, hence the multiple implementations. #ifdef _MSC_VER #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - {Eigen::ei_static_assert<(CONDITION)>::MSG;} + {Eigen::internal::static_assertion<(CONDITION)>::MSG;} #else #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - if (Eigen::ei_static_assert<(CONDITION)>::MSG) {} + if (Eigen::internal::static_assertion<(CONDITION)>::MSG) {} #endif @@ -113,7 +117,7 @@ #else // EIGEN_NO_STATIC_ASSERT - #define EIGEN_STATIC_ASSERT(CONDITION,MSG) ei_assert((CONDITION) && #MSG); + #define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG); #endif // EIGEN_NO_STATIC_ASSERT diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 7232fa0f8..9f5bd7d71 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -1,4 +1,4 @@ -// // This file is part of Eigen, a lightweight C++ template library +// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> @@ -37,46 +37,48 @@ #define EIGEN_EMPTY_STRUCT_CTOR(X) #endif -//classes inheriting ei_no_assignment_operator don't generate a default operator=. -class ei_no_assignment_operator +typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; + +namespace internal { + +//classes inheriting no_assignment_operator don't generate a default operator=. +class no_assignment_operator { private: - ei_no_assignment_operator& operator=(const ei_no_assignment_operator&); + no_assignment_operator& operator=(const no_assignment_operator&); }; -typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; - /** \internal return the index type with the largest number of bits */ template<typename I1, typename I2> -struct ei_promote_index_type +struct promote_index_type { - typedef typename ei_meta_if<(sizeof(I1)<sizeof(I2)), I2, I1>::ret type; + typedef typename meta_if<(sizeof(I1)<sizeof(I2)), I2, I1>::ret type; }; /** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that * can be accessed using value() and setValue(). * Otherwise, this class is an empty structure and value() just returns the template parameter Value. */ -template<typename T, int Value> class ei_variable_if_dynamic +template<typename T, int Value> class variable_if_dynamic { public: - EIGEN_EMPTY_STRUCT_CTOR(ei_variable_if_dynamic) - explicit ei_variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); ei_assert(v == T(Value)); } + EIGEN_EMPTY_STRUCT_CTOR(variable_if_dynamic) + explicit variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); assert(v == T(Value)); } static T value() { return T(Value); } void setValue(T) {} }; -template<typename T> class ei_variable_if_dynamic<T, Dynamic> +template<typename T> class variable_if_dynamic<T, Dynamic> { T m_value; - ei_variable_if_dynamic() { ei_assert(false); } + variable_if_dynamic() { assert(false); } public: - explicit ei_variable_if_dynamic(T value) : m_value(value) {} + explicit variable_if_dynamic(T value) : m_value(value) {} T value() const { return m_value; } void setValue(T value) { m_value = value; } }; -template<typename T> struct ei_functor_traits +template<typename T> struct functor_traits { enum { @@ -85,9 +87,9 @@ template<typename T> struct ei_functor_traits }; }; -template<typename T> struct ei_packet_traits; +template<typename T> struct packet_traits; -template<typename T> struct ei_unpacket_traits +template<typename T> struct unpacket_traits { typedef T type; enum {size=1}; @@ -100,7 +102,7 @@ template<typename _Scalar, int _Rows, int _Cols, : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ), int _MaxRows = _Rows, int _MaxCols = _Cols -> class ei_make_proper_matrix_type +> class make_proper_matrix_type { enum { IsColVector = _Cols==1 && _Rows!=1, @@ -114,7 +116,7 @@ template<typename _Scalar, int _Rows, int _Cols, }; template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> -class ei_compute_matrix_flags +class compute_matrix_flags { enum { row_major_bit = Options&RowMajor ? RowMajorBit : 0, @@ -123,10 +125,10 @@ class ei_compute_matrix_flags aligned_bit = ( ((Options&DontAlign)==0) - && ei_packet_traits<Scalar>::Vectorizable + && packet_traits<Scalar>::Vectorizable && ( #if EIGEN_ALIGN_STATICALLY - ((!is_dynamic_size_storage) && (((MaxCols*MaxRows) % ei_packet_traits<Scalar>::size) == 0)) + ((!is_dynamic_size_storage) && (((MaxCols*MaxRows) % packet_traits<Scalar>::size) == 0)) #else 0 #endif @@ -141,95 +143,95 @@ class ei_compute_matrix_flags ) ) ? AlignedBit : 0, - packet_access_bit = ei_packet_traits<Scalar>::Vectorizable && aligned_bit ? PacketAccessBit : 0 + packet_access_bit = packet_traits<Scalar>::Vectorizable && aligned_bit ? PacketAccessBit : 0 }; public: enum { ret = LinearAccessBit | LvalueBit | DirectAccessBit | NestByRefBit | packet_access_bit | row_major_bit | aligned_bit }; }; -template<int _Rows, int _Cols> struct ei_size_at_compile_time +template<int _Rows, int _Cols> struct size_at_compile_time { enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols }; }; -/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type, - * whereas ei_eval is a const reference in the case of a matrix +/* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type, + * whereas eval is a const reference in the case of a matrix */ -template<typename T, typename StorageKind = typename ei_traits<T>::StorageKind> struct ei_plain_matrix_type; -template<typename T, typename BaseClassType> struct ei_plain_matrix_type_dense; -template<typename T> struct ei_plain_matrix_type<T,Dense> +template<typename T, typename StorageKind = typename traits<T>::StorageKind> struct plain_matrix_type; +template<typename T, typename BaseClassType> struct plain_matrix_type_dense; +template<typename T> struct plain_matrix_type<T,Dense> { - typedef typename ei_plain_matrix_type_dense<T,typename ei_traits<T>::XprKind>::type type; + typedef typename plain_matrix_type_dense<T,typename traits<T>::XprKind>::type type; }; -template<typename T> struct ei_plain_matrix_type_dense<T,MatrixXpr> +template<typename T> struct plain_matrix_type_dense<T,MatrixXpr> { - typedef Matrix<typename ei_traits<T>::Scalar, - ei_traits<T>::RowsAtCompileTime, - ei_traits<T>::ColsAtCompileTime, - AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<T>::MaxRowsAtCompileTime, - ei_traits<T>::MaxColsAtCompileTime + typedef Matrix<typename traits<T>::Scalar, + traits<T>::RowsAtCompileTime, + traits<T>::ColsAtCompileTime, + AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), + traits<T>::MaxRowsAtCompileTime, + traits<T>::MaxColsAtCompileTime > type; }; -template<typename T> struct ei_plain_matrix_type_dense<T,ArrayXpr> +template<typename T> struct plain_matrix_type_dense<T,ArrayXpr> { - typedef Array<typename ei_traits<T>::Scalar, - ei_traits<T>::RowsAtCompileTime, - ei_traits<T>::ColsAtCompileTime, - AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<T>::MaxRowsAtCompileTime, - ei_traits<T>::MaxColsAtCompileTime + typedef Array<typename traits<T>::Scalar, + traits<T>::RowsAtCompileTime, + traits<T>::ColsAtCompileTime, + AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), + traits<T>::MaxRowsAtCompileTime, + traits<T>::MaxColsAtCompileTime > type; }; -/* ei_eval : the return type of eval(). For matrices, this is just a const reference +/* eval : the return type of eval(). For matrices, this is just a const reference * in order to avoid a useless copy */ -template<typename T, typename StorageKind = typename ei_traits<T>::StorageKind> struct ei_eval; +template<typename T, typename StorageKind = typename traits<T>::StorageKind> struct eval; -template<typename T> struct ei_eval<T,Dense> +template<typename T> struct eval<T,Dense> { - typedef typename ei_plain_matrix_type<T>::type type; + typedef typename plain_matrix_type<T>::type type; // typedef typename T::PlainObject type; -// typedef T::Matrix<typename ei_traits<T>::Scalar, -// ei_traits<T>::RowsAtCompileTime, -// ei_traits<T>::ColsAtCompileTime, -// AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), -// ei_traits<T>::MaxRowsAtCompileTime, -// ei_traits<T>::MaxColsAtCompileTime +// typedef T::Matrix<typename traits<T>::Scalar, +// traits<T>::RowsAtCompileTime, +// traits<T>::ColsAtCompileTime, +// AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), +// traits<T>::MaxRowsAtCompileTime, +// traits<T>::MaxColsAtCompileTime // > type; }; // for matrices, no need to evaluate, just use a const reference to avoid a useless copy template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> +struct eval<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> { typedef const Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_eval<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> +struct eval<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> { typedef const Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; -/* ei_plain_matrix_type_column_major : same as ei_plain_matrix_type but guaranteed to be column-major +/* plain_matrix_type_column_major : same as plain_matrix_type but guaranteed to be column-major */ -template<typename T> struct ei_plain_matrix_type_column_major +template<typename T> struct plain_matrix_type_column_major { - enum { Rows = ei_traits<T>::RowsAtCompileTime, - Cols = ei_traits<T>::ColsAtCompileTime, - MaxRows = ei_traits<T>::MaxRowsAtCompileTime, - MaxCols = ei_traits<T>::MaxColsAtCompileTime + enum { Rows = traits<T>::RowsAtCompileTime, + Cols = traits<T>::ColsAtCompileTime, + MaxRows = traits<T>::MaxRowsAtCompileTime, + MaxCols = traits<T>::MaxColsAtCompileTime }; - typedef Matrix<typename ei_traits<T>::Scalar, + typedef Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxRows==1&&MaxCols!=1) ? RowMajor : ColMajor, @@ -238,16 +240,16 @@ template<typename T> struct ei_plain_matrix_type_column_major > type; }; -/* ei_plain_matrix_type_row_major : same as ei_plain_matrix_type but guaranteed to be row-major +/* plain_matrix_type_row_major : same as plain_matrix_type but guaranteed to be row-major */ -template<typename T> struct ei_plain_matrix_type_row_major +template<typename T> struct plain_matrix_type_row_major { - enum { Rows = ei_traits<T>::RowsAtCompileTime, - Cols = ei_traits<T>::ColsAtCompileTime, - MaxRows = ei_traits<T>::MaxRowsAtCompileTime, - MaxCols = ei_traits<T>::MaxColsAtCompileTime + enum { Rows = traits<T>::RowsAtCompileTime, + Cols = traits<T>::ColsAtCompileTime, + MaxRows = traits<T>::MaxRowsAtCompileTime, + MaxCols = traits<T>::MaxColsAtCompileTime }; - typedef Matrix<typename ei_traits<T>::Scalar, + typedef Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxCols==1&&MaxRows!=1) ? RowMajor : ColMajor, @@ -257,16 +259,16 @@ template<typename T> struct ei_plain_matrix_type_row_major }; // we should be able to get rid of this one too -template<typename T> struct ei_must_nest_by_value { enum { ret = false }; }; +template<typename T> struct must_nest_by_value { enum { ret = false }; }; template<class T> -struct ei_is_reference +struct is_reference { enum { ret = false }; }; template<class T> -struct ei_is_reference<T&> +struct is_reference<T&> { enum { ret = true }; }; @@ -277,10 +279,10 @@ struct ei_is_reference<T&> * objects which should generate no copying overhead. **/ template <typename T> -struct ei_ref_selector +struct ref_selector { - typedef typename ei_meta_if< - bool(ei_traits<T>::Flags & NestByRefBit), + typedef typename meta_if< + bool(traits<T>::Flags & NestByRefBit), T const&, T >::ret type; @@ -298,70 +300,70 @@ struct ei_ref_selector * * Example. Suppose that a, b, and c are of type Matrix3d. The user forms the expression a*(b+c). * b+c is an expression "sum of matrices", which we will denote by S. In order to determine how to nest it, - * the Product expression uses: ei_nested<S, 3>::ret, which turns out to be Matrix3d because the internal logic of - * ei_nested determined that in this case it was better to evaluate the expression b+c into a temporary. On the other hand, - * since a is of type Matrix3d, the Product expression nests it as ei_nested<Matrix3d, 3>::ret, which turns out to be - * const Matrix3d&, because the internal logic of ei_nested determined that since a was already a matrix, there was no point + * the Product expression uses: nested<S, 3>::ret, which turns out to be Matrix3d because the internal logic of + * nested determined that in this case it was better to evaluate the expression b+c into a temporary. On the other hand, + * since a is of type Matrix3d, the Product expression nests it as nested<Matrix3d, 3>::ret, which turns out to be + * const Matrix3d&, because the internal logic of nested determined that since a was already a matrix, there was no point * in copying it into another matrix. */ -template<typename T, int n=1, typename PlainObject = typename ei_eval<T>::type> struct ei_nested +template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested { // this is a direct port of the logic used when Dynamic was 33331, to make an atomic commit. enum { - _ScalarReadCost = NumTraits<typename ei_traits<T>::Scalar>::ReadCost, + _ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, ScalarReadCost = _ScalarReadCost == Dynamic ? 33331 : int(_ScalarReadCost), - _CoeffReadCost = int(ei_traits<T>::CoeffReadCost), + _CoeffReadCost = int(traits<T>::CoeffReadCost), CoeffReadCost = _CoeffReadCost == Dynamic ? 33331 : int(_CoeffReadCost), N = n == Dynamic ? 33331 : n, CostEval = (N+1) * int(ScalarReadCost), CostNoEval = (N-1) * int(CoeffReadCost) }; - typedef typename ei_meta_if< - ( int(ei_traits<T>::Flags) & EvalBeforeNestingBit ) || + typedef typename meta_if< + ( int(traits<T>::Flags) & EvalBeforeNestingBit ) || ( int(CostEval) <= int(CostNoEval) ), PlainObject, - typename ei_ref_selector<T>::type + typename ref_selector<T>::type >::ret type; /* this is what the above logic should be updated to look like: enum { - ScalarReadCost = NumTraits<typename ei_traits<T>::Scalar>::ReadCost, - CoeffReadCost = ei_traits<T>::CoeffReadCost, + ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, + CoeffReadCost = traits<T>::CoeffReadCost, CostEval = n == Dynamic || ScalarReadCost == Dynamic ? int(Dynamic) : (n+1) * int(ScalarReadCost), CostNoEval = n == Dynamic || (CoeffReadCost == Dynamic && n>1) ? int(Dynamic) : (n-1) * int(CoeffReadCost) }; - typedef typename ei_meta_if< - ( int(ei_traits<T>::Flags) & EvalBeforeNestingBit ) || + typedef typename meta_if< + ( int(traits<T>::Flags) & EvalBeforeNestingBit ) || ( int(CostNoEval) == Dynamic ? true : int(CostEval) == Dynamic ? false : int(CostEval) <= int(CostNoEval) ), PlainObject, - typename ei_ref_selector<T>::type + typename ref_selector<T>::type >::ret type; */ }; -template<unsigned int Flags> struct ei_are_flags_consistent +template<unsigned int Flags> struct are_flags_consistent { enum { ret = EIGEN_IMPLIES(bool(Flags&DirectAccessBit), bool(Flags&LvalueBit)) }; }; -template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind> -struct ei_dense_xpr_base +template<typename Derived, typename XprKind = typename traits<Derived>::XprKind> +struct dense_xpr_base { - /* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */ + /* dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */ }; template<typename Derived> -struct ei_dense_xpr_base<Derived, MatrixXpr> +struct dense_xpr_base<Derived, MatrixXpr> { typedef MatrixBase<Derived> type; }; template<typename Derived> -struct ei_dense_xpr_base<Derived, ArrayXpr> +struct dense_xpr_base<Derived, ArrayXpr> { typedef ArrayBase<Derived> type; }; @@ -369,27 +371,27 @@ struct ei_dense_xpr_base<Derived, ArrayXpr> /** \internal Helper base class to add a scalar multiple operator * overloads for complex types */ template<typename Derived,typename Scalar,typename OtherScalar, - bool EnableIt = !ei_is_same_type<Scalar,OtherScalar>::ret > -struct ei_special_scalar_op_base : public DenseCoeffsBase<Derived> + bool EnableIt = !is_same_type<Scalar,OtherScalar>::ret > +struct special_scalar_op_base : public DenseCoeffsBase<Derived> { // dummy operator* so that the - // "using ei_special_scalar_op_base::operator*" compiles + // "using special_scalar_op_base::operator*" compiles void operator*() const; }; template<typename Derived,typename Scalar,typename OtherScalar> -struct ei_special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCoeffsBase<Derived> +struct special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCoeffsBase<Derived> { - const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> + const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> operator*(const OtherScalar& scalar) const { - return CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> - (*static_cast<const Derived*>(this), ei_scalar_multiple2_op<Scalar,OtherScalar>(scalar)); + return CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> + (*static_cast<const Derived*>(this), scalar_multiple2_op<Scalar,OtherScalar>(scalar)); } - inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> + inline friend const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> operator*(const OtherScalar& scalar, const Derived& matrix) - { return static_cast<const ei_special_scalar_op_base&>(matrix).operator*(scalar); } + { return static_cast<const special_scalar_op_base&>(matrix).operator*(scalar); } }; template<typename ExpressionType> struct HNormalizedReturnType { @@ -399,24 +401,24 @@ template<typename ExpressionType> struct HNormalizedReturnType { SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1 }; typedef Block<ExpressionType, - ei_traits<ExpressionType>::ColsAtCompileTime==1 ? SizeMinusOne : 1, - ei_traits<ExpressionType>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; - typedef CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<ExpressionType>::Scalar>, + traits<ExpressionType>::ColsAtCompileTime==1 ? SizeMinusOne : 1, + traits<ExpressionType>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; + typedef CwiseUnaryOp<scalar_quotient1_op<typename traits<ExpressionType>::Scalar>, StartMinusOne > Type; }; -template<typename XprType, typename CastType> struct ei_cast_return_type +template<typename XprType, typename CastType> struct cast_return_type { typedef typename XprType::Scalar CurrentScalarType; - typedef typename ei_cleantype<CastType>::type _CastType; + typedef typename cleantype<CastType>::type _CastType; typedef typename _CastType::Scalar NewScalarType; - typedef typename ei_meta_if<ei_is_same_type<CurrentScalarType,NewScalarType>::ret, + typedef typename meta_if<is_same_type<CurrentScalarType,NewScalarType>::ret, const XprType&,CastType>::ret type; }; -template <typename A, typename B> struct ei_promote_storage_type; +template <typename A, typename B> struct promote_storage_type; -template <typename A> struct ei_promote_storage_type<A,A> +template <typename A> struct promote_storage_type<A,A> { typedef A ret; }; @@ -425,37 +427,37 @@ template <typename A> struct ei_promote_storage_type<A,A> * \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType. */ template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_row_type +struct plain_row_type { typedef Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> MatrixRowType; typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixRowType, ArrayRowType >::ret type; }; template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_col_type +struct plain_col_type { typedef Matrix<Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> MatrixColType; typedef Array<Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> ArrayColType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixColType, ArrayColType >::ret type; }; template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_diag_type +struct plain_diag_type { enum { diag_size = EIGEN_SIZE_MIN_PREFER_DYNAMIC(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime), max_diag_size = EIGEN_SIZE_MIN_PREFER_FIXED(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime) @@ -463,11 +465,13 @@ struct ei_plain_diag_type typedef Matrix<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> MatrixDiagType; typedef Array<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> ArrayDiagType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixDiagType, ArrayDiagType >::ret type; }; +} // end namespace internal + #endif // EIGEN_XPRHELPER_H |