From 1e286464ab90417a60f885a498f98be36e97bf29 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 6 May 2009 08:43:38 +0000 Subject: [PATCH] * compilation fixes for gcc 3.3 * test Part::swap --- Eigen/src/Core/Block.h | 2 +- Eigen/src/Core/Part.h | 10 +++--- Eigen/src/Core/arch/SSE/MathFunctions.h | 44 ++++++++++++------------- test/triangular.cpp | 8 +++++ 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 3866d2912..b58ef8af3 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -221,7 +221,7 @@ class Block class InnerIterator; typedef typename ei_traits::AlignedDerivedType AlignedDerivedType; - friend class Block; + friend class Block; EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) diff --git a/Eigen/src/Core/Part.h b/Eigen/src/Core/Part.h index d79c2f2ad..9c273f249 100644 --- a/Eigen/src/Core/Part.h +++ b/Eigen/src/Core/Part.h @@ -26,7 +26,7 @@ #ifndef EIGEN_PART_H #define EIGEN_PART_H -/** \nonstableyet +/** \nonstableyet * \class Part * * \brief Expression of a triangular matrix extracted from a given matrix @@ -117,10 +117,10 @@ template class Part const Block col(int i) { return Base::col(i); } const Block col(int i) const { return Base::col(i); } - template + template void swap(const MatrixBase& other) { - Part,Mode>(SwapWrapper(const_cast(m_matrix))).lazyAssign(other.derived()); + Part,Mode>(const_cast(m_matrix)).lazyAssign(other.derived()); } protected: @@ -128,7 +128,7 @@ template class Part const typename MatrixType::Nested m_matrix; }; -/** \nonstableyet +/** \nonstableyet * \returns an expression of a triangular matrix extracted from the current matrix * * The parameter \a Mode can have the following values: \c UpperTriangular, \c StrictlyUpperTriangular, \c UnitUpperTriangular, @@ -280,7 +280,7 @@ void Part::lazyAssign(const Other& other) >::run(m_matrix.const_cast_derived(), other.derived()); } -/** \nonstableyet +/** \nonstableyet * \returns a lvalue pseudo-expression allowing to perform special operations on \c *this. * * The \a Mode parameter can have the following values: \c UpperTriangular, \c StrictlyUpperTriangular, \c LowerTriangular, diff --git a/Eigen/src/Core/arch/SSE/MathFunctions.h b/Eigen/src/Core/arch/SSE/MathFunctions.h index 5675594df..4caff0dfb 100644 --- a/Eigen/src/Core/arch/SSE/MathFunctions.h +++ b/Eigen/src/Core/arch/SSE/MathFunctions.h @@ -41,7 +41,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_plog(Packet4f x) /* the smallest non denormalized float number */ _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(min_norm_pos, 0x00800000); - /* natural logarithm computed for 4 simultaneous float + /* natural logarithm computed for 4 simultaneous float return NaN for x <= 0 */ _EIGEN_DECLARE_CONST_Packet4f(cephes_SQRTHF, 0.707106781186547524f); @@ -72,7 +72,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_plog(Packet4f x) emm0 = _mm_sub_epi32(emm0, ei_p4i_0x7f); Packet4f e = ei_padd(_mm_cvtepi32_ps(emm0), ei_p4f_1); - /* part2: + /* part2: if( x < SQRTHF ) { e -= 1; x = x + x - 1.0; @@ -86,7 +86,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_plog(Packet4f x) Packet4f x2 = ei_pmul(x,x); Packet4f x3 = ei_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); @@ -97,7 +97,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_plog(Packet4f x) 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); @@ -142,7 +142,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_pexp(Packet4f x) emm0 = _mm_cvttps_epi32(fx); tmp = _mm_cvtepi32_ps(emm0); /* if greater, substract 1 */ - Packet4f mask = _mm_cmpgt_ps(tmp, fx); + Packet4f mask = _mm_cmpgt_ps(tmp, fx); mask = _mm_and_ps(mask, ei_p4f_1); fx = ei_psub(tmp, mask); @@ -152,7 +152,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_pexp(Packet4f x) x = ei_psub(x, z); z = ei_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); @@ -210,12 +210,12 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_psin(Packet4f x) sign_bit = x; /* take the absolute value */ x = ei_pabs(x); - + /* take the modulo */ - + /* extract the sign bit (upper one) */ sign_bit = _mm_and_ps(sign_bit, ei_p4f_sign_mask); - + /* scale by 4/Pi */ y = ei_pmul(x, ei_p4f_cephes_FOPI); @@ -228,7 +228,7 @@ static EIGEN_DONT_INLINE EIGEN_UNUSED Packet4f ei_psin(Packet4f x) /* get the swap sign flag */ emm0 = _mm_and_si128(emm2, ei_p4i_4); emm0 = _mm_slli_epi32(emm0, 29); - /* get the polynom selection mask + /* get the polynom selection mask there is one polynom for 0 <= x <= Pi/4 and another one for Pi/4 void triangular(const MatrixType& m) VERIFY((m1.template part() * m2.template part()).isUpperTriangular()); + // test swap + m1.setOnes(); + m2.setZero(); + m2.template part().swap(m1); + m3.setZero(); + m3.template part().setOnes(); + VERIFY_IS_APPROX(m2,m3); + } void test_triangular()