bug fix in inverse for 1x1 matrix,

some compilation fixes in sparse_solvers
This commit is contained in:
Gael Guennebaud
2009-07-27 18:09:56 +02:00
parent 94cc30180e
commit 5f3606bce9
4 changed files with 14 additions and 17 deletions

View File

@@ -309,9 +309,8 @@ struct ei_compute_inverse_with_check<MatrixType, 1>
{
static inline bool run(const MatrixType& matrix, MatrixType* result)
{
if( 0 == result->coeffRef(0,0) ) return false;
typedef typename MatrixType::Scalar Scalar;
if( matrix.coeff(0,0) == Scalar(0) ) return false;
result->coeffRef(0,0) = Scalar(1) / matrix.coeff(0,0);
return true;
}

View File

@@ -333,12 +333,12 @@ bool SparseLDLT<MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const
return false;
if (m_matrix.nonZeros()>0) // otherwise L==I
m_matrix.template triangular<LowerTriangular|UnitDiagBit>().solveInPlace(b);
m_matrix.template triangular<UnitLowerTriangular>().solveInPlace(b);
b = b.cwise() / m_diag;
// FIXME should be .adjoint() but it fails to compile...
if (m_matrix.nonZeros()>0) // otherwise L==I
m_matrix.transpose().template triangular<UpperTriangular|UnitDiagBit>().solveInPlace(b);
m_matrix.transpose().template triangular<UnitUpperTriangular>().solveInPlace(b);
return true;
}