From 14487ed14e7e04cf1d84681274ae9d36fda23a39 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Mon, 15 Mar 2021 10:50:37 -0700 Subject: Add increment/decrement operators to Eigen::half. This is for consistency with bfloat16, and to support initialization with `std::iota`. --- test/half_float.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/half_float.cpp b/test/half_float.cpp index b2c22197f..1cfe69e93 100644 --- a/test/half_float.cpp +++ b/test/half_float.cpp @@ -168,6 +168,20 @@ void test_arithmetic() VERIFY_IS_APPROX(float(half(1.0f) / half(3.0f)), 0.33333f); VERIFY_IS_EQUAL(float(-half(4096.0f)), -4096.0f); VERIFY_IS_EQUAL(float(-half(-4096.0f)), 4096.0f); + + half x(3); + half y = ++x; + VERIFY_IS_EQUAL(x, half(4)); + VERIFY_IS_EQUAL(y, half(4)); + y = --x; + VERIFY_IS_EQUAL(x, half(3)); + VERIFY_IS_EQUAL(y, half(3)); + y = x++; + VERIFY_IS_EQUAL(x, half(4)); + VERIFY_IS_EQUAL(y, half(3)); + y = x--; + VERIFY_IS_EQUAL(x, half(3)); + VERIFY_IS_EQUAL(y, half(4)); } void test_comparison() -- cgit v1.2.3