xtensor
Loading...
Searching...
No Matches
xt::xrepeat< CT, R > Class Template Reference

Expression with repeated values along an axis. More...

#include <xrepeat.hpp>

Inheritance diagram for xt::xrepeat< CT, R >:
xt::xconst_iterable< xrepeat< CT, R > > xt::xconst_accessible< xrepeat< CT, R > > xt::xsharable_expression< xrepeat< CT, R > > xt::xexpression< xrepeat< CT, R > >

Public Types

using self_type = xrepeat<CT, R>
using xexpression_type = std::decay_t<CT>
using accessible_base = xconst_accessible<self_type>
using extension_base = extension::xrepeat_base_t<CT, R>
using expression_tag = typename extension_base::expression_tag
using value_type = typename xexpression_type::value_type
using shape_type = typename xexpression_type::shape_type
using repeats_type = xtl::const_closure_type_t<R>
using container_type = xcontainer_inner_types<xrepeat<CT, R>>
using reference = typename container_type::reference
using const_reference = typename container_type::const_reference
using size_type = typename container_type::size_type
using temporary_type = typename container_type::temporary_type
using bool_load_type = typename xexpression_type::bool_load_type
using pointer = typename xexpression_type::pointer
using const_pointer = typename xexpression_type::const_pointer
using difference_type = typename xexpression_type::difference_type
using iterable_type = xiterable<xrepeat<CT, R>>
using stepper = typename iterable_type::stepper
using const_stepper = typename iterable_type::const_stepper
Public Types inherited from xt::xconst_iterable< xrepeat< CT, R > >
using derived_type
using iterable_types
using inner_shape_type
using stepper
using const_stepper
using layout_iterator
using const_layout_iterator
using reverse_layout_iterator
using const_reverse_layout_iterator
using linear_iterator
using const_linear_iterator
using reverse_linear_iterator
using const_reverse_linear_iterator
using broadcast_iterator
using const_broadcast_iterator
using reverse_broadcast_iterator
using const_reverse_broadcast_iterator
using iterator
using const_iterator
using reverse_iterator
using const_reverse_iterator
Public Types inherited from xt::xconst_accessible< xrepeat< CT, R > >
using derived_type
using inner_types
using reference
using const_reference
using size_type
Public Types inherited from xt::xexpression< xrepeat< CT, R > >
using derived_type

Public Member Functions

template<class CTA>
 xrepeat (CTA &&e, R &&repeats, size_type axis)
 Constructs an xrepeat expression repeating the element of the specified xexpression.
size_type size () const noexcept(noexcept(derived_cast().shape()))
 Returns the size of the expression.
size_type shape (size_type index) const
 Returns the i-th dimension of the expression.
Size and shape
const shape_type & shape () const noexcept
 Returns the shape of the expression.
layout_type layout () const noexcept
 Returns the layout_type of the expression.
bool is_contiguous () const noexcept
Data
template<class... Args>
const_reference operator() (Args... args) const
 Returns a constant reference to the element at the specified position in the expression.
template<class... Args>
const_reference unchecked (Args... args) const
 Returns a constant reference to the element at the specified position in the expression.
template<class It>
const_reference element (It first, It last) const
 Returns a constant reference to the element at the specified position in the view.
const xexpression_type & expression () const noexcept
 Returns a constant reference to the underlying expression of the broadcast expression.
Public Member Functions inherited from xt::xconst_iterable< xrepeat< CT, R > >
const_layout_iterator< L > begin () const noexcept
 Returns a constant iterator to the first element of the expression.
const_layout_iterator< L > end () const noexcept
 Returns a constant iterator to the element following the last element of the expression.
const_layout_iterator< L > cbegin () const noexcept
 Returns a constant iterator to the first element of the expression.
const_layout_iterator< L > cend () const noexcept
 Returns a constant iterator to the element following the last element of the expression.
const_reverse_layout_iterator< L > rbegin () const noexcept
 Returns a constant iterator to the first element of the reversed expression.
