From 32f72555e1ca1978fbce5158b9503e6557c92b2a Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Sun, 13 Jul 2014 02:49:50 +0900 Subject: [PATCH] sprout::proj should return an argument as it is. sprout::proj should return the argument as it is unless the argument is infinite. --- sprout/complex/values.hpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/sprout/complex/values.hpp b/sprout/complex/values.hpp index 2d8aaec2..ef8f3eb4 100644 --- a/sprout/complex/values.hpp +++ b/sprout/complex/values.hpp @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include namespace sprout { template @@ -62,23 +65,12 @@ namespace sprout { conj(sprout::complex const& x) { return sprout::complex(x.real(), -x.imag()); } - namespace detail { - template - inline SPROUT_CONSTEXPR sprout::complex - proj_impl(sprout::complex const& x, T const& den) { - return sprout::complex( - T(2) * x.real() / den, - T(2) * x.imag() / den - ); - } - } // detail template inline SPROUT_CONSTEXPR sprout::complex proj(sprout::complex const& x) { - return sprout::detail::proj_impl( - x, - sprout::norm(x) + T(1) - ); + return sprout::isinf(x.real()) || sprout::isinf(x.imag()) + ? sprout::complex(sprout::numeric_limits::infinity(), sprout::copysign(T(), x.imag())) + : x; } template inline SPROUT_CONSTEXPR sprout::complex