Added the ability to compute the absolute value of a complex number on GPU, as well as a test to catch the problem.

This commit is contained in:
Benoit Steiner
2016-09-12 13:46:13 -07:00
parent 8321dcce76
commit 5f50f12d2c
3 changed files with 89 additions and 0 deletions

View File

@@ -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>