method works without matrix having been built

This commit is contained in:
konstantinos katrioplas 2017-09-27 15:17:20 +03:00
parent 551c066ddd
commit f2af36d34f
1 changed files with 35 additions and 4 deletions

View File

@ -190,8 +190,39 @@ public:
CGAL_precondition(i < row_dimension()); CGAL_precondition(i < row_dimension());
CGAL_precondition(j < column_dimension()); CGAL_precondition(j < column_dimension());
NT val = m_matrix.coeffRef(i,j); NT val;
return val; if (m_is_already_built)
val = m_matrix.coeffRef(i,j);
else
{
// with lambda
auto pred = [i, j](const Triplet& triplet)
{
return triplet.row() == i && triplet.col() == j;
};
typename std::vector<Triplet>::iterator it;
it = std::find_if(m_triplets.begin(), m_triplets.end(), pred);
Triplet tr = *it;
val = tr.value();
/*
// with a functor
struct WantedTriplet
{
unsigned int i_, j_;
WantedTriplet(const unsigned int& i, const unsigned int& j) : i_(i), j_(j) {}
bool operator()(const Triplet& triplet) const
{
return triplet.row() == i_ && triplet.col() == j_;
}
};
typename std::vector<Triplet>::iterator it;
it = std::find_if(m_triplets.begin(), m_triplets.end(), WantedTriplet(i, j));
Triplet tr = *it;
val = tr.value();
*/
}
return val;
} }
void assemble_matrix() const void assemble_matrix() const