xtensor
Loading...
Searching...
No Matches
xt::xindex_view< CT, I > Class Template Reference

View of an xexpression from vector of indices. More...

#include <xindex_view.hpp>

Inheritance diagram for xt::xindex_view< CT, I >:
xt::xview_semantic< xindex_view< CT, I > > xt::xiterable< xindex_view< CT, I > > xt::xsemantic_base< xindex_view< CT, I > > xt::xconst_iterable< xindex_view< CT, I > >

Public Types

using self_type = xindex_view<CT, I>
using xexpression_type = std::decay_t<CT>
using semantic_base = xview_semantic<self_type>
using extension_base = extension::xindex_view_base_t<CT, I>
using expression_tag = typename extension_base::expression_tag
using value_type = typename xexpression_type::value_type
using reference = inner_reference_t<CT>
using const_reference = typename xexpression_type::const_reference
using pointer = typename xexpression_type::pointer
using const_pointer = typename xexpression_type::const_pointer
using size_type = typename xexpression_type::size_type
using difference_type = typename xexpression_type::difference_type
using iterable_base = xiterable<self_type>
using inner_shape_type = typename iterable_base::inner_shape_type
using shape_type = inner_shape_type
using indices_type = I
using stepper = typename iterable_base::stepper
using const_stepper = typename iterable_base::const_stepper
using temporary_type = typename xcontainer_inner_types<self_type>::temporary_type
using base_index_type = xindex_type_t<shape_type>
using bool_load_type = typename xexpression_type::bool_load_type
template<class E>
using rebind_t = xindex_view<E, I>
Public Types inherited from xt::xview_semantic< xindex_view< CT, I > >
using base_type
using derived_type
using temporary_type
Public Types inherited from xt::xsemantic_base< xindex_view< CT, I > >
using base_type
using derived_type
using temporary_type
Public Types inherited from xt::xiterable< xindex_view< CT, I > >
using derived_type
using base_type
using inner_shape_type
using stepper
using const_stepper
using linear_iterator
using reverse_linear_iterator
using layout_iterator
using const_layout_iterator
using reverse_layout_iterator
using const_reverse_layout_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_iterable< xindex_view< CT, I > >
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 Member Functions

Constructor
template<class CTA, class I2>
 xindex_view (CTA &&e, I2 &&indices) noexcept
 Constructs an xindex_view, selecting the indices specified by indices.
Size and shape
size_type size () const noexcept
 Returns the size of the xindex_view.
size_type dimension () const noexcept
 Returns the number of dimensions of the xindex_view.
const inner_shape_type & shape () const noexcept
 Returns the shape of the xindex_view.
size_type shape (size_type index) const
 Returns the i-th dimension of the expression.
layout_type layout () const noexcept
bool is_contiguous () const noexcept
Data
template<class T>
void fill (const T &value)
 Fills the view with the given value.
reference operator() (size_type idx=size_type(0))
 Returns a reference to the element at the specified position in the xindex_view.
template<class... Args>
reference operator() (size_type idx0, size_type idx1, Args... args)
reference unchecked (size_type idx)
 Returns a reference to the element at the specified position in the xindex_view.
template<class S>
disable_integral_t< S, reference > operator[] (const S &index)
 Returns a reference to the element at the specified position in the container.
template<class OI>
reference operator[] (std::initializer_list< OI > index)
reference operator[] (size_type i)
template<class It>
reference element (It first, It last)
 Returns a reference to the element at the specified position in the xindex_view.
const_reference operator() (size_type idx=size_type(0)) const
 Returns a constant reference to the element at the specified position in the xindex_view.
template<class... Args>
const_reference operator() (size_type idx0, size_type idx1, Args... args) const
const_reference unchecked (size_type idx) const
 Returns a constant reference to the element at the specified position in the xindex_view.
template<class S>
disable_integral_t< S, const_reference > operator[] (const S &index) const
 Returns a constant reference to the element at the specified position in the container.
template<class OI>
const_reference operator[] (std::initializer_list< OI > index) const
const_reference operator[] (size_type i) const
template<class It>
const_reference element (It first, It last) const
 Returns a reference to the element at the specified position in the xindex_view.
xexpression_type & expression () noexcept
 Returns a reference to the underlying expression of the view.
const xexpression_type & expression () const noexcept
 Returns a constant reference to the underlying expression of the view.
