mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 01:43:13 +08:00
Make test matrices for eigensolver/selfadjoint even more tricky
This commit is contained in:
parent
ef81730625
commit
e66caf48e8
@ -53,19 +53,35 @@ void svd_fill_random(MatrixType &m, int Option = 0)
|
||||
VT.setRandom();
|
||||
}
|
||||
|
||||
Matrix<Scalar,Dynamic,1> samples(7);
|
||||
samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits<RealScalar>::highest(), 1./NumTraits<RealScalar>::highest();
|
||||
|
||||
if(Option==Symmetric)
|
||||
{
|
||||
m = U * d.asDiagonal() * U.transpose();
|
||||
|
||||
// randomly nullify some rows/columns
|
||||
{
|
||||
Index count = internal::random<Index>(-1,1);
|
||||
Index count = internal::random<Index>(-diagSize,diagSize);
|
||||
for(Index k=0; k<count; ++k)
|
||||
{
|
||||
Index i = internal::random<Index>(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<Index>(0,m.size()-1);
|
||||
for(Index k=0; k<n; ++k)
|
||||
{
|
||||
Index i = internal::random<Index>(0,m.rows()-1);
|
||||
Index j = internal::random<Index>(0,m.cols()-1);
|
||||
m(j,i) = m(i,j) = samples(internal::random<Index>(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<Scalar,Dynamic,1> samples(7);
|
||||
samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits<RealScalar>::highest(), 1./NumTraits<RealScalar>::highest();
|
||||
Index n = internal::random<Index>(0,m.size()-1);
|
||||
for(Index i=0; i<n; ++i)
|
||||
m(internal::random<Index>(0,m.rows()-1), internal::random<Index>(0,m.cols()-1)) = samples(internal::random<Index>(0,6));
|
||||
m(internal::random<Index>(0,m.rows()-1), internal::random<Index>(0,m.cols()-1)) = samples(internal::random<Index>(0,samples.size()-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user