I have not tried this, but according to docs there are STL style iterators for accessing matrix elements:
// compute sum of positive matrix elements, iterator-based variant double sum=0; MatConstIterator_<double> it = M.begin<double>(), it_end = M.end<double>(); for(; it != it_end; ++it) sum += std::max(*it, 0.);
If they are implemented correctly, you can use them with std :: for_each something like this:
std::for_each(M.begin<double>(), M.end<double>(), [](double& e) { });
source share