xview

template <class CT, class... S>
class xt::xview

Multidimensional view with tensor semantic.

The xview class implements a multidimensional view with tensor semantic. It is used to adapt the shape of an xexpression without changing it. xview is not meant to be used directly, but only with the view helper functions.

See
view, range, all, newaxis
Template Parameters
  • CT: the closure type of the xexpression to adapt
  • S: the slices type describing the shape adaptation

Inherits from xt::xview_semantic< xview< CT, S... > >, xt::xexpression_iterable< xview< CT, S... > >

Extended copy semantic

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

The extended assignment operator.

Constructor

template <class... SL>
xview(CT e, SL&&... slices)

Constructs a view on the specified xexpression.

Users should not call directly this constructor but use the view function instead.

See
view
Parameters
  • e: the xexpression to adapt
  • slices: the slices list describing the view

Size and shape

auto dimension() const

Returns the number of dimensions of the view.

auto size() const

Returns the size of the expression.

auto shape() const

Returns the shape of the view.

auto slices() const

Returns the slices of the view.

Data

template <class... Args>
auto operator()(Args... args)

Returns a reference to the element at the specified position in the view.

Parameters
  • args: a list of indices specifying the position in the view. Indices must be unsigned integers, the number of indices should be equal or greater than the number of dimensions of the view.

template <class... Args>
auto operator()(Args... args) const

Returns a constant reference to the element at the specified position in the view.

Parameters
  • args: a list of indices specifying the position in the view. Indices must be unsigned integers, the number of indices should be equal or greater than the number of dimensions of the view.

Broadcasting

template <class ST>
bool broadcast_shape(ST &shape) const

Broadcast the shape of the view to the specified parameter.

Return
a boolean indicating whether the broadcasting is trivial
Parameters
  • shape: the result shape

template <class ST>
bool is_trivial_broadcast(const ST &strides) const

Compares the specified strides with those of the view to see whether the broadcasting is trivial.

Return
a boolean indicating whether the broadcasting is trivial

template <class E, class... S>
auto xt::view(E &&e, S&&... slices)

Constructs and returns a view on the specified xexpression.

Users should not directly construct the slices but call helper functions instead.

See
range, all, newaxis
Parameters
  • e: the xexpression to adapt
  • slices: the slices list describing the view

template <class T, class E = std::enable_if_t<!std::is_same<T, placeholders::xtuph>::value>>
auto xt::range(T min_val, T max_val)

Returns a slice representing an interval, to be used as an argument of view function.

See
view
Parameters
  • min_val: the first index of the interval
  • max_val: the last index of the interval

template <class T, class E = std::enable_if_t<!std::is_same<T, placeholders::xtuph>::value>>
auto xt::range(T min_val, T max_val, T step)

Returns a slice representing an interval, to be used as an argument of view function.

See
view
Parameters
  • min_val: the first index of the interval
  • max_val: the last index of the interval
  • step: the space between two indices

auto xt::all()

Returns a slice representing a full dimension, to be used as an argument of view function.

See
view

auto xt::newaxis()

Returns a slice representing a new axis of length one, to be used as an argument of view function.

See
view