Help with a generic algorithm using boost::MultiArray/Multiple nested range traversal

12 Jan
2009
12 Jan
'09
7:25 p.m.
Steven:
int index_of(const multi_array
& 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
5886
Age (days ago)
5886
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jesse Perla