const_reverse_layout_iterator< L > rend () const noexcept
 Returns a constant iterator to the element following the last element of the reversed expression.
const_reverse_layout_iterator< L > crbegin () const noexcept
 Returns a constant iterator to the first element of the reversed expression.
const_reverse_layout_iterator< L > crend () const noexcept
 Returns a constant iterator to the element following the last element of the reversed expression.
Public Member Functions inherited from xt::xconst_accessible< xrepeat< CT, R > >
size_type size () const noexcept(noexcept(derived_cast().shape()))
 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.
const_reference at (Args... args) const
 Returns a constant reference to the element at the specified position in the expression, after dimension and bounds checking.
disable_integral_t< S, const_reference > operator[] (const S &index) const
 Returns a constant reference to the element at the specified position in the expression.
const_reference periodic (Args... args) const
 Returns a constant reference to the element at the specified position in the expression, after applying periodicity to the indices (negative and 'overflowing' indices are changed).
bool in_bounds (Args... args) const
 Returns true only if the the specified position is a valid entry in the expression.
const_reference front () const
 Returns a constant reference to first the element of the expression.
const_reference back () const
 Returns a constant reference to last the element of the expression.
Public Member Functions inherited from xt::xexpression< xrepeat< CT, R > >
derived_type & derived_cast () &noexcept
 Returns a reference to the actual derived type of the xexpression.

Static Public Attributes

static constexpr layout_type static_layout = xexpression_type::static_layout
static constexpr bool contiguous_layout = false

Broadcasting

template<class S>
bool broadcast_shape (S &shape, bool reuse_cache=false) const
 Broadcast the shape of the function to the specified parameter.
template<class S>
bool has_linear_assign (const S &strides) const noexcept
 Checks whether the xbroadcast can be linearly assigned to an expression with the specified strides.
const_stepper stepper_begin () const
const_stepper stepper_begin (const shape_type &s) const
const_stepper stepper_end (layout_type l) const
const_stepper stepper_end (const shape_type &s, layout_type l) const

Additional Inherited Members

const inner_shape_type & get_shape () const
Protected Member Functions inherited from xt::xconst_accessible< xrepeat< CT, R > >
xconst_accessible & operator= (const xconst_accessible &)=default
Protected Member Functions inherited from xt::xsharable_expression< xrepeat< CT, R > >
xsharable_expression & operator= (const xsharable_expression &)=default
Protected Member Functions inherited from xt::xexpression< xrepeat< CT, R > >
xexpression & operator= (const xexpression &)=default

Detailed Description

template<class CT, class R>
class xt::xrepeat< CT, R >

Expression with repeated values along an axis.

The xrepeat class implements the repetition of the elements of an xexpression along a given axis. xrepeat is not meant to be used directly, but only with the repeat helper functions.

See also
repeat

Definition at line 96 of file xrepeat.hpp.

Member Typedef Documentation

◆ accessible_base

template<class CT, class R>
using xt::xrepeat< CT, R >::accessible_base = xconst_accessible<self_type>

Definition at line 105 of file xrepeat.hpp.

◆ bool_load_type

template<class CT, class R>
using xt::xrepeat< CT, R >::bool_load_type = typename xexpression_type::bool_load_type

Definition at line 122 of file xrepeat.hpp.

◆ const_pointer

template<class CT, class R>
using xt::xrepeat< CT, R >::const_pointer = typename xexpression_type::const_pointer

Definition at line 124 of file xrepeat.hpp.

◆ const_reference

template<class CT, class R>
using xt::xrepeat< CT, R >::const_reference = typename container_type::const_reference

Definition at line 115 of file xrepeat.hpp.

◆ const_stepper

template<class CT, class R>
using xt::xrepeat< CT, R >::const_stepper = typename iterable_type::const_stepper

Definition at line 129 of file xrepeat.hpp.

◆ container_type

template<class CT, class R>
using xt::xrepeat< CT, R >::container_type = xcontainer_inner_types<xrepeat<CT, R>>

