Boost logo

Boost Users :

Subject: [Boost-users] [multiarray] Obtain MultiArray implementation instance from base, extents, strides
From: Rhys Ulerich (rhys.ulerich_at_[hidden])
Date: 2010-03-22 15:33:42


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::array<std::size_t,3> extents = { 2, 3, 4 };
    boost::array<std::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<int,3> a(raw.get(), extents, strides);

except that the appropriate constructor in multi_array_view is private
(boost/multi_array/view.hpp:442).
boost::detail::multi_array::sub_array would also be ideal if it's
constructor was accessible(boost/multi_array/subarray.hpp:370). I can
make either accessible by #defining BOOST_NO_MEMBER_TEMPLATE_FRIENDS,
but that's evil.

Am I missing something in Boost.MultiArray? Or is there no publicly
accessible way to provide a custom stride list?

- Rhys


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net