Broadcasting
template<class O>
bool broadcast_shape (O &shape, bool reuse_cache=false) const
 Broadcast the shape of the xindex_view to the specified parameter.
template<class O>
bool has_linear_assign (const O &) const noexcept
 Checks whether the xindex_view can be linearly assigned to an expression with the specified strides.
template<class ST>
stepper stepper_begin (const ST &shape)
template<class ST>
stepper stepper_end (const ST &shape, layout_type)
template<class ST>
const_stepper stepper_begin (const ST &shape) const
template<class ST>
const_stepper stepper_end (const ST &shape, layout_type) const
template<class E>
rebind_t< E > build_index_view (E &&e) const
Public Member Functions inherited from xt::xview_semantic< xindex_view< CT, I > >
derived_type & assign_temporary (temporary_type &&)
 Assigns the temporary tmp to *this.
derived_type & assign_xexpression (const xexpression< E > &e)
derived_type & computed_assign (const xexpression< E > &e)
derived_type & scalar_computed_assign (const E &e, F &&f)
Public Member Functions inherited from xt::xsemantic_base< xindex_view< CT, I > >
disable_xexpression< E, derived_type & > operator+= (const E &)
 Adds the scalar e to *this.
disable_xexpression< E, derived_type & > operator-= (const E &)
 Subtracts the scalar e from *this.
disable_xexpression< E, derived_type & > operator*= (const E &)
 Multiplies *this with the scalar e.
disable_xexpression< E, derived_type & > operator/= (const E &)
 Divides *this by the scalar e.
disable_xexpression< E, derived_type & > operator%= (const E &)
 Computes the remainder of *this after division by the scalar e.
disable_xexpression< E, derived_type & > operator&= (const E &)
 Computes the bitwise and of *this and the scalar e and assigns it to *this.
disable_xexpression< E, derived_type & > operator|= (const E &)
 Computes the bitwise or of *this and the scalar e and assigns it to *this.
disable_xexpression< E, derived_type & > operator^= (const E &)
 Computes the bitwise xor of *this and the scalar e and assigns it to *this.
derived_type & assign (const xexpression< E > &)
 Assigns the xexpression e to *this.
derived_type & plus_assign (const xexpression< E > &)
 Adds the xexpression e to *this.
derived_type & minus_assign (const xexpression< E > &)
 Subtracts the xexpression e to *this.
derived_type & multiplies_assign (const xexpression< E > &)
 Multiplies *this with the xexpression e.
derived_type & divides_assign (const xexpression< E > &)
 Divides *this by the xexpression e.
derived_type & modulus_assign (const xexpression< E > &)
 Computes the remainder of *this after division by the xexpression e.
derived_type & bit_and_assign (const xexpression< E > &)
 Computes the bitwise and of e to *this.
derived_type & bit_or_assign (const xexpression< E > &)
 Computes the bitwise or of e to *this.
derived_type & bit_xor_assign (const xexpression< E > &)
 Computes the bitwise xor of e to *this.
Public Member Functions inherited from xt::xiterable< xindex_view< CT, I > >
const_layout_iterator< L > begin () const noexcept
 Returns a constant iterator to the first element of the expression.
const_broadcast_iterator< S, L > begin (const S &shape) 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_broadcast_iterator< S, L > end (const S &shape) 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_broadcast_iterator< S, L > rbegin (const S &shape) 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_broadcast_iterator< S, L > rend (const S &shape) const noexcept
 Returns a constant iterator to the element following the last element of the reversed expression.
Public Member Functions inherited from xt::xconst_iterable< xindex_view< CT, I > >
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.

Static Public Attributes

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

Friends

class xview_semantic< xindex_view< CT, I > >

Extended copy semantic

template<class E>
self_type & operator= (const xexpression< E > &e)
 The extended assignment operator.
template<class E>
disable_xexpression< E, self_type > & operator= (const E &e)

Additional Inherited Members

Protected Member Functions inherited from xt::xview_semantic< xindex_view< CT, I > >
xview_semantic & operator= (const xview_semantic &)=default
Protected Member Functions inherited from xt::xsemantic_base< xindex_view< CT, I > >
xsemantic_base & operator= (const xsemantic_base &)=default
const inner_shape_type & get_shape () const

Detailed Description

template<class CT, class I>
class xt::xindex_view< CT, I >

View of an xexpression from vector of indices.

The xindex_view class implements a flat (1D) view into a multidimensional xexpression yielding the values at the indices of the index array. xindex_view is not meant to be used directly, but only with the index_view and filter helper functions.

