xtensor
Loading...
Searching...
No Matches
xt::xstrided_view_base< D > Class Template Reference
Inheritance diagram for xt::xstrided_view_base< D >:
xt::xaccessible< D > xt::xconst_accessible< D > xt::xdynamic_view< uvt, S, L, typename FST::template rebind_t< uvt > > xt::xdynamic_view< uft, S, L, typename FST::template rebind_t< uft > > xt::xdynamic_view< ucvt, S, L, typename FST::template rebind_t< ucvt > > xt::xdynamic_view< ucft, S, L, typename FST::template rebind_t< ucft > > xt::xdynamic_view< CT, S, L, FST > xt::xdynamic_view< E, S, L, typename FST::template rebind_t< E > > xt::xstrided_view< uvt, S, L, typename FST::template rebind_t< uvt > > xt::xstrided_view< uft, S, L, typename FST::template rebind_t< uft > > xt::xstrided_view< ucvt, S, L, typename FST::template rebind_t< ucvt > > xt::xstrided_view< ucft, S, L, typename FST::template rebind_t< ucft > > xt::xstrided_view< CT, shape_type > xt::xstrided_view< CT, S, L, FST > xt::xstrided_view< E, S, L, typename FST::template rebind_t< E > > xt::xdynamic_view< CT, S, L, FST > xt::xstrided_view< CT, S, L, FST >

Public Types

using base_type = xaccessible<D>
using inner_types = xcontainer_inner_types<D>
using xexpression_type = typename inner_types::xexpression_type
using undecay_expression = typename inner_types::undecay_expression
using value_type = typename xexpression_type::value_type
using reference = typename inner_types::reference
using const_reference = typename inner_types::const_reference
using 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 storage_getter = typename inner_types::storage_getter
using inner_storage_type = typename inner_types::inner_storage_type
using storage_type = std::remove_reference_t<inner_storage_type>
using shape_type = typename inner_types::shape_type
using strides_type = get_strides_t<shape_type>
using backstrides_type = strides_type
using inner_shape_type = shape_type
using inner_strides_type = strides_type
using inner_backstrides_type = backstrides_type
using undecay_shape = typename inner_types::undecay_shape
using simd_value_type = xt_simd::simd_type<value_type>
using bool_load_type = typename xexpression_type::bool_load_type
Public Types inherited from xt::xaccessible< D >
using base_type = xconst_accessible<D>
using derived_type = typename base_type::derived_type
using reference = typename base_type::reference
using size_type = typename base_type::size_type
Public Types inherited from xt::xconst_accessible< D >
using derived_type = D
using inner_types = xcontainer_inner_types<D>
using reference = typename inner_types::reference
using const_reference = typename inner_types::const_reference
using size_type = typename inner_types::size_type

Public Member Functions

Constructor
template<class CTA, class SA>
 xstrided_view_base (CTA &&e, SA &&shape, strides_type &&strides, size_type offset, layout_type layout) noexcept
 Constructs an xstrided_view_base.
 xstrided_view_base (xstrided_view_base &&rhs)
 xstrided_view_base (const xstrided_view_base &rhs)
Size and shape
const inner_shape_type & shape () const noexcept
 Returns the shape of the xtrided_view_base.
const inner_strides_type & strides () const noexcept
 Returns the strides of the xtrided_view_base.
const inner_backstrides_type & backstrides () const noexcept
 Returns the backstrides of the xtrided_view_base.
layout_type layout () const noexcept
 Returns the layout of the xtrided_view_base.
bool is_contiguous () const noexcept
Data
reference operator() ()
const_reference operator() () const
template<class... Args>
reference operator() (Args... args)
 Returns a reference to the element at the specified position in the view.
template<class... Args>
const_reference operator() (Args... args) const
 Returns a constant reference to the element at the specified position in the view.
template<class... Args>
reference unchecked (Args... args)
 Returns a reference to the element at the specified position in the view.
template<class... Args>
const_reference unchecked (Args... args) const
 Returns a constant reference to the element at the specified position in the view.
