From: Todd V. <tve...@oo...> - 1998-04-11 02:28:36
|
> Date: Fri, 10 Apr 1998 15:48:43 -0700 (PDT) > From: "Sean O'Keeffe" <sok...@uc...> > To: tve...@oo... > 1. When compiling with egcs I get warnings about an initializer oredering > problem on line 461 of array.h for the base initializer > memoryBlockReference<T_type>. Fixed, thanks. > 2. I am writing some code that outputs and reads sequences of data into > arbitrary rank Array objects. I don't want to specialize the routines > based upon the data rank so I can't use TinyVector indices. > > I am currently casting away the const return value of dataFirst() member > and writing directly from ptr[0] to ptr[size()-1]. This is pretty ugly > and I think the correct approach is to define STL like bidirectional > iterators that iterate over all element values using operator++ according > to the order they are stored in memory. (Which may not be the best way > for a human to view them but is very useful for simulations which need to > checkpoint their state occasionally.) > > If you haven't already coded up something close to this I will give it a > spin myself and submit it back to you. I just don't want to duplicate > something that has already been done. Writing an STL-style iterator for Array has been on my todo for a long time. If you want to tackle it that would be a big help. Also, your input/output code might be a useful start on an array persistence mechanism. Unfortunately a bidirectional iterator for Array<T,N> is a bit more complicated than first appearances because of subarrays. In subarrays you have to skip at the end of each row/column. The easiest way I've found for doing this is using a stack-style iterator. There is some code for doing stack iteration in blitz/arrayeval.cc and blitz/arrayiter.h which you could adapt if you wanted. See particularly evaluateWithStackTraversalN() in blitz/arrayeval.cc. This routine only goes forward, but backward might not be too hard. Even a forward iterator only would be a big step forward. That routine is a mess-- I will put in more comments. There is some code in there to handle loop collapse (i.e. turn an N-dimensional array traversal into a 1-dimensional array traversal when possible). This could go in the ctor for your iterator? Anyway, let me know how I can help. Cheers, Todd --------------------- blitz-dev list -------------------------------- * To subscribe/unsubscribe: mail to maj...@oo..., with "subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message * Blitz++ web page: http://oonumerics.org/blitz/ |