UPDATE: I had a look around, figured I would try substituting a std::vector<std::vector<double> > for the uBLAS matrix<double>, still got the same error. So I started looking better into templates (no, I'm not quite done with vol2 of "Thinking in C++") and found out about typename. Seems to fix the problem.
I know I should probably post this to stackoverflow or the Boost/UBLAS mailing list, but I figure there are plenty of smart people here at slashdot.
Let's say you are using UBLAS from Boost and you want to implement a cumulative summing function for matrices. Here's what I think is a fairly straightforward way to do it:
// For boost::numeric::ublas::matrix<>.
// For std::partial_sum().
(const boost::numeric::ublas::matrix<T>& input_,
const bool& colWise_ = true)
using namespace boost::numeric::ublas;
using namespace std;
for (matrix<T>::iterator2 colIter = result_.begin2();
colIter < result_.end2();
for (matrix<T>::iterator1 rowIter = result_.begin1();
rowIter < result_.end1();
For now, I'm ignoring completely templatizing this to make the row-wise/column-wise distinction disappear in the code and focusing on just getting it working. Only it doesn't work; won't compile. Couldn't figure out why, but g++ kept saying it was expecting a ';' before colIter and rowIter. I had a hunch and replaced one of the iterator's 'T's with 'double' and it stopped complaining about that one. Am I missing something, or does UBLAS not implement iterators properly?What am I missing?