template<class It>
reference element (It first, It last)
 Returns a reference to the element at the specified position in the view.
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.
storage_type & storage () noexcept
 Returns a reference to the buffer containing the elements of the view.
const storage_type & storage () const noexcept
 Returns a constant reference to the buffer containing the elements of the view.
pointer data () noexcept
 Returns a pointer to the underlying array serving as element storage.
const_pointer data () const noexcept
 Returns a constant pointer to the underlying array serving as element storage.
size_type data_offset () const noexcept
 Returns the offset to the first element in the 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.
Public Member Functions inherited from xt::xaccessible< D >
template<class... Args>
reference at (Args... args)
 Returns a reference to the element at the specified position in the expression, after dimension and bounds checking.
template<class S>
disable_integral_t< S, reference > operator[] (const S &index)
 Returns a reference to the element at the specified position in the expression.
template<class I>
reference operator[] (std::initializer_list< I > index)
reference operator[] (size_type i)
template<class... Args>
reference periodic (Args... args)
 Returns a reference to the element at the specified position in the expression, after applying periodicity to the indices (negative and 'overflowing' indices are changed).
reference front ()
 Returns a reference to the first element of the expression.
reference back ()
 Returns a reference to the last element of the expression.
template<class... Args>
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.
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 expression.
template<class I>
const_reference operator[] (std::initializer_list< I > index) const
const_reference operator[] (size_type i) const
const_reference back () const
 Returns a constant reference to last the element of the expression.
const_reference front () const
 Returns a constant reference to first the element of the expression.
template<class... Args>
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).
Public Member Functions inherited from xt::xconst_accessible< D >
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.
template<class... Args>
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.
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 expression.
template<class I>
const_reference operator[] (std::initializer_list< I > index) const
const_reference operator[] (size_type i) const
template<class... Args>
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).
template<class... Args>
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 bool is_const = std::is_const<std::remove_reference_t<undecay_expression>>::value
static constexpr layout_type static_layout = inner_types::layout
static constexpr bool contiguous_layout
static constexpr bool provides_data_interface = detail::provides_data_interface<xexpression_type, storage_type>::value

Protected Types

using offset_type = typename strides_type::value_type

Broadcasting

template<class O>
bool broadcast_shape (O &shape, bool reuse_cache=false) const
 Broadcast the shape of the view to the specified parameter.
template<class O>
bool has_linear_assign (const O &strides) const noexcept
 Checks whether the xstrided_view_base can be linearly assigned to an expression with the specified strides.
template<class... Args>
offset_type compute_index (Args... args) const
template<class... Args>
offset_type compute_unchecked_index (Args... args) const
template<class It>
offset_type compute_element_index (It first, It last) const
void set_offset (size_type offset)

Additional Inherited Members

Protected Member Functions inherited from xt::xaccessible< D >
 xaccessible (const xaccessible &)=default
xaccessible & operator= (const xaccessible &)=default
 xaccessible (xaccessible &&)=default
xaccessible & operator= (xaccessible &&)=default
Protected Member Functions inherited from xt::xconst_accessible< D >
 xconst_accessible (const xconst_accessible &)=default
xconst_accessible & operator= (const xconst_accessible &)=default
 xconst_accessible (xconst_accessible &&)=default
xconst_accessible & operator= (xconst_accessible &&)=default

Detailed Description

template<class D>
class xt::xstrided_view_base< D >

Definition at line 96 of file xstrided_view_base.hpp.

Member Typedef Documentation

◆ backstrides_type

template<class D>
using xt::xstrided_view_base< D >::backstrides_type = strides_type

Definition at line 121 of file xstrided_view_base.hpp.

◆ base_type

template<class D>
using xt::xstrided_view_base< D >::base_type = xaccessible<D>

Definition at line 100 of file xstrided_view_base.hpp.

◆ bool_load_type

template<class D>
using xt::xstrided_view_base< D >::bool_load_type = typename xexpression_type::bool_load_type

