xfunctorview

Defined in xtensor/xfunctorview.hpp

template <class F, class CT>
class xt::xfunctorview

View of an xexpression .

The xfunctorview class is an expression addressing its elements by applying a functor to the corresponding element of an underlying expression. Unlike e.g. xgenerator, an xfunctorview is an lvalue. It is used e.g. to access real and imaginary parts of complex expressions.

xfunctorview is not meant to be used directly, but through helper functions such as real or imag.

See
real, imag
Template Parameters
  • F: the functor type to be applied to the elements of specified expression.
  • CT: the closure type of the xexpression type underlying this view

Inherits from xt::xview_semantic< xfunctorview< F, CT > >

Constructors

xfunctorview(CT e)

Constructs an xfunctorview expression wrappering the specified xexpression.

Parameters
  • e: the underlying expression

template <class Func, class E>
xfunctorview(Func &&func, E &&e)

Constructs an xfunctorview expression wrappering the specified xexpression.

Parameters
  • func: the functor to be applied to the elements of the underlying expression.
  • e: the underlying expression

Extended copy semantic

template <class E>
auto operator=(const xexpression<E> &e)

The extended assignment operator.

Size and shape

auto size() const

Returns the size of the expression.

auto dimension() const

Returns the number of dimensions of the expression.

auto shape() const

Returns the shape of the expression.

layout_type layout() const

Returns the layout_type of the expression.

Data

auto operator[](const xindex &index)

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

Parameters
  • index: a sequence of indices specifying the position in the function. Indices must be unsigned integers, the number of indices in the sequence should be equal or greater than the number of dimensions of the container.

auto operator[](const xindex &index) const

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

Parameters
  • index: a sequence of indices specifying the position in the function. Indices must be unsigned integers, the number of indices in the sequence should be equal or greater than the number of dimensions of the container.

template <class… Args>
auto operator()(Args... args)

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

Parameters
  • args: a 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.

template <class… Args>
auto at(Args... args)

Returns a reference to the element at the specified position in the expression, after dimension and bounds checking.

Parameters
  • args: a list of indices specifying the position in the function. Indices must be unsigned integers, the number of indices should be equal to the number of dimensions of the expression.
Exceptions
  • std::out_of_range: if the number of argument is greater than the number of dimensions or if indices are out of bounds.

template <class IT>
auto element(IT first, IT last)

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

Parameters
  • first: iterator starting the sequence of indices
  • last: iterator 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.

template <class… Args>
auto operator()(Args... args) const

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

Parameters
  • args: a 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.

template <class… Args>
auto at(Args... args) const

Returns a constant reference to the element at the specified position in the expression, after dimension and bounds checking.

Parameters
  • args: a list of indices specifying the position in the function. Indices must be unsigned integers, the number of indices should be equal to the number of dimensions of the expression.
Exceptions
  • std::out_of_range: if the number of argument is greater than the number of dimensions or if indices are out of bounds.

template <class IT>
auto element(IT first, IT last) const

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

Parameters
  • first: iterator starting the sequence of indices
  • last: iterator 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.

Broadcasting

template <class S>
bool broadcast_shape(S &shape) const

Broadcast the shape of the function to the specified parameter.

Return
a boolean indicating whether the broadcasting is trivial
Parameters
  • shape: the result shape

template <class S>
bool is_trivial_broadcast(const S &strides) const

Compares the specified strides with those of the container to see whether the broadcasting is trivial.

Return
a boolean indicating whether the broadcasting is trivial

Iterators

template <layout_type L = DL>
auto begin()

Returns an iterator to the first element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto end()

Returns an iterator to the element following the last element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto begin() const

Returns a constant iterator to the first element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto end() const

Returns a constant iterator to the element following the last element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto cbegin() const

Returns a constant iterator to the first element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto cend() const

Returns a constant iterator to the element following the last element of the expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

Broadcast iterators

template <class S, layout_type L>
auto begin(const S &shape)

Returns a constant iterator to the first element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto end(const S &shape)

Returns a constant iterator to the element following the last element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto begin(const S &shape) const

Returns a constant iterator to the first element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto end(const S &shape) const

Returns a constant iterator to the element following the last element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto cbegin(const S &shape) const

Returns a constant iterator to the first element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto cend(const S &shape) const

Returns a constant iterator to the element following the last element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

Reverse iterators

template <layout_type L = DL>
auto rbegin()

Returns an iterator to the first element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto rend()

Returns an iterator to the element following the last element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto rbegin() const

Returns a constant iterator to the first element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto rend() const

Returns a constant iterator to the element following the last element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto crbegin() const

Returns a constant iterator to the first element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <layout_type L = DL>
auto crend() const

Returns a constant iterator to the element following the last element of the reversed expression.

Template Parameters
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

Reverse broadcast iterators

template <class S, layout_type L>
auto rbegin(const S &shape)

Returns an iterator to the first element of the expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto rend(const S &shape)

Returns an iterator to the element following the last element of the reversed expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto rbegin(const S &shape) const

Returns a constant iterator to the first element of the reversed expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto rend(const S&) const

Returns a constant iterator to the element following the last element of the reversed expression.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto crbegin(const S&) const

Returns a constant iterator to the first element of the reversed expression.

The iteration is broadcasted to the specified shape.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

template <class S, layout_type L>
auto crend(const S &shape) const

Returns a constant iterator to the element following the last element of the reversed expression.

Parameters
  • shape: the shape used for broadcasting
Template Parameters
  • S: type of the shape parameter.
  • L: layout used for the traversal. Default value is DEFAULT_LAYOUT.

Defined in xtensor/xcomplex.hpp

template <class E>
decltype(auto) xt::real(E && e)

Returns an xexpression representing the real part of the given expression.

The returned expression either hold a const reference to e or a copy depending on whether e is an lvalue or an rvalue.

Template Parameters

template <class E>
decltype(auto) xt::imag(E && e)

Returns an xexpression representing the imaginary part of the given expression.

The returned expression either hold a const reference to e or a copy depending on whether e is an lvalue or an rvalue.

Template Parameters