From 7e6a1c129c201db4eff46f4dd68acdc7e935eaf2 Mon Sep 17 00:00:00 2001 From: Nathan Luehr Date: Mon, 19 Apr 2021 18:05:27 -0500 Subject: Device implementation of log for std::complex types. --- Eigen/src/Core/MathFunctionsImpl.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Eigen/src/Core/MathFunctionsImpl.h') diff --git a/Eigen/src/Core/MathFunctionsImpl.h b/Eigen/src/Core/MathFunctionsImpl.h index 0d3f317bb..4eaaaa784 100644 --- a/Eigen/src/Core/MathFunctionsImpl.h +++ b/Eigen/src/Core/MathFunctionsImpl.h @@ -184,6 +184,15 @@ EIGEN_DEVICE_FUNC std::complex complex_rsqrt(const std::complex& z) { : std::complex(numext::abs(y) / (2 * w * abs_z), y < zero ? woz : -woz ); } +template +EIGEN_DEVICE_FUNC std::complex complex_log(const std::complex& z) { + // Computes complex log. + T a = numext::abs(z); + EIGEN_USING_STD(atan2); + T b = atan2(z.imag(), z.real()); + return std::complex(numext::log(a), b); +} + } // end namespace internal } // end namespace Eigen -- cgit v1.2.3