aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-09-27 18:30:53 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-09-27 18:30:53 +0200
commit683ea3c93fc2bf1c4724252c0eef70aa4b8ca2b0 (patch)
treece54c1dc30b46a3b47a8cdc7423a48bbda48990a /unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
parentac3ad9c1e7da56cebc4c8153513c3927b0f4ccce (diff)
fix superLU when the salver is called multiple times
Diffstat (limited to 'unsupported/Eigen/src/SparseExtra/SuperLUSupport.h')
-rw-r--r--unsupported/Eigen/src/SparseExtra/SuperLUSupport.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
index e512bfcd2..e485a9f50 100644
--- a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
+++ b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
@@ -208,8 +208,9 @@ struct SluMatrix : SuperMatrix
res.Mtype = SLU_TRU;
if (MatrixType::Flags & Lower)
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;
}
};
@@ -266,8 +267,8 @@ struct SluMatrixMapHelper<SparseMatrixBase<Derived> >
res.Mtype = SLU_TRU;
if (MatrixType::Flags & Lower)
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()
{
- if(m_sluL.Store)
- Destroy_SuperNode_Matrix(&m_sluL);
- if(m_sluU.Store)
- Destroy_CompCol_Matrix(&m_sluU);
+ clearFactors();
}
Derived& derived() { return *static_cast<Derived*>(this); }
@@ -400,8 +398,7 @@ class SuperLUBase
m_matrix = a;
m_sluA = internal::asSluMatrix(m_matrix);
- memset(&m_sluL,0,sizeof m_sluL);
- memset(&m_sluU,0,sizeof m_sluU);
+ clearFactors();
m_p.resize(size);
m_q.resize(size);
@@ -432,6 +429,20 @@ class SuperLUBase
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.
mutable LUMatrixType m_l;
mutable LUMatrixType m_u;
@@ -478,7 +489,7 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> >
SuperLU(const MatrixType& matrix) : Base()
{
- init();
+ Base::init();
compute(matrix);
}
@@ -494,6 +505,7 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> >
*/
void analyzePattern(const MatrixType& matrix)
{
+ init();
Base::analyzePattern(matrix);
}