Definition at line 130 of file xstrided_view_base.hpp.

◆ const_pointer

template<class D>
using xt::xstrided_view_base< D >::const_pointer = typename xexpression_type::const_pointer

Definition at line 111 of file xstrided_view_base.hpp.

◆ const_reference

template<class D>
using xt::xstrided_view_base< D >::const_reference = typename inner_types::const_reference

Definition at line 108 of file xstrided_view_base.hpp.

◆ difference_type

template<class D>
using xt::xstrided_view_base< D >::difference_type = typename xexpression_type::difference_type

Definition at line 113 of file xstrided_view_base.hpp.

◆ inner_backstrides_type

template<class D>
using xt::xstrided_view_base< D >::inner_backstrides_type = backstrides_type

Definition at line 125 of file xstrided_view_base.hpp.

◆ inner_shape_type

template<class D>
using xt::xstrided_view_base< D >::inner_shape_type = shape_type

Definition at line 123 of file xstrided_view_base.hpp.

◆ inner_storage_type

template<class D>
using xt::xstrided_view_base< D >::inner_storage_type = typename inner_types::inner_storage_type

Definition at line 116 of file xstrided_view_base.hpp.

◆ inner_strides_type

template<class D>
using xt::xstrided_view_base< D >::inner_strides_type = strides_type

Definition at line 124 of file xstrided_view_base.hpp.

◆ inner_types

template<class D>
using xt::xstrided_view_base< D >::inner_types = xcontainer_inner_types<D>

Definition at line 101 of file xstrided_view_base.hpp.

◆ offset_type

template<class D>
using xt::xstrided_view_base< D >::offset_type = typename strides_type::value_type
protected

Definition at line 195 of file xstrided_view_base.hpp.

◆ pointer

template<class D>
using xt::xstrided_view_base< D >::pointer
Initial value:
std::
conditional_t<is_const, typename xexpression_type::const_pointer, typename xexpression_type::pointer>

Definition at line 109 of file xstrided_view_base.hpp.

◆ reference

template<class D>
using xt::xstrided_view_base< D >::reference = typename inner_types::reference

Definition at line 107 of file xstrided_view_base.hpp.

◆ shape_type

template<class D>
using xt::xstrided_view_base< D >::shape_type = typename inner_types::shape_type

Definition at line 119 of file xstrided_view_base.hpp.

◆ simd_value_type

template<class D>
using xt::xstrided_view_base< D >::simd_value_type = xt_simd::simd_type<value_type>

Definition at line 129 of file xstrided_view_base.hpp.

◆ size_type

template<class D>
using xt::xstrided_view_base< D >::size_type = typename inner_types::size_type

Definition at line 112 of file xstrided_view_base.hpp.

◆ storage_getter

template<class D>
using xt::xstrided_view_base< D >::storage_getter = typename inner_types::storage_getter

Definition at line 115 of file xstrided_view_base.hpp.

◆ storage_type

template<class D>
using xt::xstrided_view_base< D >::storage_type = std::remove_reference_t<inner_storage_type>

Definition at line 117 of file xstrided_view_base.hpp.

◆ strides_type

template<class D>
using xt::xstrided_view_base< D >::strides_type = get_strides_t<shape_type>

Definition at line 120 of file xstrided_view_base.hpp.

◆ undecay_expression

template<class D>
using xt::xstrided_view_base< D >::undecay_expression = typename inner_types::undecay_expression

Definition at line 103 of file xstrided_view_base.hpp.

◆ undecay_shape

template<class D>
using xt::xstrided_view_base< D >::undecay_shape = typename inner_types::undecay_shape

Definition at line 127 of file xstrided_view_base.hpp.

◆ value_type

template<class D>
using xt::xstrided_view_base< D >::value_type = typename xexpression_type::value_type

Definition at line 106 of file xstrided_view_base.hpp.

◆ xexpression_type

template<class D>
using xt::xstrided_view_base< D >::xexpression_type = typename inner_types::xexpression_type

