
I'm going to second Antonio's comments. A globally applicable iterator across a multi-array's data elements would provide a /very/ useful tool, and doesn't seem all that impossible to program, requiring all the magic be done behind the scenes in operator+ etc. In addition, I'd love to see a Boost statistical package, but am unfamiliar with the process of getting support for a new boost library, nor what the early stages of development look like. - Greg Link On May 17, 2006, at 2:46 PM, Antonio Piccolboni wrote:
As I said in a former message that I am afraid fell through the cracks, sorry if I am repeating myself, I don't think rewriting the whole STL algorithm lib for multi_array is a solution. for_each, accumulate, sort, where do we stop? I recently needed to apply random shuffle, for instance. I think the solution is to define iterators that provide a "flat", element by element view of a multi_array. These iterators would be regular skip iterators that just a have a fancy increment operation that looks at the stride vector to decide by how much to jump when incremented. Let's say that these are returned by begin_element and end_element. Then you could do on multi array ma things like
for_each(ma.begin_element(), ma.end_element(), do_something())
or
accumulate(ma.begin_element(), ma.end_element(), 0)
and so on for all STL algorithms, all the statstical functions that I wrote (GPLed, maybe the beginning of a boost stats lib?, mail me if interested) and more. I've been using data() and data()+num_elements for the same purpose, but that breaks for non contiguos storage (that is, not guaranteed to work for views)
I don't think rewriting all the algorithms for multi_array is a viable strategy, nor is in keeping with the idea that data structures and algorithms should be made as ortogonal as reasonably possible. Just my 2c
Antonio