66
77#include " xshape.hpp"
88#include " xblockwise_reducer_functors.hpp"
9- #include " xgrid_iterator .hpp"
9+ #include " xmultiindex_iterator .hpp"
1010#include " xreducer.hpp"
1111
1212namespace xt
@@ -50,12 +50,13 @@ class xblockwise_reducer
5050 using mapping_type = filter_fixed_shape_t <shape_type>;
5151 using input_chunked_view_type = xchunked_view<const std::decay_t <CT> &>;
5252 using input_const_chunked_iterator_type = typename input_chunked_view_type::const_chunk_iterator;
53+ using input_chunk_range_type = std::array<xmultiindex_iterator<input_chunk_index_type>, 2 >;
5354
5455 template <class CI >
5556 void assign_to_chunk (CI & result_chunk_iter) const ;
5657
5758 template <class CI >
58- std::array<xsubgrid_iterator<input_chunk_index_type>, 2 > compute_input_chunk_range (CI & result_chunk_iter) const ;
59+ input_chunk_range_type compute_input_chunk_range (CI & result_chunk_iter) const ;
5960
6061 input_const_chunked_iterator_type get_input_chunk_iter (input_chunk_index_type input_chunk_index) const ;
6162 void init_shapes ();
@@ -184,12 +185,14 @@ void xblockwise_reducer<CT, F, X, O>::assign_to_chunk(CI & result_chunk_iter) co
184185
185186template <class CT , class F , class X , class O >
186187template <class CI >
187- auto xblockwise_reducer<CT, F, X, O>::compute_input_chunk_range(CI & result_chunk_iter) const -> std::array<xsubgrid_iterator<input_chunk_index_type>, 2 >
188+ auto xblockwise_reducer<CT, F, X, O>::compute_input_chunk_range(CI & result_chunk_iter) const -> input_chunk_range_type
188189{
189- auto input_chunks_begin = construct_container_with_size<input_chunk_index_type>(m_e_chunked_view.dimension ());
190- auto input_chunks_end = construct_container_with_size<input_chunk_index_type>(m_e_chunked_view.dimension ());
190+ auto input_chunks_begin = xtl::make_sequence<input_chunk_index_type>(m_e_chunked_view.dimension (), 0 );
191+ auto input_chunks_end = xtl::make_sequence<input_chunk_index_type>(m_e_chunked_view.dimension ());
192+
193+ XTENSOR_ASSERT (input_chunks_begin.size () == m_e_chunked_view.dimension ());
194+ XTENSOR_ASSERT (input_chunks_end.size () == m_e_chunked_view.dimension ());
191195
192- std::fill (input_chunks_begin.begin (), input_chunks_begin.end (), 0 );
193196 std::copy (m_e_chunked_view.grid_shape ().begin (), m_e_chunked_view.grid_shape ().end (), input_chunks_end.begin ());
194197
195198 const auto & chunk_index = result_chunk_iter.chunk_index ();
@@ -202,9 +205,9 @@ auto xblockwise_reducer<CT, F, X, O>::compute_input_chunk_range(CI & result_chun
202205 input_chunks_end[input_ax_index] = chunk_index[result_ax_index] + 1 ;
203206 }
204207 }
205- return std::array<xsubgrid_iterator<input_chunk_index_type>, 2 > {
206- subgrid_iterator_begin <input_chunk_index_type>(input_chunks_begin, input_chunks_end),
207- subgrid_iterator_end <input_chunk_index_type>(input_chunks_begin, input_chunks_end)
208+ return input_chunk_range_type {
209+ multiindex_iterator_begin <input_chunk_index_type>(input_chunks_begin, input_chunks_end),
210+ multiindex_iterator_end <input_chunk_index_type>(input_chunks_begin, input_chunks_end)
208211 };
209212}
210213
@@ -318,7 +321,8 @@ namespace blockwise
318321 {\
319322 using input_expression_type = std::decay_t <E>;\
320323 using axes_type = filter_fixed_shape_t <typename input_expression_type::shape_type>;\
321- axes_type axes = construct_container_with_size<axes_type>(e.dimension ());\
324+ axes_type axes = xtl::make_sequence<axes_type>(e.dimension ());\
325+ XTENSOR_ASSERT (axes.dimension () == e.dimension ());\
322326 std::iota (axes.begin (), axes.end (), 0 );\
323327 using functor_type = FUNCTOR <typename input_expression_type::value_type, T>;\
324328 return blockwise_reducer (\
@@ -392,7 +396,8 @@ namespace blockwise
392396 {\
393397 using input_expression_type = std::decay_t <E>;\
394398 using axes_type = filter_fixed_shape_t <typename input_expression_type::shape_type>;\
395- axes_type axes = construct_container_with_size<axes_type>(e.dimension ());\
399+ axes_type axes = xtl::make_sequence<axes_type>(e.dimension ());\
400+ XTENSOR_ASSERT (axes.dimension () == e.dimension ());\
396401 std::iota (axes.begin (), axes.end (), 0 );\
397402 using functor_type = FUNCTOR <typename input_expression_type::value_type>;\
398403 return blockwise_reducer (\
@@ -462,7 +467,8 @@ namespace blockwise
462467 {\
463468 using input_expression_type = std::decay_t <E>;\
464469 using axes_type = filter_fixed_shape_t <typename input_expression_type::shape_type>;\
465- axes_type axes = construct_container_with_size<axes_type>(e.dimension ());\
470+ axes_type axes = xtl::make_sequence<axes_type>(e.dimension ());\
471+ XTENSOR_ASSERT (axes.dimension () == e.dimension ());\
466472 std::iota (axes.begin (), axes.end (), 0 );\
467473 using functor_type = FUNCTOR <typename input_expression_type::value_type>;\
468474 return blockwise_reducer (\
0 commit comments