Template Parameters
CTthe closure type of the xexpression type underlying this view
Ithe index array type of the view
See also
index_view, filter

Definition at line 90 of file xindex_view.hpp.

Member Typedef Documentation

◆ base_index_type

template<class CT, class I>
using xt::xindex_view< CT, I >::base_index_type = xindex_type_t<shape_type>

Definition at line 121 of file xindex_view.hpp.

◆ bool_load_type

template<class CT, class I>
using xt::xindex_view< CT, I >::bool_load_type = typename xexpression_type::bool_load_type

Definition at line 123 of file xindex_view.hpp.

◆ const_pointer

template<class CT, class I>
using xt::xindex_view< CT, I >::const_pointer = typename xexpression_type::const_pointer

Definition at line 107 of file xindex_view.hpp.

◆ const_reference

template<class CT, class I>
using xt::xindex_view< CT, I >::const_reference = typename xexpression_type::const_reference

Definition at line 105 of file xindex_view.hpp.

◆ const_stepper

template<class CT, class I>
using xt::xindex_view< CT, I >::const_stepper = typename iterable_base::const_stepper

Definition at line 118 of file xindex_view.hpp.

◆ difference_type

template<class CT, class I>
using xt::xindex_view< CT, I >::difference_type = typename xexpression_type::difference_type

Definition at line 109 of file xindex_view.hpp.

◆ expression_tag

template<class CT, class I>
using xt::xindex_view< CT, I >::expression_tag = typename extension_base::expression_tag

Definition at line 101 of file xindex_view.hpp.

◆ extension_base

template<class CT, class I>
using xt::xindex_view< CT, I >::extension_base = extension::xindex_view_base_t<CT, I>

Definition at line 100 of file xindex_view.hpp.

◆ indices_type

template<class CT, class I>
using xt::xindex_view< CT, I >::indices_type = I

Definition at line 115 of file xindex_view.hpp.

◆ inner_shape_type

template<class CT, class I>
using xt::xindex_view< CT, I >::inner_shape_type = typename iterable_base::inner_shape_type

Definition at line 112 of file xindex_view.hpp.

◆ iterable_base

template<class CT, class I>
using xt::xindex_view< CT, I >::iterable_base = xiterable<self_type>

Definition at line 111 of file xindex_view.hpp.

◆ pointer

template<class CT, class I>
using xt::xindex_view< CT, I >::pointer = typename xexpression_type::pointer

Definition at line 106 of file xindex_view.hpp.

◆ rebind_t

template<class CT, class I>
template<class E>
using xt::xindex_view< CT, I >::rebind_t = xindex_view<E, I>

Definition at line 193 of file xindex_view.hpp.

◆ reference

template<class CT, class I>
using xt::xindex_view< CT, I >::reference = inner_reference_t<CT>

Definition at line 104 of file xindex_view.hpp.

◆ self_type

template<class CT, class I>
using xt::xindex_view< CT, I >::self_type = xindex_view<CT, I>

Definition at line 96 of file xindex_view.hpp.

◆ semantic_base

template<class CT, class I>
using xt::xindex_view< CT, I >::semantic_base = xview_semantic<self_type>

Definition at line 98 of file xindex_view.hpp.

◆ shape_type

template<class CT, class I>
using xt::xindex_view< CT, I >::shape_type = inner_shape_type

Definition at line 113 of file xindex_view.hpp.

◆ size_type

template<class CT, class I>
using xt::xindex_view< CT, I >::size_type = typename xexpression_type::size_type

Definition at line 108 of file xindex_view.hpp.

◆ stepper

template<class CT, class I>
using xt::xindex_view< CT, I >::stepper = typename iterable_base::stepper

Definition at line 117 of file xindex_view.hpp.

◆ temporary_type

template<class CT, class I>
using xt::xindex_view< CT, I >::temporary_type = typename xcontainer_inner_types<self_type>::temporary_type

Definition at line 120 of file xindex_view.hpp.

◆ value_type

template<class CT, class I>
using xt::xindex_view< CT, I >::value_type = typename xexpression_type::value_type

Definition at line 103 of file xindex_view.hpp.

◆ xexpression_type

template<class CT, class I>
using xt::xindex_view< CT, I >::xexpression_type = std::decay_t<CT>

Definition at line 97 of file xindex_view.hpp.

Constructor & Destructor Documentation

