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< D >

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< D >
using derived_type = D
 

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.
 
template<class... Args>
const_reference operator() (Args... args) const
 
template<class... Args>
const_reference unchecked (Args... args) const
 
template<class It >
const_reference element (It first, It last) const
 
size_type size () const noexcept
 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
const xexpression_type & expression () const noexcept
 Returns a constant reference to the underlying expression of the broadcast expression.
 
template<class... Args>
auto operator() (Args... args) const -> const_reference
 Returns a constant reference to the element at the specified position in the expression.
 
template<class... Args>
auto unchecked (Args... args) const -> const_reference
 Returns a constant reference to the element at the specified position in the expression.
 
template<class It >
auto element (It first, It last) const -> const_reference
 Returns a constant reference to the element at the specified position in the view.
 
- Public Member Functions inherited from xt::xconst_iterable< xrepeat< CT, R > >
const_layout_iterator< Lbegin () const noexcept
 
const_broadcast_iterator< S, Lbegin (const S &shape) const noexcept
 
const_layout_iterator< Lend () const noexcept
 
const_broadcast_iterator< S, Lend (const S &shape) const noexcept
 
const_layout_iterator< Lcbegin () const noexcept
 
const_broadcast_iterator< S, Lcbegin (const S &shape) const noexcept
 
const_layout_iterator< Lcend () const noexcept
 
const_broadcast_iterator< S, Lcend (const S &shape) const noexcept
 
const_reverse_layout_iterator< Lrbegin () const noexcept
 
const_reverse_broadcast_iterator< S, Lrbegin (const S &shape) const noexcept
 
const_reverse_layout_iterator< Lrend () const noexcept
 
const_reverse_broadcast_iterator< S, Lrend (const S &shape) const noexcept
 
const_reverse_layout_iterator< Lcrbegin () const noexcept
 
const_reverse_broadcast_iterator< S, Lcrbegin (const S &shape) const noexcept
 
const_reverse_layout_iterator< Lcrend () const noexcept
 
const_reverse_broadcast_iterator< S, Lcrend (const S &shape) const noexcept
 
auto begin () const noexcept -> const_layout_iterator< L >
 Returns a constant iterator to the first element of the expression.
 
auto end () const noexcept -> const_layout_iterator< L >
 Returns a constant iterator to the element following the last element of the expression.
 
auto cbegin () const noexcept -> const_layout_iterator< L >
 Returns a constant iterator to the first element of the expression.
 
auto cend () const noexcept -> const_layout_iterator< L >
 Returns a constant iterator to the element following the last element of the expression.
 
auto begin (const S &shape) const noexcept -> const_broadcast_iterator< S, L >
 Returns a constant iterator to the first element of the expression.
 
auto end (const S &shape) const noexcept -> const_broadcast_iterator< S, L >
 Returns a constant iterator to the element following the last element of the expression.
 
auto cbegin (const S &shape) const noexcept -> const_broadcast_iterator< S, L >
 Returns a constant iterator to the first element of the expression.
 
auto cend (const S &shape) const noexcept -> const_broadcast_iterator< S, L >
 Returns a constant iterator to the element following the last element of the expression.
 
auto rbegin () const noexcept -> const_reverse_layout_iterator< L >
 Returns a constant iterator to the first element of the reversed expression.
 
auto rend () const noexcept -> const_reverse_layout_iterator< L >
 Returns a constant iterator to the element following the last element of the reversed expression.
 
auto crbegin () const noexcept -> const_reverse_layout_iterator< L >
 Returns a constant iterator to the first element of the reversed expression.
 
auto crend () const noexcept -> const_reverse_layout_iterator< L >
 Returns a constant iterator to the element following the last element of the reversed expression.
 
auto rbegin (const S &shape) const noexcept -> const_reverse_broadcast_iterator< S, L >
 Returns a constant iterator to the first element of the reversed expression.
 
auto rend (const S &shape) const noexcept -> const_reverse_broadcast_iterator< S, L >
 Returns a constant iterator to the element following the last element of the reversed expression.
 
auto crbegin (const S &shape) const noexcept -> const_reverse_broadcast_iterator< S, L >
 Returns a constant iterator to the first element of the reversed expression.
 
auto crend (const S &shape) const noexcept -> const_reverse_broadcast_iterator< S, L >
 Returns a constant iterator to the element following the last element of the reversed expression.
 
