mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-22 01:29:35 +08:00
Check for positive definiteness in SimplicialLLT
This commit is contained in:
parent
5e4dfa4a09
commit
362fcabc44
@ -764,18 +764,24 @@ void SimplicialCholeskyBase<Derived>::factorize(const MatrixType& a)
|
|||||||
++m_nonZerosPerCol[i]; /* increment count of nonzeros in col i */
|
++m_nonZerosPerCol[i]; /* increment count of nonzeros in col i */
|
||||||
}
|
}
|
||||||
if(DoLDLt)
|
if(DoLDLt)
|
||||||
|
{
|
||||||
m_diag[k] = d;
|
m_diag[k] = d;
|
||||||
|
if(d == Scalar(0))
|
||||||
|
{
|
||||||
|
ok = false; /* failure, D(k,k) is zero */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Index p = Lp[k]+m_nonZerosPerCol[k]++;
|
Index p = Lp[k]+m_nonZerosPerCol[k]++;
|
||||||
Li[p] = k ; /* store L(k,k) = sqrt (d) in column k */
|
Li[p] = k ; /* store L(k,k) = sqrt (d) in column k */
|
||||||
|
if(d <= Scalar(0)) {
|
||||||
|
ok = false; /* failure, matrix is not positive definite */
|
||||||
|
break;
|
||||||
|
}
|
||||||
Lx[p] = internal::sqrt(d) ;
|
Lx[p] = internal::sqrt(d) ;
|
||||||
}
|
}
|
||||||
if(d == Scalar(0))
|
|
||||||
{
|
|
||||||
ok = false; /* failure, D(k,k) is zero */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_info = ok ? Success : NumericalIssue;
|
m_info = ok ? Success : NumericalIssue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user