◆ xindex_view()

template<class CT, class I>
template<class CTA, class I2>
xt::xindex_view< CT, I >::xindex_view ( CTA && e,
I2 && indices )
inlinenoexcept

Constructs an xindex_view, selecting the indices specified by indices.

The resulting xexpression has a 1D shape with a length of n for n indices.

Parameters
ethe underlying xexpression for this view
indicesthe indices to select

Definition at line 287 of file xindex_view.hpp.

Member Function Documentation

◆ broadcast_shape()

template<class CT, class I>
template<class O>
bool xt::xindex_view< CT, I >::broadcast_shape ( O & shape,
bool reuse_cache = false ) const
inline

Broadcast the shape of the xindex_view 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 562 of file xindex_view.hpp.

◆ build_index_view()

template<class CT, class I>
template<class E>
auto xt::xindex_view< CT, I >::build_index_view ( E && e) const -> rebind_t< E >
inline

Definition at line 619 of file xindex_view.hpp.

◆ dimension()

template<class CT, class I>
auto xt::xindex_view< CT, I >::dimension ( ) const
inlinenoexcept

Returns the number of dimensions of the xindex_view.

Definition at line 343 of file xindex_view.hpp.

◆ element() [1/2]

template<class CT, class I>
template<class It>
auto xt::xindex_view< CT, I >::element ( It first,
It last ) -> reference
inline

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

Parameters
firstiterator starting the sequence of indices
lastiterator ending the sequence of indices (not used, only for compatibility with xexpression operator()) The number of indices in the sequence should be equal to or greater 1.

Definition at line 512 of file xindex_view.hpp.

◆ element() [2/2]

template<class CT, class I>
template<class It>
auto xt::xindex_view< CT, I >::element ( It first,
It last ) const
inline

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

Parameters
firstiterator starting the sequence of indices
lastiterator ending the sequence of indices (not used, only for compatibility with xexpression operator()) The number of indices in the sequence should be equal to or greater 1.

Definition at line 525 of file xindex_view.hpp.

