mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
fix superLU when the salver is called multiple times
This commit is contained in:
parent
ac3ad9c1e7
commit
683ea3c93f
@ -208,8 +208,9 @@ struct SluMatrix : SuperMatrix
|
|||||||
res.Mtype = SLU_TRU;
|
res.Mtype = SLU_TRU;
|
||||||
if (MatrixType::Flags & Lower)
|
if (MatrixType::Flags & Lower)
|
||||||
res.Mtype = SLU_TRL;
|
res.Mtype = SLU_TRL;
|
||||||
if (MatrixType::Flags & SelfAdjoint)
|
|
||||||
eigen_assert(false && "SelfAdjoint matrix shape not supported by SuperLU");
|
eigen_assert(((MatrixType::Flags & SelfAdjoint)==0) && "SelfAdjoint matrix shape not supported by SuperLU");
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -266,8 +267,8 @@ struct SluMatrixMapHelper<SparseMatrixBase<Derived> >
|
|||||||
res.Mtype = SLU_TRU;
|
res.Mtype = SLU_TRU;
|
||||||
if (MatrixType::Flags & Lower)
|
if (MatrixType::Flags & Lower)
|
||||||
res.Mtype = SLU_TRL;
|
res.Mtype = SLU_TRL;
|
||||||
if (MatrixType::Flags & SelfAdjoint)
|
|
||||||
eigen_assert(false && "SelfAdjoint matrix shape not supported by SuperLU");
|
eigen_assert(((MatrixType::Flags & SelfAdjoint)==0) && "SelfAdjoint matrix shape not supported by SuperLU");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -315,10 +316,7 @@ class SuperLUBase
|
|||||||
|
|
||||||
~SuperLUBase()
|
~SuperLUBase()
|
||||||
{
|
{
|
||||||
if(m_sluL.Store)
|
clearFactors();
|
||||||
Destroy_SuperNode_Matrix(&m_sluL);
|
|
||||||
if(m_sluU.Store)
|
|
||||||
Destroy_CompCol_Matrix(&m_sluU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Derived& derived() { return *static_cast<Derived*>(this); }
|
Derived& derived() { return *static_cast<Derived*>(this); }
|
||||||
@ -400,8 +398,7 @@ class SuperLUBase
|
|||||||
m_matrix = a;
|
m_matrix = a;
|
||||||
|
|
||||||
m_sluA = internal::asSluMatrix(m_matrix);
|
m_sluA = internal::asSluMatrix(m_matrix);
|
||||||
memset(&m_sluL,0,sizeof m_sluL);
|
clearFactors();
|
||||||
memset(&m_sluU,0,sizeof m_sluU);
|
|
||||||
|
|
||||||
m_p.resize(size);
|
m_p.resize(size);
|
||||||
m_q.resize(size);
|
m_q.resize(size);
|
||||||
@ -432,6 +429,20 @@ class SuperLUBase
|
|||||||
|
|
||||||
void extractData() const;
|
void extractData() const;
|
||||||
|
|
||||||
|
void clearFactors()
|
||||||
|
{
|
||||||
|
if(m_sluL.Store)
|
||||||
|
Destroy_SuperNode_Matrix(&m_sluL);
|
||||||
|
if(m_sluU.Store)
|
||||||
|
Destroy_CompCol_Matrix(&m_sluU);
|
||||||
|
|
||||||
|
m_sluL.Store = 0;
|
||||||
|
m_sluU.Store = 0;
|
||||||
|
|
||||||
|
memset(&m_sluL,0,sizeof m_sluL);
|
||||||
|
memset(&m_sluU,0,sizeof m_sluU);
|
||||||
|
}
|
||||||
|
|
||||||
// cached data to reduce reallocation, etc.
|
// cached data to reduce reallocation, etc.
|
||||||
mutable LUMatrixType m_l;
|
mutable LUMatrixType m_l;
|
||||||
mutable LUMatrixType m_u;
|
mutable LUMatrixType m_u;
|
||||||
@ -478,7 +489,7 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> >
|
|||||||
|
|
||||||
SuperLU(const MatrixType& matrix) : Base()
|
SuperLU(const MatrixType& matrix) : Base()
|
||||||
{
|
{
|
||||||
init();
|
Base::init();
|
||||||
compute(matrix);
|
compute(matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,6 +505,7 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> >
|
|||||||
*/
|
*/
|
||||||
void analyzePattern(const MatrixType& matrix)
|
void analyzePattern(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
|
init();
|
||||||
Base::analyzePattern(matrix);
|
Base::analyzePattern(matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,10 @@ template<typename LUSolver> void sparse_lu(LUSolver& lu)
|
|||||||
DenseVector refX(size), x(size);
|
DenseVector refX(size), x(size);
|
||||||
|
|
||||||
initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag, &zeroCoords, &nonzeroCoords);
|
initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag, &zeroCoords, &nonzeroCoords);
|
||||||
|
check_slu(lu, m2, b, refMat2, b);
|
||||||
|
|
||||||
|
refMat2.setZero();
|
||||||
|
m2.setZero();
|
||||||
|
initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag, &zeroCoords, &nonzeroCoords);
|
||||||
check_slu(lu, m2, b, refMat2, b);
|
check_slu(lu, m2, b, refMat2, b);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user