xfunction¶
Defined in xtensor/xfunction.hpp
- template <class F, class R, class... CT>
-
class
xt::
xfunction
¶ Multidimensional function operating on xexpression.
Th xfunction class implements a multidimensional function operating on xexpression.
- Template Parameters
F
: the function typeR
: the return type of the functionCT
: the closure types for arguments of the function
Inherits from xt::xexpression< xfunction< F, R, CT... > >, xt::xconst_iterable< xfunction< F, R, CT... > >
Constructor
- template <class Func>
-
xfunction
(Func &&f, CT... e)¶ Constructs an xfunction applying the specified function to the given arguments.
- Parameters
f
: the function to applye
: the xexpression arguments
Size and shape
-
auto
size
() const¶ Returns the size of the expression.
-
auto
dimension
() const¶ Returns the number of dimensions of the function.
-
auto
shape
() const¶ Returns the shape of the xfunction.
-
layout_type
layout
() const¶ Returns the layout_type of the xfunction.
Data
- template <class... Args>
-
auto
operator()
(Args... args) const¶ Returns a constant reference to the element at the specified position in the function.
- 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 function.
- template <class It>
-
auto
element
(It first, It last) const¶ Returns a constant reference to the element at the specified position in the function.
- Parameters
first
: iterator starting the sequence of indiceslast
: 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 container.
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
-
auto
begin
() const¶ Returns an iterator to the first element of the buffer containing the elements of the function.
-
auto
end
() const¶ Returns a constant iterator to the element following the last element of the buffer containing the elements of the function.
-
auto
cbegin
() const¶ Returns a constant iterator to the first element of the buffer containing the elements of the function.
-
auto
cend
() const¶ Returns a constant iterator to the element following the last element of the buffer containing the elements of the function.
Reverse Iterators
-
auto
rbegin
() const¶ Returns an iterator to the first element of the reversed buffer containing the elements of the function.
-
auto
rend
() const¶ Returns a constant iterator to the element following the last element of the reversed buffer containing the elements of the function.
-
auto
crbegin
() const¶ Returns an iterator to the first element of the reversed buffer containing the elements of the function.
-
auto
crend
() const¶ Returns a constant iterator to the element following the last element of the reversed buffer containing the elements of the function.