ENH: exp supports complex type for cuda

This commit is contained in:
Yan Facai (颜发才) 2018-01-04 16:01:01 +08:00
parent f9bdcea022
commit 42a8334668

View File

@ -1289,6 +1289,22 @@ float exp(const float &x) { return ::expf(x); }
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
double exp(const double &x) { return ::exp(x); } 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 #endif
template<typename Scalar> template<typename Scalar>