On Sat, May 1, 2010 at 9:08 AM, Rhys Ulerich
<rhys.ulerich@gmail.com> wrote:
Not as far as I know. You could accomplish this accumulating indices
and strides relative to the origin (similar to the pseudocode for
a(index_list) in Table 3 of
http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/reference.html).
One other option might be &a(index_list) - a.origin().
... since origin() is arr [0][0]...[0], neither of these is the answer in general. But thanks, good pointers there! Sad there isn't a multi_array::offset( indices ) or something that:
assert (
&arr( index_list ) == arr.data() + arr.offset( index_list )
)
this kind of stuff is useful when interacting with legacy libs or other languages.
On a separate note, since for whatever reason the multi_array::index_bases() doesn't return a const Collection reference or something, the following doesn't work:
T element = arr( arr.index_bases() );
Is there an easier alternative to the following (setting the first element of any Multi Array model, note that data() may not be available for all):
indices I; // a collection object
for ( int i = 0; i < arr.num_dimensions(); ++i )
I[i] = arr.index_bases()[i];
arr( I ) = ... ;