aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/MathFunctionsImpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen/src/Core/MathFunctionsImpl.h')
-rw-r--r--Eigen/src/Core/MathFunctionsImpl.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/Eigen/src/Core/MathFunctionsImpl.h b/Eigen/src/Core/MathFunctionsImpl.h
index ae1386b4c..034cfad7b 100644
--- a/Eigen/src/Core/MathFunctionsImpl.h
+++ b/Eigen/src/Core/MathFunctionsImpl.h
@@ -66,6 +66,25 @@ T generic_fast_tanh_float(const T& a_x)
return pdiv(p, q);
}
+
+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);
+ EIGEN_USING_STD_MATH(sqrt);
+ RealScalar _x = abs(x);
+ RealScalar _y = abs(y);
+ 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);
+ }
+};
+
} // end namespace internal
} // end namespace Eigen