308 inner_shape_type& shape_impl()
noexcept;
311 inner_strides_type& strides_impl()
noexcept;
314 inner_backstrides_type& backstrides_impl()
noexcept;
326 inner_shape_type m_shape;
327 inner_strides_type m_strides;
328 inner_backstrides_type m_backstrides;
340 return strided_data_end(*
this, begin,
l,
offset);
346 return derived_cast().shape_impl();
350 inline auto xcontainer<D>::mutable_strides() -> inner_strides_type&
352 return derived_cast().strides_impl();
356 inline auto xcontainer<D>::mutable_backstrides() -> inner_backstrides_type&
358 return derived_cast().backstrides_impl();
371 return contiguous_layout ?
storage().size() : compute_size(
shape());
380 return shape().size();
389 return derived_cast().shape_impl();
398 return derived_cast().strides_impl();
407 return derived_cast().backstrides_impl();
425 if (contiguous_layout)
427 std::fill(this->linear_begin(), this->linear_end(), value);
431 std::fill(this->begin(), this->end(), value);
442 template <
class...
Args>
445 XTENSOR_TRY(check_index(
shape(),
args...));
446 XTENSOR_CHECK_DIMENSION(
shape(),
args...);
458 template <
class...
Args>
461 XTENSOR_TRY(check_index(
shape(),
args...));
462 XTENSOR_CHECK_DIMENSION(
shape(),
args...);
487 template <
class...
Args>
492 static_cast<std::ptrdiff_t
>(
args)...
517 template <
class...
Args>
522 static_cast<std::ptrdiff_t
>(
args)...
563 return derived_cast().storage_impl();
573 return derived_cast().storage_impl();
623 return xt::broadcast_shape(this->
shape(), shape);
643 return *
static_cast<const derived_type*
>(
this);
647 inline auto xcontainer<D>::derived_cast() &&
noexcept -> derived_type
649 return *
static_cast<derived_type*
>(
this);
653 inline auto xcontainer<D>::data_element(size_type i) -> reference
659 inline auto xcontainer<D>::data_element(size_type i)
const -> const_reference
673 XTENSOR_ASSERT(
i <
size());
686 XTENSOR_ASSERT(
i <
size());
699 return stepper(
static_cast<derived_type*
>(
this), data_xbegin(),
offset);
704 inline auto xcontainer<D>::stepper_end(
const S&
shape,
layout_type l)
noexcept -> stepper
707 return stepper(
static_cast<derived_type*
>(
this), data_xend(l, offset), offset);
712 inline auto xcontainer<D>::stepper_begin(
const S&
shape)
const noexcept -> const_stepper
715 return const_stepper(
static_cast<const derived_type*
>(
this), data_xbegin(), offset);
720 inline auto xcontainer<D>::stepper_end(
const S&
shape,
layout_type l)
const noexcept -> const_stepper
723 return const_stepper(
static_cast<const derived_type*
>(
this), data_xend(l, offset), offset);
727 inline auto xcontainer<D>::data_xbegin() noexcept -> container_iterator
733 inline auto xcontainer<D>::data_xbegin() const noexcept -> const_container_iterator
739 inline auto xcontainer<D>::data_xend(
layout_type l, size_type offset)
noexcept -> container_iterator
741 return data_xend_impl(
storage().begin(), l, offset);
745 inline auto xcontainer<D>::data_xend(
layout_type l, size_type offset)
const noexcept
746 -> const_container_iterator
748 return data_xend_impl(
storage().cbegin(), l, offset);
752 template <
class alignment,
class simd>
753 inline void xcontainer<D>::store_simd(size_type i,
const simd& e)
755 using align_mode = driven_align_mode_t<alignment, data_alignment>;
756 xt_simd::store_as(std::addressof(
storage()[i]), e, align_mode());
760 template <
class alignment,
class requested_type, std::
size_t N>
761 inline auto xcontainer<D>::load_simd(size_type i)
const
762 -> container_simd_return_type_t<storage_type, value_type, requested_type>
764 using align_mode = driven_align_mode_t<alignment, data_alignment>;
765 return xt_simd::load_as<requested_type>(std::addressof(
storage()[i]), align_mode());
769 inline auto xcontainer<D>::linear_begin() noexcept -> linear_iterator
775 inline auto xcontainer<D>::linear_end() noexcept -> linear_iterator
781 inline auto xcontainer<D>::linear_begin() const noexcept -> const_linear_iterator
787 inline auto xcontainer<D>::linear_end() const noexcept -> const_linear_iterator
793 inline auto xcontainer<D>::linear_cbegin() const noexcept -> const_linear_iterator
799 inline auto xcontainer<D>::linear_cend() const noexcept -> const_linear_iterator
805 inline auto xcontainer<D>::linear_rbegin() noexcept -> reverse_linear_iterator
811 inline auto xcontainer<D>::linear_rend() noexcept -> reverse_linear_iterator
817 inline auto xcontainer<D>::linear_rbegin() const noexcept -> const_reverse_linear_iterator
823 inline auto xcontainer<D>::linear_rend() const noexcept -> const_reverse_linear_iterator
829 inline auto xcontainer<D>::linear_crbegin() const noexcept -> const_reverse_linear_iterator
835 inline auto xcontainer<D>::linear_crend() const noexcept -> const_reverse_linear_iterator
841 inline auto xcontainer<D>::derived_cast() &
noexcept -> derived_type&
843 return *
static_cast<derived_type*
>(
this);
851 inline xstrided_container<D>::xstrided_container() noexcept
860 inline xstrided_container<D>::xstrided_container(inner_shape_type&&
shape, inner_strides_type&&
strides) noexcept
862 , m_shape(std::move(
shape))
863 , m_strides(std::move(
strides))
865 m_backstrides = xtl::make_sequence<inner_backstrides_type>(m_shape.size(), 0);
866 adapt_strides(m_shape, m_strides, m_backstrides);
870 inline xstrided_container<D>::xstrided_container(
871 inner_shape_type&&
shape,
877 , m_shape(std::move(
shape))
878 , m_strides(std::move(
strides))
880 , m_layout(std::move(layout))
885 inline auto xstrided_container<D>::shape_impl() noexcept -> inner_shape_type&
891 inline auto xstrided_container<D>::shape_impl() const noexcept -> const inner_shape_type&
897 inline auto xstrided_container<D>::strides_impl() noexcept -> inner_strides_type&
903 inline auto xstrided_container<D>::strides_impl() const noexcept -> const inner_strides_type&
909 inline auto xstrided_container<D>::backstrides_impl() noexcept -> inner_backstrides_type&
911 return m_backstrides;
915 inline auto xstrided_container<D>::backstrides_impl() const noexcept -> const inner_backstrides_type&
917 return m_backstrides;