From 3ab8f482561581b9e718fe353c3f8a19d37ae14f Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Wed, 7 Feb 2024 04:50:11 +0000 Subject: [PATCH] fix tests when scalar is bfloat16, half --- test/array_for_matrix.cpp | 2 +- test/product.h | 2 +- test/redux.cpp | 4 ++-- test/stl_iterators.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 6d7d0dd4e..237ac6722 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp @@ -26,7 +26,7 @@ void array_for_matrix(const MatrixType& m) { // Prevent overflows for integer types. if (Eigen::NumTraits::IsInteger) { - constexpr Scalar kMaxVal = Scalar(10000); + Scalar kMaxVal = Scalar(10000); m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal); m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal); } diff --git a/test/product.h b/test/product.h index 31f577f4e..74f01b050 100644 --- a/test/product.h +++ b/test/product.h @@ -72,7 +72,7 @@ void product(const MatrixType& m) { // Prevent overflows for integer types. if (Eigen::NumTraits::IsInteger) { - constexpr Scalar kMaxVal = Scalar(10000); + Scalar kMaxVal = Scalar(10000); m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal); m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal); v1.array() = v1.array() - kMaxVal * (v1.array() / kMaxVal); diff --git a/test/redux.cpp b/test/redux.cpp index 872e44f69..42c269ae7 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -24,7 +24,7 @@ void matrixRedux(const MatrixType& m) { MatrixType m1 = MatrixType::Random(rows, cols); - // The entries of m1 are uniformly distributed in [0,1], so m1.prod() is very small. This may lead to test + // The entries of m1 are uniformly distributed in [-1,1), so m1.prod() is very small. This may lead to test // failures if we underflow into denormals. Thus, we scale so that entries are close to 1. MatrixType m1_for_prod = MatrixType::Ones(rows, cols) + RealScalar(0.2) * m1; @@ -32,7 +32,7 @@ void matrixRedux(const MatrixType& m) { m2.setRandom(); // Prevent overflows for integer types. if (Eigen::NumTraits::IsInteger) { - constexpr Scalar kMaxVal = Scalar(10000); + Scalar kMaxVal = Scalar(10000); m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal); m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal); } diff --git a/test/stl_iterators.cpp b/test/stl_iterators.cpp index 4b60e683a..fee8ef51a 100644 --- a/test/stl_iterators.cpp +++ b/test/stl_iterators.cpp @@ -466,7 +466,7 @@ void test_stl_iterators(int rows = Rows, int cols = Cols) { VectorType col = VectorType::Random(rows); // Prevent overflows for integer types. if (Eigen::NumTraits::IsInteger) { - constexpr Scalar kMaxVal = Scalar(1000); + Scalar kMaxVal = Scalar(1000); row.array() = row.array() - kMaxVal * (row.array() / kMaxVal); col.array() = col.array() - kMaxVal * (col.array() / kMaxVal); }