Boost logo

Boost Users :

From: Alexander Bell (a.bell_at_[hidden])
Date: 2006-05-31 11:18:53

Ed Johnson <ed_at_[hidden]> writes:

> Does anyone know how to recreate this example using the iterators?


using namespace boost::numeric::ublas;
typedef matrix<double> MatType;
MatType m(3,3);

for(MatType::iterator1 i1 = m.begin1(); i1!=m.end1(); ++i1)
  for(MatType::iterator2 i2 = i1.begin2(); i2!=i1.end2(); ++i2)
    *i2= ... // obviously you cannot assign the iterators here

untested - but the main idea is, that iterator1 accesses each row and iterator2
loops over the columns of the rows - this should work for all models of Matrix
(including sparse matrices)

Good luck,


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at