[Home]UBLAS Matrix Iterators

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Showing revision 2

current state

As of today (2006-07-06) ublas' matrix iterators look like this:

const_iterator1 moves from one row to another for a fixed column.

const_iterator2 moves from one column to another for a fixed row.

One can always switch from one iterator to the other (called dual iterator) by calling the begin() or end() member function. Both iterators store the current row and column index and have to implement the movement in both fast (inner loop) and slow (outer loop) direction. Thus the code is complex and the memory footprint is not optimal. On the other hand the design of generic algorithms is easy because you can arbitrarily choose which iterator is outer or inner loop (but this is typically a bad design).

quick survey

Does anyone use the duality feature?

edit by Gunter: Up to now I got only negative answers.

ideas for a better design

Drop the strong duality and provide a major (outer loop) and minor (inner loop) iterator. The major iterator could always be a random access dense iterator that only stores an index. The minor iterator holds a copy of the major index and can use an optimized way to traverse along matrix elements. The minor iterator should have an advance_to_index(k) function that moves the iterator at the first element with index >= k (like std::lower_bound). This way traversal orthogonal to the storage layout can be emulated and we don't need any find functions.

BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit revision 2 of this page | View other revisions | View current revision
Edited July 7, 2006 12:11 am (diff)
Disclaimer: This site not officially maintained by Boost Developers