xstrided_view

Defined in xtensor/xstrided_view.hpp

template<class CT, class S, layout_type L = layout_type::dynamic, class FST = detail::flat_storage_getter<CT, ::xt::layout_type::row_major>>
class xt::xstrided_view : public xt::xview_semantic<xstrided_view<CT, S, layout_type::dynamic, detail::flat_storage_getter<CT, ::xt::layout_type::row_major>>>, public select_iterable_base_t<layout_type::dynamic, std::decay_t<CT>::static_layout, xstrided_view<CT, S, layout_type::dynamic, detail::flat_storage_getter<CT, ::xt::layout_type::row_major>>>, private xt::xstrided_view_base<xstrided_view<CT, S, layout_type::dynamic, detail::flat_storage_getter<CT, ::xt::layout_type::row_major>>>, public extension::xstrided_view_base_t<CT, S, layout_type::dynamic, detail::flat_storage_getter<CT, ::xt::layout_type::row_major>>

View of an xexpression using strides.

The xstrided_view class implements a view utilizing an initial offset and strides.

See

strided_view, transpose

Template Parameters
  • CT: the closure type of the xexpression type underlying this view

  • L: the layout of the strided view

  • S: the strides type of the strided view

  • FST: the flat storage type used for the strided view

Constructor

template<class CTA, class SA>
xstrided_view(CTA &&e, SA &&shape, strides_type &&strides, std::size_t offset, layout_type layout) noexcept

Constructs an xstrided_view.

Parameters
  • e: the underlying xexpression for this view

  • shape: the shape of the view

  • strides: the strides of the view

  • offset: the offset of the first element in the underlying container

  • layout: the layout of the view

Data

template<class T>
void fill(const T &value)

Fills the view with the given value.

Parameters
  • value: the value to fill the view with.

Extended copy semantic

template<class E>
auto operator=(const xexpression<E> &e) -> self_type&

The extended assignment operator.

Public Functions

size_type size() const noexcept

Returns the size of the expression.

size_type dimension() const noexcept

Returns the number of dimensions of the expression.

size_type shape(size_type index) const

Returns the i-th dimension of the expression.

template<class ...Args>
auto at(Args... args) const -> const_reference

Returns a constant reference to the element at the specified position in the expression, after dimension and bounds checking.

Parameters
  • args: a list of indices specifying the position in the expression. Indices must be unsigned integers, the number of indices should be equal to the number of dimensions of the expression.

Exceptions
  • std::out_of_range: if the number of argument is greater than the number of dimensions or if indices are out of bounds.

typedef std::vector<xstrided_slice<std::ptrdiff_t>> xt::xstrided_slice_vector

vector of slices used to build a xstrided_view

Warning

doxygenfunction: Unable to resolve multiple matches for function “xt::strided_view” with arguments ((E&&, S&&, X&&, std::size_t, layout_type)) in doxygen xml output for project “xtensor” from directory: ../xml. Potential matches:

- template<class E> auto strided_view(E &&e, const xstrided_slice_vector &slices)
- template<layout_type L = layout_type::dynamic, class E, class S, class X> auto strided_view(E &&e, S &&shape, X &&strides, std::size_t offset, layout_type layout) noexcept
template<class E>
auto xt::strided_view(E &&e, const xstrided_slice_vector &slices)

Function to create a dynamic view from an xexpression and an xstrided_slice_vector.

xt::xarray<double> a = {{1, 2, 3}, {4, 5, 6}};
xt::xstrided_slice_vector sv({xt::range(0, 1)});
sv.push_back(xt::range(0, 3, 2));
auto v = xt::strided_view(a, sv);
// ==> {{1, 3}}
Return

initialized strided_view according to slices

Parameters
  • e: xexpression

  • slices: the slice vector

You can also achieve the same with the following short-hand syntax:

xt::xarray<double> a = {{1, 2, 3}, {4, 5, 6}};
auto v = xt::strided_view(a, {xt::range(0, 1), xt::range(0, 3, 2)});
// ==> {{1, 3}}

template<layout_type L = ::xt::layout_type::row_major, class E, class S>
auto xt::reshape_view(E &&e, S &&shape, layout_type)

Return a view on a container with a new shape.

Deprecated:

Note: if you resize the underlying container, this view becomes invalidated.

Return

view on xexpression with new shape

Parameters
  • e: xexpression to reshape

  • shape: new shape

  • order: traversal order (optional)