◆ expression() [1/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::expression ( ) const
inlinenoexcept

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

Definition at line 543 of file xindex_view.hpp.

◆ expression() [2/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::expression ( )
inlinenoexcept

Returns a reference to the underlying expression of the view.

Definition at line 534 of file xindex_view.hpp.

◆ fill()

template<class CT, class I>
template<class T>
void xt::xindex_view< CT, I >::fill ( const T & value)
inline

Fills the view with the given value.

Parameters
valuethe value to fill the view with.

Definition at line 391 of file xindex_view.hpp.

◆ has_linear_assign()

template<class CT, class I>
template<class O>
bool xt::xindex_view< CT, I >::has_linear_assign ( const O & ) const
inlinenoexcept

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

Returns
a boolean indicating whether a linear assign is possible

Definition at line 574 of file xindex_view.hpp.

◆ is_contiguous()

template<class CT, class I>
bool xt::xindex_view< CT, I >::is_contiguous ( ) const
inlinenoexcept

Definition at line 373 of file xindex_view.hpp.

◆ layout()

template<class CT, class I>
layout_type xt::xindex_view< CT, I >::layout ( ) const
inlinenoexcept

Definition at line 367 of file xindex_view.hpp.

◆ operator()() [1/4]

template<class CT, class I>
template<class... Args>
auto xt::xindex_view< CT, I >::operator() ( size_type idx0,
size_type idx1,
Args... args ) -> reference
inline

Definition at line 409 of file xindex_view.hpp.

◆ operator()() [2/4]

template<class CT, class I>
template<class... Args>
auto xt::xindex_view< CT, I >::operator() ( size_type idx0,
size_type idx1,
Args... args ) const
inline

Definition at line 437 of file xindex_view.hpp.

◆ operator()() [3/4]

template<class CT, class I>
auto xt::xindex_view< CT, I >::operator() ( size_type idx = size_type(0))
inline

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

Parameters
idxindex specifying the position in the index_view. More indices may be provided, only the last one will be used.

Definition at line 402 of file xindex_view.hpp.

◆ operator()() [4/4]

template<class CT, class I>
auto xt::xindex_view< CT, I >::operator() ( size_type idx = size_type(0)) const
inline

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

Parameters
idxindex specifying the position in the index_view. More indices may be provided, only the last one will be used.

Definition at line 430 of file xindex_view.hpp.

◆ operator=() [1/2]

template<class CT, class I>
template<class E>
auto xt::xindex_view< CT, I >::operator= ( const E & e)
inline

Definition at line 314 of file xindex_view.hpp.

◆ operator=() [2/2]

template<class CT, class I>
template<class E>
auto xt::xindex_view< CT, I >::operator= ( const xexpression< E > & e) -> self_type &
inline

The extended assignment operator.

Definition at line 305 of file xindex_view.hpp.

◆ operator[]() [1/6]

template<class CT, class I>
template<class S>
auto xt::xindex_view< CT, I >::operator[] ( const S & index) -> disable_integral_t< S, reference >
inline

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

Parameters
indexa 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.

Definition at line 460 of file xindex_view.hpp.

◆ operator[]() [2/6]

template<class CT, class I>
template<class S>
auto xt::xindex_view< CT, I >::operator[] ( const S & index) const
inline

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

Parameters
indexa 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.

Definition at line 486 of file xindex_view.hpp.

◆ operator[]() [3/6]

template<class CT, class I>
auto xt::xindex_view< CT, I >::operator[] ( size_type i)
inline

Definition at line 473 of file xindex_view.hpp.

◆ operator[]() [4/6]

template<class CT, class I>
auto xt::xindex_view< CT, I >::operator[] ( size_type i) const
inline

Definition at line 499 of file xindex_view.hpp.

◆ operator[]() [5/6]

template<class CT, class I>
template<class OI>
auto xt::xindex_view< CT, I >::operator[] ( std::initializer_list< OI > index)
inline

Definition at line 467 of file xindex_view.hpp.

◆ operator[]() [6/6]

template<class CT, class I>
template<class OI>
auto xt::xindex_view< CT, I >::operator[] ( std::initializer_list< OI > index) const
inline

Definition at line 493 of file xindex_view.hpp.

◆ shape() [1/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::shape ( ) const
inlinenoexcept

Returns the shape of the xindex_view.

Definition at line 352 of file xindex_view.hpp.

◆ shape() [2/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::shape ( size_type index) const
inline

Returns the i-th dimension of the expression.

Definition at line 361 of file xindex_view.hpp.

◆ size()

template<class CT, class I>
auto xt::xindex_view< CT, I >::size ( ) const
inlinenoexcept

Returns the size of the xindex_view.

Definition at line 334 of file xindex_view.hpp.

◆ stepper_begin() [1/2]

template<class CT, class I>
template<class ST>
auto xt::xindex_view< CT, I >::stepper_begin ( const ST & shape) -> stepper
inline

Definition at line 587 of file xindex_view.hpp.

◆ stepper_begin() [2/2]

template<class CT, class I>
template<class ST>
auto xt::xindex_view< CT, I >::stepper_begin ( const ST & shape) const
inline

Definition at line 603 of file xindex_view.hpp.

◆ stepper_end() [1/2]

template<class CT, class I>
template<class ST>
auto xt::xindex_view< CT, I >::stepper_end ( const ST & shape,
layout_type  ) -> stepper
inline

Definition at line 595 of file xindex_view.hpp.

◆ stepper_end() [2/2]

template<class CT, class I>
template<class ST>
auto xt::xindex_view< CT, I >::stepper_end ( const ST & shape,
layout_type  ) const
inline

Definition at line 611 of file xindex_view.hpp.

◆ unchecked() [1/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::unchecked ( size_type idx)
inline

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

Parameters
idxindex specifying the position in the index_view.

Definition at line 419 of file xindex_view.hpp.

◆ unchecked() [2/2]

template<class CT, class I>
auto xt::xindex_view< CT, I >::unchecked ( size_type idx) const
inline

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

Parameters
idxindex specifying the position in the index_view.

Definition at line 447 of file xindex_view.hpp.

◆ xview_semantic< xindex_view< CT, I > >

template<class CT, class I>
friend class xview_semantic< xindex_view< CT, I > >
friend

Definition at line 204 of file xindex_view.hpp.

Member Data Documentation

◆ contiguous_layout

template<class CT, class I>
bool xt::xindex_view< CT, I >::contiguous_layout = false
staticconstexpr

Definition at line 126 of file xindex_view.hpp.

◆ static_layout

template<class CT, class I>
layout_type xt::xindex_view< CT, I >::static_layout = layout_type::dynamic
staticconstexpr

Definition at line 125 of file xindex_view.hpp.


The documentation for this class was generated from the following file: