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::xstrided_view< CT, shape_type > 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

template<class... Args>
reference operator() (Args... args)
 
template<class... Args>
const_reference operator() (Args... args) const
 
template<class... Args>
reference unchecked (Args... args)
 
template<class... Args>
const_reference unchecked (Args... args) const
 
template<class It >
reference element (It first, It last)
 
template<class It >
const_reference element (It first, It last) const
 
template<class E = xexpression_type, class ST = storage_type>
std::enable_if_t< detail::provides_data_interface< E, ST >::value, pointer > data () noexcept
 
template<class E = xexpression_type, class ST = storage_type>
std::enable_if_t< detail::provides_data_interface< E, ST >::value, const_pointer > data () const noexcept
 
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_typestrides () const noexcept
 Returns the strides of the xtrided_view_base.
 
const inner_backstrides_typebackstrides () 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
 
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.
 
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.
 
template<class... Args>
auto operator() (Args... args) -> reference
 Returns a reference to the element at the specified position in the view.
 
template<class... Args>
auto operator() (Args... args) const -> const_reference
 Returns a constant reference to the element at the specified position in the view.
 
template<class... Args>
auto unchecked (Args... args) -> reference
 Returns a reference to the element at the specified position in the view.
 
template<class... Args>
auto unchecked (Args... args) const -> const_reference
 Returns a constant reference to the element at the specified position in the view.
 
template<class It >
auto element (It first, It last) -> reference
 Returns a reference to the element at the specified position in the view.
 
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.
 
template<class E , class ST >
auto data () noexcept -> std::enable_if_t< detail::provides_data_interface< E, ST >::value, pointer >
 Returns a pointer to the underlying array serving as element storage.
 
template<class E , class ST >
auto data () const noexcept -> std::enable_if_t< detail::provides_data_interface< E, ST >::value, const_pointer >
 Returns a constant pointer to the underlying array serving as element storage.
 
- Public Member Functions inherited from xt::xaccessible< D >
template<class... Args>
reference at (Args... args)
 
template<class S >
disable_integral_t< S, reference > operator[] (const S &index)
 
template<class I >
reference operator[] (std::initializer_list< I > index)
 
reference operator[] (size_type i)
 
template<class... Args>
reference periodic (Args... args)
 
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>
auto at (Args... args) -> reference
 Returns a reference to the element at the specified position in the expression, after dimension and bounds checking.
 
template<class S >
auto operator[] (const S &index) -> disable_integral_t< S, reference >
 Returns a reference to the element at the specified position in the expression.
 
template<class I >
auto operator[] (std::initializer_list< I > index) -> reference
 
template<class... Args>
auto periodic (Args... args) -> reference
 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).
 
template<class... Args>
const_reference at (Args... args) const
 
template<class... Args>
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.
 
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
 
template<class... Args>
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).
 
- Public Member Functions inherited from xt::xconst_accessible< D >
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.
 
template<class... Args>
const_reference at (Args... args) const
 
template<class S >
disable_integral_t< S, const_reference > operator[] (const S &index) const
 
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
 
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.
 
template<class... Args>
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.
 
template<class S >
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.
 
template<class I >
auto operator[] (std::initializer_list< I > index) const -> const_reference
 
template<class... Args>
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).
 

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
 

Protected Types

using offset_type = typename strides_type::value_type
 

Protected Member Functions

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
 
- Protected Member Functions inherited from xt::xaccessible< D >
 xaccessible (const xaccessible &)=default
 
xaccessibleoperator= (const xaccessible &)=default
 
 xaccessible (xaccessible &&)=default
 
xaccessibleoperator= (xaccessible &&)=default
 
- Protected Member Functions inherited from xt::xconst_accessible< D >
 xconst_accessible (const xconst_accessible &)=default
 
xconst_accessibleoperator= (const xconst_accessible &)=default
 
 xconst_accessible (xconst_accessible &&)=default
 
xconst_accessibleoperator= (xconst_accessible &&)=default
 

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>
auto compute_index (Args... args) const -> offset_type
 
template<class... Args>
auto compute_unchecked_index (Args... args) const -> offset_type
 
template<class It >
auto compute_element_index (It first, It last) const -> offset_type
 
void set_offset (size_type offset)
 

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 191 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 313 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 351 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 364 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 404 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 641 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
inline

Definition at line 679 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
inline

Definition at line 663 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
inline

Definition at line 671 of file xstrided_view_base.hpp.

◆ data() [1/2]

template<class D >
template<class E , class ST >
auto xt::xstrided_view_base< D >::data ( ) const -> std::enable_if_t<detail::provides_data_interface<E, ST>::value, const_pointer>
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 594 of file xstrided_view_base.hpp.

◆ data() [2/2]

template<class D >
template<class E , class ST >
auto xt::xstrided_view_base< D >::data ( ) -> std::enable_if_t<detail::provides_data_interface<E, ST>::value, pointer>
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 582 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 604 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 537 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 -> 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 552 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 622 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 613 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 653 of file xstrided_view_base.hpp.

◆ is_contiguous()

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

Definition at line 419 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 413 of file xstrided_view_base.hpp.

◆ operator()() [1/4]

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

Definition at line 431 of file xstrided_view_base.hpp.

◆ operator()() [2/4]

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

Definition at line 437 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 450 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 -> const_reference
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 466 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 685 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 386 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 571 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 562 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 395 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);

Definition at line 495 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 -> const_reference
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 522 of file xstrided_view_base.hpp.

Member Data Documentation

◆ contiguous_layout

template<class D >
constexpr 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 >
constexpr 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.

◆ static_layout

template<class D >
constexpr 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: