From a85cbcf6ba9fcb556b5f5f43d8f63cd0e2644047 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sat, 19 Jan 2019 13:59:52 +0100 Subject: [PATCH] removed exp() and replaced hypot() with sqrt(norm()) --- complex.hh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/complex.hh b/complex.hh index ae090cc..16470e0 100644 --- a/complex.hh +++ b/complex.hh @@ -102,15 +102,15 @@ static constexpr Complex operator / (Complex a, Complex b) } template -static constexpr Complex exp(Complex a) +static constexpr T norm(Complex a) { - return Complex(exp(a.real()) * cos(a.imag()), exp(a.real()) * sin(a.imag())); + return a.real() * a.real() + a.imag() * a.imag(); } template static constexpr T abs(Complex a) { - return hypot(a.real(), a.imag()); + return sqrt(norm(a)); } template @@ -119,10 +119,4 @@ static constexpr T arg(Complex a) return atan2(a.imag(), a.real()); } -template -static constexpr T norm(Complex a) -{ - return a.real() * a.real() + a.imag() * a.imag(); -} - #endif