From 42a83346683861e7a58e8c9aa407eb001d56befa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Thu, 4 Jan 2018 16:01:01 +0800 Subject: [PATCH] ENH: exp supports complex type for cuda --- Eigen/src/Core/MathFunctions.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 5ba5293a0..1b864a405 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -1289,6 +1289,22 @@ float exp(const float &x) { return ::expf(x); } template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp(const double &x) { return ::exp(x); } + +template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +std::complex exp(const std::complex& x) { + auto com = ::expf(x.real()); + auto res_real = com * ::cosf(x.imag()); + auto res_imag = com * ::sinf(x.imag()); + return std::complex(res_real, res_imag); +} + +template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +std::complex exp(const std::complex& x) { + auto com = ::exp(x.real()); + auto res_real = com * ::cos(x.imag()); + auto res_imag = com * ::sin(x.imag()); + return std::complex(res_real, res_imag); +} #endif template