diff options
author | Nathan Luehr <nluehr@nvidia.com> | 2021-04-19 18:05:27 -0500 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2021-05-11 22:02:21 +0000 |
commit | 7e6a1c129c201db4eff46f4dd68acdc7e935eaf2 (patch) | |
tree | ce3662dea2b4b5329e89f7dc75f7bb1918bbff9b /Eigen/src/Core/MathFunctionsImpl.h | |
parent | 6753f0f197e7b8a8019e82e7b144ac0281d6a7f1 (diff) |
Device implementation of log for std::complex types.
Diffstat (limited to 'Eigen/src/Core/MathFunctionsImpl.h')
-rw-r--r-- | Eigen/src/Core/MathFunctionsImpl.h | 9 |
1 files changed, 9 insertions, 0 deletions
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<T> complex_rsqrt(const std::complex<T>& z) { : std::complex<T>(numext::abs(y) / (2 * w * abs_z), y < zero ? woz : -woz ); } +template<typename T> +EIGEN_DEVICE_FUNC std::complex<T> complex_log(const std::complex<T>& z) { + // Computes complex log. + T a = numext::abs(z); + EIGEN_USING_STD(atan2); + T b = atan2(z.imag(), z.real()); + return std::complex<T>(numext::log(a), b); +} + } // end namespace internal } // end namespace Eigen |