Definition at line 102 of file xstrided_view_base.hpp.

Constructor & Destructor Documentation

◆ xstrided_view_base() [1/3]

template<class D>
template<class CTA, class SA>
xt::xstrided_view_base< D >::xstrided_view_base ( CTA && e,
SA && shape,
strides_type && strides,
size_type offset,
layout_type layout )
inlinenoexcept

Constructs an xstrided_view_base.

Parameters
ethe underlying xexpression for this view
shapethe shape of the view
stridesthe strides of the view
offsetthe offset of the first element in the underlying container
layoutthe layout of the view

Definition at line 317 of file xstrided_view_base.hpp.

◆ xstrided_view_base() [2/3]

template<class D>
xt::xstrided_view_base< D >::xstrided_view_base ( xstrided_view_base< D > && rhs)
inline

Definition at line 355 of file xstrided_view_base.hpp.

◆ xstrided_view_base() [3/3]

template<class D>
xt::xstrided_view_base< D >::xstrided_view_base ( const xstrided_view_base< D > & rhs)
inline

Definition at line 368 of file xstrided_view_base.hpp.

Member Function Documentation

◆ backstrides()

template<class D>
auto xt::xstrided_view_base< D >::backstrides ( ) const
inlinenoexcept

Returns the backstrides of the xtrided_view_base.

Definition at line 408 of file xstrided_view_base.hpp.

◆ broadcast_shape()

template<class D>
template<class O>
bool xt::xstrided_view_base< D >::broadcast_shape ( O & shape,
bool reuse_cache = false ) const
inline

Broadcast the shape of the 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 643 of file xstrided_view_base.hpp.

◆ compute_element_index()

template<class D>
template<class It>
auto xt::xstrided_view_base< D >::compute_element_index ( It first,
It last ) const -> offset_type
inlineprotected

Definition at line 681 of file xstrided_view_base.hpp.

◆ compute_index()

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::compute_index ( Args... args) const -> offset_type
inlineprotected

Definition at line 665 of file xstrided_view_base.hpp.

◆ compute_unchecked_index()

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::compute_unchecked_index ( Args... args) const -> offset_type
inlineprotected

Definition at line 673 of file xstrided_view_base.hpp.

◆ data() [1/2]

template<class D>
requires (provides_data_interface)
auto xt::xstrided_view_base< D >::data ( ) const
inlinenoexcept

Returns a constant pointer to the underlying array serving as element storage.

The first element of the view is at data() + data_offset().

Definition at line 596 of file xstrided_view_base.hpp.

◆ data() [2/2]

template<class D>
requires (provides_data_interface)
auto xt::xstrided_view_base< D >::data ( )
inlinenoexcept

Returns a pointer to the underlying array serving as element storage.

The first element of the view is at data() + data_offset().

Definition at line 585 of file xstrided_view_base.hpp.

◆ data_offset()

template<class D>
auto xt::xstrided_view_base< D >::data_offset ( ) const
inlinenoexcept

Returns the offset to the first element in the view.

Definition at line 606 of file xstrided_view_base.hpp.

◆ element() [1/2]

template<class D>
template<class It>
auto xt::xstrided_view_base< D >::element ( It first,
It last ) -> reference
inline

Returns a 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 541 of file xstrided_view_base.hpp.

◆ element() [2/2]

template<class D>
template<class It>
auto xt::xstrided_view_base< D >::element ( It first,
It last ) const
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 556 of file xstrided_view_base.hpp.

◆ expression() [1/2]

template<class D>
auto xt::xstrided_view_base< D >::expression ( ) const
inlinenoexcept

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

Definition at line 624 of file xstrided_view_base.hpp.

◆ expression() [2/2]

template<class D>
auto xt::xstrided_view_base< D >::expression ( )
inlinenoexcept

Returns a reference to the underlying expression of the view.

Definition at line 615 of file xstrided_view_base.hpp.

◆ has_linear_assign()

template<class D>
template<class O>
bool xt::xstrided_view_base< D >::has_linear_assign ( const O & str) const
inlinenoexcept

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

