Merged in facaiy/eigen/ENH/exp_support_complex_for_gpu (pull request PR-359) ENH: exp supports complex type for cuda
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 5ba5293..1b864a4 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h
@@ -1289,6 +1289,22 @@ template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp(const double &x) { return ::exp(x); } + +template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +std::complex<float> exp(const std::complex<float>& x) { + auto com = ::expf(x.real()); + auto res_real = com * ::cosf(x.imag()); + auto res_imag = com * ::sinf(x.imag()); + return std::complex<float>(res_real, res_imag); +} + +template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +std::complex<double> exp(const std::complex<double>& x) { + auto com = ::exp(x.real()); + auto res_real = com * ::cos(x.imag()); + auto res_imag = com * ::sin(x.imag()); + return std::complex<double>(res_real, res_imag); +} #endif template<typename Scalar>