From b1eca55328436f9778254c6bbc8852910a0d3d2a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 3 Feb 2015 23:46:05 +0100 Subject: Use Ref<> to ensure that both x and b in Ax=b are compatible with Umfpack/SuperLU expectations --- Eigen/src/SuperLUSupport/SuperLUSupport.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'Eigen/src/SuperLUSupport') diff --git a/Eigen/src/SuperLUSupport/SuperLUSupport.h b/Eigen/src/SuperLUSupport/SuperLUSupport.h index ef73587a7..6de5b3dc5 100644 --- a/Eigen/src/SuperLUSupport/SuperLUSupport.h +++ b/Eigen/src/SuperLUSupport/SuperLUSupport.h @@ -627,8 +627,12 @@ void SuperLU::_solve_impl(const MatrixBase &b, MatrixBase m_sluFerr.resize(rhsCols); m_sluBerr.resize(rhsCols); - m_sluB = SluMatrix::Map(b.const_cast_derived()); - m_sluX = SluMatrix::Map(x.derived()); + + Ref > b_ref(b); + Ref > x_ref(x); + + m_sluB = SluMatrix::Map(b_ref.const_cast_derived()); + m_sluX = SluMatrix::Map(x_ref.const_cast_derived()); typename Rhs::PlainObject b_cpy; if(m_sluEqued!='N') @@ -651,6 +655,10 @@ void SuperLU::_solve_impl(const MatrixBase &b, MatrixBase &m_sluFerr[0], &m_sluBerr[0], &m_sluStat, &info, Scalar()); StatFree(&m_sluStat); + + if(&x.coeffRef(0) != x_ref.data()) + x = x_ref; + m_info = info==0 ? Success : NumericalIssue; } @@ -938,8 +946,12 @@ void SuperILU::_solve_impl(const MatrixBase &b, MatrixBase > b_ref(b); + Ref > x_ref(x); + + m_sluB = SluMatrix::Map(b_ref.const_cast_derived()); + m_sluX = SluMatrix::Map(x_ref.const_cast_derived()); typename Rhs::PlainObject b_cpy; if(m_sluEqued!='N') @@ -962,6 +974,9 @@ void SuperILU::_solve_impl(const MatrixBase &b, MatrixBase