Fix PPC rand and other failures.

This commit is contained in:
Antonio Sánchez
2024-02-05 20:07:15 +00:00
parent ebd13c3b14
commit 3ebaab8a63
6 changed files with 51 additions and 8 deletions

View File

@@ -30,6 +30,12 @@ void matrixRedux(const MatrixType& m) {
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(