mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-25 22:34:30 +08:00
fix LU and QR solve when rank==0, fix LLT when the matrix is purely 0
This commit is contained in:
parent
468863f3a0
commit
c44bbabdcc
@ -136,7 +136,7 @@ void LLT<MatrixType>::compute(const MatrixType& a)
|
|||||||
for (int j = 1; j < size; ++j)
|
for (int j = 1; j < size; ++j)
|
||||||
{
|
{
|
||||||
x = ei_real(a.coeff(j,j)) - m_matrix.row(j).start(j).squaredNorm();
|
x = ei_real(a.coeff(j,j)) - m_matrix.row(j).start(j).squaredNorm();
|
||||||
if (x < cutoff)
|
if (x <= cutoff)
|
||||||
{
|
{
|
||||||
m_isPositiveDefinite = false;
|
m_isPositiveDefinite = false;
|
||||||
continue;
|
continue;
|
||||||
|
@ -515,9 +515,10 @@ bool LU<MatrixType>::solve(
|
|||||||
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
|
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
if(m_rank>0)
|
||||||
.template marked<UpperTriangular>()
|
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||||
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
.template marked<UpperTriangular>()
|
||||||
|
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
result->resize(m_lu.cols(), b.cols());
|
result->resize(m_lu.cols(), b.cols());
|
||||||
|
@ -276,6 +276,9 @@ bool QR<MatrixType>::solve(
|
|||||||
// Q^T without explicitly forming matrixQ(). Investigate.
|
// Q^T without explicitly forming matrixQ(). Investigate.
|
||||||
*result = matrixQ().transpose()*b;
|
*result = matrixQ().transpose()*b;
|
||||||
|
|
||||||
|
if(m_rank==0)
|
||||||
|
return result.isZero();
|
||||||
|
|
||||||
if(!isSurjective())
|
if(!isSurjective())
|
||||||
{
|
{
|
||||||
// is result is in the image of R ?
|
// is result is in the image of R ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user