[multiarray] Obtain MultiArray implementation instance from base, extents, strides
Hi all,
I'd like to obtain an N-dimensional MultiArray implementation given a
base pointer, N extents, and N strides. My use case requires padding
the stride in one dimension in a way seemingly not obtainable taking
views of the usual boost::multi_array_ref.
Code like the following would be ideal
boost::arraystd::size_t,3 extents = { 2, 3, 4 };
boost::arraystd::size_t,3 strides = { 1, 2, 7 }; // Note 7 not 6
boost::scoped_array<int> raw(new int[extents[2]*strides[2]]);
using boost::detail::multi_array::multi_array_view;
multi_array_view
I'd like to obtain an N-dimensional MultiArray implementation given a base pointer, N extents, and N strides. My use case requires padding the stride in one dimension in a way seemingly not obtainable taking views of the usual boost::multi_array_ref.
...
Am I missing something in Boost.MultiArray? Or is there no publicly accessible way to provide a custom stride list?
I was missing something. boost::multi_array_ref maintains its stride information in a protected member named stride_list_. Subclass multi_array_ref and manipulate stride_list_ directly. Still not pretty, but much better than the other kludges I'd suggested. - Rhys
participants (1)
-
Rhys Ulerich