From 2a69290ddb165b7103c87ba8f5b257eca23f62aa Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 22 Sep 2016 15:52:23 -0700 Subject: [PATCH] Added a specialization of Eigen::numext::real and Eigen::numext::imag for std::complex to be used when compiling a cuda kernel. This is unfortunately necessary to be able to process complex numbers from a CUDA kernel on MacOS. --- Eigen/src/Core/MathFunctions.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 4d8f8970e..8d47fb8a4 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -97,6 +97,19 @@ struct real_default_impl template struct real_impl : real_default_impl {}; +#ifdef __CUDA_ARCH__ +template +struct real_impl > +{ + typedef T RealScalar; + EIGEN_DEVICE_FUNC + static inline T run(const std::complex& x) + { + return x.real(); + } +}; +#endif + template struct real_retval { @@ -132,6 +145,19 @@ struct imag_default_impl template struct imag_impl : imag_default_impl {}; +#ifdef __CUDA_ARCH__ +template +struct imag_impl > +{ + typedef T RealScalar; + EIGEN_DEVICE_FUNC + static inline T run(const std::complex& x) + { + return x.imag(); + } +}; +#endif + template struct imag_retval {