From fad1ce69f0101e682fb0728e1f802271d5fcd1cc Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 7 May 2015 14:00:10 +0300 Subject: [PATCH] [extensions][ttmath] add missing mathematical functions for ttmath_big and specialize detail::math::equals for ttmath_big and ttmath::Big --- .../extensions/contrib/ttmath_stub.hpp | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index cb53fc114..91ef63eb1 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp @@ -175,6 +175,39 @@ inline ttmath_big operator/(ttmath_big const& x, ttmath_big const& y) } +// math functions for ttmath_big + +#define TTMATH_BIG_UNARY_MATH_FUNCTION(FCT) \ + ttmath_big FCT(ttmath_big const& x) \ + { \ + return ttmath::FCT(static_cast const&>(x)); \ + } + +#define TTMATH_BIG_BINARY_MATH_FUNCTION(FCT) \ + ttmath_big FCT(ttmath_big const& x, ttmath_big const& y) \ + { \ + return ttmath::FCT(static_cast const&>(x), \ + static_cast const&>(y)); \ + } + +TTMATH_BIG_UNARY_MATH_FUNCTION(sqrt) +TTMATH_BIG_UNARY_MATH_FUNCTION(abs) +TTMATH_BIG_UNARY_MATH_FUNCTION(ceil) +TTMATH_BIG_UNARY_MATH_FUNCTION(floor) +TTMATH_BIG_UNARY_MATH_FUNCTION(asin) +TTMATH_BIG_UNARY_MATH_FUNCTION(acos) +TTMATH_BIG_UNARY_MATH_FUNCTION(atan) +TTMATH_BIG_UNARY_MATH_FUNCTION(sin) +TTMATH_BIG_UNARY_MATH_FUNCTION(cos) +TTMATH_BIG_UNARY_MATH_FUNCTION(tan) + +TTMATH_BIG_BINARY_MATH_FUNCTION(atan2) +TTMATH_BIG_BINARY_MATH_FUNCTION(mod) + +#undef TTMATH_BIG_UNARY_MATH_FUNCTION +#undef TTMATH_BIG_BINARY_MATH_FUNCTION + + namespace boost{ namespace geometry { namespace math { @@ -235,6 +268,7 @@ namespace detail : public define_two_pi > {}; + template struct equals_with_epsilon, false> { @@ -252,6 +286,33 @@ namespace detail : public equals_with_epsilon, false> {}; + template + struct equals, false> + { + template + static inline bool apply(ttmath::Big const& a, + ttmath::Big const& b, + Policy const&) + { + return equals_with_epsilon + < + ttmath::Big + >::apply(a, b); + } + }; + + template <> + struct equals + { + template + static inline bool apply(ttmath_big const& a, + ttmath_big const& b, + Policy const&) + { + return equals_with_epsilon::apply(a, b); + } + }; + } // detail } // ttmath