xtensor
Loading...
Searching...
No Matches
xt::xbroadcast< CT, X > Class Template Reference

Broadcasted xexpression to a specified shape. More...

#include <xbroadcast.hpp>

Inheritance diagram for xt::xbroadcast< CT, X >:
xt::xsharable_expression< xbroadcast< CT, X > > xt::xconst_iterable< xbroadcast< CT, X > > xt::xconst_accessible< xbroadcast< CT, X > > xt::xexpression< xbroadcast< CT, X > >

Public Types

using self_type = xbroadcast<CT, X>
using xexpression_type = std::decay_t<CT>
using accessible_base = xconst_accessible<self_type>
using extension_base = extension::xbroadcast_base_t<CT, X>
using expression_tag = typename extension_base::expression_tag
using inner_types = xcontainer_inner_types<self_type>
using value_type = typename xexpression_type::value_type
using reference = typename inner_types::reference
using const_reference = typename inner_types::const_reference
using pointer = typename xexpression_type::const_pointer
using const_pointer = typename xexpression_type::const_pointer
using size_type = typename inner_types::size_type
using difference_type = typename xexpression_type::difference_type
using iterable_base = xconst_iterable<self_type>
using inner_shape_type = typename iterable_base::inner_shape_type
using shape_type = inner_shape_type
using stepper = typename iterable_base::stepper
using const_stepper = typename iterable_base::const_stepper
using bool_load_type = typename xexpression_type::bool_load_type
template<class E>
using rebind_t = xbroadcast<E, X>
Public Types inherited from xt::xexpression< xbroadcast< CT, X > >
using derived_type
Public Types inherited from xt::xconst_iterable< xbroadcast< CT, X > >
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< xbroadcast< CT, X > >
using derived_type
using inner_types
using reference
using const_reference
using size_type

Public Member Functions

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.
Constructor
template<class CTA, class S>
 xbroadcast (CTA &&e, const S &s)
 Constructs an xbroadcast expression broadcasting the specified xexpression to the given shape.
template<class CTA>
 xbroadcast (CTA &&e, shape_type &&s)
 Constructs an xbroadcast expression broadcasting the specified xexpression to the given shape.
Size and shape
const inner_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 expression.
const xexpression_type & expression () const noexcept
 Returns a constant reference to the underlying expression of the broadcast expression.
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.
template<class S>
const_stepper stepper_begin (const S &shape) const noexcept
template<class S>
const_stepper stepper_end (const S &shape, layout_type l) const noexcept
template<class E, xscalar_concept XCT = CT>
void assign_to (xexpression< E > &e) const
template<class E>
rebind_t< E > build_broadcast (E &&e) const
Public Member Functions inherited from xt::xexpression< xbroadcast< CT, X > >
derived_type & derived_cast () &noexcept
 Returns a reference to the actual derived type of the xexpression.
Public Member Functions inherited from xt::xconst_iterable< xbroadcast< CT, X > >
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< xbroadcast< CT, X > >
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.

Static Public Attributes

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

Additional Inherited Members

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

Detailed Description

template<class CT, class X>
class xt::xbroadcast< CT, X >

Broadcasted xexpression to a specified shape.

The xbroadcast class implements the broadcasting of an xexpression to a specified shape. xbroadcast is not meant to be used directly, but only with the broadcast helper functions.

Template Parameters
CTthe closure type of the xexpression to broadcast
Xthe type of the specified shape.
See also
broadcast

Definition at line 158 of file xbroadcast.hpp.

Member Typedef Documentation

◆ accessible_base

template<class CT, class X>
using xt::xbroadcast< CT, X >::accessible_base = xconst_accessible<self_type>

Definition at line 167 of file xbroadcast.hpp.

◆ bool_load_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::bool_load_type = typename xexpression_type::bool_load_type

Definition at line 187 of file xbroadcast.hpp.

◆ const_pointer

template<class CT, class X>
using xt::xbroadcast< CT, X >::const_pointer = typename xexpression_type::const_pointer

Definition at line 176 of file xbroadcast.hpp.

◆ const_reference

template<class CT, class X>
using xt::xbroadcast< CT, X >::const_reference = typename inner_types::const_reference

Definition at line 174 of file xbroadcast.hpp.

◆ const_stepper

template<class CT, class X>
using xt::xbroadcast< CT, X >::const_stepper = typename iterable_base::const_stepper

Definition at line 185 of file xbroadcast.hpp.

◆ difference_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::difference_type = typename xexpression_type::difference_type

Definition at line 178 of file xbroadcast.hpp.

◆ expression_tag

template<class CT, class X>
using xt::xbroadcast< CT, X >::expression_tag = typename extension_base::expression_tag

Definition at line 169 of file xbroadcast.hpp.

◆ extension_base

template<class CT, class X>
using xt::xbroadcast< CT, X >::extension_base = extension::xbroadcast_base_t<CT, X>

Definition at line 168 of file xbroadcast.hpp.

◆ inner_shape_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::inner_shape_type = typename iterable_base::inner_shape_type

Definition at line 181 of file xbroadcast.hpp.

◆ inner_types

template<class CT, class X>
using xt::xbroadcast< CT, X >::inner_types = xcontainer_inner_types<self_type>

Definition at line 171 of file xbroadcast.hpp.

◆ iterable_base

template<class CT, class X>
using xt::xbroadcast< CT, X >::iterable_base = xconst_iterable<self_type>

Definition at line 180 of file xbroadcast.hpp.

