aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2021-03-15 10:50:37 -0700
committerGravatar Antonio Sanchez <cantonios@google.com>2021-03-15 10:52:23 -0700
commit14487ed14e7e04cf1d84681274ae9d36fda23a39 (patch)
treec9765707d72551be2835ad06e8157ecbb1cc24c8 /test
parentb271110788827f77192d38acac536eb6fb617a0d (diff)
Add increment/decrement operators to Eigen::half.
This is for consistency with bfloat16, and to support initialization with `std::iota`.
Diffstat (limited to 'test')
-rw-r--r--test/half_float.cpp14
1 files changed, 14 insertions, 0 deletions
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()