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