Fix two numerical issues in unit tests.

This commit is contained in:
Gael Guennebaud 2013-02-27 08:07:18 +01:00
parent 61a2995d03
commit 455e6e38b6
2 changed files with 6 additions and 6 deletions

View File

@ -42,10 +42,10 @@ template<typename MatrixType> void array_for_matrix(const MatrixType& m)
VERIFY_IS_APPROX(m3, (m1.array() - s1).matrix());
// reductions
VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum().sum() - m1.sum(), m1.cwiseAbs().maxCoeff());
VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum().sum() - m1.sum(), m1.cwiseAbs().maxCoeff());
VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum() + m2.colwise().sum() - (m1+m2).colwise().sum(), (m1+m2).cwiseAbs().maxCoeff());
VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum() - m2.rowwise().sum() - (m1-m2).rowwise().sum(), (m1-m2).cwiseAbs().maxCoeff());
VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum().sum() - m1.sum(), m1.norm());
VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum().sum() - m1.sum(), m1.norm());
VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum() + m2.colwise().sum() - (m1+m2).colwise().sum(), (m1+m2).norm());
VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum() - m2.rowwise().sum() - (m1-m2).rowwise().sum(), (m1-m2).norm());
VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar>()));
// vector-wise ops

View File

@ -42,7 +42,7 @@ template<typename MatrixType> void ref_matrix(const MatrixType& m)
typedef Ref<const DynMatrixType> ConstRefDynMat;
typedef Ref<RealDynMatrixType , 0, Stride<Dynamic,Dynamic> > RefRealMatWithStride;
Index rows = m.rows(), cols = m.cols(), size = rows*cols;
Index rows = m.rows(), cols = m.cols();
MatrixType m1 = MatrixType::Random(rows, cols),
m2 = m1;
@ -136,7 +136,7 @@ template<typename VectorType> void ref_vector(const VectorType& m)
VERIFY_IS_EQUAL(mat1, mat2);
rm5.noalias() = rm4.transpose() * mat3;
mat2.row(i) = v2.real().transpose() * mat3;
VERIFY_IS_EQUAL(mat1, mat2);
VERIFY_IS_APPROX(mat1, mat2);
}
template<typename PlainObjectType> void check_const_correctness(const PlainObjectType&)