Definition at line 113 of file xrepeat.hpp.

◆ difference_type

template<class CT, class R>
using xt::xrepeat< CT, R >::difference_type = typename xexpression_type::difference_type

Definition at line 125 of file xrepeat.hpp.

◆ expression_tag

template<class CT, class R>
using xt::xrepeat< CT, R >::expression_tag = typename extension_base::expression_tag

Definition at line 107 of file xrepeat.hpp.

◆ extension_base

template<class CT, class R>
using xt::xrepeat< CT, R >::extension_base = extension::xrepeat_base_t<CT, R>

Definition at line 106 of file xrepeat.hpp.

◆ iterable_type

template<class CT, class R>
using xt::xrepeat< CT, R >::iterable_type = xiterable<xrepeat<CT, R>>

Definition at line 127 of file xrepeat.hpp.

◆ pointer

template<class CT, class R>
using xt::xrepeat< CT, R >::pointer = typename xexpression_type::pointer

Definition at line 123 of file xrepeat.hpp.

◆ reference

template<class CT, class R>
using xt::xrepeat< CT, R >::reference = typename container_type::reference

Definition at line 114 of file xrepeat.hpp.

◆ repeats_type

template<class CT, class R>
using xt::xrepeat< CT, R >::repeats_type = xtl::const_closure_type_t<R>

Definition at line 111 of file xrepeat.hpp.

◆ self_type

template<class CT, class R>
using xt::xrepeat< CT, R >::self_type = xrepeat<CT, R>

Definition at line 103 of file xrepeat.hpp.

◆ shape_type

template<class CT, class R>
using xt::xrepeat< CT, R >::shape_type = typename xexpression_type::shape_type

Definition at line 110 of file xrepeat.hpp.

◆ size_type

template<class CT, class R>
using xt::xrepeat< CT, R >::size_type = typename container_type::size_type

Definition at line 116 of file xrepeat.hpp.

◆ stepper

template<class CT, class R>
using xt::xrepeat< CT, R >::stepper = typename iterable_type::stepper

Definition at line 128 of file xrepeat.hpp.

◆ temporary_type

template<class CT, class R>
using xt::xrepeat< CT, R >::temporary_type = typename container_type::temporary_type

Definition at line 117 of file xrepeat.hpp.

◆ value_type

template<class CT, class R>
using xt::xrepeat< CT, R >::value_type = typename xexpression_type::value_type

Definition at line 109 of file xrepeat.hpp.

◆ xexpression_type

template<class CT, class R>
using xt::xrepeat< CT, R >::xexpression_type = std::decay_t<CT>

Definition at line 104 of file xrepeat.hpp.

Constructor & Destructor Documentation

◆ xrepeat()

template<class CT, class R>
template<class CTA>
xt::xrepeat< CT, R >::xrepeat ( CTA && e,
R && repeats,
size_type axis )
explicit

Constructs an xrepeat expression repeating the element of the specified xexpression.

Parameters
ethe input expression
repeatsThe number of repetitions for each elements
axisThe axis along which to repeat the value

Definition at line 259 of file xrepeat.hpp.

Member Function Documentation

◆ broadcast_shape()

template<class CT, class R>
template<class S>
bool xt::xrepeat< CT, R >::broadcast_shape ( S & shape,
bool reuse_cache = false ) const
inline

Broadcast the shape of the function to the specified parameter.

Parameters
shapethe result shape
reuse_cacheparameter for internal optimization
Returns
a boolean indicating whether the broadcasting is trivial

Definition at line 390 of file xrepeat.hpp.

◆ element()

template<class CT, class R>
template<class It>
auto xt::xrepeat< CT, R >::element ( It first,
It last ) const -> const_reference
inline

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

Parameters
firstiterator starting the sequence of indices
lastiterator ending the sequence of indices The number of indices in the sequence should be equal to or greater than the the number of dimensions of the view..

Definition at line 353 of file xrepeat.hpp.

◆ expression()

