diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-11-12 06:42:35 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-11-12 06:42:35 +0100 |
commit | 407b6208604d2822b1067ac64949e78a9167572b (patch) | |
tree | 8e4371deef2804e77e2fe6e17158be2536de28da /eigen/Eigen/src/Core/MathFunctionsImpl.h | |
parent | ca2e0fcdcfff03747500344e2522ff330ccafa14 (diff) |
eigen update
Diffstat (limited to 'eigen/Eigen/src/Core/MathFunctionsImpl.h')
-rw-r--r-- | eigen/Eigen/src/Core/MathFunctionsImpl.h | 23 |
1 files changed, 23 insertions, 0 deletions
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<typename RealScalar> +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<typename Scalar> +struct hypot_impl +{ + typedef typename NumTraits<Scalar>::Real RealScalar; + static inline RealScalar run(const Scalar& x, const Scalar& y) + { + EIGEN_USING_STD_MATH(abs); + return positive_real_hypot<RealScalar>(abs(x), abs(y)); + } +}; + } // end namespace internal } // end namespace Eigen |