From 407b6208604d2822b1067ac64949e78a9167572b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 12 Nov 2018 06:42:35 +0100 Subject: eigen update --- eigen/Eigen/src/Core/MathFunctionsImpl.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'eigen/Eigen/src/Core/MathFunctionsImpl.h') diff --git a/eigen/Eigen/src/Core/MathFunctionsImpl.h b/eigen/Eigen/src/Core/MathFunctionsImpl.h index 3c9ef22..9c1ceb0 100644 --- a/eigen/Eigen/src/Core/MathFunctionsImpl.h +++ b/eigen/Eigen/src/Core/MathFunctionsImpl.h @@ -71,6 +71,29 @@ T generic_fast_tanh_float(const T& a_x) return pdiv(p, q); } +template +EIGEN_STRONG_INLINE +RealScalar positive_real_hypot(const RealScalar& x, const RealScalar& y) +{ + EIGEN_USING_STD_MATH(sqrt); + RealScalar p, qp; + p = numext::maxi(x,y); + if(p==RealScalar(0)) return RealScalar(0); + qp = numext::mini(y,x) / p; + return p * sqrt(RealScalar(1) + qp*qp); +} + +template +struct hypot_impl +{ + typedef typename NumTraits::Real RealScalar; + static inline RealScalar run(const Scalar& x, const Scalar& y) + { + EIGEN_USING_STD_MATH(abs); + return positive_real_hypot(abs(x), abs(y)); + } +}; + } // end namespace internal } // end namespace Eigen -- cgit v1.2.3