mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
Fixed bad memory access in the SVD.
This commit is contained in:
parent
e0ea25fc21
commit
62bf04b339
@ -464,7 +464,7 @@ struct ei_solve_retval<SVD<_MatrixType>, Rhs>
|
||||
{
|
||||
Matrix<Scalar,MatrixType::RowsAtCompileTime,1> aux = dec().matrixU().adjoint() * rhs().col(j);
|
||||
|
||||
for (Index i = 0; i < dec().rows(); ++i)
|
||||
for (Index i = 0; i < dec().singularValues().size(); ++i)
|
||||
{
|
||||
Scalar si = dec().singularValues().coeff(i);
|
||||
if(si == RealScalar(0))
|
||||
@ -472,6 +472,8 @@ struct ei_solve_retval<SVD<_MatrixType>, Rhs>
|
||||
else
|
||||
aux.coeffRef(i) /= si;
|
||||
}
|
||||
aux.tail(aux.size() - dec().singularValues().size()).setZero();
|
||||
|
||||
const Index minsize = std::min(dec().rows(),dec().cols());
|
||||
dst.col(j).head(minsize) = aux.head(minsize);
|
||||
if(dec().cols()>dec().rows()) dst.col(j).tail(cols()-minsize).setZero();
|
||||
|
@ -51,7 +51,7 @@ template<typename MatrixType> void svd(const MatrixType& m)
|
||||
}
|
||||
|
||||
|
||||
if (rows==cols)
|
||||
if (rows>=cols)
|
||||
{
|
||||
if (ei_is_same_type<RealScalar,float>::ret)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user