Boost logo

Ublas :

Subject: Re: [ublas] How to understand the meanings of the member function index1() and index2() in the iterator of compressed_matrix
From: 魏华祎 (huayiwei1984_at_[hidden])
Date: 2010-11-12 20:52:08


 Hi, Rutger,

     Thanks for your help. In my program, I want to access the entries of
sparse matrix M as following:

typename ublas::compressed_matrix<double, ublas::row_major> ::iterator1 row;
   // Iterator over rows
 typename ublas::compressed_matrix<double, ublas::row_major> ::iterator2
entry; // Iterator over entries
 for (row = M.begin1();row != M.end1(); ++row) {
     unit& i1 = row.index1(); // the row index

     unit& j1 = row.index2(); // the column index for which one of the
elements of M ? Is it the beginning element of row?

     for (entry = row.begin(); entry != row.end(); ++entry) {

         unit& i2 = entry.index1(); // the row index of element pointed by
entry
         unit& j2 = entry.index2(); // the column index of element pointed
by entry

  }
}

Best

Huayi