[proto] iterating array expressions

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

Daniel Oberhoff a écrit :
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. You'll need to build an evaluation context that takes an expression and an iterator. In this context, you evaluates each element of the expression for this iterator. Then you'll add an operator= to your array class that take an expression and walk through your iterator and call the eval function on your expression, using a context initialized with the current iterator.
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
participants (2)
-
Daniel Oberhoff
-
Joel Falcou