diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-03-31 14:57:32 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-03-31 14:57:32 +0200 |
commit | bd76d837e6eeaf82dd7db30435d49e939b4674af (patch) | |
tree | 67d61bc87f242a8c958e2e6794d02f180a501772 /Eigen/src/SuperLUSupport | |
parent | 35d3053d55fdd7e1ff7c765381ff43b02346d542 (diff) |
Fix sign of SuperLU::determinant
Diffstat (limited to 'Eigen/src/SuperLUSupport')
-rw-r--r-- | Eigen/src/SuperLUSupport/SuperLUSupport.h | 8 |
1 files changed, 6 insertions, 2 deletions
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<Derived> typedef Matrix<Scalar,Dynamic,1> Vector; typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType; typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType; + typedef Map<PermutationMatrix<Dynamic,Dynamic,int> > PermutationMap; typedef SparseMatrix<Scalar> 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<LUMatrixType, Lower|UnitDiag> LMatrixType; - typedef TriangularView<LUMatrixType, Upper> UMatrixType; + typedef TriangularView<LUMatrixType, Upper> UMatrixType; public: using Base::_solve_impl; @@ -774,6 +776,8 @@ typename SuperLU<MatrixType>::Scalar SuperLU<MatrixType>::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 |