From 3ddc0974ce42d7cdd9161dda2a9558d6800d12c8 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Fri, 2 Apr 2021 22:06:27 +0000 Subject: Fix two bugs in commit --- test/AnnoyingScalar.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'test/AnnoyingScalar.h') diff --git a/test/AnnoyingScalar.h b/test/AnnoyingScalar.h index 889e6cc86..9f8d52796 100644 --- a/test/AnnoyingScalar.h +++ b/test/AnnoyingScalar.h @@ -76,20 +76,20 @@ class AnnoyingScalar AnnoyingScalar operator/(const AnnoyingScalar& other) const { return AnnoyingScalar((*v)/(*other.v)); } - + AnnoyingScalar& operator+=(const AnnoyingScalar& other) { *v += *other.v; return *this; } AnnoyingScalar& operator-=(const AnnoyingScalar& other) { *v -= *other.v; return *this; } AnnoyingScalar& operator*=(const AnnoyingScalar& other) { *v *= *other.v; return *this; } AnnoyingScalar& operator/=(const AnnoyingScalar& other) { *v /= *other.v; return *this; } AnnoyingScalar& operator= (const AnnoyingScalar& other) { *v = *other.v; return *this; } - + bool operator==(const AnnoyingScalar& other) const { return *v == *other.v; } bool operator!=(const AnnoyingScalar& other) const { return *v != *other.v; } bool operator<=(const AnnoyingScalar& other) const { return *v <= *other.v; } bool operator< (const AnnoyingScalar& other) const { return *v < *other.v; } bool operator>=(const AnnoyingScalar& other) const { return *v >= *other.v; } bool operator> (const AnnoyingScalar& other) const { return *v > *other.v; } - + float* v; float data; static int instances; @@ -136,12 +136,23 @@ struct NumTraits : NumTraits template<> inline AnnoyingScalar test_precision() { return test_precision(); } +namespace numext { +template<> +EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +bool (isfinite)(const AnnoyingScalar& x) { + return (numext::isfinite)(*x.v); +} +} + namespace internal { + template<> AnnoyingScalar pcmp_eq(const AnnoyingScalar& x, const AnnoyingScalar& y) + { return AnnoyingScalar(pcmp_eq(*x.v, *y.v)); } + template<> AnnoyingScalar pselect(const AnnoyingScalar& cond, const AnnoyingScalar& x, const AnnoyingScalar& y) + { return numext::equal_strict(*cond.v, 0.f) ? y : x; } template<> double cast(const AnnoyingScalar& x) { return double(*x.v); } template<> float cast(const AnnoyingScalar& x) { return *x.v; } } - -} +} // namespace Eigen AnnoyingScalar get_test_precision(const AnnoyingScalar&) { return Eigen::test_precision(); } -- cgit v1.2.3