Boost logo

Boost Users :

Subject: [Boost-users] Help with a generic algorithm using boost::MultiArray/Multiple nested range traversal
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2009-01-12 14:25:20


Steven:
>int index_of(const multi_array<int, 3>& m, int* iter, int dimension) {
> int offset = iter - m.origin();
> return(offset / m.strides()[dimension] % m.shape()[dimension] +
>m.index_bases()[dimension]); }

Thanks for the code suggestion. Does this code work for N dimensions? it
appears to. I would prefer to keep a tight count of the indices in the
iterator itself to ensure that we don't need to do this expensive
calculation each time, but this looks like a pretty good starting point and
would work similarly for my sequential ublas::matrix iteration as well.

-Jesse



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