Returns
a boolean indicating whether a linear assign is possible

Definition at line 655 of file xstrided_view_base.hpp.

◆ is_contiguous()

template<class D>
bool xt::xstrided_view_base< D >::is_contiguous ( ) const
inlinenoexcept

Definition at line 423 of file xstrided_view_base.hpp.

◆ layout()

template<class D>
auto xt::xstrided_view_base< D >::layout ( ) const
inlinenoexcept

Returns the layout of the xtrided_view_base.

Definition at line 417 of file xstrided_view_base.hpp.

◆ operator()() [1/4]

template<class D>
auto xt::xstrided_view_base< D >::operator() ( )
inline

Definition at line 435 of file xstrided_view_base.hpp.

◆ operator()() [2/4]

template<class D>
auto xt::xstrided_view_base< D >::operator() ( ) const
inline

Definition at line 441 of file xstrided_view_base.hpp.

◆ operator()() [3/4]

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::operator() ( Args... args) -> reference
inline

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

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

Definition at line 454 of file xstrided_view_base.hpp.

◆ operator()() [4/4]

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::operator() ( Args... args) const
inline

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

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

Definition at line 470 of file xstrided_view_base.hpp.

◆ set_offset()

template<class D>
void xt::xstrided_view_base< D >::set_offset ( size_type offset)
protected

Definition at line 687 of file xstrided_view_base.hpp.

◆ shape()

template<class D>
auto xt::xstrided_view_base< D >::shape ( ) const
inlinenoexcept

Returns the shape of the xtrided_view_base.

Definition at line 390 of file xstrided_view_base.hpp.

◆ storage() [1/2]

template<class D>
auto xt::xstrided_view_base< D >::storage ( ) const
inlinenoexcept

Returns a constant reference to the buffer containing the elements of the view.

Definition at line 575 of file xstrided_view_base.hpp.

◆ storage() [2/2]

template<class D>
auto xt::xstrided_view_base< D >::storage ( )
inlinenoexcept

Returns a reference to the buffer containing the elements of the view.

Definition at line 566 of file xstrided_view_base.hpp.

◆ strides()

template<class D>
auto xt::xstrided_view_base< D >::strides ( ) const
inlinenoexcept

Returns the strides of the xtrided_view_base.

Definition at line 399 of file xstrided_view_base.hpp.

◆ unchecked() [1/2]

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::unchecked ( Args... args) -> reference
inline

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

Parameters
argsa list of indices specifying the position in the view. Indices must be unsigned integers, the number of indices must be equal to the number of dimensions of the view, 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 499 of file xstrided_view_base.hpp.

◆ unchecked() [2/2]

template<class D>
template<class... Args>
auto xt::xstrided_view_base< D >::unchecked ( Args... args) const
inline

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

Parameters
argsa list of indices specifying the position in the view. Indices must be unsigned integers, the number of indices must be equal to the number of dimensions of the view, 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 526 of file xstrided_view_base.hpp.

Member Data Documentation

◆ contiguous_layout

template<class D>
bool xt::xstrided_view_base< D >::contiguous_layout
staticconstexpr
Initial value:
= static_layout != layout_type::dynamic
&& xexpression_type::contiguous_layout

Definition at line 133 of file xstrided_view_base.hpp.

◆ is_const

template<class D>
bool xt::xstrided_view_base< D >::is_const = std::is_const<std::remove_reference_t<undecay_expression>>::value
staticconstexpr

Definition at line 104 of file xstrided_view_base.hpp.

◆ provides_data_interface

template<class D>
bool xt::xstrided_view_base< D >::provides_data_interface = detail::provides_data_interface<xexpression_type, storage_type>::value
staticconstexpr

Definition at line 137 of file xstrided_view_base.hpp.

◆ static_layout

template<class D>
layout_type xt::xstrided_view_base< D >::static_layout = inner_types::layout
staticconstexpr

Definition at line 132 of file xstrided_view_base.hpp.


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