From e66caf48e871f4c63460d6632605e055bde14156 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 12 May 2015 18:44:46 +0200 Subject: [PATCH] Make test matrices for eigensolver/selfadjoint even more tricky --- test/svd_fill.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test/svd_fill.h b/test/svd_fill.h index aa75326d9..7e44b3d05 100644 --- a/test/svd_fill.h +++ b/test/svd_fill.h @@ -53,19 +53,35 @@ void svd_fill_random(MatrixType &m, int Option = 0) VT.setRandom(); } + Matrix samples(7); + samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits::highest(), 1./NumTraits::highest(); + if(Option==Symmetric) { m = U * d.asDiagonal() * U.transpose(); // randomly nullify some rows/columns { - Index count = internal::random(-1,1); + Index count = internal::random(-diagSize,diagSize); for(Index k=0; k(0,diagSize-1); m.row(i).setZero(); m.col(i).setZero(); } + if(count<0) + // (partly) cancel some coeffs + if(!(dup && unit_uv)) + { + + Index n = internal::random(0,m.size()-1); + for(Index k=0; k(0,m.rows()-1); + Index j = internal::random(0,m.cols()-1); + m(j,i) = m(i,j) = samples(internal::random(0,samples.size()-1)); + } + } } } else @@ -74,11 +90,9 @@ void svd_fill_random(MatrixType &m, int Option = 0) // (partly) cancel some coeffs if(!(dup && unit_uv)) { - Matrix samples(7); - samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits::highest(), 1./NumTraits::highest(); Index n = internal::random(0,m.size()-1); for(Index i=0; i(0,m.rows()-1), internal::random(0,m.cols()-1)) = samples(internal::random(0,6)); + m(internal::random(0,m.rows()-1), internal::random(0,m.cols()-1)) = samples(internal::random(0,samples.size()-1)); } } }