diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index f3b0ccce4..44880dcf4 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -239,6 +239,9 @@ struct ei_qr_preconditioner_impl +EIGEN_DONT_INLINE Scalar zero() { return Scalar(0); } + template void jacobisvd_inf_nan() { + // all this function does is verify we don't iterate infinitely on nan/inf values + JacobiSVD svd; typedef typename MatrixType::Scalar Scalar; - Scalar some_inf = Scalar(1) / Scalar(0); + Scalar some_inf = Scalar(1) / zero(); + VERIFY((some_inf - some_inf) != (some_inf - some_inf)); svd.compute(MatrixType::Constant(10,10,some_inf), ComputeFullU | ComputeFullV); - Scalar some_nan = Scalar(0) / Scalar(0); + + Scalar some_nan = zero() / zero(); + VERIFY(some_nan != some_nan); svd.compute(MatrixType::Constant(10,10,some_nan), ComputeFullU | ComputeFullV); + MatrixType m = MatrixType::Zero(10,10); m(ei_random(0,9), ei_random(0,9)) = some_inf; svd.compute(m, ComputeFullU | ComputeFullV); + m = MatrixType::Zero(10,10); m(ei_random(0,9), ei_random(0,9)) = some_nan; svd.compute(m, ComputeFullU | ComputeFullV);