diff options
author | David Tellenbach <david.tellenbach@me.com> | 2020-07-09 17:24:00 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-07-09 17:24:00 +0000 |
commit | ee4715ff488d5cf685820ad06374cbe7d509ac1a (patch) | |
tree | 29ffd26a21626eda74c101a8df497d323acfb8e3 /Eigen/src/Core/arch/Default/Half.h | |
parent | 8889a2c1c648f5dd1413dc2d94c2407c7ce1bd32 (diff) |
Fix test basic stuff
- Guard fundamental types that are not available pre C++11
- Separate subsequent angle brackets >> by spaces
- Allow casting of Eigen::half and Eigen::bfloat16 to complex types
Diffstat (limited to 'Eigen/src/Core/arch/Default/Half.h')
-rw-r--r-- | Eigen/src/Core/arch/Default/Half.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h index b84cfc7db..bbc15d463 100644 --- a/Eigen/src/Core/arch/Default/Half.h +++ b/Eigen/src/Core/arch/Default/Half.h @@ -36,7 +36,7 @@ #ifndef EIGEN_HALF_H #define EIGEN_HALF_H -#if __cplusplus > 199711L +#if EIGEN_HAS_CXX11 #define EIGEN_EXPLICIT_CAST(tgt_type) explicit operator tgt_type() #else #define EIGEN_EXPLICIT_CAST(tgt_type) operator tgt_type() @@ -48,6 +48,20 @@ namespace Eigen { struct half; +// explicit conversion operators are no available before C++11 so we first cast +// half to RealScalar rather than to std::complex<RealScalar> directly +#if !EIGEN_HAS_CXX11 +namespace internal { +template <typename RealScalar> +struct cast_impl<half, std::complex<RealScalar> > { + EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const half &x) + { + return static_cast<std::complex<RealScalar> >(static_cast<RealScalar>(x)); + } +}; +} // namespace internal +#endif // EIGEN_HAS_CXX11 + namespace half_impl { #if !defined(EIGEN_HAS_GPU_FP16) @@ -737,7 +751,6 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half __ldg(const Eigen::half* ptr) } #endif - #if defined(EIGEN_GPU_COMPILE_PHASE) namespace Eigen { namespace numext { |