198 using base_type::is_contiguous;
204 using base_type::operator();
206 using base_type::unchecked;
207 using base_type::operator[];
208 using base_type::data;
210 using base_type::element;
220 linear_iterator linear_begin();
221 linear_iterator linear_end();
222 const_linear_iterator linear_begin()
const;
223 const_linear_iterator linear_end()
const;
224 const_linear_iterator linear_cbegin()
const;
225 const_linear_iterator linear_cend()
const;
227 reverse_linear_iterator linear_rbegin();
228 reverse_linear_iterator linear_rend();
229 const_reverse_linear_iterator linear_rbegin()
const;
230 const_reverse_linear_iterator linear_rend()
const;
231 const_reverse_linear_iterator linear_crbegin()
const;
232 const_reverse_linear_iterator linear_crend()
const;
234 template <
class ST,
class STEP = stepper>
236 template <
class ST,
class STEP = stepper>
239 template <
class ST,
class STEP = stepper>
241 template <
class ST,
class STEP = stepper>
244 template <
class ST,
class STEP = const_stepper>
246 template <
class ST,
class STEP = const_stepper>
249 template <
class ST,
class STEP = const_stepper>
251 template <
class ST,
class STEP = const_stepper>
254 template <
class requested_type>
255 using simd_return_type = xt_simd::simd_return_type<value_type, requested_type>;
257 template <
class T,
class R>
258 using enable_simd_interface = std::enable_if_t<has_simd_interface<T>::value &&
L !=
layout_type::dynamic,
R>;
260 template <
class align,
class simd,
class T = xexpression_type>
266 class T = xexpression_type>
269 reference data_element(size_type
i);
270 const_reference data_element(size_type
i)
const;
272 reference flat(size_type
i);
273 const_reference flat(size_type
i)
const;
275 using container_iterator = std::
276 conditional_t<is_const, typename storage_type::const_iterator, typename storage_type::iterator>;
277 using const_container_iterator =
typename storage_type::const_iterator;
287 container_iterator data_xbegin()
noexcept;
298 void assign_temporary_impl(temporary_type&&
tmp);
330 xrange_adaptor<placeholders::xtuph, placeholders::xtuph, placeholders::xtuph>,
383 template <
class CT,
class S, layout_type L,
class FST>
397 template <
class CT,
class S, layout_type L,
class FST>
401 return semantic_base::operator=(
e);
406 template <
class CT,
class S, layout_type L,
class FST>
414 namespace xstrided_view_detail
416 template <
class V,
class T>
417 inline void run_assign_temporary_impl(V& v,
const T& t, std::true_type )
419 strided_loop_assigner<true>::run(v, t);
422 template <
class V,
class T>
424 run_assign_temporary_impl(V& v,
const T& t, std::false_type )
426 std::copy(t.cbegin(), t.cend(), v.begin());
430 template <
class CT,
class S, layout_type L,
class FST>
431 inline void xstrided_view<CT, S, L, FST>::assign_temporary_impl(temporary_type&& tmp)
434 fast_assign = xassign_traits<xstrided_view<CT, S, L, FST>, temporary_type>::simd_strided_assign();
435 xstrided_view_detail::run_assign_temporary_impl(*
this, tmp, std::integral_constant<bool, fast_assign>{});
447 template <
class CT,
class S, layout_type L,
class FST>
453 std::fill(this->linear_begin(), this->linear_end(), value);
457 std::fill(this->begin(), this->end(), value);
463 template <
class CT,
class S, layout_type L,
class FST>
469 template <
class CT,
class S, layout_type L,
class FST>
470 inline auto xstrided_view<CT, S, L, FST>::data_element(size_type i)
const -> const_reference
475 template <
class CT,
class S, layout_type L,
class FST>
476 inline auto xstrided_view<CT, S, L, FST>::flat(size_type i) -> reference
481 template <
class CT,
class S, layout_type L,
class FST>
482 inline auto xstrided_view<CT, S, L, FST>::flat(size_type i)
const -> const_reference
487 template <
class CT,
class S, layout_type L,
class FST>
488 inline auto xstrided_view<CT, S, L, FST>::linear_begin() -> linear_iterator
493 template <
class CT,
class S, layout_type L,
class FST>
494 inline auto xstrided_view<CT, S, L, FST>::linear_end() -> linear_iterator
499 template <
class CT,
class S, layout_type L,
class FST>
500 inline auto xstrided_view<CT, S, L, FST>::linear_begin() const -> const_linear_iterator
502 return this->linear_cbegin();
505 template <
class CT,
class S, layout_type L,
class FST>
506 inline auto xstrided_view<CT, S, L, FST>::linear_end() const -> const_linear_iterator
508 return this->linear_cend();
511 template <
class CT,
class S, layout_type L,
class FST>
512 inline auto xstrided_view<CT, S, L, FST>::linear_cbegin() const -> const_linear_iterator
517 template <
class CT,
class S, layout_type L,
class FST>
518 inline auto xstrided_view<CT, S, L, FST>::linear_cend() const -> const_linear_iterator
523 template <
class CT,
class S, layout_type L,
class FST>
524 inline auto xstrided_view<CT, S, L, FST>::linear_rbegin() -> reverse_linear_iterator
526 return reverse_linear_iterator(this->linear_begin());
529 template <
class CT,
class S, layout_type L,
class FST>
530 inline auto xstrided_view<CT, S, L, FST>::linear_rend() -> reverse_linear_iterator
532 return reverse_linear_iterator(this->linear_end());
535 template <
class CT,
class S, layout_type L,
class FST>
536 inline auto xstrided_view<CT, S, L, FST>::linear_rbegin() const -> const_reverse_linear_iterator
538 return this->linear_crbegin();
541 template <
class CT,
class S, layout_type L,
class FST>
542 inline auto xstrided_view<CT, S, L, FST>::linear_rend() const -> const_reverse_linear_iterator
544 return this->linear_crend();
547 template <
class CT,
class S, layout_type L,
class FST>
548 inline auto xstrided_view<CT, S, L, FST>::linear_crbegin() const -> const_reverse_linear_iterator
550 return const_reverse_linear_iterator(this->linear_cbegin());
553 template <
class CT,
class S, layout_type L,
class FST>
554 inline auto xstrided_view<CT, S, L, FST>::linear_crend() const -> const_reverse_linear_iterator
556 return const_reverse_linear_iterator(this->linear_cend());
563 template <
class CT,
class S, layout_type L,
class FST>
564 template <
class ST,
class STEP>
565 inline auto xstrided_view<CT, S, L, FST>::stepper_begin(
const ST&
shape) -> disable_indexed_stepper_t<STEP>
568 return stepper(
this, data_xbegin(), offset);
571 template <
class CT,
class S, layout_type L,
class FST>
572 template <
class ST,
class STEP>
573 inline auto xstrided_view<CT, S, L, FST>::stepper_end(
const ST&
shape,
layout_type l)
574 -> disable_indexed_stepper_t<STEP>
577 return stepper(
this, data_xend(l, offset), offset);
580 template <
class CT,
class S, layout_type L,
class FST>
581 template <
class ST,
class STEP>
582 inline auto xstrided_view<CT, S, L, FST>::stepper_begin(
const ST&
shape) -> enable_indexed_stepper_t<STEP>
585 return stepper(
this, offset);
588 template <
class CT,
class S, layout_type L,
class FST>
589 template <
class ST,
class STEP>
590 inline auto xstrided_view<CT, S, L, FST>::stepper_end(
const ST&
shape,
layout_type )
591 -> enable_indexed_stepper_t<STEP>
594 return stepper(
this, offset,
true);
597 template <
class CT,
class S, layout_type L,
class FST>
598 template <
class ST,
class STEP>
599 inline auto xstrided_view<CT, S, L, FST>::stepper_begin(
const ST&
shape)
const
600 -> disable_indexed_stepper_t<STEP>
603 return const_stepper(
this, data_xbegin(), offset);
606 template <
class CT,
class S, layout_type L,
class FST>
607 template <
class ST,
class STEP>
608 inline auto xstrided_view<CT, S, L, FST>::stepper_end(
const ST&
shape,
layout_type l)
const
609 -> disable_indexed_stepper_t<STEP>
612 return const_stepper(
this, data_xend(l, offset), offset);
615 template <
class CT,
class S, layout_type L,
class FST>
616 template <
class ST,
class STEP>
617 inline auto xstrided_view<CT, S, L, FST>::stepper_begin(
const ST&
shape)
const
618 -> enable_indexed_stepper_t<STEP>
621 return const_stepper(
this, offset);
624 template <
class CT,
class S, layout_type L,
class FST>
625 template <
class ST,
class STEP>
626 inline auto xstrided_view<CT, S, L, FST>::stepper_end(
const ST&
shape,
layout_type )
const
627 -> enable_indexed_stepper_t<STEP>
630 return const_stepper(
this, offset,
true);
633 template <
class CT,
class S, layout_type L,
class FST>
635 inline It xstrided_view<CT, S, L, FST>::data_xbegin_impl(It begin)
const noexcept
637 return begin +
static_cast<std::ptrdiff_t
>(this->
data_offset());
640 template <
class CT,
class S, layout_type L,
class FST>
643 xstrided_view<CT, S, L, FST>::data_xend_impl(It begin,
layout_type l, size_type offset)
const noexcept
645 return strided_data_end(*
this, begin + std::ptrdiff_t(this->
data_offset()), l, offset);
648 template <
class CT,
class S, layout_type L,
class FST>
649 inline auto xstrided_view<CT, S, L, FST>::data_xbegin() noexcept -> container_iterator
651 return data_xbegin_impl(this->
storage().begin());
654 template <
class CT,
class S, layout_type L,
class FST>
655 inline auto xstrided_view<CT, S, L, FST>::data_xbegin() const noexcept -> const_container_iterator
657 return data_xbegin_impl(this->
storage().cbegin());
660 template <
class CT,
class S, layout_type L,
class FST>
661 inline auto xstrided_view<CT, S, L, FST>::data_xend(
layout_type l, size_type offset)
noexcept
662 -> container_iterator
664 return data_xend_impl(this->
storage().begin(), l, offset);
667 template <
class CT,
class S, layout_type L,
class FST>
668 inline auto xstrided_view<CT, S, L, FST>::data_xend(
layout_type l, size_type offset)
const noexcept
669 -> const_container_iterator
671 return data_xend_impl(this->
storage().cbegin(), l, offset);
674 template <
class CT,
class S, layout_type L,
class FST>
675 template <
class alignment,
class simd,
class T>
676 inline auto xstrided_view<CT, S, L, FST>::store_simd(size_type i,
const simd& e)
677 -> enable_simd_interface<T, void>
679 using align_mode = driven_align_mode_t<alignment, data_alignment>;
680 xt_simd::store_as(&(
storage()[i]), e, align_mode());
683 template <
class CT,
class S, layout_type L,
class FST>
684 template <
class alignment,
class requested_type, std::
size_t N,
class T>
685 inline auto xstrided_view<CT, S, L, FST>::load_simd(size_type i)
const
686 -> enable_simd_interface<T, simd_return_type<requested_type>>
688 using align_mode = driven_align_mode_t<alignment, data_alignment>;
689 return xt_simd::load_as<requested_type>(&(
storage()[i]), align_mode());
692 template <
class CT,
class S, layout_type L,
class FST>
694 inline auto xstrided_view<CT, S, L, FST>::build_view(E&& e)
const -> rebind_t<E>
696 inner_shape_type sh(this->
shape());
697 inner_strides_type str(this->
strides());
727 template <layout_type L,
class E,
class S,
class X>
736 struct no_adj_strides_policy
740 inline void resize(std::size_t)
744 inline void set_fake_slice(std::size_t)
748 template <
class ST,
class S>
750 const xstrided_slice_vector& ,
792 detail::strided_view_args<detail::no_adj_strides_policy>
args;
795 detail::get_strides<XTENSOR_DEFAULT_TRAVERSAL>(
e),
796 detail::get_offset<XTENSOR_DEFAULT_TRAVERSAL>(
e),
803 std::move(
args.new_shape),
804 std::move(
args.new_strides),
812 template <
typename S>
815 template <std::size_t... X>
816 struct rebind_shape<
xt::fixed_shape<X...>>
824 using type = rebind_container_t<size_t, S>;
829 std::enable_if_t<std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value,
bool> =
true>
830 inline void recalculate_shape_impl(S& shape,
size_t size)
832 using value_type = get_value_type_t<typename std::decay_t<S>>;
833 XTENSOR_ASSERT(std::count(shape.cbegin(), shape.cend(), -1) <= 1);
834 auto iter = std::find(shape.begin(), shape.end(), -1);
835 if (iter != std::end(shape))
837 const auto total = std::accumulate(shape.cbegin(), shape.cend(), -1, std::multiplies<int>{});
838 const auto missing_dimension = size / total;
839 (*iter) =
static_cast<value_type
>(missing_dimension);
845 std::enable_if_t<!std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value,
bool> =
true>
846 inline void recalculate_shape_impl(S&,
size_t)
851 inline auto recalculate_shape(S&& shape,
size_t size)
853 return recalculate_shape_impl(shape, size);
857 template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL,
class E,
class S>
858 inline auto reshape_view(E&& e, S&&
shape)
862 "traversal has to be row or column major"
865 using shape_type = std::decay_t<
decltype(
shape)>;
866 using unsigned_shape_type =
typename detail::rebind_shape<shape_type>::type;
867 get_strides_t<unsigned_shape_type>
strides;
869 detail::recalculate_shape(
shape, e.size());
872 constexpr auto computed_layout = std::decay_t<E>::static_layout == L ? L :
layout_type::dynamic;
877 detail::flat_adaptor_getter<xclosure_t<E>, L>>;
880 xtl::forward_sequence<unsigned_shape_type, S>(
shape),
900 template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL,
class E,
class S>
906 template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL,
class E,
class I, std::
size_t N>
909 using shape_type = std::array<std::size_t, N>;
910 return reshape_view<L>(std::forward<E>(e), xtl::forward_sequence<shape_type,
decltype(
shape)>(
shape), order);
913 template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL,
class E,
class I, std::
size_t N>
914 inline auto reshape_view(E&& e,
const I (&
shape)[N])
916 using shape_type = std::array<I, N>;
917 return reshape_view<L>(std::forward<E>(e), xtl::forward_sequence<shape_type,
decltype(
shape)>(
shape));