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... > >
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.
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 squence 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.
Broadcast iterators
-
auto
xbegin
() const¶ Returns a constant iterator to the first element of the function.
-
auto
xend
() const¶ Returns a constant iterator to the element following the last element of the function.
-
auto
cxbegin
() const¶ Returns a constant iterator to the first element of the function.
-
auto
cxend
() const¶ Returns a constant iterator to the element following the last element of the function.
- template <class S>
-
auto
xbegin
(const S &shape) const¶ Returns a constant iterator to the first element of the function.
The iteration is broadcasted to the specified shape.
- Parameters
shape
: the shape used for broadcasting
- template <class S>
-
auto
xend
(const S &shape) const¶ Returns a constant iterator to the element following the last element of the function.
The iteration is broadcasted to the specified shape.
- Parameters
shape
: the shape used for broadcasting
- template <class S>
-
auto
cxbegin
(const S &shape) const¶ Returns a constant iterator to the first element of the function.
The iteration is broadcasted to the specified shape.
- Parameters
shape
: the shape used for broadcasting
- template <class S>
-
auto
cxend
(const S &shape) const¶ Returns a constant iterator to the element following the last element of the function.
The iteration is broadcasted to the specified shape.
- Parameters
shape
: the shape used for broadcasting