Boost logo

Boost :

Subject: Re: [boost] matrix and vector iterators
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-12-31 14:41:10


On 06/12/01 14:50, David Abrahams wrote:
>
> ----- Original Message -----
> From: "Larry Evans" <jcampbell3_at_[hidden]>
>
>
>> David Abrahams wrote:
>>
>>> One problem with this is that it requires much more of the iterator in
> some
>>> cases than it otherwise might. In an array stored as vectors of vectors
>>> of... vectors, each iterator would need to have references to all of the
>>> containing vectors.
>>
>> Couldn't the iterator just contain a vector of indices of length == rank,
>> and a pointer to the vector of vectors of... vectors (VofV), and then just
> index into
>> the VofV with the vector of indices.
>
> When you start talking about iterators containing vectors, I get worried.
>
>> I guess bad thing about that is that it takes longer.
>
> That's putting it mildly. Iterators should be lightweight.
>
> -Dave
>
>
Another type of iterator which essentially flattens a multi-dimensional
array and *may* be more lightweight is implemented here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/stepper/boost/array_stepper/index_stack_length_stride_crtp.hpp

and demonstrated here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/index_stack_length_stride_crtp~demo.cpp

A more realistic demonstration is in the Partial Differential Equation
example here:

 http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/array_dyn.diff_pde.cpp

which uses an axes rotation feature that, IIUC, was requested by
Petros here:

 http://article.gmane.org/gmane.comp.lib.boost.user/68017

Its also used here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/solve_tridiag.cpp

which is probably a bit easier to follow than the array_dyn.diff_pde.cpp
one ;)

I've done no benchmarks; hence, I can't say how lightweight it is;
however, since all it does is keep a stack of indices in a data
structure instead of on the stack, I would think it wouldn't be
that much more heavyweight than simply a nested for loop
nested N deep where N is the array dimensionality.

BTW, Petros, in a private email to me, has indicated he has
some other method for solving the rotated axes problem; however,
I've no idea if that's more or less lightweight than this one.

-regards,
Larry

I've run no benchmarks to show how lightweight it may be. Petros, in
a private email to me, says he has another way of


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