1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add math::copysign

fix hyperbolic and exponental functions: for special values
This commit is contained in:
bolero-MURAKAMI 2013-04-24 22:48:36 +09:00
parent a27c83e939
commit 32c3ba02d4
50 changed files with 540 additions and 216 deletions

View file

@ -7,8 +7,9 @@
#include <sprout/math/detail/config.hpp>
#include <sprout/math/detail/float_compute.hpp>
#include <sprout/math/constants.hpp>
#include <sprout/math/copysign.hpp>
#include <sprout/math/signbit.hpp>
#include <sprout/math/atan.hpp>
#include <sprout/type_traits/float_promote.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/type_traits/float_promote.hpp>
@ -35,20 +36,21 @@ namespace sprout {
return x == -std::numeric_limits<FloatType>::infinity()
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::three_quarters_pi<FloatType>()
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::three_quarters_pi<FloatType>()
: y < 0 ? -sprout::math::half_pi<FloatType>()
: sprout::math::half_pi<FloatType>()
: sprout::math::copysign(sprout::math::pi<FloatType>(), y)
: x == std::numeric_limits<FloatType>::infinity()
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::quarter_pi<FloatType>()
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::quarter_pi<FloatType>()
: FloatType(0)
: sprout::math::copysign(FloatType(0), y)
: y == std::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
: std::atan2(y, x)
#else
: y == 0
? x < 0 ? sprout::math::pi<FloatType>()
: FloatType(0)
? x < 0 ? sprout::math::copysign(sprout::math::pi<FloatType>(), y)
: x > 0 ? sprout::math::copysign(FloatType(0), y)
: sprout::math::signbit(x) ? sprout::math::copysign(sprout::math::pi<FloatType>(), y)
: sprout::math::copysign(FloatType(0), y)
: x == 0
? y < 0 ? -sprout::math::half_pi<FloatType>()
: sprout::math::half_pi<FloatType>()