aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-09-12 13:46:13 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-09-12 13:46:13 -0700
commit5f50f12d2c2eb721906f9974f4778d759376c2ef (patch)
tree5d98e2d1562dceab3e4c9a7b657cfe84a48cc47d /Eigen
parent8321dcce764de99235a86dd0d562e4c8de107e74 (diff)
Added the ability to compute the absolute value of a complex number on GPU, as well as a test to catch the problem.
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/MathFunctions.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
index a18b79408..bf3044b96 100644
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -1046,6 +1046,16 @@ float abs(const float &x) { return ::fabsf(x); }
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
double abs(const double &x) { return ::fabs(x); }
+
+template <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
+float abs(const std::complex<float>& x) {
+ return ::hypotf(real(x), imag(x));
+}
+
+template <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
+double abs(const std::complex<double>& x) {
+ return ::hypot(real(x), imag(x));
+}
#endif
template<typename T>