◆ pointer

template<class CT, class X>
using xt::xbroadcast< CT, X >::pointer = typename xexpression_type::const_pointer

Definition at line 175 of file xbroadcast.hpp.

◆ rebind_t

template<class CT, class X>
template<class E>
using xt::xbroadcast< CT, X >::rebind_t = xbroadcast<E, X>

Definition at line 230 of file xbroadcast.hpp.

◆ reference

template<class CT, class X>
using xt::xbroadcast< CT, X >::reference = typename inner_types::reference

Definition at line 173 of file xbroadcast.hpp.

◆ self_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::self_type = xbroadcast<CT, X>

Definition at line 165 of file xbroadcast.hpp.

◆ shape_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::shape_type = inner_shape_type

Definition at line 182 of file xbroadcast.hpp.

◆ size_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::size_type = typename inner_types::size_type

Definition at line 177 of file xbroadcast.hpp.

◆ stepper

template<class CT, class X>
using xt::xbroadcast< CT, X >::stepper = typename iterable_base::stepper

Definition at line 184 of file xbroadcast.hpp.

◆ value_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::value_type = typename xexpression_type::value_type

Definition at line 172 of file xbroadcast.hpp.

◆ xexpression_type

template<class CT, class X>
using xt::xbroadcast< CT, X >::xexpression_type = std::decay_t<CT>

Definition at line 166 of file xbroadcast.hpp.

Constructor & Destructor Documentation

◆ xbroadcast() [1/2]

template<class CT, class X>
template<class CTA, class S>
xt::xbroadcast< CT, X >::xbroadcast ( CTA && e,
const S & s )
inline

Constructs an xbroadcast expression broadcasting the specified xexpression to the given shape.

Parameters
ethe expression to broadcast
sthe shape to apply

Definition at line 288 of file xbroadcast.hpp.

◆ xbroadcast() [2/2]

template<class CT, class X>
template<class CTA>
xt::xbroadcast< CT, X >::xbroadcast ( CTA && e,
shape_type && s )
inline

Constructs an xbroadcast expression broadcasting the specified xexpression to the given shape.

Parameters
ethe expression to broadcast
sthe shape to apply

Definition at line 309 of file xbroadcast.hpp.

Member Function Documentation

◆ assign_to()

template<class CT, class X>
template<class E, xscalar_concept XCT>
void xt::xbroadcast< CT, X >::assign_to ( xexpression< E > & e) const
inline

Definition at line 467 of file xbroadcast.hpp.

◆ broadcast_shape()

template<class CT, class X>
template<class S>
bool xt::xbroadcast< CT, X >::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 428 of file xbroadcast.hpp.

◆ build_broadcast()

template<class CT, class X>
template<class E>
auto xt::xbroadcast< CT, X >::build_broadcast ( E && e) const -> rebind_t< E >
inline

Definition at line 476 of file xbroadcast.hpp.

◆ element()

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

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

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 number of dimensions of the function.

Definition at line 400 of file xbroadcast.hpp.

◆ expression()

template<class CT, class X>
auto xt::xbroadcast< CT, X >::expression ( ) const
inlinenoexcept

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

Definition at line 409 of file xbroadcast.hpp.

◆ has_linear_assign()

template<class CT, class X>
template<class S>
bool xt::xbroadcast< CT, X >::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 440 of file xbroadcast.hpp.

◆ is_contiguous()

template<class CT, class X>
bool xt::xbroadcast< CT, X >::is_contiguous ( ) const
inlinenoexcept

Definition at line 341 of file xbroadcast.hpp.

◆ layout()

template<class CT, class X>
layout_type xt::xbroadcast< CT, X >::layout ( ) const
inlinenoexcept

Returns the layout_type of the expression.

Definition at line 335 of file xbroadcast.hpp.

◆ operator()()

template<class CT, class X>
template<class... Args>
auto xt::xbroadcast< CT, X >::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 360 of file xbroadcast.hpp.

◆ shape()

template<class CT, class X>
auto xt::xbroadcast< CT, X >::shape ( ) const
inlinenoexcept

Returns the shape of the expression.

Definition at line 326 of file xbroadcast.hpp.

◆ stepper_begin()

template<class CT, class X>
template<class S>
auto xt::xbroadcast< CT, X >::stepper_begin ( const S & shape) const -> const_stepper
inlinenoexcept

Definition at line 451 of file xbroadcast.hpp.

◆ stepper_end()

template<class CT, class X>
template<class S>
auto xt::xbroadcast< CT, X >::stepper_end ( const S & shape,
layout_type l ) const -> const_stepper
inlinenoexcept

Definition at line 459 of file xbroadcast.hpp.

◆ unchecked()

template<class CT, class X>
template<class... Args>
auto xt::xbroadcast< CT, X >::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 386 of file xbroadcast.hpp.

Member Data Documentation

◆ contiguous_layout

template<class CT, class X>
bool xt::xbroadcast< CT, X >::contiguous_layout = false
staticconstexpr

Definition at line 190 of file xbroadcast.hpp.

◆ static_layout

template<class CT, class X>
layout_type xt::xbroadcast< CT, X >::static_layout = layout_type::dynamic
staticconstexpr

Definition at line 189 of file xbroadcast.hpp.


The documentation for this class was generated from the following files:
  • /home/runner/work/xtensor/xtensor/include/xtensor/io/xmime.hpp
  • /home/runner/work/xtensor/xtensor/include/xtensor/views/xbroadcast.hpp