Boost logo

Ublas :

From: Dima Sorkin (dsorkin_at_[hidden])
Date: 2006-07-10 04:53:20


Quoting Gunter Winkler:
Hi.
 I almost always use the following pattern:
With sparse colmunn major matrices:
 1) I iterate untill the needed column over the row no 0, with row iterator.
 2) then create the (dual) column iterator and iterate over the whole column.
(With row major matrices the pattern is dual to the described above.)

 So I would prefer to have (for example) a RowIterator_type
with the properties:
1) advancing it advances over whole columns
2) it has "matrix_column & RowIterator_type::operator * ()"
   i.e. gives whole columns.

Regards,
 Dima.

> Do you use the duality feature of ublas' matrix iterators?
>
> That means create an iterator1, advance a few rows, create an iterator2 for
> the current row, advance some columns, create an iterator1, advance to
> another row:
> matrix<double> A(n,n);
> const_iterator1 it1 = A.begin1();
> ++it1;
> const_iterator2 it2 = it1.begin();
> ++it2;
> const_iterator1 it1a = it2.begin();
> ...
>
> This feature is a major cause of the complexity of ublas' matrix iterators
> and
> the (strange & still undocumented) find{1,2}(...) functions.
>
> I wonder if anyone really _needs_ this behavior. For dense matrices one could
>
> easily use indices and for sparse matrices one should never iterate
> orthogonal to the storage layout.