xcontainer

template <class D>
class xt::xcontainer

Base class for dense multidimensional containers.

The xcontainer class defines the interface for dense multidimensional container classes. It does not embed any data container, this responsibility is delegated to the inheriting classes.

Template Parameters
  • D: The derived type, i.e. the inheriting class for which xcontainer provides the interface.

Inherits from xt::xiterable< D >

Subclassed by xt::xstrided_container< D >

Size and shape

auto size() const

Returns the number of element in the container.

auto dimension() const

Returns the number of dimensions of the container.

auto shape() const

Returns the shape of the container.

auto strides() const

Returns the strides of the container.

auto backstrides() const

Returns the backstrides of the container.

void transpose()

Transposes the container inplace by reversing the dimensions.

template <class S, class Tag = check_policy::none>
void transpose(S &&permutation, Tag check_policy = Tag())

Transposes the container inplace by permuting the shape with permutation.

Parameters
  • permutation: the sequence containing permutation
  • check_policy: the check level (check_policy::full() or check_policy::none())
Template Parameters
  • Tag: selects the level of error checking on permutation vector defaults to check_policy::none.

Data

auto operator[](const xindex &index)

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

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

auto operator[](const xindex &index) const

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

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

auto data()

Returns a reference to the buffer containing the elements of the container.

auto data() const

Returns a constant reference to the buffer containing the elements of the container.

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

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

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

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

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

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

template <class It>
auto element(It first, It last)

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

Parameters
  • first: iterator starting the sequence of indices
  • last: iterator ending the sequence of indices The number of indices in the squence should be equal to or greater than the number of dimensions of the container.

template <class It>
auto element(It first, It last) const

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

Parameters
  • first: iterator starting the sequence of indices
  • last: iterator ending the sequence of indices The number of indices in the squence should be equal to or greater than the number of dimensions of the container.

Broadcasting

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

Broadcast the shape of the container to the specified parameter.

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

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

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

Return
a boolean indicating whether the broadcasting is trivial

Iterators

auto begin()

Returns an iterator to the first element of the buffer containing the elements of the container.

auto end()

Returns an iterator to the element following the last element of the buffer containing the elements of the container.

auto begin() const

Returns a constant iterator to the first element of the buffer containing the elements of the container.

auto end() const

Returns a constant iterator to the element following the last element of the buffer containing the elements of the container.

auto cbegin() const

Returns a constant iterator to the first element of the buffer containing the elements of the container.

auto cend() const

Returns a constant iterator to the element following the last element of the buffer containing the elements of the container.

template <class D>
class xt::xstrided_container

Partial implementation of xcontainer that embeds the strides and the shape.

The xstrided_container class is a partial implementation of the xcontainer interface that embed the strides and the shape of the multidimensional container. It does not embed the data container, this responsibility is delegated to the inheriting classes.

Template Parameters
  • D: The derived type, i.e. the inheriting class for which xstrided provides the partial imlpementation of xcontainer.

Inherits from xt::xcontainer< D >

Public Functions

void reshape(const shape_type &shape)

Reshapes the container.

Parameters
  • shape: the new shape

void reshape(const shape_type &shape, layout l)

Reshapes the container.

Parameters
  • shape: the new shape
  • l: the new layout

void reshape(const shape_type &shape, const strides_type &strides)

Reshapes the container.

Parameters
  • shape: the new shape
  • strides: the new strides