Boost logo

Boost Users :

Subject: [Boost-users] [proto] iterating array expressions
From: Daniel Oberhoff (daniel.oberhoff_at_[hidden])
Date: 2009-01-11 16:21:26


Hi,

First off: much thanks for previous replies to related problems. One
comment: I got told to properly use proto on my array class I needed
to separate data from user interface. I found now that it is possible
to define expressions non-intrusively without having to change my
array structure, but still I understand the motivation, and possibly
this way is better anyway.

Anhow, now to my new problems. I have now set up proto to be able to
evaluate expressions such as:

A(_i,_j) + B(_j,_i*_j-2)

at a given index (i.e. substituting given numbers for index
placeholders _i and _j).

Here A and B are of my own n-dimensional array class.

Now I would like to iterate such expressions efficiently to evaluate
assignment expressions like:

C = A(_i,_j) + B(_j,_i*_j-2);

efficiently.

What I want to do is base it around basic "iterators" for each array
indexing expression ( i.e. B(_j,_i*_j-2) and A(_i,_j) in the example)
that know how to move to a certain setting for the index placeholders
and how to advance along the index placeholders (e.g. advance the data
pointer for _i -> _i+1, _j -> _j+1). I think I could implement such
iterators (not in the STL sense, since I dont use begin/end, but
enough for what I need) for the array indexing expressions, but I dont
know how to generate the iterator for the complete expression. I would
like such an iterator be generated automatically given the individual
iterators for the array indexing expressions and be able to call move,
advance, and evaluate on such an iterator.

Any hints on where to start before I lose myself deeply in the
documents and examples?

Any help much appreciated.

Best

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net