auto get_cbegin (bool end_index) const noexcept -> const_layout_iterator< L >
 
auto get_cbegin (const S &shape, bool end_index) const noexcept -> const_broadcast_iterator< S, L >
 
auto get_cend (bool end_index) const noexcept -> const_layout_iterator< L >
 
auto get_cend (const S &shape, bool end_index) const noexcept -> const_broadcast_iterator< S, L >
 
auto get_stepper_begin (const S &shape) const noexcept -> const_stepper
 
auto get_stepper_end (const S &shape, layout_type l) const noexcept -> const_stepper
 
- Public Member Functions inherited from xt::xconst_accessible< xrepeat< CT, R > >
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.
 
const_reference at (Args... args) const
 
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.
 
disable_integral_t< S, const_reference > operator[] (const S &index) const
 
const_reference operator[] (std::initializer_list< I > index) const
 
const_reference operator[] (size_type i) const
 
auto operator[] (const S &index) const -> disable_integral_t< S, const_reference >
 Returns a constant reference to the element at the specified position in the expression.
 
auto operator[] (std::initializer_list< I > index) const -> const_reference
 
const_reference periodic (Args... args) const
 
auto periodic (Args... args) const -> const_reference
 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< D >
derived_typederived_cast () &noexcept
 Returns a reference to the actual derived type of the xexpression.
 
const derived_typederived_cast () const &noexcept
 Returns a constant reference to the actual derived type of the xexpression.
 
derived_type derived_cast () &&noexcept
 Returns a constant 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
 
template<class Arg , class... Args>
auto access (Arg arg, Args... args) const -> const_reference
 
template<std::size_t I, class Arg , class... Args>
auto access_impl (stepper &&s, Arg arg, Args... args) const -> const_reference
 
template<std::size_t I>
auto access_impl (stepper &&s) const -> const_reference
 

Additional Inherited Members

- Protected Member Functions inherited from xt::xconst_iterable< xrepeat< CT, R > >
const inner_shape_type & get_shape () const
 
- Protected Member Functions inherited from xt::xconst_accessible< xrepeat< CT, R > >
 xconst_accessible (const xconst_accessible &)=default
 
 xconst_accessible (xconst_accessible &&)=default
 
xconst_accessibleoperator= (const xconst_accessible &)=default
 
xconst_accessibleoperator= (xconst_accessible &&)=default
 
- Protected Member Functions inherited from xt::xsharable_expression< xrepeat< CT, R > >
 xsharable_expression (const xsharable_expression &)=default
 
 xsharable_expression (xsharable_expression &&)=default
 
xsharable_expressionoperator= (const xsharable_expression &)=default
 
xsharable_expressionoperator= (xsharable_expression &&)=default
 
- Protected Member Functions inherited from xt::xexpression< D >
 xexpression (const xexpression &)=default
 
xexpressionoperator= (const xexpression &)=default
 
 xexpression (xexpression &&)=default
 
xexpressionoperator= (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

◆ access()

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

Definition at line 417 of file xrepeat.hpp.

◆ access_impl() [1/2]

template<class CT , class R >
template<std::size_t I>
auto xt::xrepeat< CT, R >::access_impl ( stepper && s) const -> const_reference
inline

Definition at line 463 of file xrepeat.hpp.

◆ access_impl() [2/2]

template<class CT , class R >
template<std::size_t I, class Arg , class... Args>
auto xt::xrepeat< CT, R >::access_impl ( stepper && s,
Arg arg,
Args... args ) const -> const_reference
inline

Definition at line 455 of file xrepeat.hpp.

◆ 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() [1/2]

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.

◆ shape() [2/2]

template<class CT , class R >
auto xt::xconst_accessible< D >::shape ( size_type index) const
inline

Returns the i-th dimension of the expression.

Definition at line 41 of file xaccessible.hpp.

◆ size()

template<class CT , class R >
auto xt::xconst_accessible< D >::size ( ) const
inlinenoexcept

Returns the size of the expression.

Definition at line 39 of file xaccessible.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);

Definition at line 339 of file xrepeat.hpp.

Member Data Documentation

◆ contiguous_layout

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

Definition at line 120 of file xrepeat.hpp.

◆ static_layout

template<class CT , class R >
constexpr 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: