mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 11:49:02 +08:00
add an assertion in sparse LLT for invalid input matrix
This commit is contained in:
parent
adf5104bae
commit
ff3a3209ca
@ -147,6 +147,8 @@ void SparseLLT<MatrixType,Backend>::compute(const MatrixType& a)
|
|||||||
// init with current matrix a
|
// init with current matrix a
|
||||||
{
|
{
|
||||||
typename MatrixType::InnerIterator it(a,j);
|
typename MatrixType::InnerIterator it(a,j);
|
||||||
|
ei_assert(it.index()==j &&
|
||||||
|
"matrix must has non zero diagonal entries and only the lower triangular part must be stored");
|
||||||
++it; // skip diagonal element
|
++it; // skip diagonal element
|
||||||
for (; it; ++it)
|
for (; it; ++it)
|
||||||
tempVector.coeffRef(it.index()) = it.value();
|
tempVector.coeffRef(it.index()) = it.value();
|
||||||
@ -189,15 +191,15 @@ bool SparseLLT<MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const
|
|||||||
const int size = m_matrix.rows();
|
const int size = m_matrix.rows();
|
||||||
ei_assert(size==b.rows());
|
ei_assert(size==b.rows());
|
||||||
|
|
||||||
m_matrix.solveTriangularInPlace(b);
|
m_matrix.template triangular<LowerTriangular>.solveInPlace(b);
|
||||||
// FIXME should be simply .adjoint() but it fails to compile...
|
// FIXME should be simply .adjoint() but it fails to compile...
|
||||||
if (NumTraits<Scalar>::IsComplex)
|
if (NumTraits<Scalar>::IsComplex)
|
||||||
{
|
{
|
||||||
CholMatrixType aux = m_matrix.conjugate();
|
CholMatrixType aux = m_matrix.conjugate();
|
||||||
aux.transpose().solveTriangularInPlace(b);
|
aux.transpose().template triangular<UpperTriangular>.solveInPlace(b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_matrix.transpose().solveTriangularInPlace(b);
|
m_matrix.transpose().template triangular<UpperTriangular>.solveInPlace(b);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user