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)); } } }