34 using xexpression_type = std::decay_t<CT>;
35 using size_type =
typename xexpression_type::size_type;
36 using difference_type =
typename xexpression_type::difference_type;
37 using shape_type =
typename xexpression_type::shape_type;
38 using strides_type =
typename xexpression_type::strides_type;
40 using reference = std::remove_reference_t<xtl::apply_cv_t<CT, value_type>>;
41 using pointer = xtl::xclosure_pointer<std::remove_reference_t<xtl::apply_cv_t<CT, value_type>>>;
43 using iterator_category = std::forward_iterator_tag;
56 bool equal(
const self_type& rhs)
const;
60 using storing_type = xtl::ptr_closure_type_t<CT>;
61 mutable storing_type p_expression;
64 size_type m_axis_stride;
65 size_type m_lower_shape;
66 size_type m_upper_shape;
67 size_type m_iter_size;
68 bool m_is_target_axis;
71 template <
class T,
class CTA>
72 T get_storage_init(CTA&& e)
const;
139 : p_expression(get_storage_init<storing_type>(std::forward<CTA>(e)))
142 , m_axis_stride(static_cast<size_type>(e.
strides()[axis]) * (e.shape()[axis] - 1u))
146 , m_is_target_axis(false)
149 std::forward<shape_type>({e.shape()[axis]}),
150 std::forward<strides_type>({e.strides()[axis]}),
157 m_is_target_axis = axis == e.dimension() - 1;
158 m_lower_shape = std::accumulate(
159 e.shape().begin() + axis + 1,
164 m_iter_size = std::accumulate(e.shape().begin() + 1, e.shape().end(),
size_t(1), std::multiplies<>());
168 m_is_target_axis = axis == 0;
169 m_lower_shape = std::accumulate(
171 e.shape().begin() + axis,
175 m_iter_size = std::accumulate(e.shape().begin(), e.shape().end() - 1,
size_t(1), std::multiplies<>());
177 m_upper_shape = m_lower_shape + m_axis_stride;
345 auto index_sum = std::accumulate(
347 e.shape().begin() + axis,
354 std::accumulate(e.shape().begin() + axis + 1, e.shape().end(), index_sum, std::multiplies<>()),
auto strided_view(E &&e, S &&shape, X &&stride, std::size_t offset=0, layout_type layout=L) noexcept
Construct a strided view from an xexpression, shape, strides and offset.