aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-09-24 14:20:31 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-09-24 14:20:31 +0200
commitb2988375e83c0fa7af7eb1435ad2011d779b4638 (patch)
treeee211a6424039b1372aaf1f25f1399f912aab9e9 /unsupported
parent6799fabba95ef475d5da3435025b811c5a2516ff (diff)
fix a couple of issues in SuperLU support (memory and determinant)
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Eigen/src/SparseExtra/SuperLUSupport.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
index c4292c283..e512bfcd2 100644
--- a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
+++ b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h
@@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -315,8 +315,10 @@ class SuperLUBase
~SuperLUBase()
{
- Destroy_SuperNode_Matrix(&m_sluL);
- Destroy_CompCol_Matrix(&m_sluU);
+ if(m_sluL.Store)
+ Destroy_SuperNode_Matrix(&m_sluL);
+ if(m_sluU.Store)
+ Destroy_CompCol_Matrix(&m_sluU);
}
Derived& derived() { return *static_cast<Derived*>(this); }
@@ -424,6 +426,8 @@ class SuperLUBase
{
m_info = InvalidInput;
m_isInitialized = false;
+ m_sluL.Store = 0;
+ m_sluU.Store = 0;
}
void extractData() const;
@@ -441,8 +445,8 @@ class SuperLUBase
mutable SuperLUStat_t m_sluStat;
mutable superlu_options_t m_sluOptions;
mutable std::vector<int> m_sluEtree;
- mutable std::vector<RealScalar> m_sluRscale, m_sluCscale;
- mutable std::vector<RealScalar> m_sluFerr, m_sluBerr;
+ mutable Matrix<RealScalar,Dynamic,1> m_sluRscale, m_sluCscale;
+ mutable Matrix<RealScalar,Dynamic,1> m_sluFerr, m_sluBerr;
mutable char m_sluEqued;
mutable ComputationInfo m_info;
@@ -746,13 +750,11 @@ void SuperLUBase<MatrixType,Derived>::extractData() const
template<typename MatrixType>
typename SuperLU<MatrixType>::Scalar SuperLU<MatrixType>::determinant() const
{
- eigen_assert((!NumTraits<Scalar>::IsComplex) && "This function is not implemented for complex yet");
eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for computing the determinant, you must first call either compute() or analyzePattern()/factorize()");
if (m_extractedDataAreDirty)
this->extractData();
- // FIXME perhaps we have to take into account the scale factors m_sluRscale and m_sluCscale ???
Scalar det = Scalar(1);
for (int j=0; j<m_u.cols(); ++j)
{
@@ -761,12 +763,13 @@ typename SuperLU<MatrixType>::Scalar SuperLU<MatrixType>::determinant() const
int lastId = m_u._outerIndexPtr()[j+1]-1;
eigen_assert(m_u._innerIndexPtr()[lastId]<=j);
if (m_u._innerIndexPtr()[lastId]==j)
- {
det *= m_u._valuePtr()[lastId];
- }
}
}
- return det;
+ if(m_sluEqued!='N')
+ return det/m_sluRscale.prod()/m_sluCscale.prod();
+ else
+ return det;
}
#ifdef EIGEN_SUPERLU_HAS_ILU