view of multiarray without knowledge of dimension
Hi all - My basic need is to step through a portion of my multiarray at runtime. I don't know the dimension apriori, since the class I'm writing is templatized on dimension. This means that the multiarray can serve my other purposes just fine, since the dimesion is compile time constant, but I don't know the number of [] and the nesting of loops I'll need to iterate through the valid indices in my range min to max in my multiarray. Essentially, if I could specify a view of my multiarray, likely it shouldn't be too hard to iterate through the elements of that sub-multiarray, even without knowing the dimension at coding time. Anyone know of a way to get a view without knowing the dimensions at coding time? Thanks, Brian -- View this message in context: http://www.nabble.com/view-of-multiarray-without-knowledge-of-dimension-t105... Sent from the Boost - Users forum at Nabble.com.
On Thu, 2 Feb 2006, graphicsMan69 (sent by Nabble.com) wrote:
Hi all -
My basic need is to step through a portion of my multiarray at runtime. I don't know the dimension apriori, since the class I'm writing is templatized on dimension. This means that the multiarray can serve my other purposes just fine, since the dimesion is compile time constant, but I don't know the number of [] and the nesting of loops I'll need to iterate through the valid indices in my range min to max in my multiarray.
Essentially, if I could specify a view of my multiarray, likely it shouldn't be too hard to iterate through the elements of that sub-multiarray, even without knowing the dimension at coding time.
Anyone know of a way to get a view without knowing the dimensions at coding time?
I came across similar problems with boost::multi_array. I wanted to iterate on all cells of just a portion of the whole multi_array. The way I solved the problem was to use operator() instead of operator[], and a multi-dimensional counting iterator (e.g. http://www-etud.iro.umontreal.ca/~duranlef/code/multi_counting_iterator.hpp). I am not convinced it is the most efficient way (or event elegant), but it works very well to make an abstraction of the multi_array's dimension. -- François Duranleau LIGUM, Université de Montréal "'Reality' is the temporary resultant of continuous struggles between rival gangs of programmers." - Robert Anton Wilson, _Prometheus Rising_, 1983
Thanks! That's very similar to the idea I had, but I thought that perhaps multiarray had it somewhere hidden away. I'll probably use yours -- no need to reinvent the wheel! Brian -- View this message in context: http://www.nabble.com/view-of-multiarray-without-knowledge-of-dimension-t105... Sent from the Boost - Users forum at Nabble.com.
participants (2)
-
François Duranleau
-
graphicsMan69 (sent by Nabble.com)