layout¶
Defined in xtensor/xlayout.hpp
-
enum
xt::
layout_type
¶ layout_type enum for xcontainer based xexpressions
Values:
-
dynamic
= 0x00¶ dynamic layout_type: you can reshape to row major, column major, or use custom strides
-
any
= 0xFF¶ layout_type compatible with all others
-
row_major
= 0x01¶ row major layout_type
-
column_major
= 0x02¶ column major layout_type
-
- template <class... Args>
-
constexpr layout_type
xt::
compute_layout
(Args... args)¶ Implementation of the following logical table:
Using bitmasks to avoid nested if-else statements.| d | a | r | c | --+---+---+---+---+ d | d | d | d | d | a | d | a | r | c | r | d | r | r | d | c | d | c | d | c | d = dynamic, a = any, r = row_major, c = column_major.
- Return
- the output layout, computed with the previous logical table.
- Parameters
args
: the input layouts.
xcontainer¶
Defined in xtensor/xcontainer.hpp
- 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, L >
Size and shape
-
auto
size
() const¶ Returns the number of element in the container.
-
constexpr 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.
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.
-
auto
raw_data
()¶ Returns the offset to the first element in the container.
-
auto
raw_data_offset
() const¶ Returns the offset to the first element in 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 indiceslast
: iterator ending the sequence of indices The number of indices in the sequence 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 indiceslast
: iterator ending the sequence of indices The number of indices in the sequence 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.
Reverse Iterators
-
auto
rbegin
()¶ Returns an iterator to the first element of the reversed buffer containing the elements of the container.
-
auto
rend
()¶ Returns an iterator to the element following the last element of the reversed buffer containing the elements of the container.
-
auto
rbegin
() const¶ Returns a constant iterator to the first element of the reversed buffer containing the elements of the container.
-
auto
rend
() const¶ Returns a constant iterator to the element following the last element of the reversed buffer containing the elements of the container.
-
auto
crbegin
() const¶ Returns a constant iterator to the first element of the reversed buffer containing the elements of the container.
-
auto
crend
() const¶ Returns a constant iterator to the element following the last element of the reversed buffer containing the elements of the container.
xstrided_container¶
Defined in xtensor/xcontainer.hpp
- template <class D, layout_type L>
-
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_container provides the partial imlpementation of xcontainer.L
: The layout_type of the xstrided_container.
Inherits from xt::xcontainer< D >
Public Functions
- template <class S = shape_type>
-
void
reshape
(const S &shape, bool force = false)¶ Reshapes the container.
- Parameters
shape
: the new shapeforce
: force reshaping, even if the shape stays the same (default: false)
- template <class S = shape_type>
-
void
reshape
(const S &shape, layout_type l)¶ Reshapes the container.
- Parameters
shape
: the new shapel
: the new layout_type
- template <class S = shape_type>
-
void
reshape
(const S &shape, const strides_type &strides)¶ Reshapes the container.
- Parameters
shape
: the new shapestrides
: the new strides
-
layout_type
layout
() const¶ Return the layout_type of the container.
- Return
- layout_type of the container