aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Yan Facai (颜发才) <facai.yan@gmail.com>2018-01-04 16:01:01 +0800
committerGravatar Yan Facai (颜发才) <facai.yan@gmail.com>2018-01-04 16:01:01 +0800
commit42a83346683861e7a58e8c9aa407eb001d56befa (patch)
treeff7eac4a6d232f3d827d5a8f3a3e0e6e5649d275 /Eigen/src
parentf9bdcea022e24bac4a66a937c37de92f7f22b9da (diff)
ENH: exp supports complex type for cuda
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/MathFunctions.h16
1 files changed, 16 insertions, 0 deletions
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<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>