From bd76d837e6eeaf82dd7db30435d49e939b4674af Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 31 Mar 2015 14:57:32 +0200 Subject: Fix sign of SuperLU::determinant --- Eigen/src/SuperLUSupport/SuperLUSupport.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Eigen/src/SuperLUSupport') diff --git a/Eigen/src/SuperLUSupport/SuperLUSupport.h b/Eigen/src/SuperLUSupport/SuperLUSupport.h index efdc6d046..b9d5e48fb 100644 --- a/Eigen/src/SuperLUSupport/SuperLUSupport.h +++ b/Eigen/src/SuperLUSupport/SuperLUSupport.h @@ -302,6 +302,7 @@ class SuperLUBase : public SparseSolverBase typedef Matrix Vector; typedef Matrix IntRowVectorType; typedef Matrix IntColVectorType; + typedef Map > PermutationMap; typedef SparseMatrix LUMatrixType; public: @@ -459,10 +460,11 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> > typedef typename Base::RealScalar RealScalar; typedef typename Base::StorageIndex StorageIndex; typedef typename Base::IntRowVectorType IntRowVectorType; - typedef typename Base::IntColVectorType IntColVectorType; + typedef typename Base::IntColVectorType IntColVectorType; + typedef typename Base::PermutationMap PermutationMap; typedef typename Base::LUMatrixType LUMatrixType; typedef TriangularView LMatrixType; - typedef TriangularView UMatrixType; + typedef TriangularView UMatrixType; public: using Base::_solve_impl; @@ -774,6 +776,8 @@ typename SuperLU::Scalar SuperLU::determinant() const det *= m_u.valuePtr()[lastId]; } } + if(PermutationMap(m_p.data(),m_p.size()).determinant()*PermutationMap(m_q.data(),m_q.size()).determinant()<0) + det = -det; if(m_sluEqued!='N') return det/m_sluRscale.prod()/m_sluCscale.prod(); else -- cgit v1.2.3