template<class CT, class R>
auto xt::xrepeat< CT, R >::expression ( ) const
inlinenoexcept

Returns a constant reference to the underlying expression of the broadcast expression.

Definition at line 371 of file xrepeat.hpp.

◆ has_linear_assign()

template<class CT, class R>
template<class S>
bool xt::xrepeat< CT, R >::has_linear_assign ( const S & strides) const
inlinenoexcept

Checks whether the xbroadcast can be linearly assigned to an expression with the specified strides.

Returns
a boolean indicating whether a linear assign is possible

Definition at line 402 of file xrepeat.hpp.

◆ is_contiguous()

template<class CT, class R>
bool xt::xrepeat< CT, R >::is_contiguous ( ) const
inlinenoexcept

Definition at line 294 of file xrepeat.hpp.

◆ layout()

template<class CT, class R>
auto xt::xrepeat< CT, R >::layout ( ) const
inlinenoexcept

Returns the layout_type of the expression.

Definition at line 288 of file xrepeat.hpp.

◆ operator()()

template<class CT, class R>
template<class... Args>
auto xt::xrepeat< CT, R >::operator() ( Args... args) const -> const_reference
inline

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

Parameters
argsa list of indices specifying the position in the function. Indices must be unsigned integers, the number of indices should be equal or greater than the number of dimensions of the expression.

Definition at line 313 of file xrepeat.hpp.

◆ shape()

template<class CT, class R>
auto xt::xrepeat< CT, R >::shape ( ) const
inlinenoexcept

Returns the shape of the expression.

Definition at line 279 of file xrepeat.hpp.

◆ stepper_begin() [1/2]

template<class CT, class R>
auto xt::xrepeat< CT, R >::stepper_begin ( ) const
inline

Definition at line 428 of file xrepeat.hpp.

◆ stepper_begin() [2/2]

template<class CT, class R>
auto xt::xrepeat< CT, R >::stepper_begin ( const shape_type & s) const
inline

Definition at line 434 of file xrepeat.hpp.

◆ stepper_end() [1/2]

template<class CT, class R>
auto xt::xrepeat< CT, R >::stepper_end ( const shape_type & s,
layout_type l ) const
inline

Definition at line 446 of file xrepeat.hpp.

◆ stepper_end() [2/2]

template<class CT, class R>
auto xt::xrepeat< CT, R >::stepper_end ( layout_type l) const
inline

Definition at line 440 of file xrepeat.hpp.

◆ unchecked()

template<class CT, class R>
template<class... Args>
auto xt::xrepeat< CT, R >::unchecked ( Args... args) const -> const_reference
inline

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

Parameters
argsa list of indices specifying the position in the expression. Indices must be unsigned integers, the number of indices must be equal to the number of dimensions of the expression, else the behavior is undefined.
Warning
This method is meant for performance, for expressions with a dynamic number of dimensions (i.e. not known at compile time). Since it may have undefined behavior (see parameters), operator() should be preferred whenever it is possible.
This method is NOT compatible with broadcasting, meaning the following code has undefined behavior:
xt::xarray<double> a = {{0, 1}, {2, 3}};
xt::xarray<double> b = {0, 1};
auto fd = a + b;
double res = fd.uncheked(0, 1);
xarray_container< uvector< T, A >, L, xt::svector< typename uvector< T, A >::size_type, 4, SA, true > > xarray
Alias template on xarray_container with default parameters for data container type and shape / stride...

Definition at line 339 of file xrepeat.hpp.

Member Data Documentation

◆ contiguous_layout

template<class CT, class R>
bool xt::xrepeat< CT, R >::contiguous_layout = false
staticconstexpr

Definition at line 120 of file xrepeat.hpp.

◆ static_layout

template<class CT, class R>
layout_type xt::xrepeat< CT, R >::static_layout = xexpression_type::static_layout
staticconstexpr

Definition at line 119 of file xrepeat.hpp.


The documentation for this class was generated from the following file:
  • /home/runner/work/xtensor/xtensor/include/xtensor/views/xrepeat.hpp