Boost C++ Libraries: Ticket #4045: MultiArray implementation from base, extents, strides https://svn.boost.org/trac10/ticket/4045 <p> It would be useful to have a multi_array_ref constructor or some other <a class="missing wiki">MultiArray</a> implementation that can accept explicit stride information rather than storage order information. The former is more flexible and can accomplish things the latter cannot (see example below). </p> <hr /> <p> I sent the following question to boost-users (<a class="ext-link" href="http://lists.boost.org/boost-users/2010/03/57634.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2010/03/57634.php</a>): </p> <p> I'd like to obtain an N-dimensional <a class="missing wiki">MultiArray</a> 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. </p> <p> Code like the following would be ideal </p> <pre class="wiki"> boost::array&lt;std::size_t,3&gt; extents = { 2, 3, 4 }; boost::array&lt;std::size_t,3&gt; strides = { 1, 2, 7 }; // Note 7 not 6 boost::scoped_array&lt;int&gt; raw(new int[extents[2]*strides[2]]); using boost::detail::multi_array::multi_array_view; multi_array_view&lt;int,3&gt; a(raw.get(), extents, strides); </pre><p> 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. </p> <p> Am I missing something in Boost.<a class="missing wiki">MultiArray</a>? Or is there no publicly accessible way to provide a custom stride list? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4045 Trac 1.4.3 Rhys Ulerich <rhys.ulerich@…> Thu, 25 Mar 2010 19:42:21 GMT <link>https://svn.boost.org/trac10/ticket/4045#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4045#comment:1</guid> <description> <p> I'd failed to notice that boost::multi_array_ref maintains its stride information in a protected member named stride_list_. I have achieved what I was after by subclassing and modifying stride_list_ directly. </p> <p> From what I can read in the code, mutating stride_list_ underneath multi_array_ref should have no ill side effects. If it does, what are they? If not, would you please add a constructor to multi_array_ref that supports arbitrary strides by invoking the super_type's constructor and then modifying the stride list directly? </p> </description> <category>Ticket</category> </item> </channel> </rss>