[eigen] Map and pointer freeing in unsupported/Eigen/src/SparseExtra/CholmodSupport.h |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Map and pointer freeing in unsupported/Eigen/src/SparseExtra/CholmodSupport.h
- From: Douglas Bates <bates@xxxxxxxxxxxxx>
- Date: Sat, 30 Jul 2011 17:06:07 -0500
- Cc: lme4-authors <lme4-authors@xxxxxxxxxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=VeGadQ4iLrVPD1Qnc+60xu9acQcVOARCvPETdbEPoMY=; b=fbdOcg2enXxtd7WbbaMwKnN3rmsfw3BzlOqw4MQjkbIdF9mFOi0sgyAxVn+KR7IgZ3 MBkOfSMYaQfekY1a7QuZAJa4a6cLvNK8jwB/Ae8/l/jZ70XrVsmLhWsBRSnuuutkB8v9 PAdmHk8AMbm8mgzn5to7+lqmfU0xuw2ECCn3Q=
/** \internal */
template<typename Rhs,typename Dest>
void _solve(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const
{
eigen_assert(m_factorizationIsOk && "The decomposition is not in
a valid state for solving, you must first call either compute() or
symbolic()/numeric()");
const Index size = m_cholmodFactor->n;
eigen_assert(size==b.rows());
// note: cd stands for Cholmod Dense
cholmod_dense b_cd = viewAsCholmod(b.const_cast_derived());
cholmod_dense* x_cd = cholmod_solve(m_solveType, m_cholmodFactor,
&b_cd, &m_cholmod);
if(!x_cd)
{
this->m_info = NumericalIssue;
}
// TODO optimize this copy by swapping when possible (be carreful
with alignment, etc.)
dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
cholmod_free_dense(&x_cd, &m_cholmod);
}
It appears to me that the last two lines change the dest argument to
map the storage from the (x_cd->x) pointer then free that storage
(cholmod_free_dense frees all the storage pointed to by the members of
the cholmod_dense struct).