Fix PPC rand and other failures.
diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp
index afe6894..6d7d0dd 100644
--- a/test/array_for_matrix.cpp
+++ b/test/array_for_matrix.cpp
@@ -19,12 +19,18 @@
Index cols = m.cols();
MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols);
-
ColVectorType cv1 = ColVectorType::Random(rows);
RowVectorType rv1 = RowVectorType::Random(cols);
Scalar s1 = internal::random<Scalar>(), s2 = internal::random<Scalar>();
+ // Prevent overflows for integer types.
+ if (Eigen::NumTraits<Scalar>::IsInteger) {
+ constexpr Scalar kMaxVal = Scalar(10000);
+ m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
+ m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
+ }
+
// scalar addition
VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array());
VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows, cols, s1) + m1);
diff --git a/test/main.h b/test/main.h
index 771725f..bce6736 100644
--- a/test/main.h
+++ b/test/main.h
@@ -176,11 +176,6 @@
#define DEBUG
#endif
-// bounds integer values for AltiVec
-#if defined(__ALTIVEC__) || defined(__VSX__)
-#define EIGEN_MAKING_DOCS
-#endif
-
#define DEFAULT_REPEAT 10
namespace Eigen {
diff --git a/test/product.h b/test/product.h
index 8d46846..31f577f 100644
--- a/test/product.h
+++ b/test/product.h
@@ -53,7 +53,7 @@
MatrixType::Flags & RowMajorBit ? ColMajor : RowMajor>
OtherMajorMatrixType;
- // Wwe want a tighter epsilon for not-approx tests. Otherwise, for certain
+ // We want a tighter epsilon for not-approx tests. Otherwise, for certain
// low-precision types (e.g. bfloat16), the bound ends up being relatively large
// (e.g. 0.12), causing flaky tests.
RealScalar not_approx_epsilon = RealScalar(0.1) * NumTraits<RealScalar>::dummy_precision();
@@ -69,6 +69,15 @@
ColSquareMatrixType square2 = ColSquareMatrixType::Random(cols, cols), res2 = ColSquareMatrixType::Random(cols, cols);
RowVectorType v1 = RowVectorType::Random(rows);
ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols);
+
+ // Prevent overflows for integer types.
+ if (Eigen::NumTraits<Scalar>::IsInteger) {
+ constexpr 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);
+ }
+
OtherMajorMatrixType tm1 = m1;
Scalar s1 = internal::random<Scalar>();
diff --git a/test/redux.cpp b/test/redux.cpp
index 8a8138d..872e44f 100644
--- a/test/redux.cpp
+++ b/test/redux.cpp
@@ -30,6 +30,12 @@
Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> m2(rows, rows);
m2.setRandom();
+ // Prevent overflows for integer types.
+ if (Eigen::NumTraits<Scalar>::IsInteger) {
+ constexpr Scalar kMaxVal = Scalar(10000);
+ m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
+ m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
+ }
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1));
VERIFY_IS_APPROX(
diff --git a/test/stl_iterators.cpp b/test/stl_iterators.cpp
index 7a62673..4b60e68 100644
--- a/test/stl_iterators.cpp
+++ b/test/stl_iterators.cpp
@@ -463,6 +463,13 @@
// check rows/cols iterators with STL algorithms
{
RowVectorType row = RowVectorType::Random(cols);
+ VectorType col = VectorType::Random(rows);
+ // Prevent overflows for integer types.
+ if (Eigen::NumTraits<Scalar>::IsInteger) {
+ constexpr Scalar kMaxVal = Scalar(1000);
+ row.array() = row.array() - kMaxVal * (row.array() / kMaxVal);
+ col.array() = col.array() - kMaxVal * (col.array() / kMaxVal);
+ }
A.rowwise() = row;
VERIFY(std::all_of(A.rowwise().begin(), A.rowwise().end(), [&row](typename ColMatrixType::RowXpr x) {
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
@@ -471,7 +478,6 @@
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
}));
- VectorType col = VectorType::Random(rows);
A.colwise() = col;
VERIFY(std::all_of(A.colwise().begin(), A.colwise().end(), [&col](typename ColMatrixType::ColXpr x) {
return internal::isApprox(x.squaredNorm(), col.squaredNorm());