Boost logo

Boost :

From: jcampbell3_at_[hidden]
Date: 2001-06-10 21:33:34


--- In boost_at_y..., Toon Knapen <toon_at_s...> wrote:
> "Peter Schmitteckert (boost)" wrote:
> > > One thing that we need to decide on is the interface for
traversing
> > > vectors and matrices. I see a couple options:
> > >
> > > 1. MTL-style iterators
> > >
> > > *i // return a matrix/vector element
> > > i.index() // return the index of the element pointed to
(for vectors)
> > > i.row() // return the row index (for matrices)
> > > i.colummn() // return the column indexn (for matrices)
> > >
> > > 2. iterator over "matrix elements" or "vector elements"
> > > *i // returns a matrix or vector element object.
> > > value(*i) // return the element value
> > > row(*i) // returns the row index
> > > column(*i) // return the column index
> > > index(*i) // return the index (for vectors)
> > >
>
> AFAIK this does not seem compatible with the multi-dimensional
approach
> taken so far. There has been a lot of discussion and effort (on your
> part in development of the prototype) to take a real n-dimensional
> generic approach.
> Using `row()` and `column()` renders this effort meaningless since
how
> will you get the index for the 3th, 4th, ... dimension.
>
> I certainly prefer the 'richer' iterator and thus the MTL approach
but
> how about : i.index(dim) and maybe also i.distance() if you want
more
> information about linear-memory-mapping.
>
> I also would like add another issue to the boost.numeric
iterators : For
> matrices e.g. will you have iterators of iterators or true 2D-
iterators.
> The latter would e.g. allow you to go the next row or column (both
> operations supported by the same iterator object). I'm not sure
about
I need some clarification on this. For example, given a rank n
array analagous to the following c array:

  T a[sn][sn_1][sn_2]...[s1];

then the following statements:

 iterator<n> in = a.begin();
 iterator<n-1> in_1 = *in;
...
 iterator<1> i1 = *i2;
 T& i0 = *i1;

Then this would be an example of the iterator of iterators idea?
To be more specific, the difference between

  successive elements of i1 would be 1;
  successive elements of i2 would be s1;
  successive elements of i3 would be s2*s1;
...
  successive elements of in would be sn_1*sn_2*...*s2*s1.
   
If this is what you mean, then I think this is the best
way to go since I think it most closely mirrors the way
c arrays and pointers to parts of c arrays work.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk