[multi_array] deduce logical shape of "parent" multi_array from view

Hi, I am programming and adaptor of the HDF5 library to handle, to some extend, multi_arrays in an elegant way. It turns out that when I try to save a multi_array_view, with strides and offsets, etc. HD5F still needs to know the logical size (shape) of the parent array (the one that has contiguous elements in memory). The paradox is that in order to save an array view I need to know the original array. The question is, is there an (elegant) way to reconstruct the shape of the original array just from the multi_array_view. For moments it seems imposible because array_view doesn't know even the dimensionality of the "parent" array (or it does?). The task is further complicated because many members that may have this information are actually private or protected within multi_array_view. This is an example of what I want: multi_array<2> A(extents[10][10]); multi_array_view<1> Aview = A[3][indeces[range(0,10,2)]]; desired_function(Aview); --> returns 10, 10. Thanks, Alfredo

The question is, is there an (elegant) way to reconstruct the shape of the original array just from the multi_array_view.
I don't believe so, but I could be very wrong. I think you could play some evil pointer games in the case where your views have some fixed number of slow-index dimensions less than the parent array. Very evil games.
It turns out that when I try to save a multi_array_view, with strides and offsets, etc. HD5F still needs to know the logical size (shape) of the parent array (the one that has contiguous elements in memory).
I know it's not as pretty, but is there any reason you can't pass the HDF API both the parent multi_array and either the view or the slicing information required to create the view? - Rhys

On Jan 29, 5:17 am, Rhys Ulerich
I know it's not as pretty, but is there any reason you can't pass the HDF API both the parent multi_array and either the view or the slicing information required to create the view?
Thank Rhys, this is what I am doing for now. something like: file f("file.h5"); f.save( A, Aview ); internally A is not used (just its shape), and from Aview the data pointer and the offsets/strides. hdf5 library insist to know what is the full extents of the contiguous memory where Aview lives. Thanks, Alfredo
participants (2)
-
alfC
-
Rhys Ulerich