aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/arch/Default/BFloat16.h
diff options
context:
space:
mode:
authorGravatar David Tellenbach <david.tellenbach@me.com>2020-07-09 17:24:00 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-07-09 17:24:00 +0000
commitee4715ff488d5cf685820ad06374cbe7d509ac1a (patch)
tree29ffd26a21626eda74c101a8df497d323acfb8e3 /Eigen/src/Core/arch/Default/BFloat16.h
parent8889a2c1c648f5dd1413dc2d94c2407c7ce1bd32 (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/BFloat16.h')
-rw-r--r--Eigen/src/Core/arch/Default/BFloat16.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h
index 99ce99a27..561304f80 100644
--- a/Eigen/src/Core/arch/Default/BFloat16.h
+++ b/Eigen/src/Core/arch/Default/BFloat16.h
@@ -27,6 +27,20 @@ namespace Eigen {
struct bfloat16;
+// explicit conversion operators are no available before C++11 so we first cast
+// bfloat16 to RealScalar rather than to std::complex<RealScalar> directly
+#if !EIGEN_HAS_CXX11
+namespace internal {
+template <typename RealScalar>
+struct cast_impl<bfloat16, std::complex<RealScalar> > {
+ EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const bfloat16 &x)
+ {
+ return static_cast<std::complex<RealScalar> >(static_cast<RealScalar>(x));
+ }
+};
+} // namespace internal
+#endif // EIGEN_HAS_CXX11
+
namespace bfloat16_impl {
// Make our own __bfloat16_raw definition.