aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
diff options
context:
space:
mode:
authorGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2013-05-13 13:04:12 +0200
committerGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2013-05-13 13:04:12 +0200
commit122b16d841eac3b0c5f6cf1a1d6ee6616723dc08 (patch)
treea81432b38de5998e1c08120688391cd55f2dbe85 /Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
parent43bb94236589168914f9e3cf742f7eaa188c5dba (diff)
fix memory leak from Cholmod data in SPQR support
Diffstat (limited to 'Eigen/src/SPQRSupport/SuiteSparseQRSupport.h')
-rw-r--r--Eigen/src/SPQRSupport/SuiteSparseQRSupport.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
index 0ffb894f6..ff304a546 100644
--- a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
+++ b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
@@ -64,7 +64,7 @@ class SPQR
typedef PermutationMatrix<Dynamic, Dynamic> PermutationType;
public:
SPQR()
- : m_ordering(SPQR_ORDERING_DEFAULT),
+ : m_ordering(SPQR_ORDERING_AMD),
m_allow_tol(SPQR_DEFAULT_TOL),
m_tolerance (NumTraits<Scalar>::epsilon())
{
@@ -72,7 +72,7 @@ class SPQR
}
SPQR(const _MatrixType& matrix)
- : m_ordering(SPQR_ORDERING_DEFAULT),
+ : m_ordering(SPQR_ORDERING_AMD),
m_allow_tol(SPQR_DEFAULT_TOL),
m_tolerance (NumTraits<Scalar>::epsilon())
{
@@ -83,10 +83,12 @@ class SPQR
~SPQR()
{
// Calls SuiteSparseQR_free()
- cholmod_free_sparse(&m_H, &m_cc);
- cholmod_free_dense(&m_HTau, &m_cc);
- delete[] m_E;
- delete[] m_HPinv;
+ cholmod_l_free_sparse(&m_H, &m_cc);
+ cholmod_l_free_sparse(&m_cR, &m_cc);
+ cholmod_l_free_dense(&m_HTau, &m_cc);
+ std::free(m_E);
+ std::free(m_HPinv);
+ cholmod_l_finish(&m_cc);
}
void compute(const _MatrixType& matrix)
{
@@ -244,7 +246,7 @@ struct SPQR_QProduct : ReturnByValue<SPQR_QProduct<SPQRType,Derived> >
y_cd = viewAsCholmod(m_other.const_cast_derived());
x_cd = SuiteSparseQR_qmult<Scalar>(method, m_spqr.m_H, m_spqr.m_HTau, m_spqr.m_HPinv, &y_cd, cc);
res = Matrix<Scalar,ResType::RowsAtCompileTime,ResType::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x), x_cd->nrow, x_cd->ncol);
- cholmod_free_dense(&x_cd, cc);
+ cholmod_l_free_dense(&x_cd, cc);
}
const SPQRType& m_spqr;
const Derived& m_other;
@@ -301,4 +303,4 @@ struct solve_retval<SPQR<_MatrixType>, Rhs>
} // end namespace internal
}// End namespace Eigen
-#endif \ No newline at end of file
+#endif