From aa8b8976075823636b7a266cb6307dbba2ee2705 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 19 Apr 2013 14:03:16 +0200 Subject: document the evaluation order of the comma initializer --- Eigen/src/Core/CommaInitializer.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index f20c1774c..a96867af4 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -118,6 +118,8 @@ struct CommaInitializer * * Example: \include MatrixBase_set.cpp * Output: \verbinclude MatrixBase_set.out + * + * \note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order. * * \sa CommaInitializer::finished(), class CommaInitializer */ -- cgit v1.2.3 From 43bb94236589168914f9e3cf742f7eaa188c5dba Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 13 May 2013 10:39:50 +0200 Subject: Add missing support for x.noalias() = ReturnByValue<...> --- Eigen/src/Core/NoAlias.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index 0112c865b..768bfb18c 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -80,6 +80,10 @@ class NoAlias template EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct& other) { return m_expression.derived() -= CoeffBasedProduct(other.lhs(), other.rhs()); } + + template + ExpressionType& operator=(const ReturnByValue& func) + { return m_expression = func; } #endif ExpressionType& expression() const -- cgit v1.2.3 From b5e5b6aa575cc6eb14576a7ad76cb47cee20b2f3 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 16 May 2013 10:18:19 +0200 Subject: Fix non const data() member in Array and Matrix wrappers. --- Eigen/src/Core/ArrayWrapper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/ArrayWrapper.h b/Eigen/src/Core/ArrayWrapper.h index 1e021b0b9..a791bc358 100644 --- a/Eigen/src/Core/ArrayWrapper.h +++ b/Eigen/src/Core/ArrayWrapper.h @@ -55,7 +55,7 @@ class ArrayWrapper : public ArrayBase > inline Index outerStride() const { return m_expression.outerStride(); } inline Index innerStride() const { return m_expression.innerStride(); } - inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } + inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } inline const Scalar* data() const { return m_expression.data(); } inline CoeffReturnType coeff(Index rowId, Index colId) const @@ -175,7 +175,7 @@ class MatrixWrapper : public MatrixBase > inline Index outerStride() const { return m_expression.outerStride(); } inline Index innerStride() const { return m_expression.innerStride(); } - inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } + inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } inline const Scalar* data() const { return m_expression.data(); } inline CoeffReturnType coeff(Index rowId, Index colId) const -- cgit v1.2.3 From b3adc4face5c7855fd63d8f6f96f6a8f63dc40c4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 17 May 2013 17:25:29 +0200 Subject: Add missing pconj specializations --- Eigen/src/Core/arch/AltiVec/PacketMath.h | 3 +++ Eigen/src/Core/arch/NEON/PacketMath.h | 3 +++ Eigen/src/Core/arch/SSE/PacketMath.h | 4 ++++ 3 files changed, 10 insertions(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h index 75de19311..e4089962d 100644 --- a/Eigen/src/Core/arch/AltiVec/PacketMath.h +++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h @@ -173,6 +173,9 @@ template<> EIGEN_STRONG_INLINE Packet4i psub(const Packet4i& a, const template<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { return psub(p4f_ZERO, a); } template<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return psub(p4i_ZERO, a); } +template<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; } +template<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; } + template<> EIGEN_STRONG_INLINE Packet4f pmul(const Packet4f& a, const Packet4f& b) { return vec_madd(a,b,p4f_ZERO); } /* Commented out: it's actually slower than processing it scalar * diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h index 2662e2ebf..4c0702715 100644 --- a/Eigen/src/Core/arch/NEON/PacketMath.h +++ b/Eigen/src/Core/arch/NEON/PacketMath.h @@ -115,6 +115,9 @@ template<> EIGEN_STRONG_INLINE Packet4i psub(const Packet4i& a, const 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 pconj(const Packet4f& a) { return a; } +template<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; } + template<> EIGEN_STRONG_INLINE Packet4f pmul(const Packet4f& a, const Packet4f& b) { return vmulq_f32(a,b); } template<> EIGEN_STRONG_INLINE Packet4i pmul(const Packet4i& a, const Packet4i& b) { return vmulq_s32(a,b); } diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index addb2fc0e..e256f4bac 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -141,6 +141,10 @@ template<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) return psub(_mm_setr_epi32(0,0,0,0), a); } +template<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; } +template<> EIGEN_STRONG_INLINE Packet2d pconj(const Packet2d& a) { return a; } +template<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; } + template<> EIGEN_STRONG_INLINE Packet4f pmul(const Packet4f& a, const Packet4f& b) { return _mm_mul_ps(a,b); } template<> EIGEN_STRONG_INLINE Packet2d pmul(const Packet2d& a, const Packet2d& b) { return _mm_mul_pd(a,b); } template<> EIGEN_STRONG_INLINE Packet4i pmul(const Packet4i& a, const Packet4i& b) -- cgit v1.2.3 From e3929485486ad4450dd93d24fa2af9dd72aa368e Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 10 Jun 2013 00:06:40 +0200 Subject: Fix bug #607: handle implicit transposition from sparse vector to dense vector --- Eigen/src/Core/Assign.h | 10 ++++++---- Eigen/src/SparseCore/SparseMatrixBase.h | 26 +++++++++++++------------- test/sparse_vector.cpp | 5 +++++ 3 files changed, 24 insertions(+), 17 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 288f8ec53..6400f5ae7 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -520,18 +520,22 @@ struct assign_selector; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); } + static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { other.evalTo(dst); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); } + static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { other.evalTo(dst); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); } + static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); } + static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } }; } // end namespace internal @@ -566,16 +570,14 @@ template template EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) { - other.derived().evalTo(derived()); - return derived(); + return internal::assign_selector::evalTo(derived(), other.derived()); } template template EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) { - other.evalTo(derived()); - return derived(); + return internal::assign_selector::evalTo(derived(), other.derived()); } } // end namespace Eigen diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h index 590339663..6c73b7172 100644 --- a/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/Eigen/src/SparseCore/SparseMatrixBase.h @@ -403,20 +403,20 @@ template class SparseMatrixBase : public EigenBase Block innerVectors(Index outerStart, Index outerSize); const Block innerVectors(Index outerStart, Index outerSize) const; - /** \internal use operator= */ - template - void evalTo(MatrixBase& dst) const - { - dst.setZero(); - for (Index j=0; j + void evalTo(MatrixBase& dst) const + { + dst.setZero(); + for (Index j=0; j toDense() const - { - return derived(); - } + Matrix toDense() const + { + return derived(); + } template bool isApprox(const SparseMatrixBase& other, diff --git a/test/sparse_vector.cpp b/test/sparse_vector.cpp index d16d42f59..ec5877b6a 100644 --- a/test/sparse_vector.cpp +++ b/test/sparse_vector.cpp @@ -90,6 +90,11 @@ template void sparse_vector(int rows, int cols) VERIFY_IS_APPROX((mv1=v1),v1); VERIFY_IS_APPROX(mv1,(v1=mv1)); VERIFY_IS_APPROX(mv1,(v1=mv1.transpose())); + + // check copy to dense vector with transpose + refV3.resize(0); + VERIFY_IS_APPROX(refV3 = v1.transpose(),v1.toDense()); + VERIFY_IS_APPROX(DenseVector(v1),v1.toDense()); } -- cgit v1.2.3 From b6d3fcf6f28c189bf270e8f9cffc13913a814925 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 10 Jun 2013 10:11:29 +0200 Subject: Fix bug #605: ambiguous call to std::min when calling .diagonal() on a sparse matrix with non default index type --- Eigen/src/Core/Diagonal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index 0927e9969..c106f93c4 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -75,7 +75,7 @@ template class Diagonal EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal) inline Index rows() const - { return m_index.value()<0 ? (std::min)(m_matrix.cols(),m_matrix.rows()+m_index.value()) : (std::min)(m_matrix.rows(),m_matrix.cols()-m_index.value()); } + { return m_index.value()<0 ? (std::min)(m_matrix.cols(),m_matrix.rows()+m_index.value()) : (std::min)(m_matrix.rows(),m_matrix.cols()-m_index.value()); } inline Index cols() const { return 1; } -- cgit v1.2.3 From e8c963568cd70c525234b283d15b0653114a93f4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 10 Jun 2013 10:32:29 +0200 Subject: Simplify and generalize assign_selector logic --- Eigen/src/Core/Assign.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 6400f5ae7..1dccc2f42 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -507,35 +507,33 @@ EIGEN_STRONG_INLINE Derived& DenseBase namespace internal { template + bool EvalBeforeAssigning = (int(internal::traits::Flags) & EvalBeforeAssigningBit) != 0, + bool NeedToTranspose = ((int(Derived::RowsAtCompileTime) == 1 && int(OtherDerived::ColsAtCompileTime) == 1) + | // FIXME | instead of || to please GCC 4.4.0 stupid warning "suggest parentheses around &&". + // revert to || as soon as not needed anymore. + (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1)) + && int(Derived::SizeAtCompileTime) != 1> struct assign_selector; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); } - static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { other.evalTo(dst); return dst; } + template + static EIGEN_STRONG_INLINE Derived& evalTo(ActualDerived& dst, const ActualOtherDerived& other) { other.evalTo(dst); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); } - static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { other.evalTo(dst); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); } - static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } + template + static EIGEN_STRONG_INLINE Derived& evalTo(ActualDerived& dst, const ActualOtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } }; template struct assign_selector { static EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); } - static EIGEN_STRONG_INLINE Derived& evalTo(Derived& dst, const OtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } }; } // end namespace internal @@ -570,14 +568,14 @@ template template EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) { - return internal::assign_selector::evalTo(derived(), other.derived()); + return internal::assign_selector::evalTo(derived(), other.derived()); } template template EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) { - return internal::assign_selector::evalTo(derived(), other.derived()); + return internal::assign_selector::evalTo(derived(), other.derived()); } } // end namespace Eigen -- cgit v1.2.3 From ca67c6015031d9740034e98774ff8de5f5bbf865 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 10 Jun 2013 15:59:03 +0200 Subject: Fix bug #591: minor optimization in NEON vectorization support --- Eigen/src/Core/arch/NEON/Complex.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/arch/NEON/Complex.h b/Eigen/src/Core/arch/NEON/Complex.h index 795b4be73..f183d31de 100644 --- a/Eigen/src/Core/arch/NEON/Complex.h +++ b/Eigen/src/Core/arch/NEON/Complex.h @@ -68,7 +68,6 @@ template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a) template<> EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) { Packet4f v1, v2; - float32x2_t a_lo, a_hi; // Get the real values of a | a1_re | a1_re | a2_re | a2_re | v1 = vcombine_f32(vdup_lane_f32(vget_low_f32(a.v), 0), vdup_lane_f32(vget_high_f32(a.v), 0)); @@ -81,9 +80,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, con // Conjugate v2 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)); - v2 = vcombine_f32(a_lo, a_hi); + v2 = vrev64q_f32(v2); // Add and return the result return Packet2cf(vaddq_f32(v1, v2)); } @@ -241,13 +238,10 @@ template<> EIGEN_STRONG_INLINE Packet2cf pdiv(const Packet2cf& a, con // TODO optimize it for AltiVec Packet2cf res = conj_helper().pmul(a,b); Packet4f s, rev_s; - float32x2_t a_lo, a_hi; // this computes the norm s = vmulq_f32(b.v, b.v); - a_lo = vrev64_f32(vget_low_f32(s)); - a_hi = vrev64_f32(vget_high_f32(s)); - rev_s = vcombine_f32(a_lo, a_hi); + rev_s = vrev64q_f32(s); return Packet2cf(pdiv(res.v, vaddq_f32(s,rev_s))); } -- cgit v1.2.3 From 18e476107e5b1b38d3e13888f2afda6b1a8b6a87 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 10 Jun 2013 17:16:16 +0200 Subject: Fix bug #583: add compile-time check that DenseIndex is signed --- Eigen/src/Core/DenseBase.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index dfdf6c4a8..4e8b820bb 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -13,6 +13,16 @@ namespace Eigen { +namespace internal { + +// The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type. +// This dummy function simply aims at checking that at compile time. +static inline void check_DenseIndex_is_signed() { + EIGEN_STATIC_ASSERT(NumTraits::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); +} + +} // end namespace internal + /** \class DenseBase * \ingroup Core_Module * -- cgit v1.2.3 From 7742eacfebaad92649ea033fd0ce55a69dd74336 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 12 Jun 2013 09:22:59 +0200 Subject: Add default value for IsRepeatable in functor_traits --- Eigen/src/Core/util/XprHelper.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 3d1290cd2..3c4773054 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -91,7 +91,8 @@ template struct functor_traits enum { Cost = 10, - PacketAccess = false + PacketAccess = false, + IsRepeatable = false }; }; -- cgit v1.2.3 From 92eb807c30962bacfc194e7f845892dd2dc4f7f4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 12 Jun 2013 09:24:07 +0200 Subject: Fix warning: explicitely initialize all member of IOFormat --- Eigen/src/Core/IO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index 50bf93d9f..c8d5f6379 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -55,7 +55,7 @@ struct IOFormat const std::string& _rowSeparator = "\n", const std::string& _rowPrefix="", const std::string& _rowSuffix="", const std::string& _matPrefix="", const std::string& _matSuffix="") : matPrefix(_matPrefix), matSuffix(_matSuffix), rowPrefix(_rowPrefix), rowSuffix(_rowSuffix), rowSeparator(_rowSeparator), - coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags) + rowSpacer(""), coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags) { int i = int(matSuffix.length())-1; while (i>=0 && matSuffix[i]!='\n') -- cgit v1.2.3 From 62670c83a0ba7cb4f45a734a4817a818a7c92bba Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 10 Jun 2013 23:40:56 +0200 Subject: Fix bug #314: move remaining math functions from internal to numext namespace --- Eigen/Core | 2 +- Eigen/src/Cholesky/LDLT.h | 18 +- Eigen/src/Cholesky/LLT.h | 10 +- Eigen/src/Core/Dot.h | 4 +- Eigen/src/Core/Functors.h | 16 +- Eigen/src/Core/Fuzzy.h | 4 +- Eigen/src/Core/GeneralProduct.h | 2 +- Eigen/src/Core/GlobalFunctions.h | 3 +- Eigen/src/Core/MathFunctions.h | 218 +++++++++++---------- Eigen/src/Core/SelfAdjointView.h | 12 +- Eigen/src/Core/StableNorm.h | 10 +- Eigen/src/Core/arch/SSE/Complex.h | 8 +- Eigen/src/Core/products/GeneralMatrixVector.h | 2 +- Eigen/src/Core/products/SelfadjointMatrixMatrix.h | 34 ++-- Eigen/src/Core/products/SelfadjointMatrixVector.h | 12 +- Eigen/src/Core/products/SelfadjointRank2Update.h | 12 +- Eigen/src/Core/products/TriangularMatrixVector.h | 2 +- Eigen/src/Core/util/BlasUtil.h | 10 +- Eigen/src/Eigen2Support/MathFunctions.h | 10 +- Eigen/src/Eigen2Support/SVD.h | 8 +- Eigen/src/Eigenvalues/ComplexEigenSolver.h | 2 +- Eigen/src/Eigenvalues/ComplexSchur.h | 10 +- Eigen/src/Eigenvalues/EigenSolver.h | 26 +-- Eigen/src/Eigenvalues/HessenbergDecomposition.h | 2 +- Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h | 16 +- Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h | 2 +- Eigen/src/Eigenvalues/Tridiagonalization.h | 8 +- Eigen/src/Geometry/OrthoMethods.h | 26 +-- Eigen/src/Householder/Householder.h | 10 +- .../src/IterativeLinearSolvers/ConjugateGradient.h | 4 +- Eigen/src/IterativeLinearSolvers/IncompleteLUT.h | 2 +- Eigen/src/Jacobi/Jacobi.h | 50 ++--- Eigen/src/MetisSupport/MetisSupport.h | 2 +- Eigen/src/QR/ColPivHouseholderQR.h | 2 +- Eigen/src/QR/FullPivHouseholderQR.h | 2 +- Eigen/src/SVD/JacobiSVD.h | 8 +- Eigen/src/SparseCholesky/SimplicialCholesky.h | 4 +- Eigen/src/SparseCholesky/SimplicialCholesky_impl.h | 8 +- Eigen/src/SparseCore/SparseDot.h | 6 +- Eigen/src/SparseCore/SparseSelfAdjointView.h | 11 +- Eigen/src/SparseCore/SparseView.h | 2 +- Eigen/src/SparseQR/SparseQR.h | 12 +- Eigen/src/UmfPackSupport/UmfPackSupport.h | 14 +- test/adjoint.cpp | 14 +- test/array.cpp | 8 +- test/array_for_matrix.cpp | 6 +- test/basicstuff.cpp | 8 +- test/block.cpp | 8 +- test/determinant.cpp | 2 +- test/eigen2support.cpp | 4 +- test/householder.cpp | 8 +- test/jacobi.cpp | 6 +- test/main.h | 2 +- test/packetmath.cpp | 2 +- test/product_extra.cpp | 2 +- test/product_selfadjoint.cpp | 4 +- test/product_trmm.cpp | 2 +- test/redux.cpp | 28 +-- test/sparse.h | 4 +- test/spqr_support.cpp | 2 +- test/triangular.cpp | 2 +- test/umeyama.cpp | 2 +- unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 12 +- unsupported/Eigen/src/AutoDiff/AutoDiffVector.h | 4 +- unsupported/Eigen/src/IterativeSolvers/DGMRES.h | 2 +- .../Eigen/src/LevenbergMarquardt/LMonestep.h | 6 +- .../Eigen/src/MatrixFunctions/MatrixPowerBase.h | 2 +- .../NonLinearOptimization/HybridNonLinearSolver.h | 8 +- .../src/NonLinearOptimization/LevenbergMarquardt.h | 12 +- .../Eigen/src/Polynomials/PolynomialSolver.h | 8 +- .../Eigen/src/Polynomials/PolynomialUtils.h | 2 +- 71 files changed, 408 insertions(+), 388 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/Core b/Eigen/Core index 8197c944f..7e068cbbd 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -245,8 +245,8 @@ using std::ptrdiff_t; #include "src/Core/util/Constants.h" #include "src/Core/util/ForwardDeclarations.h" #include "src/Core/util/Meta.h" -#include "src/Core/util/XprHelper.h" #include "src/Core/util/StaticAssert.h" +#include "src/Core/util/XprHelper.h" #include "src/Core/util/Memory.h" #include "src/Core/NumTraits.h" diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index d933b10d4..d19cb3968 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -259,7 +259,7 @@ template<> struct ldlt_inplace { transpositions.setIdentity(); if(sign) - *sign = real(mat.coeff(0,0))>0 ? 1:-1; + *sign = numext::real(mat.coeff(0,0))>0 ? 1:-1; return true; } @@ -300,11 +300,11 @@ template<> struct ldlt_inplace for(int i=k+1;i::IsComplex) - mat.coeffRef(index_of_biggest_in_corner,k) = conj(mat.coeff(index_of_biggest_in_corner,k)); + mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k)); } // partition the matrix: @@ -329,7 +329,7 @@ template<> struct ldlt_inplace if(sign) { // LDLT is not guaranteed to work for indefinite matrices, but let's try to get the sign right - int newSign = real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0; + int newSign = numext::real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0; if(k == 0) *sign = newSign; else if(*sign != newSign) @@ -350,7 +350,7 @@ template<> struct ldlt_inplace template static bool updateInPlace(MatrixType& mat, MatrixBase& w, const typename MatrixType::RealScalar& sigma=1) { - using internal::isfinite; + using numext::isfinite; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef typename MatrixType::Index Index; @@ -368,9 +368,9 @@ template<> struct ldlt_inplace break; // Update the diagonal terms - RealScalar dj = real(mat.coeff(j,j)); + RealScalar dj = numext::real(mat.coeff(j,j)); Scalar wj = w.coeff(j); - RealScalar swj2 = sigma*abs2(wj); + RealScalar swj2 = sigma*numext::abs2(wj); RealScalar gamma = dj*alpha + swj2; mat.coeffRef(j,j) += swj2/alpha; @@ -381,7 +381,7 @@ template<> struct ldlt_inplace Index rs = size-j-1; w.tail(rs) -= wj * mat.col(j).tail(rs); if(gamma != 0) - mat.col(j).tail(rs) += (sigma*conj(wj)/gamma)*w.tail(rs); + mat.col(j).tail(rs) += (sigma*numext::conj(wj)/gamma)*w.tail(rs); } return true; } diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index db22a2f85..2e6189f7d 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -232,10 +232,10 @@ static typename MatrixType::Index llt_rank_update_lower(MatrixType& mat, const V RealScalar beta = 1; for(Index j=0; j struct llt_inplace Block A10(mat,k,0,1,k); Block A20(mat,k+1,0,rs,k); - RealScalar x = real(mat.coeff(k,k)); + RealScalar x = numext::real(mat.coeff(k,k)); if (k>0) x -= A10.squaredNorm(); if (x<=RealScalar(0)) return k; diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 9d513d699..e4107a1ac 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -112,7 +112,7 @@ MatrixBase::eigen2_dot(const MatrixBase& other) const template EIGEN_STRONG_INLINE typename NumTraits::Scalar>::Real MatrixBase::squaredNorm() const { - return internal::real((*this).cwiseAbs2().sum()); + return numext::real((*this).cwiseAbs2().sum()); } /** \returns, for vectors, the \em l2 norm of \c *this, and for matrices the Frobenius norm. @@ -228,7 +228,7 @@ bool MatrixBase::isOrthogonal { typename internal::nested::type nested(derived()); typename internal::nested::type otherNested(other.derived()); - return internal::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm(); + return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm(); } /** \returns true if *this is approximately an unitary matrix, diff --git a/Eigen/src/Core/Functors.h b/Eigen/src/Core/Functors.h index 9a84e8f26..04fb21732 100644 --- a/Eigen/src/Core/Functors.h +++ b/Eigen/src/Core/Functors.h @@ -171,7 +171,7 @@ struct functor_traits > { */ template struct scalar_binary_pow_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_binary_pow_op) - inline Scalar operator() (const Scalar& a, const OtherScalar& b) const { return internal::pow(a, b); } + inline Scalar operator() (const Scalar& a, const OtherScalar& b) const { return numext::pow(a, b); } }; template struct functor_traits > { @@ -310,7 +310,7 @@ struct functor_traits > template struct scalar_abs2_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_abs2_op) typedef typename NumTraits::Real result_type; - EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return internal::abs2(a); } + EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs2(a); } template EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pmul(a,a); } @@ -326,7 +326,7 @@ struct functor_traits > */ template struct scalar_conjugate_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op) - EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using internal::conj; return conj(a); } + EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using numext::conj; return conj(a); } template EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); } }; @@ -363,7 +363,7 @@ template struct scalar_real_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_real_op) typedef typename NumTraits::Real result_type; - EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return internal::real(a); } + EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::real(a); } }; template struct functor_traits > @@ -378,7 +378,7 @@ template struct scalar_imag_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_op) typedef typename NumTraits::Real result_type; - EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return internal::imag(a); } + EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::imag(a); } }; template struct functor_traits > @@ -393,7 +393,7 @@ template struct scalar_real_ref_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_real_ref_op) typedef typename NumTraits::Real result_type; - EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return internal::real_ref(*const_cast(&a)); } + EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::real_ref(*const_cast(&a)); } }; template struct functor_traits > @@ -408,7 +408,7 @@ template struct scalar_imag_ref_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_ref_op) typedef typename NumTraits::Real result_type; - EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return internal::imag_ref(*const_cast(&a)); } + EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::imag_ref(*const_cast(&a)); } }; template struct functor_traits > @@ -801,7 +801,7 @@ struct scalar_pow_op { // FIXME default copy constructors seems bugged with std::complex<> 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); } + inline Scalar operator() (const Scalar& a) const { return numext::pow(a, m_exponent); } const Scalar m_exponent; }; template diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index 8fb9a01dd..fe63bd298 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -42,7 +42,7 @@ struct isMuchSmallerThan_object_selector { static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec) { - return x.cwiseAbs2().sum() <= abs2(prec) * y.cwiseAbs2().sum(); + return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum(); } }; @@ -60,7 +60,7 @@ struct isMuchSmallerThan_scalar_selector { static bool run(const Derived& x, const typename Derived::RealScalar& y, const typename Derived::RealScalar& prec) { - return x.cwiseAbs2().sum() <= abs2(prec * y); + return x.cwiseAbs2().sum() <= numext::abs2(prec * y); } }; diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 4e6448353..2a59d9464 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -435,7 +435,7 @@ template<> struct gemv_selector gemv_static_vector_if static_dest; - bool alphaIsCompatible = (!ComplexByReal) || (imag(actualAlpha)==RealScalar(0)); + bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0)); bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; RhsScalar compatibleAlpha = get_factor::run(actualAlpha); diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index 02cae552e..2acf97723 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -39,6 +39,7 @@ namespace Eigen { EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op) + EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op) @@ -86,6 +87,6 @@ namespace Eigen } } -// TODO: cleanly disable those functions that are not supported on Array (internal::real_ref, internal::random, internal::isApprox...) +// TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...) #endif // EIGEN_GLOBAL_FUNCTIONS_H diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index a2c55f255..5df2d8bca 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -51,16 +51,15 @@ struct global_math_functions_filtering_base typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type; }; -#define EIGEN_MATHFUNC_IMPL(func, scalar) func##_impl::type> -#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename func##_retval::type>::type - +#define EIGEN_MATHFUNC_IMPL(func, scalar) Eigen::internal::func##_impl::type> +#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename Eigen::internal::func##_retval::type>::type /**************************************************************************** * Implementation of real * ****************************************************************************/ -template -struct real_impl +template::IsComplex> +struct real_default_impl { typedef typename NumTraits::Real RealScalar; static inline RealScalar run(const Scalar& x) @@ -69,34 +68,32 @@ struct real_impl } }; -template -struct real_impl > +template +struct real_default_impl { - static inline RealScalar run(const std::complex& x) + typedef typename NumTraits::Real RealScalar; + static inline RealScalar run(const Scalar& x) { using std::real; return real(x); } }; +template struct real_impl : real_default_impl {}; + template struct real_retval { typedef typename NumTraits::Real type; }; -template -inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x); -} /**************************************************************************** * Implementation of imag * ****************************************************************************/ -template -struct imag_impl +template::IsComplex> +struct imag_default_impl { typedef typename NumTraits::Real RealScalar; static inline RealScalar run(const Scalar&) @@ -105,28 +102,25 @@ struct imag_impl } }; -template -struct imag_impl > +template +struct imag_default_impl { - static inline RealScalar run(const std::complex& x) + typedef typename NumTraits::Real RealScalar; + static inline RealScalar run(const Scalar& x) { using std::imag; return imag(x); } }; +template struct imag_impl : imag_default_impl {}; + template struct imag_retval { typedef typename NumTraits::Real type; }; -template -inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x); -} - /**************************************************************************** * Implementation of real_ref * ****************************************************************************/ @@ -151,18 +145,6 @@ struct real_ref_retval typedef typename NumTraits::Real & type; }; -template -inline typename add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x) -{ - return real_ref_impl::run(x); -} - -template -inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x); -} - /**************************************************************************** * Implementation of imag_ref * ****************************************************************************/ @@ -203,23 +185,11 @@ struct imag_ref_retval typedef typename NumTraits::Real & type; }; -template -inline typename add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x) -{ - return imag_ref_impl::run(x); -} - -template -inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x); -} - /**************************************************************************** * Implementation of conj * ****************************************************************************/ -template +template::IsComplex> struct conj_impl { static inline Scalar run(const Scalar& x) @@ -228,10 +198,10 @@ struct conj_impl } }; -template -struct conj_impl > +template +struct conj_impl { - static inline std::complex run(const std::complex& x) + static inline Scalar run(const Scalar& x) { using std::conj; return conj(x); @@ -244,12 +214,6 @@ struct conj_retval typedef Scalar type; }; -template -inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x); -} - /**************************************************************************** * Implementation of abs2 * ****************************************************************************/ @@ -279,12 +243,6 @@ struct abs2_retval typedef typename NumTraits::Real type; }; -template -inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x); -} - /**************************************************************************** * Implementation of norm1 * ****************************************************************************/ @@ -319,12 +277,6 @@ struct norm1_retval typedef typename NumTraits::Real type; }; -template -inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) -{ - return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x); -} - /**************************************************************************** * Implementation of hypot * ****************************************************************************/ @@ -342,6 +294,7 @@ struct hypot_impl RealScalar _x = abs(x); RealScalar _y = abs(y); RealScalar p = (max)(_x, _y); + if(p==RealScalar(0)) return 0; RealScalar q = (min)(_x, _y); RealScalar qp = q/p; return p * sqrt(RealScalar(1) + qp*qp); @@ -354,12 +307,6 @@ struct hypot_retval typedef typename NumTraits::Real type; }; -template -inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) -{ - return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y); -} - /**************************************************************************** * Implementation of cast * ****************************************************************************/ @@ -422,12 +369,6 @@ struct atanh2_retval typedef Scalar type; }; -template -inline EIGEN_MATHFUNC_RETVAL(atanh2, Scalar) atanh2(const Scalar& x, const Scalar& y) -{ - return EIGEN_MATHFUNC_IMPL(atanh2, Scalar)::run(x, y); -} - /**************************************************************************** * Implementation of pow * ****************************************************************************/ @@ -471,12 +412,6 @@ struct pow_retval typedef Scalar type; }; -template -inline EIGEN_MATHFUNC_RETVAL(pow, Scalar) pow(const Scalar& x, const Scalar& y) -{ - return EIGEN_MATHFUNC_IMPL(pow, Scalar)::run(x, y); -} - /**************************************************************************** * Implementation of random * ****************************************************************************/ @@ -611,6 +546,97 @@ inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random() return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(); } +} // end namespace internal + +/**************************************************************************** +* Generic math function * +****************************************************************************/ + +namespace numext { + +template +inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x); +} + +template +inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x) +{ + return internal::real_ref_impl::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x); +} + +template +inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x) +{ + return internal::imag_ref_impl::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x); +} + +template +inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) +{ + return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y); +} + +template +inline EIGEN_MATHFUNC_RETVAL(atanh2, Scalar) atanh2(const Scalar& x, const Scalar& y) +{ + return EIGEN_MATHFUNC_IMPL(atanh2, Scalar)::run(x, y); +} + +template +inline EIGEN_MATHFUNC_RETVAL(pow, Scalar) pow(const Scalar& x, const Scalar& y) +{ + return EIGEN_MATHFUNC_IMPL(pow, Scalar)::run(x, y); +} + +// std::isfinite is non standard, so let's define our own version, +// even though it is not very efficient. +template bool (isfinite)(const T& x) +{ + return x::highest() && x>NumTraits::lowest(); +} + +} // end namespace numext + +namespace internal { + /**************************************************************************** * Implementation of fuzzy comparisons * ****************************************************************************/ @@ -668,12 +694,12 @@ struct scalar_fuzzy_default_impl template static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec) { - return abs2(x) <= abs2(y) * prec * prec; + return numext::abs2(x) <= numext::abs2(y) * prec * prec; } static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) { using std::min; - return abs2(x - y) <= (min)(abs2(x), abs2(y)) * prec * prec; + return numext::abs2(x - y) <= (min)(numext::abs2(x), numext::abs2(y)) * prec * prec; } }; @@ -735,17 +761,7 @@ template<> struct scalar_fuzzy_impl }; -/**************************************************************************** -* Special functions * -****************************************************************************/ - -// std::isfinite is non standard, so let's define our own version, -// even though it is not very efficient. -template bool (isfinite)(const T& x) -{ - return x::highest() && x>NumTraits::lowest(); -} - + } // end namespace internal } // end namespace Eigen diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index d43789123..6fa7cd15e 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -214,9 +214,9 @@ struct triangular_assignment_selector::run(dst, src); if(row == col) - dst.coeffRef(row, col) = real(src.coeff(row, col)); + dst.coeffRef(row, col) = numext::real(src.coeff(row, col)); else if(row < col) - dst.coeffRef(col, row) = conj(dst.coeffRef(row, col) = src.coeff(row, col)); + dst.coeffRef(col, row) = numext::conj(dst.coeffRef(row, col) = src.coeff(row, col)); } }; @@ -239,9 +239,9 @@ struct triangular_assignment_selector::run(dst, src); if(row == col) - dst.coeffRef(row, col) = real(src.coeff(row, col)); + dst.coeffRef(row, col) = numext::real(src.coeff(row, col)); else if(row > col) - dst.coeffRef(col, row) = conj(dst.coeffRef(row, col) = src.coeff(row, col)); + dst.coeffRef(col, row) = numext::conj(dst.coeffRef(row, col) = src.coeff(row, col)); } }; @@ -262,7 +262,7 @@ struct triangular_assignment_selectorscale) { - ssq = ssq * abs2(scale/max); + ssq = ssq * numext::abs2(scale/max); scale = max; invScale = Scalar(1)/scale; } @@ -84,9 +84,9 @@ blueNorm_impl(const EigenBase& _vec) for(typename Derived::InnerIterator it(vec, 0); it; ++it) { RealScalar ax = abs(it.value()); - if(ax > ab2) abig += internal::abs2(ax*s2m); - else if(ax < b1) asml += internal::abs2(ax*s1m); - else amed += internal::abs2(ax); + if(ax > ab2) abig += numext::abs2(ax*s2m); + else if(ax < b1) asml += numext::abs2(ax*s1m); + else amed += numext::abs2(ax); } if(abig > RealScalar(0)) { @@ -120,7 +120,7 @@ blueNorm_impl(const EigenBase& _vec) if(asml <= abig*relerr) return abig; else - return abig * sqrt(RealScalar(1) + internal::abs2(asml/abig)); + return abig * sqrt(RealScalar(1) + numext::abs2(asml/abig)); } } // end namespace internal diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h index bd76d75ed..91bba5e38 100644 --- a/Eigen/src/Core/arch/SSE/Complex.h +++ b/Eigen/src/Core/arch/SSE/Complex.h @@ -81,8 +81,8 @@ template<> EIGEN_STRONG_INLINE Packet2cf por (const Packet2cf& a, template<> EIGEN_STRONG_INLINE Packet2cf pxor (const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_xor_ps(a.v,b.v)); } template<> EIGEN_STRONG_INLINE Packet2cf pandnot(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_andnot_ps(a.v,b.v)); } -template<> EIGEN_STRONG_INLINE Packet2cf pload (const std::complex* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload(&real_ref(*from))); } -template<> EIGEN_STRONG_INLINE Packet2cf ploadu(const std::complex* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu(&real_ref(*from))); } +template<> EIGEN_STRONG_INLINE Packet2cf pload (const std::complex* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload(&numext::real_ref(*from))); } +template<> EIGEN_STRONG_INLINE Packet2cf ploadu(const std::complex* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu(&numext::real_ref(*from))); } template<> EIGEN_STRONG_INLINE Packet2cf pset1(const std::complex& from) { @@ -104,8 +104,8 @@ template<> EIGEN_STRONG_INLINE Packet2cf pset1(const std::complex EIGEN_STRONG_INLINE Packet2cf ploaddup(const std::complex* from) { return pset1(*from); } -template<> EIGEN_STRONG_INLINE void pstore >(std::complex * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&real_ref(*to), from.v); } -template<> EIGEN_STRONG_INLINE void pstoreu >(std::complex * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&real_ref(*to), from.v); } +template<> EIGEN_STRONG_INLINE void pstore >(std::complex * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), from.v); } +template<> EIGEN_STRONG_INLINE void pstoreu >(std::complex * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), from.v); } template<> EIGEN_STRONG_INLINE void prefetch >(const std::complex * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); } diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index 9bdd588df..c1cb78498 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -86,7 +86,7 @@ EIGEN_DONT_INLINE void general_matrix_vector_product cj; conj_helper pcj; if(ConjugateRhs) - alpha = conj(alpha); + alpha = numext::conj(alpha); enum { AllAligned = 0, EvenAligned, FirstAligned, NoneAligned }; const Index columnsAtOnce = 4; diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index ee619df99..99cf9e0ae 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -30,9 +30,9 @@ struct symm_pack_lhs for(Index k=i; k::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, IsRowMajor), ConjugateRhs> pcj0; conj_helper::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> pcj1; - Scalar cjAlpha = ConjugateRhs ? conj(alpha) : alpha; + Scalar cjAlpha = ConjugateRhs ? numext::conj(alpha) : alpha; // FIXME this copy is now handled outside product_selfadjoint_vector, so it could probably be removed. // if the rhs is not sequentially stored in memory we copy it to a temporary buffer, @@ -98,8 +98,8 @@ EIGEN_DONT_INLINE void selfadjoint_matrix_vector_product huge speed up) // gcc 4.2 does this optimization automatically. @@ -152,7 +152,7 @@ EIGEN_DONT_INLINE void selfadjoint_matrix_vector_product for (Index i=0; i >(mat+stride*i+i, size-i) += - (conj(alpha) * conj(u.coeff(i))) * v.tail(size-i) - + (alpha * conj(v.coeff(i))) * u.tail(size-i); + (numext::conj(alpha) * numext::conj(u.coeff(i))) * v.tail(size-i) + + (alpha * numext::conj(v.coeff(i))) * u.tail(size-i); } } }; @@ -44,8 +44,8 @@ struct selfadjoint_rank2_update_selector const Index size = u.size(); for (Index i=0; i >(mat+stride*i, i+1) += - (conj(alpha) * conj(u.coeff(i))) * v.head(i+1) - + (alpha * conj(v.coeff(i))) * u.head(i+1); + (numext::conj(alpha) * numext::conj(u.coeff(i))) * v.head(i+1) + + (alpha * numext::conj(v.coeff(i))) * u.head(i+1); } }; @@ -75,9 +75,9 @@ SelfAdjointView& SelfAdjointView enum { IsRowMajor = (internal::traits::Flags&RowMajorBit) ? 1 : 0 }; Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) - * internal::conj(VBlasTraits::extractScalarFactor(v.derived())); + * numext::conj(VBlasTraits::extractScalarFactor(v.derived())); if (IsRowMajor) - actualAlpha = internal::conj(actualAlpha); + actualAlpha = numext::conj(actualAlpha); internal::selfadjoint_rank2_update_selector::type>::type, diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h index c8b7d28c4..6117d5a82 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector.h +++ b/Eigen/src/Core/products/TriangularMatrixVector.h @@ -245,7 +245,7 @@ template<> struct trmv_selector gemv_static_vector_if static_dest; - bool alphaIsCompatible = (!ComplexByReal) || (imag(actualAlpha)==RealScalar(0)); + bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0)); bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; RhsScalar compatibleAlpha = get_factor::run(actualAlpha); diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index 91496651c..a28f16fa0 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -42,7 +42,7 @@ template struct conj_if; template<> struct conj_if { template - inline T operator()(const T& x) { return conj(x); } + inline T operator()(const T& x) { return numext::conj(x); } template inline T pconj(const T& x) { return internal::pconj(x); } }; @@ -67,7 +67,7 @@ template struct conj_helper, std:: { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(real(x)*real(y) + imag(x)*imag(y), imag(x)*real(y) - real(x)*imag(y)); } + { return Scalar(numext::real(x)*numext::real(y) + numext::imag(x)*numext::imag(y), numext::imag(x)*numext::real(y) - numext::real(x)*numext::imag(y)); } }; template struct conj_helper, std::complex, true,false> @@ -77,7 +77,7 @@ template struct conj_helper, std:: { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(real(x)*real(y) + imag(x)*imag(y), real(x)*imag(y) - imag(x)*real(y)); } + { return Scalar(numext::real(x)*numext::real(y) + numext::imag(x)*numext::imag(y), numext::real(x)*numext::imag(y) - numext::imag(x)*numext::real(y)); } }; template struct conj_helper, std::complex, true,true> @@ -87,7 +87,7 @@ template struct conj_helper, std:: { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(real(x)*real(y) - imag(x)*imag(y), - real(x)*imag(y) - imag(x)*real(y)); } + { return Scalar(numext::real(x)*numext::real(y) - numext::imag(x)*numext::imag(y), - numext::real(x)*numext::imag(y) - numext::imag(x)*numext::real(y)); } }; template struct conj_helper, RealScalar, Conj,false> @@ -113,7 +113,7 @@ template struct get_factor { }; template struct get_factor::Real> { - static EIGEN_STRONG_INLINE typename NumTraits::Real run(const Scalar& x) { return real(x); } + static EIGEN_STRONG_INLINE typename NumTraits::Real run(const Scalar& x) { return numext::real(x); } }; // Lightweight helper class to access matrix coefficients. diff --git a/Eigen/src/Eigen2Support/MathFunctions.h b/Eigen/src/Eigen2Support/MathFunctions.h index bde5dd441..3544af253 100644 --- a/Eigen/src/Eigen2Support/MathFunctions.h +++ b/Eigen/src/Eigen2Support/MathFunctions.h @@ -12,18 +12,18 @@ namespace Eigen { -template inline typename NumTraits::Real ei_real(const T& x) { return internal::real(x); } -template inline typename NumTraits::Real ei_imag(const T& x) { return internal::imag(x); } -template inline T ei_conj(const T& x) { return internal::conj(x); } +template inline typename NumTraits::Real ei_real(const T& x) { return numext::real(x); } +template inline typename NumTraits::Real ei_imag(const T& x) { return numext::imag(x); } +template inline T ei_conj(const T& x) { return numext::conj(x); } template inline typename NumTraits::Real ei_abs (const T& x) { using std::abs; return abs(x); } -template inline typename NumTraits::Real ei_abs2(const T& x) { return internal::abs2(x); } +template inline typename NumTraits::Real ei_abs2(const T& x) { return numext::abs2(x); } template inline T ei_sqrt(const T& x) { using std::sqrt; return sqrt(x); } template inline T ei_exp (const T& x) { using std::exp; return exp(x); } template inline T ei_log (const T& x) { using std::log; return log(x); } template inline T ei_sin (const T& x) { using std::sin; return sin(x); } template inline T ei_cos (const T& x) { using std::cos; return cos(x); } template inline T ei_atan2(const T& x,const T& y) { using std::atan2; return atan2(x,y); } -template inline T ei_pow (const T& x,const T& y) { return internal::pow(x,y); } +template inline T ei_pow (const T& x,const T& y) { return numext::pow(x,y); } template inline T ei_random () { return internal::random(); } template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } diff --git a/Eigen/src/Eigen2Support/SVD.h b/Eigen/src/Eigen2Support/SVD.h index a08b695a4..077d26d54 100644 --- a/Eigen/src/Eigen2Support/SVD.h +++ b/Eigen/src/Eigen2Support/SVD.h @@ -315,7 +315,7 @@ void SVD::compute(const MatrixType& matrix) e[p-2] = 0.0; for (j = p-2; j >= k; --j) { - Scalar t(internal::hypot(m_sigma[j],f)); + Scalar t(numext::hypot(m_sigma[j],f)); Scalar cs(m_sigma[j]/t); Scalar sn(f/t); m_sigma[j] = t; @@ -344,7 +344,7 @@ void SVD::compute(const MatrixType& matrix) e[k-1] = 0.0; for (j = k; j < p; ++j) { - Scalar t(internal::hypot(m_sigma[j],f)); + Scalar t(numext::hypot(m_sigma[j],f)); Scalar cs( m_sigma[j]/t); Scalar sn(f/t); m_sigma[j] = t; @@ -392,7 +392,7 @@ void SVD::compute(const MatrixType& matrix) for (j = k; j < p-1; ++j) { - Scalar t = internal::hypot(f,g); + Scalar t = numext::hypot(f,g); Scalar cs = f/t; Scalar sn = g/t; if (j != k) @@ -410,7 +410,7 @@ void SVD::compute(const MatrixType& matrix) m_matV(i,j) = t; } } - t = internal::hypot(f,g); + t = numext::hypot(f,g); cs = f/t; sn = g/t; m_sigma[j] = t; diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index bd41bf7ed..af434bc9b 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -294,7 +294,7 @@ void ComplexEigenSolver::doComputeEigenvectors(const RealScalar& mat { // If the i-th and k-th eigenvalue are equal, then z equals 0. // Use a small value instead, to prevent division by zero. - internal::real_ref(z) = NumTraits::epsilon() * matrixnorm; + numext::real_ref(z) = NumTraits::epsilon() * matrixnorm; } m_matX.coeffRef(i,k) = m_matX.coeff(i,k) / z; } diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index 62b57ff66..89e6cade3 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -263,8 +263,8 @@ template class ComplexSchur template inline bool ComplexSchur::subdiagonalEntryIsNeglegible(Index i) { - RealScalar d = internal::norm1(m_matT.coeff(i,i)) + internal::norm1(m_matT.coeff(i+1,i+1)); - RealScalar sd = internal::norm1(m_matT.coeff(i+1,i)); + RealScalar d = numext::norm1(m_matT.coeff(i,i)) + numext::norm1(m_matT.coeff(i+1,i+1)); + RealScalar sd = numext::norm1(m_matT.coeff(i+1,i)); if (internal::isMuchSmallerThan(sd, d, NumTraits::epsilon())) { m_matT.coeffRef(i+1,i) = ComplexScalar(0); @@ -282,7 +282,7 @@ typename ComplexSchur::ComplexScalar ComplexSchur::compu if (iter == 10 || iter == 20) { // exceptional shift, taken from http://www.netlib.org/eispack/comqr.f - return abs(internal::real(m_matT.coeff(iu,iu-1))) + abs(internal::real(m_matT.coeff(iu-1,iu-2))); + return abs(numext::real(m_matT.coeff(iu,iu-1))) + abs(numext::real(m_matT.coeff(iu-1,iu-2))); } // compute the shift as one of the eigenvalues of t, the 2x2 @@ -299,13 +299,13 @@ typename ComplexSchur::ComplexScalar ComplexSchur::compu ComplexScalar eival1 = (trace + disc) / RealScalar(2); ComplexScalar eival2 = (trace - disc) / RealScalar(2); - if(internal::norm1(eival1) > internal::norm1(eival2)) + if(numext::norm1(eival1) > numext::norm1(eival2)) eival2 = det / eival1; else eival1 = det / eival2; // choose the eigenvalue closest to the bottom entry of the diagonal - if(internal::norm1(eival1-t.coeff(1,1)) < internal::norm1(eival2-t.coeff(1,1))) + if(numext::norm1(eival1-t.coeff(1,1)) < numext::norm1(eival2-t.coeff(1,1))) return normt * eival1; else return normt * eival2; diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index f0d4e5afa..6e7150685 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -317,12 +317,12 @@ MatrixType EigenSolver::pseudoEigenvalueMatrix() const MatrixType matD = MatrixType::Zero(n,n); for (Index i=0; i(i,i) << internal::real(m_eivalues.coeff(i)), internal::imag(m_eivalues.coeff(i)), - -internal::imag(m_eivalues.coeff(i)), internal::real(m_eivalues.coeff(i)); + matD.template block<2,2>(i,i) << numext::real(m_eivalues.coeff(i)), numext::imag(m_eivalues.coeff(i)), + -numext::imag(m_eivalues.coeff(i)), numext::real(m_eivalues.coeff(i)); ++i; } } @@ -338,7 +338,7 @@ typename EigenSolver::EigenvectorsType EigenSolver::eige EigenvectorsType matV(n,n); for (Index j=0; j(); @@ -515,8 +515,8 @@ void EigenSolver::doComputeEigenvectors() else { std::complex cc = cdiv(0.0,-m_matT.coeff(n-1,n),m_matT.coeff(n-1,n-1)-p,q); - m_matT.coeffRef(n-1,n-1) = internal::real(cc); - m_matT.coeffRef(n-1,n) = internal::imag(cc); + m_matT.coeffRef(n-1,n-1) = numext::real(cc); + m_matT.coeffRef(n-1,n) = numext::imag(cc); } m_matT.coeffRef(n,n-1) = 0.0; m_matT.coeffRef(n,n) = 1.0; @@ -538,8 +538,8 @@ void EigenSolver::doComputeEigenvectors() if (m_eivalues.coeff(i).imag() == RealScalar(0)) { std::complex cc = cdiv(-ra,-sa,w,q); - m_matT.coeffRef(i,n-1) = internal::real(cc); - m_matT.coeffRef(i,n) = internal::imag(cc); + m_matT.coeffRef(i,n-1) = numext::real(cc); + m_matT.coeffRef(i,n) = numext::imag(cc); } else { @@ -552,8 +552,8 @@ void EigenSolver::doComputeEigenvectors() vr = eps * norm * (abs(w) + abs(q) + abs(x) + abs(y) + abs(lastw)); std::complex cc = cdiv(x*lastra-lastw*ra+q*sa,x*lastsa-lastw*sa-q*ra,vr,vi); - m_matT.coeffRef(i,n-1) = internal::real(cc); - m_matT.coeffRef(i,n) = internal::imag(cc); + m_matT.coeffRef(i,n-1) = numext::real(cc); + m_matT.coeffRef(i,n) = numext::imag(cc); if (abs(x) > (abs(lastw) + abs(q))) { m_matT.coeffRef(i+1,n-1) = (-ra - w * m_matT.coeff(i,n-1) + q * m_matT.coeff(i,n)) / x; @@ -562,8 +562,8 @@ void EigenSolver::doComputeEigenvectors() else { cc = cdiv(-lastra-y*m_matT.coeff(i,n-1),-lastsa-y*m_matT.coeff(i,n),lastw,q); - m_matT.coeffRef(i+1,n-1) = internal::real(cc); - m_matT.coeffRef(i+1,n) = internal::imag(cc); + m_matT.coeffRef(i+1,n-1) = numext::real(cc); + m_matT.coeffRef(i+1,n) = numext::imag(cc); } } diff --git a/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/Eigen/src/Eigenvalues/HessenbergDecomposition.h index ebd8ae908..afa636ffa 100644 --- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -313,7 +313,7 @@ void HessenbergDecomposition::_compute(MatrixType& matA, CoeffVector // A = A H' matA.rightCols(remainingSize) - .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), internal::conj(h), &temp.coeffRef(0)); + .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), numext::conj(h), &temp.coeffRef(0)); } } diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 03c024927..3993046a8 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -395,7 +395,7 @@ SelfAdjointEigenSolver& SelfAdjointEigenSolver if(n==1) { - m_eivalues.coeffRef(0,0) = internal::real(matrix.coeff(0,0)); + m_eivalues.coeffRef(0,0) = numext::real(matrix.coeff(0,0)); if(computeEigenvectors) m_eivec.setOnes(n,n); m_info = Success; @@ -669,7 +669,7 @@ template struct direct_selfadjoint_eigenvalues struct direct_selfadjoint_eigenvaluesc2) { eivecs.col(1) << -scaledMat(1,0), scaledMat(0,0); @@ -744,7 +744,7 @@ static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index sta RealScalar e = subdiag[end-1]; // Note that thanks to scaling, e^2 or td^2 cannot overflow, however they can still // underflow thus leading to inf/NaN values when using the following commented code: -// RealScalar e2 = abs2(subdiag[end-1]); +// RealScalar e2 = numext::abs2(subdiag[end-1]); // RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2)); // This explain the following, somewhat more complicated, version: RealScalar mu = diag[end]; @@ -752,8 +752,8 @@ static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index sta mu -= abs(e); else { - RealScalar e2 = abs2(subdiag[end-1]); - RealScalar h = hypot(td,e); + RealScalar e2 = numext::abs2(subdiag[end-1]); + RealScalar h = numext::hypot(td,e); if(e2==0) mu -= (e / (td + (td>0 ? 1 : -1))) * (e / h); else mu -= e2 / (td + (td>0 ? h : -h)); } diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h index 5de5f15d6..17c0dadd2 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h @@ -56,7 +56,7 @@ SelfAdjointEigenSolver >::compute(c \ if(n==1) \ { \ - m_eivalues.coeffRef(0,0) = internal::real(matrix.coeff(0,0)); \ + m_eivalues.coeffRef(0,0) = numext::real(matrix.coeff(0,0)); \ if(computeEigenvectors) m_eivec.setOnes(n,n); \ m_info = Success; \ m_isInitialized = true; \ diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h index e8408761d..b55a01d3a 100644 --- a/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -345,7 +345,7 @@ namespace internal { template void tridiagonalization_inplace(MatrixType& matA, CoeffVectorType& hCoeffs) { - using internal::conj; + using numext::conj; typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; @@ -468,7 +468,7 @@ struct tridiagonalization_inplace_selector { using std::sqrt; diag[0] = mat(0,0); - RealScalar v1norm2 = abs2(mat(2,0)); + RealScalar v1norm2 = numext::abs2(mat(2,0)); if(v1norm2 == RealScalar(0)) { diag[1] = mat(1,1); @@ -480,7 +480,7 @@ struct tridiagonalization_inplace_selector } else { - RealScalar beta = sqrt(abs2(mat(1,0)) + v1norm2); + RealScalar beta = sqrt(numext::abs2(mat(1,0)) + v1norm2); RealScalar invBeta = RealScalar(1)/beta; Scalar m01 = mat(1,0) * invBeta; Scalar m02 = mat(2,0) * invBeta; @@ -510,7 +510,7 @@ struct tridiagonalization_inplace_selector template static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType&, bool extractQ) { - diag(0,0) = real(mat(0,0)); + diag(0,0) = numext::real(mat(0,0)); if(extractQ) mat(0,0) = Scalar(1); } diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index 4c1bf5fcd..556bc8160 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -33,9 +33,9 @@ MatrixBase::cross(const MatrixBase& other) const typename internal::nested::type lhs(derived()); typename internal::nested::type rhs(other.derived()); return typename cross_product_return_type::type( - internal::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)), - internal::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)), - internal::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)) + numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)), + numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)), + numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)) ); } @@ -49,9 +49,9 @@ struct cross3_impl { run(const VectorLhs& lhs, const VectorRhs& rhs) { return typename internal::plain_matrix_type::type( - internal::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)), - internal::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)), - internal::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)), + numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)), + numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)), + numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)), 0 ); } @@ -141,8 +141,8 @@ struct unitOrthogonal_selector if (maxi==0) sndi = 1; RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm(); - perp.coeffRef(maxi) = -conj(src.coeff(sndi)) * invnm; - perp.coeffRef(sndi) = conj(src.coeff(maxi)) * invnm; + perp.coeffRef(maxi) = -numext::conj(src.coeff(sndi)) * invnm; + perp.coeffRef(sndi) = numext::conj(src.coeff(maxi)) * invnm; return perp; } @@ -168,8 +168,8 @@ struct unitOrthogonal_selector || (!isMuchSmallerThan(src.y(), src.z()))) { RealScalar invnm = RealScalar(1)/src.template head<2>().norm(); - perp.coeffRef(0) = -conj(src.y())*invnm; - perp.coeffRef(1) = conj(src.x())*invnm; + perp.coeffRef(0) = -numext::conj(src.y())*invnm; + perp.coeffRef(1) = numext::conj(src.x())*invnm; perp.coeffRef(2) = 0; } /* if both x and y are close to zero, then the vector is close @@ -180,8 +180,8 @@ struct unitOrthogonal_selector { RealScalar invnm = RealScalar(1)/src.template tail<2>().norm(); perp.coeffRef(0) = 0; - perp.coeffRef(1) = -conj(src.z())*invnm; - perp.coeffRef(2) = conj(src.y())*invnm; + perp.coeffRef(1) = -numext::conj(src.z())*invnm; + perp.coeffRef(2) = numext::conj(src.y())*invnm; } return perp; @@ -193,7 +193,7 @@ struct unitOrthogonal_selector { typedef typename plain_matrix_type::type VectorType; static inline VectorType run(const Derived& src) - { return VectorType(-conj(src.y()), conj(src.x())).normalized(); } + { return VectorType(-numext::conj(src.y()), numext::conj(src.x())).normalized(); } }; } // end namespace internal diff --git a/Eigen/src/Householder/Householder.h b/Eigen/src/Householder/Householder.h index b7cfa9b2b..32112af9b 100644 --- a/Eigen/src/Householder/Householder.h +++ b/Eigen/src/Householder/Householder.h @@ -68,7 +68,7 @@ void MatrixBase::makeHouseholder( RealScalar& beta) const { using std::sqrt; - using internal::conj; + using numext::conj; EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart) VectorBlock tail(derived(), 1, size()-1); @@ -76,16 +76,16 @@ void MatrixBase::makeHouseholder( RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm(); Scalar c0 = coeff(0); - if(tailSqNorm == RealScalar(0) && internal::imag(c0)==RealScalar(0)) + if(tailSqNorm == RealScalar(0) && numext::imag(c0)==RealScalar(0)) { tau = RealScalar(0); - beta = internal::real(c0); + beta = numext::real(c0); essential.setZero(); } else { - beta = sqrt(internal::abs2(c0) + tailSqNorm); - if (internal::real(c0)>=RealScalar(0)) + beta = sqrt(numext::abs2(c0) + tailSqNorm); + if (numext::real(c0)>=RealScalar(0)) beta = -beta; essential = tail / (c0 - beta); tau = conj((beta - c0) / beta); diff --git a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index 00b5647c6..a74a8155e 100644 --- a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -63,7 +63,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, p = precond.solve(residual); //initial search direction VectorType z(n), tmp(n); - RealScalar absNew = internal::real(residual.dot(p)); // the square of the absolute value of r scaled by invM + RealScalar absNew = numext::real(residual.dot(p)); // the square of the absolute value of r scaled by invM int i = 0; while(i < maxIters) { @@ -80,7 +80,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, z = precond.solve(residual); // approximately solve for "A z = residual" RealScalar absOld = absNew; - absNew = internal::real(residual.dot(z)); // update the absolute value of r + absNew = numext::real(residual.dot(z)); // update the absolute value of r RealScalar beta = absNew / absOld; // calculate the Gram-Schmidt value used to create the new search direction p = z + beta * p; // update search direction i++; diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h index 17d18ef58..50a870aec 100644 --- a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +++ b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h @@ -310,7 +310,7 @@ void IncompleteLUT::factorize(const _MatrixType& amat) jr(k) = jpos; ++sizeu; } - rownorm += internal::abs2(j_it.value()); + rownorm += numext::abs2(j_it.value()); } // 2 - detect possible zero row diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index d9d75196c..956f72d57 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -50,16 +50,16 @@ template class JacobiRotation /** Concatenates two planar rotation */ JacobiRotation operator*(const JacobiRotation& other) { - using internal::conj; + using numext::conj; return JacobiRotation(m_c * other.m_c - conj(m_s) * other.m_s, conj(m_c * conj(other.m_s) + conj(m_s) * conj(other.m_c))); } /** Returns the transposed transformation */ - JacobiRotation transpose() const { using internal::conj; return JacobiRotation(m_c, -conj(m_s)); } + JacobiRotation transpose() const { using numext::conj; return JacobiRotation(m_c, -conj(m_s)); } /** Returns the adjoint transformation */ - JacobiRotation adjoint() const { using internal::conj; return JacobiRotation(conj(m_c), -m_s); } + JacobiRotation adjoint() const { using numext::conj; return JacobiRotation(conj(m_c), -m_s); } template bool makeJacobi(const MatrixBase&, typename Derived::Index p, typename Derived::Index q); @@ -94,7 +94,7 @@ bool JacobiRotation::makeJacobi(const RealScalar& x, const Scalar& y, co else { RealScalar tau = (x-z)/(RealScalar(2)*abs(y)); - RealScalar w = sqrt(internal::abs2(tau) + RealScalar(1)); + RealScalar w = sqrt(numext::abs2(tau) + RealScalar(1)); RealScalar t; if(tau>RealScalar(0)) { @@ -105,8 +105,8 @@ bool JacobiRotation::makeJacobi(const RealScalar& x, const Scalar& y, co t = RealScalar(1) / (tau - w); } RealScalar sign_t = t > RealScalar(0) ? RealScalar(1) : RealScalar(-1); - RealScalar n = RealScalar(1) / sqrt(internal::abs2(t)+RealScalar(1)); - m_s = - sign_t * (internal::conj(y) / abs(y)) * abs(t) * n; + RealScalar n = RealScalar(1) / sqrt(numext::abs2(t)+RealScalar(1)); + m_s = - sign_t * (numext::conj(y) / abs(y)) * abs(t) * n; m_c = n; return true; } @@ -125,7 +125,7 @@ template template inline bool JacobiRotation::makeJacobi(const MatrixBase& m, typename Derived::Index p, typename Derived::Index q) { - return makeJacobi(internal::real(m.coeff(p,p)), m.coeff(p,q), internal::real(m.coeff(q,q))); + return makeJacobi(numext::real(m.coeff(p,p)), m.coeff(p,q), numext::real(m.coeff(q,q))); } /** Makes \c *this as a Givens rotation \c G such that applying \f$ G^* \f$ to the left of the vector @@ -157,11 +157,11 @@ void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar { using std::sqrt; using std::abs; - using internal::conj; + using numext::conj; if(q==Scalar(0)) { - m_c = internal::real(p)<0 ? Scalar(-1) : Scalar(1); + m_c = numext::real(p)<0 ? Scalar(-1) : Scalar(1); m_s = 0; if(r) *r = m_c * p; } @@ -173,17 +173,17 @@ void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar } else { - RealScalar p1 = internal::norm1(p); - RealScalar q1 = internal::norm1(q); + RealScalar p1 = numext::norm1(p); + RealScalar q1 = numext::norm1(q); if(p1>=q1) { Scalar ps = p / p1; - RealScalar p2 = internal::abs2(ps); + RealScalar p2 = numext::abs2(ps); Scalar qs = q / p1; - RealScalar q2 = internal::abs2(qs); + RealScalar q2 = numext::abs2(qs); RealScalar u = sqrt(RealScalar(1) + q2/p2); - if(internal::real(p)::makeGivens(const Scalar& p, const Scalar& q, Scalar else { Scalar ps = p / q1; - RealScalar p2 = internal::abs2(ps); + RealScalar p2 = numext::abs2(ps); Scalar qs = q / q1; - RealScalar q2 = internal::abs2(qs); + RealScalar q2 = numext::abs2(qs); RealScalar u = q1 * sqrt(p2 + q2); - if(internal::real(p)::makeGivens(const Scalar& p, const Scalar& q, Scalar else if(abs(p) > abs(q)) { Scalar t = q/p; - Scalar u = sqrt(Scalar(1) + internal::abs2(t)); + Scalar u = sqrt(Scalar(1) + numext::abs2(t)); if(p::makeGivens(const Scalar& p, const Scalar& q, Scalar else { Scalar t = p/q; - Scalar u = sqrt(Scalar(1) + internal::abs2(t)); + Scalar u = sqrt(Scalar(1) + numext::abs2(t)); if(q& ColPivHouseholderQR::compute(const for(Index k = 0; k < cols; ++k) m_colSqNorms.coeffRef(k) = m_qr.col(k).squaredNorm(); - RealScalar threshold_helper = m_colSqNorms.maxCoeff() * internal::abs2(NumTraits::epsilon()) / RealScalar(rows); + RealScalar threshold_helper = m_colSqNorms.maxCoeff() * numext::abs2(NumTraits::epsilon()) / RealScalar(rows); m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case) m_maxpivot = RealScalar(0); diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index f82126494..0dd5ad347 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -572,7 +572,7 @@ public: template void evalTo(ResultType& result, WorkVectorType& workspace) const { - using internal::conj; + using numext::conj; // compute the product H'_0 H'_1 ... H'_n-1, // where H_k is the k-th Householder transformation I - h_k v_k v_k' // and v_k is the k-th Householder vector [1,m_qr(k+1,k), m_qr(k+2,k), ...] diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 495d3fabf..c7a7eeda0 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -374,7 +374,7 @@ struct svd_precondition_2x2_block_to_be_real using std::sqrt; Scalar z; JacobiRotation rot; - RealScalar n = sqrt(abs2(work_matrix.coeff(p,p)) + abs2(work_matrix.coeff(q,p))); + RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p))); if(n==0) { z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q); @@ -413,8 +413,8 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, { using std::sqrt; Matrix m; - m << real(matrix.coeff(p,p)), real(matrix.coeff(p,q)), - real(matrix.coeff(q,p)), real(matrix.coeff(q,q)); + m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), + numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); JacobiRotation rot1; RealScalar t = m.coeff(0,0) + m.coeff(1,1); RealScalar d = m.coeff(1,0) - m.coeff(0,1); @@ -426,7 +426,7 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, else { RealScalar u = d / t; - rot1.c() = RealScalar(1) / sqrt(RealScalar(1) + abs2(u)); + rot1.c() = RealScalar(1) / sqrt(RealScalar(1) + numext::abs2(u)); rot1.s() = rot1.c() * u; } m.applyOnTheLeft(0,1,rot1); diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky.h b/Eigen/src/SparseCholesky/SimplicialCholesky.h index 62747279d..f41d7e010 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky.h @@ -364,7 +364,7 @@ public: Scalar determinant() const { Scalar detL = Base::m_matrix.diagonal().prod(); - return internal::abs2(detL); + return numext::abs2(detL); } }; @@ -599,7 +599,7 @@ public: else { Scalar detL = Diagonal(Base::m_matrix).prod(); - return internal::abs2(detL); + return numext::abs2(detL); } } diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h index 4b249868f..7aaf702be 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h @@ -131,7 +131,7 @@ void SimplicialCholeskyBase::factorize_preordered(const CholMatrixType& Index i = it.index(); if(i <= k) { - y[i] += internal::conj(it.value()); /* scatter A(i,k) into Y (sum duplicates) */ + y[i] += numext::conj(it.value()); /* scatter A(i,k) into Y (sum duplicates) */ Index len; for(len = 0; tags[i] != k; i = m_parent[i]) { @@ -145,7 +145,7 @@ void SimplicialCholeskyBase::factorize_preordered(const CholMatrixType& /* compute numerical values kth row of L (a sparse triangular solve) */ - RealScalar d = internal::real(y[k]) * m_shiftScale + m_shiftOffset; // get D(k,k), apply the shift function, and clear Y(k) + RealScalar d = numext::real(y[k]) * m_shiftScale + m_shiftOffset; // get D(k,k), apply the shift function, and clear Y(k) y[k] = 0.0; for(; top < size; ++top) { @@ -163,8 +163,8 @@ void SimplicialCholeskyBase::factorize_preordered(const CholMatrixType& Index p2 = Lp[i] + m_nonZerosPerCol[i]; Index p; for(p = Lp[i] + (DoLDLT ? 0 : 1); p < p2; ++p) - y[Li[p]] -= internal::conj(Lx[p]) * yi; - d -= internal::real(l_ki * internal::conj(yi)); + y[Li[p]] -= numext::conj(Lx[p]) * yi; + d -= numext::real(l_ki * numext::conj(yi)); Li[p] = k; /* store L(k,i) in column form of L */ Lx[p] = l_ki; ++m_nonZerosPerCol[i]; /* increment count of nonzeros in col i */ diff --git a/Eigen/src/SparseCore/SparseDot.h b/Eigen/src/SparseCore/SparseDot.h index dfeb3a8df..db39c9aec 100644 --- a/Eigen/src/SparseCore/SparseDot.h +++ b/Eigen/src/SparseCore/SparseDot.h @@ -30,7 +30,7 @@ SparseMatrixBase::dot(const MatrixBase& other) const Scalar res(0); while (i) { - res += internal::conj(i.value()) * other.coeff(i.index()); + res += numext::conj(i.value()) * other.coeff(i.index()); ++i; } return res; @@ -64,7 +64,7 @@ SparseMatrixBase::dot(const SparseMatrixBase& other) cons { if (i.index()==j.index()) { - res += internal::conj(i.value()) * j.value(); + res += numext::conj(i.value()) * j.value(); ++i; ++j; } else if (i.index() inline typename NumTraits::Scalar>::Real SparseMatrixBase::squaredNorm() const { - return internal::real((*this).cwiseAbs2().sum()); + return numext::real((*this).cwiseAbs2().sum()); } template diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index 9630b60f5..d2e170410 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -240,7 +240,7 @@ class SparseSelfAdjointTimeDenseProduct Index b = LhsIsRowMajor ? i.index() : j; typename Lhs::Scalar v = i.value(); dest.row(a) += (v) * m_rhs.row(b); - dest.row(b) += internal::conj(v) * m_rhs.row(a); + dest.row(b) += numext::conj(v) * m_rhs.row(a); } if (ProcessFirstHalf && i && (i.index()==j)) dest.row(j) += i.value() * m_rhs.row(j); @@ -367,7 +367,7 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrixjp))) - dest.valuePtr()[k] = conj(it.value()); + dest.valuePtr()[k] = numext::conj(it.value()); else dest.valuePtr()[k] = it.value(); } @@ -461,7 +461,10 @@ class SparseSymmetricPermutationProduct template void evalTo(SparseMatrix& _dest) const { - internal::permute_symm_to_fullsymm(m_matrix,_dest,m_perm.indices().data()); +// internal::permute_symm_to_fullsymm(m_matrix,_dest,m_perm.indices().data()); + SparseMatrix tmp; + internal::permute_symm_to_fullsymm(m_matrix,tmp,m_perm.indices().data()); + _dest = tmp; } template void evalTo(SparseSelfAdjointView& dest) const diff --git a/Eigen/src/SparseCore/SparseView.h b/Eigen/src/SparseCore/SparseView.h index 4fd0cb3d8..67eb93245 100644 --- a/Eigen/src/SparseCore/SparseView.h +++ b/Eigen/src/SparseCore/SparseView.h @@ -18,7 +18,7 @@ namespace internal { template struct traits > : traits { - typedef int Index; + typedef typename MatrixType::Index Index; typedef Sparse StorageKind; enum { Flags = int(traits::Flags) & (RowMajorBit) diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h index 1bf631507..07c46e4b9 100644 --- a/Eigen/src/SparseQR/SparseQR.h +++ b/Eigen/src/SparseQR/SparseQR.h @@ -435,23 +435,23 @@ void SparseQR::factorize(const MatrixType& mat) // First, the squared norm of Q((col+1):m, col) RealScalar sqrNorm = 0.; - for (Index itq = 1; itq < nzcolQ; ++itq) sqrNorm += internal::abs2(tval(Qidx(itq))); + for (Index itq = 1; itq < nzcolQ; ++itq) sqrNorm += numext::abs2(tval(Qidx(itq))); - if(sqrNorm == RealScalar(0) && internal::imag(c0) == RealScalar(0)) + if(sqrNorm == RealScalar(0) && numext::imag(c0) == RealScalar(0)) { tau = RealScalar(0); - beta = internal::real(c0); + beta = numext::real(c0); tval(Qidx(0)) = 1; } else { - beta = std::sqrt(internal::abs2(c0) + sqrNorm); - if(internal::real(c0) >= RealScalar(0)) + beta = std::sqrt(numext::abs2(c0) + sqrNorm); + if(numext::real(c0) >= RealScalar(0)) beta = -beta; tval(Qidx(0)) = 1; for (Index itq = 1; itq < nzcolQ; ++itq) tval(Qidx(itq)) /= (c0 - beta); - tau = internal::conj((beta-c0) / beta); + tau = numext::conj((beta-c0) / beta); } diff --git a/Eigen/src/UmfPackSupport/UmfPackSupport.h b/Eigen/src/UmfPackSupport/UmfPackSupport.h index d85b8be85..3a48cecf7 100644 --- a/Eigen/src/UmfPackSupport/UmfPackSupport.h +++ b/Eigen/src/UmfPackSupport/UmfPackSupport.h @@ -39,7 +39,7 @@ inline int umfpack_symbolic(int n_row,int n_col, const int Ap[], const int Ai[], const std::complex Ax[], void **Symbolic, const double Control [UMFPACK_CONTROL], double Info [UMFPACK_INFO]) { - return umfpack_zi_symbolic(n_row,n_col,Ap,Ai,&internal::real_ref(Ax[0]),0,Symbolic,Control,Info); + return umfpack_zi_symbolic(n_row,n_col,Ap,Ai,&numext::real_ref(Ax[0]),0,Symbolic,Control,Info); } inline int umfpack_numeric( const int Ap[], const int Ai[], const double Ax[], @@ -53,7 +53,7 @@ inline int umfpack_numeric( const int Ap[], const int Ai[], const std::complex X[], const std::complex B[], void *Numeric, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) { - return umfpack_zi_solve(sys,Ap,Ai,&internal::real_ref(Ax[0]),0,&internal::real_ref(X[0]),0,&internal::real_ref(B[0]),0,Numeric,Control,Info); + return umfpack_zi_solve(sys,Ap,Ai,&numext::real_ref(Ax[0]),0,&numext::real_ref(X[0]),0,&numext::real_ref(B[0]),0,Numeric,Control,Info); } inline int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, double) @@ -89,9 +89,9 @@ inline int umfpack_get_numeric(int Lp[], int Lj[], double Lx[], int Up[], int Ui inline int umfpack_get_numeric(int Lp[], int Lj[], std::complex Lx[], int Up[], int Ui[], std::complex Ux[], int P[], int Q[], std::complex Dx[], int *do_recip, double Rs[], void *Numeric) { - double& lx0_real = internal::real_ref(Lx[0]); - double& ux0_real = internal::real_ref(Ux[0]); - double& dx0_real = internal::real_ref(Dx[0]); + double& lx0_real = numext::real_ref(Lx[0]); + double& ux0_real = numext::real_ref(Ux[0]); + double& dx0_real = numext::real_ref(Dx[0]); return umfpack_zi_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,P,Q, Dx?&dx0_real:0,0,do_recip,Rs,Numeric); } @@ -103,7 +103,7 @@ inline int umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle, inline int umfpack_get_determinant(std::complex *Mx, double *Ex, void *NumericHandle, double User_Info [UMFPACK_INFO]) { - double& mx_real = internal::real_ref(*Mx); + double& mx_real = numext::real_ref(*Mx); return umfpack_zi_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info); } diff --git a/test/adjoint.cpp b/test/adjoint.cpp index 72ad9e407..b63e843c6 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -16,7 +16,7 @@ template struct adjoint_specific; template<> struct adjoint_specific { template static void run(const Vec& v1, const Vec& v2, Vec& v3, const Mat& square, Scalar s1, Scalar s2) { - VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), 0)); + VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), numext::conj(s1) * v1.dot(v3) + numext::conj(s2) * v2.dot(v3), 0)); VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), 0)); // check compatibility of dot and adjoint @@ -30,7 +30,7 @@ template<> struct adjoint_specific { typedef typename NumTraits::Real RealScalar; RealScalar ref = NumTraits::IsInteger ? RealScalar(0) : (std::max)((s1 * v1 + s2 * v2).norm(),v3.norm()); - VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), ref)); + VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), numext::conj(s1) * v1.dot(v3) + numext::conj(s2) * v2.dot(v3), ref)); VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), ref)); VERIFY_IS_APPROX(v1.squaredNorm(), v1.norm() * v1.norm()); @@ -85,11 +85,11 @@ template void adjoint(const MatrixType& m) // check multiplicative behavior VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1); - VERIFY_IS_APPROX((s1 * m1).adjoint(), internal::conj(s1) * m1.adjoint()); + VERIFY_IS_APPROX((s1 * m1).adjoint(), numext::conj(s1) * m1.adjoint()); // check basic properties of dot, squaredNorm - VERIFY_IS_APPROX(internal::conj(v1.dot(v2)), v2.dot(v1)); - VERIFY_IS_APPROX(internal::real(v1.dot(v1)), v1.squaredNorm()); + VERIFY_IS_APPROX(numext::conj(v1.dot(v2)), v2.dot(v1)); + VERIFY_IS_APPROX(numext::real(v1.dot(v1)), v1.squaredNorm()); adjoint_specific::IsInteger>::run(v1, v2, v3, square, s1, s2); @@ -98,8 +98,8 @@ template void adjoint(const MatrixType& m) // like in testBasicStuff, test operator() to check const-qualification Index r = internal::random(0, rows-1), c = internal::random(0, cols-1); - VERIFY_IS_APPROX(m1.conjugate()(r,c), internal::conj(m1(r,c))); - VERIFY_IS_APPROX(m1.adjoint()(c,r), internal::conj(m1(r,c))); + VERIFY_IS_APPROX(m1.conjugate()(r,c), numext::conj(m1(r,c))); + VERIFY_IS_APPROX(m1.adjoint()(c,r), numext::conj(m1(r,c))); // check inplace transpose m3 = m1; diff --git a/test/array.cpp b/test/array.cpp index ceb00fa05..e39bd6352 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -182,12 +182,12 @@ template void array_real(const ArrayType& m) // VERIFY_IS_APPROX(m1.abs().sqrt(), std::sqrt(std::abs(m1))); VERIFY_IS_APPROX(m1.abs().sqrt(), sqrt(abs(m1))); - VERIFY_IS_APPROX(m1.abs(), sqrt(internal::abs2(m1))); + VERIFY_IS_APPROX(m1.abs(), sqrt(numext::abs2(m1))); - VERIFY_IS_APPROX(internal::abs2(internal::real(m1)) + internal::abs2(internal::imag(m1)), internal::abs2(m1)); - VERIFY_IS_APPROX(internal::abs2(real(m1)) + internal::abs2(imag(m1)), internal::abs2(m1)); + VERIFY_IS_APPROX(numext::abs2(numext::real(m1)) + numext::abs2(numext::imag(m1)), numext::abs2(m1)); + VERIFY_IS_APPROX(numext::abs2(real(m1)) + numext::abs2(imag(m1)), numext::abs2(m1)); if(!NumTraits::IsComplex) - VERIFY_IS_APPROX(internal::real(m1), m1); + VERIFY_IS_APPROX(numext::real(m1), m1); VERIFY((m1.abs().log() == log(abs(m1))).all()); diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 99cda1ffe..1250c9ff5 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp @@ -25,10 +25,10 @@ template void array_for_matrix(const MatrixType& m) ColVectorType cv1 = ColVectorType::Random(rows); RowVectorType rv1 = RowVectorType::Random(cols); - + Scalar s1 = internal::random(), s2 = internal::random(); - + // scalar addition VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array()); VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows,cols,s1) + m1); @@ -138,7 +138,7 @@ template void lpNorm(const VectorType& v) VERIFY_IS_APPROX(u.template lpNorm(), u.cwiseAbs().maxCoeff()); VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwiseAbs().sum()); VERIFY_IS_APPROX(u.template lpNorm<2>(), sqrt(u.array().abs().square().sum())); - VERIFY_IS_APPROX(internal::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum()); + VERIFY_IS_APPROX(numext::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum()); } template void cwise_min_max(const MatrixType& m) diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index 0fbae19e8..8c0621ecd 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -141,10 +141,10 @@ template void basicStuffComplex(const MatrixType& m) Scalar s1 = internal::random(), s2 = internal::random(); - VERIFY(internal::real(s1)==internal::real_ref(s1)); - VERIFY(internal::imag(s1)==internal::imag_ref(s1)); - internal::real_ref(s1) = internal::real(s2); - internal::imag_ref(s1) = internal::imag(s2); + VERIFY(numext::real(s1)==numext::real_ref(s1)); + VERIFY(numext::imag(s1)==numext::imag_ref(s1)); + numext::real_ref(s1) = numext::real(s2); + numext::imag_ref(s1) = numext::imag(s2); VERIFY(internal::isApprox(s1, s2, NumTraits::epsilon())); // extended precision in Intel FPUs means that s1 == s2 in the line above is not guaranteed. diff --git a/test/block.cpp b/test/block.cpp index 0969262ca..a3246f411 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -96,11 +96,11 @@ template void block(const MatrixType& m) } // stress some basic stuffs with block matrices - VERIFY(internal::real(ones.col(c1).sum()) == RealScalar(rows)); - VERIFY(internal::real(ones.row(r1).sum()) == RealScalar(cols)); + VERIFY(numext::real(ones.col(c1).sum()) == RealScalar(rows)); + VERIFY(numext::real(ones.row(r1).sum()) == RealScalar(cols)); - VERIFY(internal::real(ones.col(c1).dot(ones.col(c2))) == RealScalar(rows)); - VERIFY(internal::real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols)); + VERIFY(numext::real(ones.col(c1).dot(ones.col(c2))) == RealScalar(rows)); + VERIFY(numext::real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols)); // now test some block-inside-of-block. diff --git a/test/determinant.cpp b/test/determinant.cpp index e93f2f297..edf83fda9 100644 --- a/test/determinant.cpp +++ b/test/determinant.cpp @@ -39,7 +39,7 @@ template void determinant(const MatrixType& m) m2.col(i).swap(m2.col(j)); VERIFY_IS_APPROX(m2.determinant(), -m1.determinant()); VERIFY_IS_APPROX(m2.determinant(), m2.transpose().determinant()); - VERIFY_IS_APPROX(internal::conj(m2.determinant()), m2.adjoint().determinant()); + VERIFY_IS_APPROX(numext::conj(m2.determinant()), m2.adjoint().determinant()); m2 = m1; m2.row(i) += x*m2.row(j); VERIFY_IS_APPROX(m2.determinant(), m1.determinant()); diff --git a/test/eigen2support.cpp b/test/eigen2support.cpp index bfcc87323..ad1d98091 100644 --- a/test/eigen2support.cpp +++ b/test/eigen2support.cpp @@ -44,8 +44,8 @@ template void eigen2support(const MatrixType& m) VERIFY_IS_EQUAL((m1.col(0).template end<1>()), (m1.col(0).segment(rows-1,1))); using std::cos; - using internal::real; - using internal::abs2; + using numext::real; + using numext::abs2; VERIFY_IS_EQUAL(ei_cos(s1), cos(s1)); VERIFY_IS_EQUAL(ei_real(s1), real(s1)); VERIFY_IS_EQUAL(ei_abs2(s1), abs2(s1)); diff --git a/test/householder.cpp b/test/householder.cpp index 1dac4331f..d10cadd6c 100644 --- a/test/householder.cpp +++ b/test/householder.cpp @@ -60,8 +60,8 @@ template void householder(const MatrixType& m) m1.applyHouseholderOnTheLeft(essential,beta,tmp); VERIFY_IS_APPROX(m1.norm(), m2.norm()); if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m1.block(1,0,rows-1,cols).norm(), m1.norm()); - VERIFY_IS_MUCH_SMALLER_THAN(internal::imag(m1(0,0)), internal::real(m1(0,0))); - VERIFY_IS_APPROX(internal::real(m1(0,0)), alpha); + VERIFY_IS_MUCH_SMALLER_THAN(numext::imag(m1(0,0)), numext::real(m1(0,0))); + VERIFY_IS_APPROX(numext::real(m1(0,0)), alpha); v1 = VectorType::Random(rows); if(even) v1.tail(rows-1).setZero(); @@ -72,8 +72,8 @@ template void householder(const MatrixType& m) m3.applyHouseholderOnTheRight(essential,beta,tmp); VERIFY_IS_APPROX(m3.norm(), m4.norm()); if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m3.block(0,1,rows,rows-1).norm(), m3.norm()); - VERIFY_IS_MUCH_SMALLER_THAN(internal::imag(m3(0,0)), internal::real(m3(0,0))); - VERIFY_IS_APPROX(internal::real(m3(0,0)), alpha); + VERIFY_IS_MUCH_SMALLER_THAN(numext::imag(m3(0,0)), numext::real(m3(0,0))); + VERIFY_IS_APPROX(numext::real(m3(0,0)), alpha); // test householder sequence on the left with a shift diff --git a/test/jacobi.cpp b/test/jacobi.cpp index b123b9189..0e6f1de49 100644 --- a/test/jacobi.cpp +++ b/test/jacobi.cpp @@ -40,8 +40,8 @@ void jacobi(const MatrixType& m = MatrixType()) MatrixType b = a; b.applyOnTheLeft(p, q, rot); - VERIFY_IS_APPROX(b.row(p), c * a.row(p) + internal::conj(s) * a.row(q)); - VERIFY_IS_APPROX(b.row(q), -s * a.row(p) + internal::conj(c) * a.row(q)); + VERIFY_IS_APPROX(b.row(p), c * a.row(p) + numext::conj(s) * a.row(q)); + VERIFY_IS_APPROX(b.row(q), -s * a.row(p) + numext::conj(c) * a.row(q)); } { @@ -54,7 +54,7 @@ void jacobi(const MatrixType& m = MatrixType()) MatrixType b = a; b.applyOnTheRight(p, q, rot); VERIFY_IS_APPROX(b.col(p), c * a.col(p) - s * a.col(q)); - VERIFY_IS_APPROX(b.col(q), internal::conj(s) * a.col(p) + internal::conj(c) * a.col(q)); + VERIFY_IS_APPROX(b.col(q), numext::conj(s) * a.col(p) + numext::conj(c) * a.col(q)); } } diff --git a/test/main.h b/test/main.h index 3be0f9fca..fefeac358 100644 --- a/test/main.h +++ b/test/main.h @@ -170,7 +170,7 @@ namespace Eigen #define EIGEN_INTERNAL_DEBUGGING #include // required for createRandomPIMatrixOfRank -static void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string) +static inline void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string) { if (!condition) { diff --git a/test/packetmath.cpp b/test/packetmath.cpp index 9cdebd376..78a974e25 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -156,7 +156,7 @@ template void packetmath() CHECK_CWISE2(REF_DIV, internal::pdiv); #endif CHECK_CWISE1(internal::negate, internal::pnegate); - CHECK_CWISE1(internal::conj, internal::pconj); + CHECK_CWISE1(numext::conj, internal::pconj); for(int offset=0;offset<3;++offset) { diff --git a/test/product_extra.cpp b/test/product_extra.cpp index 53493bdd6..744a1ef7f 100644 --- a/test/product_extra.cpp +++ b/test/product_extra.cpp @@ -42,7 +42,7 @@ template void product_extra(const MatrixType& m) VERIFY_IS_APPROX(m3.noalias() = m1.adjoint() * square.adjoint(), m1.adjoint().eval() * square.adjoint().eval()); VERIFY_IS_APPROX(m3.noalias() = m1.adjoint() * m2, m1.adjoint().eval() * m2); VERIFY_IS_APPROX(m3.noalias() = (s1 * m1.adjoint()) * m2, (s1 * m1.adjoint()).eval() * m2); - VERIFY_IS_APPROX(m3.noalias() = ((s1 * m1).adjoint()) * m2, (internal::conj(s1) * m1.adjoint()).eval() * m2); + VERIFY_IS_APPROX(m3.noalias() = ((s1 * m1).adjoint()) * m2, (numext::conj(s1) * m1.adjoint()).eval() * m2); VERIFY_IS_APPROX(m3.noalias() = (- m1.adjoint() * s1) * (s3 * m2), (- m1.adjoint() * s1).eval() * (s3 * m2).eval()); VERIFY_IS_APPROX(m3.noalias() = (s2 * m1.adjoint() * s1) * m2, (s2 * m1.adjoint() * s1).eval() * m2); VERIFY_IS_APPROX(m3.noalias() = (-m1*s2) * s1*m2.adjoint(), (-m1*s2).eval() * (s1*m2.adjoint()).eval()); diff --git a/test/product_selfadjoint.cpp b/test/product_selfadjoint.cpp index aede15053..58e2ea90d 100644 --- a/test/product_selfadjoint.cpp +++ b/test/product_selfadjoint.cpp @@ -44,11 +44,11 @@ template void product_selfadjoint(const MatrixType& m) m2 = m1.template triangularView(); m2.template selfadjointView().rankUpdate(-v1,s2*v2,s3); - VERIFY_IS_APPROX(m2, (m1 + (s3*(-v1)*(s2*v2).adjoint()+internal::conj(s3)*(s2*v2)*(-v1).adjoint())).template triangularView().toDenseMatrix()); + VERIFY_IS_APPROX(m2, (m1 + (s3*(-v1)*(s2*v2).adjoint()+numext::conj(s3)*(s2*v2)*(-v1).adjoint())).template triangularView().toDenseMatrix()); m2 = m1.template triangularView(); m2.template selfadjointView().rankUpdate(-s2*r1.adjoint(),r2.adjoint()*s3,s1); - VERIFY_IS_APPROX(m2, (m1 + s1*(-s2*r1.adjoint())*(r2.adjoint()*s3).adjoint() + internal::conj(s1)*(r2.adjoint()*s3) * (-s2*r1.adjoint()).adjoint()).template triangularView().toDenseMatrix()); + VERIFY_IS_APPROX(m2, (m1 + s1*(-s2*r1.adjoint())*(r2.adjoint()*s3).adjoint() + numext::conj(s1)*(r2.adjoint()*s3) * (-s2*r1.adjoint()).adjoint()).template triangularView().toDenseMatrix()); if (rows>1) { diff --git a/test/product_trmm.cpp b/test/product_trmm.cpp index 31ac1b22e..506a1aeb9 100644 --- a/test/product_trmm.cpp +++ b/test/product_trmm.cpp @@ -54,7 +54,7 @@ void trmm(int rows=internal::random(1,EIGEN_TEST_MAX_SIZE), ge_sx_save = ge_sx; VERIFY_IS_APPROX( ge_sx_save - (ge_right.adjoint() * (-s1 * triTr).conjugate()).eval(), ge_sx.noalias() -= (ge_right.adjoint() * (-s1 * mat).adjoint().template triangularView()).eval()); - VERIFY_IS_APPROX( ge_xs = (s1*mat).adjoint().template triangularView() * ge_left.adjoint(), internal::conj(s1) * triTr.conjugate() * ge_left.adjoint()); + VERIFY_IS_APPROX( ge_xs = (s1*mat).adjoint().template triangularView() * ge_left.adjoint(), numext::conj(s1) * triTr.conjugate() * ge_left.adjoint()); // TODO check with sub-matrix expressions ? } diff --git a/test/redux.cpp b/test/redux.cpp index dd6edd1bd..bf68d2212 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -26,22 +26,22 @@ template void matrixRedux(const MatrixType& m) VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1)); VERIFY_IS_APPROX(MatrixType::Ones(rows, cols).sum(), Scalar(float(rows*cols))); // the float() here to shut up excessive MSVC warning about int->complex conversion being lossy - Scalar s(0), p(1), minc(internal::real(m1.coeff(0))), maxc(internal::real(m1.coeff(0))); + Scalar s(0), p(1), minc(numext::real(m1.coeff(0))), maxc(numext::real(m1.coeff(0))); for(int j = 0; j < cols; j++) for(int i = 0; i < rows; i++) { s += m1(i,j); p *= m1_for_prod(i,j); - minc = (std::min)(internal::real(minc), internal::real(m1(i,j))); - maxc = (std::max)(internal::real(maxc), internal::real(m1(i,j))); + minc = (std::min)(numext::real(minc), numext::real(m1(i,j))); + maxc = (std::max)(numext::real(maxc), numext::real(m1(i,j))); } const Scalar mean = s/Scalar(RealScalar(rows*cols)); VERIFY_IS_APPROX(m1.sum(), s); VERIFY_IS_APPROX(m1.mean(), mean); VERIFY_IS_APPROX(m1_for_prod.prod(), p); - VERIFY_IS_APPROX(m1.real().minCoeff(), internal::real(minc)); - VERIFY_IS_APPROX(m1.real().maxCoeff(), internal::real(maxc)); + VERIFY_IS_APPROX(m1.real().minCoeff(), numext::real(minc)); + VERIFY_IS_APPROX(m1.real().maxCoeff(), numext::real(maxc)); // test slice vectorization assuming assign is ok Index r0 = internal::random(0,rows-1); @@ -73,13 +73,13 @@ template void vectorRedux(const VectorType& w) for(int i = 1; i < size; i++) { Scalar s(0), p(1); - RealScalar minc(internal::real(v.coeff(0))), maxc(internal::real(v.coeff(0))); + RealScalar minc(numext::real(v.coeff(0))), maxc(numext::real(v.coeff(0))); for(int j = 0; j < i; j++) { s += v[j]; p *= v_for_prod[j]; - minc = (std::min)(minc, internal::real(v[j])); - maxc = (std::max)(maxc, internal::real(v[j])); + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); } VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.head(i).sum()), Scalar(1)); VERIFY_IS_APPROX(p, v_for_prod.head(i).prod()); @@ -90,13 +90,13 @@ template void vectorRedux(const VectorType& w) for(int i = 0; i < size-1; i++) { Scalar s(0), p(1); - RealScalar minc(internal::real(v.coeff(i))), maxc(internal::real(v.coeff(i))); + RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i))); for(int j = i; j < size; j++) { s += v[j]; p *= v_for_prod[j]; - minc = (std::min)(minc, internal::real(v[j])); - maxc = (std::max)(maxc, internal::real(v[j])); + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); } VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.tail(size-i).sum()), Scalar(1)); VERIFY_IS_APPROX(p, v_for_prod.tail(size-i).prod()); @@ -107,13 +107,13 @@ template void vectorRedux(const VectorType& w) for(int i = 0; i < size/2; i++) { Scalar s(0), p(1); - RealScalar minc(internal::real(v.coeff(i))), maxc(internal::real(v.coeff(i))); + RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i))); for(int j = i; j < size-i; j++) { s += v[j]; p *= v_for_prod[j]; - minc = (std::min)(minc, internal::real(v[j])); - maxc = (std::max)(maxc, internal::real(v[j])); + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); } VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.segment(i, size-2*i).sum()), Scalar(1)); VERIFY_IS_APPROX(p, v_for_prod.segment(i, size-2*i).prod()); diff --git a/test/sparse.h b/test/sparse.h index b6f6e6fce..7e2b98494 100644 --- a/test/sparse.h +++ b/test/sparse.h @@ -86,7 +86,7 @@ initSparse(double density, v = Scalar(0); if ((flags&ForceRealDiag) && (i==j)) - v = internal::real(v); + v = numext::real(v); if (v!=Scalar(0)) { @@ -136,7 +136,7 @@ initSparse(double density, v = Scalar(0); if ((flags&ForceRealDiag) && (i==j)) - v = internal::real(v); + v = numext::real(v); if (v!=Scalar(0)) { diff --git a/test/spqr_support.cpp b/test/spqr_support.cpp index 7e4b6e18a..b8980e081 100644 --- a/test/spqr_support.cpp +++ b/test/spqr_support.cpp @@ -59,4 +59,4 @@ void test_spqr_support() { CALL_SUBTEST_1(test_spqr_scalar()); CALL_SUBTEST_2(test_spqr_scalar >()); -} \ No newline at end of file +} diff --git a/test/triangular.cpp b/test/triangular.cpp index 7e1723af5..a2a7a1475 100644 --- a/test/triangular.cpp +++ b/test/triangular.cpp @@ -65,7 +65,7 @@ template void triangular_square(const MatrixType& m) m1 = MatrixType::Random(rows, cols); for (int i=0; i(); + while (numext::abs2(m1(i,i))<1e-1) m1(i,i) = internal::random(); Transpose trm4(m4); // test back and forward subsitution with a vector as the rhs diff --git a/test/umeyama.cpp b/test/umeyama.cpp index 814d19d01..738d0af70 100644 --- a/test/umeyama.cpp +++ b/test/umeyama.cpp @@ -82,7 +82,7 @@ Eigen::Matrix randMatrixSpecialUnitary(int si MatrixType Q = randMatrixUnitary(size); // tweak the first column to make the determinant be 1 - Q.col(0) *= internal::conj(Q.determinant()); + Q.col(0) *= numext::conj(Q.determinant()); return Q; } diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index bb49191b7..8d42e69b9 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -47,8 +47,8 @@ template struct auto_diff_special_op; * * It supports the following list of global math function: * - std::abs, std::sqrt, std::pow, std::exp, std::log, std::sin, std::cos, - * - internal::abs, internal::sqrt, internal::pow, internal::exp, internal::log, internal::sin, internal::cos, - * - internal::conj, internal::real, internal::imag, internal::abs2. + * - internal::abs, internal::sqrt, numext::pow, internal::exp, internal::log, internal::sin, internal::cos, + * - internal::conj, internal::real, internal::imag, numext::abs2. * * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However, * in that case, the expression template mechanism only occurs at the top Matrix level, @@ -549,7 +549,7 @@ EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs, return ReturnType(abs(x.value()), x.derivatives() * (x.value()<0 ? -1 : 1) );) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs2, - using internal::abs2; + using numext::abs2; return ReturnType(abs2(x.value()), x.derivatives() * (Scalar(2)*x.value()));) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(sqrt, @@ -612,17 +612,17 @@ atan2(const AutoDiffScalar& a, const AutoDiffScalar& b) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(tan, using std::tan; using std::cos; - return ReturnType(tan(x.value()),x.derivatives() * (Scalar(1)/internal::abs2(cos(x.value()))));) + return ReturnType(tan(x.value()),x.derivatives() * (Scalar(1)/numext::abs2(cos(x.value()))));) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(asin, using std::sqrt; using std::asin; - return ReturnType(asin(x.value()),x.derivatives() * (Scalar(1)/sqrt(1-internal::abs2(x.value()))));) + return ReturnType(asin(x.value()),x.derivatives() * (Scalar(1)/sqrt(1-numext::abs2(x.value()))));) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(acos, using std::sqrt; using std::acos; - return ReturnType(acos(x.value()),x.derivatives() * (Scalar(-1)/sqrt(1-internal::abs2(x.value()))));) + return ReturnType(acos(x.value()),x.derivatives() * (Scalar(-1)/sqrt(1-numext::abs2(x.value()))));) #undef EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h index 0540add0a..8c2d04830 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h @@ -21,8 +21,8 @@ namespace Eigen { * * It supports the following list of global math function: * - std::abs, std::sqrt, std::pow, std::exp, std::log, std::sin, std::cos, - * - internal::abs, internal::sqrt, internal::pow, internal::exp, internal::log, internal::sin, internal::cos, - * - internal::conj, internal::real, internal::imag, internal::abs2. + * - internal::abs, internal::sqrt, numext::pow, internal::exp, internal::log, internal::sin, internal::cos, + * - internal::conj, internal::real, internal::imag, numext::abs2. * * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However, * in that case, the expression template mechanism only occurs at the top Matrix level, diff --git a/unsupported/Eigen/src/IterativeSolvers/DGMRES.h b/unsupported/Eigen/src/IterativeSolvers/DGMRES.h index 7b5b5a91b..9fcc8a8d9 100644 --- a/unsupported/Eigen/src/IterativeSolvers/DGMRES.h +++ b/unsupported/Eigen/src/IterativeSolvers/DGMRES.h @@ -539,4 +539,4 @@ struct solve_retval, Rhs> } // end namespace internal } // end namespace Eigen -#endif \ No newline at end of file +#endif diff --git a/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h b/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h index 60584c523..25b32ec5b 100644 --- a/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h +++ b/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h @@ -109,13 +109,13 @@ LevenbergMarquardt::minimizeOneStep(FVectorType &x) /* compute the scaled actual reduction. */ actred = -1.; if (Scalar(.1) * fnorm1 < m_fnorm) - actred = 1. - internal::abs2(fnorm1 / m_fnorm); + actred = 1. - numext::abs2(fnorm1 / m_fnorm); /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ m_wa3 = m_rfactor.template triangularView() * (m_permutation.inverse() *m_wa1); - temp1 = internal::abs2(m_wa3.stableNorm() / m_fnorm); - temp2 = internal::abs2(sqrt(m_par) * pnorm / m_fnorm); + temp1 = numext::abs2(m_wa3.stableNorm() / m_fnorm); + temp2 = numext::abs2(sqrt(m_par) * pnorm / m_fnorm); prered = temp1 + temp2 / Scalar(.5); dirder = -(temp1 + temp2); diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h index 890225744..636df5363 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h @@ -338,7 +338,7 @@ void MatrixPowerTriangularAtomic::compute2x2(MatrixType& res, RealSc res.coeffRef(i-1,i) = m_A.coeff(i-1,i) * (res.coeff(i,i)-res.coeff(i-1,i-1)) / (m_A.coeff(i,i)-m_A.coeff(i-1,i-1)); } else { - int unwindingNumber = std::ceil((internal::imag(logTdiag[i]-logTdiag[i-1]) - M_PI) / (2*M_PI)); + int unwindingNumber = std::ceil((numext::imag(logTdiag[i]-logTdiag[i-1]) - M_PI) / (2*M_PI)); Scalar w = internal::matrix_power_unwinder::run(m_A.coeff(i,i), m_A.coeff(i-1,i-1), unwindingNumber); res.coeffRef(i-1,i) = m_A.coeff(i-1,i) * RealScalar(2) * std::exp(RealScalar(0.5)*p*(logTdiag[i]+logTdiag[i-1])) * std::sinh(p * w) / (m_A.coeff(i,i) - m_A.coeff(i-1,i-1)); diff --git a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h index 5b24b4619..b8ba6ddcb 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +++ b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h @@ -254,14 +254,14 @@ HybridNonLinearSolver::solveOneStep(FVectorType &x) /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) /* Computing 2nd power */ - actred = 1. - internal::abs2(fnorm1 / fnorm); + actred = 1. - numext::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction. */ wa3 = R.template triangularView()*wa1 + qtf; temp = wa3.stableNorm(); prered = 0.; if (temp < fnorm) /* Computing 2nd power */ - prered = 1. - internal::abs2(temp / fnorm); + prered = 1. - numext::abs2(temp / fnorm); /* compute the ratio of the actual to the predicted reduction. */ ratio = 0.; @@ -497,14 +497,14 @@ HybridNonLinearSolver::solveNumericalDiffOneStep(FVectorType /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) /* Computing 2nd power */ - actred = 1. - internal::abs2(fnorm1 / fnorm); + actred = 1. - numext::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction. */ wa3 = R.template triangularView()*wa1 + qtf; temp = wa3.stableNorm(); prered = 0.; if (temp < fnorm) /* Computing 2nd power */ - prered = 1. - internal::abs2(temp / fnorm); + prered = 1. - numext::abs2(temp / fnorm); /* compute the ratio of the actual to the predicted reduction. */ ratio = 0.; diff --git a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h index 3d0a9c8fc..bfeb26fc9 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h @@ -285,13 +285,13 @@ LevenbergMarquardt::minimizeOneStep(FVectorType &x) /* compute the scaled actual reduction. */ actred = -1.; if (Scalar(.1) * fnorm1 < fnorm) - actred = 1. - internal::abs2(fnorm1 / fnorm); + actred = 1. - numext::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ wa3 = fjac.template triangularView() * (qrfac.colsPermutation().inverse() *wa1); - temp1 = internal::abs2(wa3.stableNorm() / fnorm); - temp2 = internal::abs2(sqrt(par) * pnorm / fnorm); + temp1 = numext::abs2(wa3.stableNorm() / fnorm); + temp2 = numext::abs2(sqrt(par) * pnorm / fnorm); prered = temp1 + temp2 / Scalar(.5); dirder = -(temp1 + temp2); @@ -535,13 +535,13 @@ LevenbergMarquardt::minimizeOptimumStorageOneStep(FVectorTyp /* compute the scaled actual reduction. */ actred = -1.; if (Scalar(.1) * fnorm1 < fnorm) - actred = 1. - internal::abs2(fnorm1 / fnorm); + actred = 1. - numext::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ wa3 = fjac.topLeftCorner(n,n).template triangularView() * (permutation.inverse() * wa1); - temp1 = internal::abs2(wa3.stableNorm() / fnorm); - temp2 = internal::abs2(sqrt(par) * pnorm / fnorm); + temp1 = numext::abs2(wa3.stableNorm() / fnorm); + temp2 = numext::abs2(sqrt(par) * pnorm / fnorm); prered = temp1 + temp2 / Scalar(.5); dirder = -(temp1 + temp2); diff --git a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h index ad486f08e..cd5c04bbf 100644 --- a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h +++ b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h @@ -83,10 +83,10 @@ class PolynomialSolverBase inline const RootType& selectComplexRoot_withRespectToNorm( squaredNormBinaryPredicate& pred ) const { Index res=0; - RealScalar norm2 = internal::abs2( m_roots[0] ); + RealScalar norm2 = numext::abs2( m_roots[0] ); for( Index i=1; i::Real Real; - if( internal::abs2( x ) <= Real(1) ){ + if( numext::abs2( x ) <= Real(1) ){ return poly_eval_horner( poly, x ); } else { -- cgit v1.2.3 From f3a029e9579c7290e1e6737f7239afac51ada097 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 12 Jun 2013 13:05:23 +0200 Subject: Remove meaningless explicit qualifier --- Eigen/src/Core/Array.h | 2 +- Eigen/src/Core/DenseStorage.h | 16 ++++++++-------- Eigen/src/Core/Matrix.h | 2 +- Eigen/src/Core/PlainObjectBase.h | 2 +- Eigen/src/Geometry/AlignedBox.h | 2 +- Eigen/src/Geometry/Hyperplane.h | 2 +- Eigen/src/Geometry/ParametrizedLine.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index bd47e6cbb..497efff66 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h @@ -107,7 +107,7 @@ class Array * * \sa resize(Index,Index) */ - EIGEN_STRONG_INLINE explicit Array() : Base() + EIGEN_STRONG_INLINE Array() : Base() { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index 894dcf2c1..3e7f9c1b7 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -114,7 +114,7 @@ template class DenseSt { internal::plain_array m_data; public: - inline explicit DenseStorage() {} + inline DenseStorage() {} inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()) {} inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} @@ -131,7 +131,7 @@ template class DenseSt template class DenseStorage { public: - inline explicit DenseStorage() {} + inline DenseStorage() {} inline DenseStorage(internal::constructor_without_unaligned_array_assert) {} inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} inline void swap(DenseStorage& ) {} @@ -160,7 +160,7 @@ template class DenseStorage class DenseStorage m_data; DenseIndex m_rows; public: - inline explicit DenseStorage() : m_rows(0) {} + inline DenseStorage() : 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 nbRows, DenseIndex) : m_rows(nbRows) {} @@ -199,7 +199,7 @@ template class DenseStorage m_data; DenseIndex m_cols; public: - inline explicit DenseStorage() : m_cols(0) {} + inline DenseStorage() : 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 nbCols) : m_cols(nbCols) {} @@ -219,7 +219,7 @@ template class DenseStorage class DenseStorage(size)), m_cols(nbCols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } @@ -296,7 +296,7 @@ template class DenseStorage(size)), m_rows(nbRows) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 5f6df19fb..0ba5d90cc 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -200,7 +200,7 @@ class Matrix * * \sa resize(Index,Index) */ - EIGEN_STRONG_INLINE explicit Matrix() : Base() + EIGEN_STRONG_INLINE Matrix() : Base() { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index b01bd6df6..af0a479c7 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -418,7 +418,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type return Base::operator=(func); } - EIGEN_STRONG_INLINE explicit PlainObjectBase() : m_storage() + EIGEN_STRONG_INLINE PlainObjectBase() : m_storage() { // _check_template_params(); // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h index 538a5afb7..8e186d57a 100644 --- a/Eigen/src/Geometry/AlignedBox.h +++ b/Eigen/src/Geometry/AlignedBox.h @@ -56,7 +56,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) /** Default constructor initializing a null box. */ - inline explicit AlignedBox() + inline AlignedBox() { if (AmbientDimAtCompileTime!=Dynamic) setEmpty(); } /** Constructs a null box with \a _dim the dimension of the ambient space. */ diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index 6b31efde9..aeff43fef 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -50,7 +50,7 @@ public: typedef const Block ConstNormalReturnType; /** Default constructor without initialization */ - inline explicit Hyperplane() {} + inline Hyperplane() {} template Hyperplane(const Hyperplane& other) diff --git a/Eigen/src/Geometry/ParametrizedLine.h b/Eigen/src/Geometry/ParametrizedLine.h index 98dd0f0d1..77fa228e6 100644 --- a/Eigen/src/Geometry/ParametrizedLine.h +++ b/Eigen/src/Geometry/ParametrizedLine.h @@ -41,7 +41,7 @@ public: typedef Matrix VectorType; /** Default constructor without initialization */ - inline explicit ParametrizedLine() {} + inline ParametrizedLine() {} template ParametrizedLine(const ParametrizedLine& other) -- cgit v1.2.3 From d5fa5001a7c6ba3ea29c5a4f18aebb8c1ec71dd6 Mon Sep 17 00:00:00 2001 From: Jeff Dean Date: Thu, 13 Jun 2013 18:17:27 +0200 Subject: Fix bug #613: psqrt was incorrect for small numbers --- Eigen/src/Core/arch/SSE/MathFunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/arch/SSE/MathFunctions.h b/Eigen/src/Core/arch/SSE/MathFunctions.h index 5ede55fba..1d1a98a9d 100644 --- a/Eigen/src/Core/arch/SSE/MathFunctions.h +++ b/Eigen/src/Core/arch/SSE/MathFunctions.h @@ -450,7 +450,7 @@ Packet4f psqrt(const Packet4f& _x) Packet4f half = pmul(_x, pset1(.5f)); /* select only the inverse sqrt of non-zero inputs */ - Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1(std::numeric_limits::epsilon())); + Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1((std::numeric_limits::min)())); Packet4f x = _mm_and_ps(non_zero_mask, _mm_rsqrt_ps(_x)); x = pmul(x, psub(pset1(1.5f), pmul(half, pmul(x,x)))); -- cgit v1.2.3 From 9f11f80db1b53d0f9b9173a777c0a644e763619a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 14 Jun 2013 10:55:05 +0200 Subject: Make psqrt works with numeric_limits::min --- Eigen/src/Core/arch/SSE/MathFunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/arch/SSE/MathFunctions.h b/Eigen/src/Core/arch/SSE/MathFunctions.h index 1d1a98a9d..3376a984e 100644 --- a/Eigen/src/Core/arch/SSE/MathFunctions.h +++ b/Eigen/src/Core/arch/SSE/MathFunctions.h @@ -450,7 +450,7 @@ Packet4f psqrt(const Packet4f& _x) Packet4f half = pmul(_x, pset1(.5f)); /* select only the inverse sqrt of non-zero inputs */ - Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1((std::numeric_limits::min)())); + Packet4f non_zero_mask = _mm_cmpge_ps(_x, pset1((std::numeric_limits::min)())); Packet4f x = _mm_and_ps(non_zero_mask, _mm_rsqrt_ps(_x)); x = pmul(x, psub(pset1(1.5f), pmul(half, pmul(x,x)))); -- cgit v1.2.3 From 33788b97dd2cd8662c598e14e1e901a7bd4df93b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 18 Jun 2013 00:48:47 +0200 Subject: Fix compilation issue with some compilers (when doing using Base::foo;, foo must be visible in the direct base class) --- Eigen/src/Core/Transpose.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 2bc828e19..95a7b95e5 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -104,6 +104,7 @@ template class TransposeImpl typedef typename internal::TransposeImpl_base::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Transpose) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TransposeImpl) inline Index innerStride() const { return derived().nestedExpression().innerStride(); } inline Index outerStride() const { return derived().nestedExpression().outerStride(); } -- cgit v1.2.3 From ba79e39c5c641888f58bff01febe9b81c4a22cbc Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 18 Jun 2013 17:44:25 +0200 Subject: bug #71: enable vectorization of diagonal products in more cases. --- Eigen/src/Core/DiagonalProduct.h | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/DiagonalProduct.h b/Eigen/src/Core/DiagonalProduct.h index d55b2c250..c03a0c2e1 100644 --- a/Eigen/src/Core/DiagonalProduct.h +++ b/Eigen/src/Core/DiagonalProduct.h @@ -26,14 +26,15 @@ struct traits > MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, _StorageOrder = MatrixType::Flags & RowMajorBit ? RowMajor : ColMajor, - _PacketOnDiag = !((int(_StorageOrder) == RowMajor && int(ProductOrder) == OnTheLeft) - ||(int(_StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), + _ScalarAccessOnDiag = !((int(_StorageOrder) == ColMajor && int(ProductOrder) == OnTheLeft) + ||(int(_StorageOrder) == RowMajor && int(ProductOrder) == OnTheRight)), _SameTypes = is_same::value, // 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))), + //_Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && ((!_PacketOnDiag) || (_SameTypes && bool(int(DiagonalType::DiagonalVectorType::Flags)&PacketAccessBit))), + _Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && _SameTypes && (_ScalarAccessOnDiag || (bool(int(DiagonalType::DiagonalVectorType::Flags)&PacketAccessBit))), + _LinearAccessMask = (RowsAtCompileTime==1 || ColsAtCompileTime==1) ? LinearAccessBit : 0, - Flags = (HereditaryBits & (unsigned int)(MatrixType::Flags)) | (_Vectorizable ? PacketAccessBit : 0), + Flags = ((HereditaryBits|_LinearAccessMask) & (unsigned int)(MatrixType::Flags)) | (_Vectorizable ? PacketAccessBit : 0) | AlignedBit,//(int(MatrixType::Flags)&int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit), CoeffReadCost = NumTraits::MulCost + MatrixType::CoeffReadCost + DiagonalType::DiagonalVectorType::CoeffReadCost }; }; @@ -54,13 +55,21 @@ class DiagonalProduct : internal::no_assignment_operator, eigen_assert(diagonal.diagonal().size() == (ProductOrder == OnTheLeft ? matrix.rows() : matrix.cols())); } - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } + EIGEN_STRONG_INLINE Index rows() const { return m_matrix.rows(); } + EIGEN_STRONG_INLINE Index cols() const { return m_matrix.cols(); } - const Scalar coeff(Index row, Index col) const + EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const { return m_diagonal.diagonal().coeff(ProductOrder == OnTheLeft ? row : col) * m_matrix.coeff(row, col); } + + EIGEN_STRONG_INLINE const Scalar coeff(Index idx) const + { + enum { + StorageOrder = int(MatrixType::Flags) & RowMajorBit ? RowMajor : ColMajor + }; + return coeff(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); + } template EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const @@ -69,11 +78,19 @@ class DiagonalProduct : internal::no_assignment_operator, StorageOrder = Flags & RowMajorBit ? RowMajor : ColMajor }; const Index indexInDiagonalVector = ProductOrder == OnTheLeft ? row : col; - return packet_impl(row,col,indexInDiagonalVector,typename internal::conditional< ((int(StorageOrder) == RowMajor && int(ProductOrder) == OnTheLeft) ||(int(StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), internal::true_type, internal::false_type>::type()); } + + template + EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const + { + enum { + StorageOrder = int(MatrixType::Flags) & RowMajorBit ? RowMajor : ColMajor + }; + return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); + } protected: template @@ -88,7 +105,7 @@ class DiagonalProduct : internal::no_assignment_operator, { enum { InnerSize = (MatrixType::Flags & RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime, - DiagonalVectorPacketLoadMode = (LoadMode == Aligned && ((InnerSize%16) == 0)) ? Aligned : Unaligned + DiagonalVectorPacketLoadMode = (LoadMode == Aligned && (((InnerSize%16) == 0) || (int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit)==AlignedBit) ? Aligned : Unaligned) }; return internal::pmul(m_matrix.template packet(row, col), m_diagonal.diagonal().template packet(id)); -- cgit v1.2.3 From 8cc9b125899d47e19dd5d4e683af45390bfd565a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 21 Jun 2013 11:37:33 +0200 Subject: Add missing using std::pow in lpNorm. --- Eigen/src/Core/Dot.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index e4107a1ac..9d7651f1f 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -166,6 +166,7 @@ struct lpNorm_selector typedef typename NumTraits::Scalar>::Real RealScalar; static inline RealScalar run(const MatrixBase& m) { + using std::pow; return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p); } }; -- cgit v1.2.3 From 620e4277bc5cb434886ea8794c90def0c460fb02 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 21 Jun 2013 17:49:36 +0200 Subject: Disable ASM comments on non x86 architecture and do not redfine if EIGEN_ASM_COMMENT is already defined --- Eigen/src/Core/util/Macros.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 2368c896f..96737456a 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -240,10 +240,12 @@ // Suppresses 'unused variable' warnings. #define EIGEN_UNUSED_VARIABLE(var) (void)var; -#if !defined(EIGEN_ASM_COMMENT) && (defined __GNUC__) -#define EIGEN_ASM_COMMENT(X) asm("#" X) -#else -#define EIGEN_ASM_COMMENT(X) +#if !defined(EIGEN_ASM_COMMENT) + #if (defined __GNUC__) && ( defined(__i386__) || defined(__x86_64__) ) + #define EIGEN_ASM_COMMENT(X) asm("#" X) + #else + #define EIGEN_ASM_COMMENT(X) + #endif #endif /* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements. -- cgit v1.2.3 From fab023536980c0e90c89811f0cbed037d2539879 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 23 Jun 2013 14:13:21 +0200 Subject: Fix bug #590: NEON Duplicate lane load --- Eigen/src/Core/arch/NEON/PacketMath.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h index 4c0702715..163bac215 100644 --- a/Eigen/src/Core/arch/NEON/PacketMath.h +++ b/Eigen/src/Core/arch/NEON/PacketMath.h @@ -191,15 +191,15 @@ template<> EIGEN_STRONG_INLINE Packet4i ploadu(const int* from) { EI template<> EIGEN_STRONG_INLINE Packet4f ploaddup(const float* from) { float32x2_t lo, hi; - lo = vdup_n_f32(*from); - hi = vdup_n_f32(*(from+1)); + lo = vld1_dup_f32(from); + hi = vld1_dup_f32(from+1); return vcombine_f32(lo, hi); } template<> EIGEN_STRONG_INLINE Packet4i ploaddup(const int* from) { int32x2_t lo, hi; - lo = vdup_n_s32(*from); - hi = vdup_n_s32(*(from+1)); + lo = vld1_dup_s32(from); + hi = vld1_dup_s32(from+1); return vcombine_s32(lo, hi); } -- cgit v1.2.3 From c21a04bcf978556555f874b780cae14dbdf4827f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 24 Jun 2013 13:35:13 +0200 Subject: fix compilation of ArrayBase::transposeInPlace --- Eigen/src/Core/Transpose.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 95a7b95e5..aa197db0b 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -253,7 +253,7 @@ struct inplace_transpose_selector; template struct inplace_transpose_selector { // square matrix static void run(MatrixType& m) { - m.template triangularView().swap(m.transpose()); + m.matrix().template triangularView().swap(m.matrix().transpose()); } }; @@ -261,7 +261,7 @@ template struct inplace_transpose_selector { // non square matrix static void run(MatrixType& m) { if (m.rows()==m.cols()) - m.template triangularView().swap(m.transpose()); + m.matrix().template triangularView().swap(m.matrix().transpose()); else m = m.transpose().eval(); } -- cgit v1.2.3 From 1330ca611b7129df3c4de37a5faa08678b8f7453 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 24 Jun 2013 13:45:33 +0200 Subject: CwiseUnaryView should not inherit no_assignment_operator! --- Eigen/src/Core/CwiseUnaryView.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index 9f9d4972d..b2638d326 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -56,8 +56,7 @@ template class CwiseUnaryViewImpl; template -class CwiseUnaryView : internal::no_assignment_operator, - public CwiseUnaryViewImpl::StorageKind> +class CwiseUnaryView : public CwiseUnaryViewImpl::StorageKind> { public: @@ -99,6 +98,7 @@ class CwiseUnaryViewImpl typedef typename internal::dense_xpr_base< CwiseUnaryView >::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Derived) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl) inline Scalar* data() { return &coeffRef(0); } inline const Scalar* data() const { return &coeff(0); } -- cgit v1.2.3 From 74beb218d25e155e074500739138e6bcface1474 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 26 Jun 2013 22:49:14 +0200 Subject: Fix bug #554: include unistd.h before checking the presence of posix_memalign. --- Eigen/src/Core/util/Memory.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 3ca666fd9..451535a0c 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -58,10 +58,17 @@ #endif -#if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) \ - && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0) - #define EIGEN_HAS_POSIX_MEMALIGN 1 -#else +// See bug 554 (http://eigen.tuxfamily.org/bz/show_bug.cgi?id=554) +// It seems to be unsafe to check _POSIX_ADVISORY_INFO without including unistd.h first. +// Currently, let's include it only on unix systems: +#if defined(__unix__) || defined(__unix) + #include + #if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0) + #define EIGEN_HAS_POSIX_MEMALIGN 1 + #endif +#endif + +#ifndef EIGEN_HAS_POSIX_MEMALIGN #define EIGEN_HAS_POSIX_MEMALIGN 0 #endif @@ -215,7 +222,7 @@ inline void* aligned_malloc(size_t size) if(posix_memalign(&result, 16, size)) result = 0; #elif EIGEN_HAS_MM_MALLOC result = _mm_malloc(size, 16); -#elif defined(_MSC_VER) && (!defined(_WIN32_WCE)) + #elif defined(_MSC_VER) && (!defined(_WIN32_WCE)) result = _aligned_malloc(size, 16); #else result = handmade_aligned_malloc(size); -- cgit v1.2.3 From 419b5cff44a6d2cdd3872a809f9dfdfa283f0dc3 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Tue, 2 Jul 2013 13:35:36 +0100 Subject: doc: Mention vec=vec.head(n) in aliasing page. --- Eigen/src/Core/Transpose.h | 2 +- doc/TopicAliasing.dox | 50 ++++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 23 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index aa197db0b..798120bf4 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -388,7 +388,7 @@ struct checkTransposeAliasing_impl eigen_assert((!check_transpose_aliasing_run_time_selector ::IsTransposed,OtherDerived> ::run(extract_data(dst), other)) - && "aliasing detected during tranposition, use transposeInPlace() " + && "aliasing detected during transposition, use transposeInPlace() " "or evaluate the rhs into a temporary using .eval()"); } diff --git a/doc/TopicAliasing.dox b/doc/TopicAliasing.dox index bd1d329ce..c2654aed2 100644 --- a/doc/TopicAliasing.dox +++ b/doc/TopicAliasing.dox @@ -2,7 +2,7 @@ namespace Eigen { /** \eigenManualPage TopicAliasing Aliasing -In Eigen, aliasing refers to assignment statement in which the same matrix (or array or vector) appears on the +In %Eigen, aliasing refers to assignment statement in which the same matrix (or array or vector) appears on the left and on the right of the assignment operators. Statements like mat = 2 * mat; or mat = mat.transpose(); exhibit aliasing. The aliasing in the first example is harmless, but the aliasing in the second example leads to unexpected results. This page explains what aliasing is, when it is harmful, and what @@ -32,7 +32,7 @@ This assignment exhibits aliasing: the coefficient \c mat(1,1) appears both in t mat.bottomRightCorner(2,2) on the left-hand side of the assignment and the block mat.topLeftCorner(2,2) on the right-hand side. After the assignment, the (2,2) entry in the bottom right corner should have the value of \c mat(1,1) before the assignment, which is 5. However, the output shows -that \c mat(2,2) is actually 1. The problem is that Eigen uses lazy evaluation (see +that \c mat(2,2) is actually 1. The problem is that %Eigen uses lazy evaluation (see \ref TopicEigenExpressionTemplates) for mat.topLeftCorner(2,2). The result is similar to \code mat(1,1) = mat(0,0); @@ -43,10 +43,13 @@ mat(2,2) = mat(1,1); Thus, \c mat(2,2) is assigned the \e new value of \c mat(1,1) instead of the old value. The next section explains how to solve this problem by calling \link DenseBase::eval() eval()\endlink. -Note that if \c mat were a bigger, then the blocks would not overlap, and there would be no aliasing -problem. This means that in general aliasing cannot be detected at compile time. However, Eigen does detect -some instances of aliasing, albeit at run time. The following example exhibiting aliasing was mentioned in -\ref TutorialMatrixArithmetic : +Aliasing occurs more naturally when trying to shrink a matrix. For example, the expressions vec = +vec.head(n) and mat = mat.block(i,j,r,c) exhibit aliasing. + +In general, aliasing cannot be detected at compile time: if \c mat in the first example were a bit bigger, +then the blocks would not overlap, and there would be no aliasing problem. However, %Eigen does detect some +instances of aliasing, albeit at run time. The following example exhibiting aliasing was mentioned in \ref +TutorialMatrixArithmetic : @@ -57,24 +60,24 @@ some instances of aliasing, albeit at run time. The following example exhibitin \verbinclude tut_arithmetic_transpose_aliasing.out
ExampleOutput
-Again, the output shows the aliasing issue. However, by default Eigen uses a run-time assertion to detect this +Again, the output shows the aliasing issue. However, by default %Eigen uses a run-time assertion to detect this and exits with a message like \verbatim void Eigen::DenseBase::checkTransposeAliasing(const OtherDerived&) const [with OtherDerived = Eigen::Transpose >, Derived = Eigen::Matrix]: Assertion `(!internal::check_transpose_aliasing_selector::IsTransposed,OtherDerived>::run(internal::extract_data(derived()), other)) -&& "aliasing detected during tranposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()"' failed. +&& "aliasing detected during transposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()"' failed. \endverbatim -The user can turn Eigen's run-time assertions like the one to detect this aliasing problem off by defining the +The user can turn %Eigen's run-time assertions like the one to detect this aliasing problem off by defining the EIGEN_NO_DEBUG macro, and the above program was compiled with this macro turned off in order to illustrate the -aliasing problem. See \ref TopicAssertions for more information about Eigen's run-time assertions. +aliasing problem. See \ref TopicAssertions for more information about %Eigen's run-time assertions. \section TopicAliasingSolution Resolving aliasing issues -If you understand the cause of the aliasing issue, then it is obvious what must happen to solve it: Eigen has +If you understand the cause of the aliasing issue, then it is obvious what must happen to solve it: %Eigen has to evaluate the right-hand side fully into a temporary matrix/array and then assign it to the left-hand side. The function \link DenseBase::eval() eval() \endlink does precisely that. @@ -93,7 +96,7 @@ Now, \c mat(2,2) equals 5 after the assignment, as it should be. The same solution also works for the second example, with the transpose: simply replace the line a = a.transpose(); with a = a.transpose().eval();. However, in this common case there is a -better solution. Eigen provides the special-purpose function +better solution. %Eigen provides the special-purpose function \link DenseBase::transposeInPlace() transposeInPlace() \endlink which replaces a matrix by its transpose. This is shown below: @@ -107,7 +110,7 @@ This is shown below: If an xxxInPlace() function is available, then it is best to use it, because it indicates more clearly what you -are doing. This may also allow Eigen to optimize more aggressively. These are some of the xxxInPlace() +are doing. This may also allow %Eigen to optimize more aggressively. These are some of the xxxInPlace() functions provided: @@ -120,6 +123,9 @@ functions provided:
DenseBase::transpose() DenseBase::transposeInPlace()
+In the special case where a matrix or vector is shrunk using an expression like vec = vec.head(n), +you can use \link PlainObjectBase::conservativeResize() conservativeResize() \endlink. + \section TopicAliasingCwise Aliasing and component-wise operations @@ -128,8 +134,8 @@ right-hand side of an assignment operator, and it is then often necessary to eva explicitly. However, applying component-wise operations (such as matrix addition, scalar multiplication and array multiplication) is safe. -The following example has only component-wise operations. Thus, there is no need for .eval() even though -the same matrix appears on both sides of the assignments. +The following example has only component-wise operations. Thus, there is no need for \link DenseBase::eval() +eval() \endlink even though the same matrix appears on both sides of the assignments. @@ -147,8 +153,8 @@ not necessary to evaluate the right-hand side explicitly. \section TopicAliasingMatrixMult Aliasing and matrix multiplication -Matrix multiplication is the only operation in Eigen that assumes aliasing by default. Thus, if \c matA is a -matrix, then the statement matA = matA * matA; is safe. All other operations in Eigen assume that +Matrix multiplication is the only operation in %Eigen that assumes aliasing by default. Thus, if \c matA is a +matrix, then the statement matA = matA * matA; is safe. All other operations in %Eigen assume that there are no aliasing problems, either because the result is assigned to a different matrix or because it is a component-wise operation. @@ -161,14 +167,14 @@ component-wise operation. \verbinclude TopicAliasing_mult1.out
ExampleOutput
-However, this comes at a price. When executing the expression matA = matA * matA, Eigen evaluates the -product in a temporary matrix which is assigned to \c matA after the computation. This is fine. But Eigen does +However, this comes at a price. When executing the expression matA = matA * matA, %Eigen evaluates the +product in a temporary matrix which is assigned to \c matA after the computation. This is fine. But %Eigen does the same when the product is assigned to a different matrix (e.g., matB = matA * matA). In that case, it is more efficient to evaluate the product directly into \c matB instead of evaluating it first into a temporary matrix and copying that matrix to \c matB. The user can indicate with the \link MatrixBase::noalias() noalias()\endlink function that there is no -aliasing, as follows: matB.noalias() = matA * matA. This allows Eigen to evaluate the matrix product +aliasing, as follows: matB.noalias() = matA * matA. This allows %Eigen to evaluate the matrix product matA * matA directly into \c matB. @@ -199,9 +205,9 @@ Aliasing occurs when the same matrix or array coefficients appear both on the le an assignment operator. - Aliasing is harmless with coefficient-wise computations; this includes scalar multiplication and matrix or array addition. - - When you multiply two matrices, Eigen assumes that aliasing occurs. If you know that there is no aliasing, + - When you multiply two matrices, %Eigen assumes that aliasing occurs. If you know that there is no aliasing, then you can use \link MatrixBase::noalias() noalias()\endlink. - - In all other situations, Eigen assumes that there is no aliasing issue and thus gives the wrong result if + - In all other situations, %Eigen assumes that there is no aliasing issue and thus gives the wrong result if aliasing does in fact occur. To prevent this, you have to use \link DenseBase::eval() eval() \endlink or one of the xxxInPlace() functions. -- cgit v1.2.3 From 155fa0ca83715fca61c175251b0d7bef7344e8dc Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 3 Jul 2013 11:36:12 +0200 Subject: Add missing namespace prefix in pconj --- Eigen/src/Core/GenericPacketMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 64294420f..5f783ebee 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -106,7 +106,7 @@ pnegate(const Packet& a) { return -a; } /** \internal \returns conj(a) (coeff-wise) */ template inline Packet -pconj(const Packet& a) { return conj(a); } +pconj(const Packet& a) { return numext::conj(a); } /** \internal \returns a * b (coeff-wise) */ template inline Packet -- cgit v1.2.3 From 3edd4681f2f04c1164cb3805f1ac37fbf9a618c0 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 6 Jul 2013 20:26:02 +0200 Subject: ReturnByValue should not be assignable! --- Eigen/src/Core/ReturnByValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h index 613912ffa..d66c24ba0 100644 --- a/Eigen/src/Core/ReturnByValue.h +++ b/Eigen/src/Core/ReturnByValue.h @@ -48,7 +48,7 @@ struct nested, n, PlainObject> } // end namespace internal template class ReturnByValue - : public internal::dense_xpr_base< ReturnByValue >::type + : internal::no_assignment_operator, public internal::dense_xpr_base< ReturnByValue >::type { public: typedef typename internal::traits::ReturnType ReturnType; -- cgit v1.2.3 From 5a4519d2b4a816fd82be77e9aa1b2498af62375c Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 10 Jul 2013 21:11:41 +0200 Subject: Revisit the implementation of random_default_impl for integer to make sure avoid overflows and compiler warnings. --- Eigen/src/Core/MathFunctions.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 5df2d8bca..2bfc5ebd9 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -510,11 +510,10 @@ struct random_default_impl #else enum { rand_bits = floor_log2<(unsigned int)(RAND_MAX)+1>::value, scalar_bits = sizeof(Scalar) * CHAR_BIT, - shift = EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)) + shift = EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)), + offset = NumTraits::IsSigned ? (1 << (EIGEN_PLAIN_ENUM_MIN(rand_bits,scalar_bits)-1)) : 0 }; - Scalar x = Scalar(std::rand() >> shift); - Scalar offset = NumTraits::IsSigned ? Scalar(1 << (rand_bits-1)) : Scalar(0); - return x - offset; + return Scalar((std::rand() >> shift) - offset); #endif } }; -- cgit v1.2.3 From 84f52ad317f64d01174c622ae596701088237487 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 10 Jul 2013 23:54:53 +0200 Subject: Remove double const qualifier --- Eigen/src/Core/Diagonal.h | 2 +- Eigen/src/Core/MatrixBase.h | 2 +- Eigen/src/Core/Transpose.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index c106f93c4..aab8007b3 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -172,7 +172,7 @@ MatrixBase::diagonal() /** This is the const version of diagonal(). */ template -inline const typename MatrixBase::ConstDiagonalReturnType +inline typename MatrixBase::ConstDiagonalReturnType MatrixBase::diagonal() const { return ConstDiagonalReturnType(derived()); diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 198e51084..373c6821e 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -216,7 +216,7 @@ template class MatrixBase typedef Diagonal DiagonalReturnType; DiagonalReturnType diagonal(); typedef const Diagonal ConstDiagonalReturnType; - const ConstDiagonalReturnType diagonal() const; + ConstDiagonalReturnType diagonal() const; template struct DiagonalIndexReturnType { typedef Diagonal Type; }; template struct ConstDiagonalIndexReturnType { typedef const Diagonal Type; }; diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 798120bf4..f21b3aa65 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -207,7 +207,7 @@ DenseBase::transpose() * * \sa transposeInPlace(), adjoint() */ template -inline const typename DenseBase::ConstTransposeReturnType +inline typename DenseBase::ConstTransposeReturnType DenseBase::transpose() const { return ConstTransposeReturnType(derived()); -- cgit v1.2.3 From 444c09e31359be498e7ba4a1b54c6cc78de7f6f0 Mon Sep 17 00:00:00 2001 From: Desire Nuentsa Date: Thu, 11 Jul 2013 12:36:57 +0200 Subject: Fix constness of diagonal() and transpose() for MSVC. --- Eigen/src/Core/DenseBase.h | 2 +- Eigen/src/Core/MatrixBase.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 4e8b820bb..9551b8384 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -281,7 +281,7 @@ template class DenseBase CommaInitializer operator<< (const DenseBase& other); Eigen::Transpose transpose(); - typedef const Transpose ConstTransposeReturnType; + typedef typename internal::add_const >::type ConstTransposeReturnType; ConstTransposeReturnType transpose() const; void transposeInPlace(); #ifndef EIGEN_NO_DEBUG diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 373c6821e..9193b6abb 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -215,7 +215,7 @@ template class MatrixBase typedef Diagonal DiagonalReturnType; DiagonalReturnType diagonal(); - typedef const Diagonal ConstDiagonalReturnType; + typedef typename internal::add_const >::type ConstDiagonalReturnType; ConstDiagonalReturnType diagonal() const; template struct DiagonalIndexReturnType { typedef Diagonal Type; }; -- cgit v1.2.3 From 20e535e1429cdb2f2dace3e2e6915e33968aa198 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 17 Jul 2013 10:04:20 +0200 Subject: Bump default branch to 3.2.90 --- Eigen/src/Core/util/Macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 96737456a..6798a3e0f 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -12,8 +12,8 @@ #define EIGEN_MACROS_H #define EIGEN_WORLD_VERSION 3 -#define EIGEN_MAJOR_VERSION 1 -#define EIGEN_MINOR_VERSION 91 +#define EIGEN_MAJOR_VERSION 2 +#define EIGEN_MINOR_VERSION 90 #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \ (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \ -- cgit v1.2.3