xfunction_base

Defined in xtensor/xfunction.hpp

template <class F, class R, class… CT>
class xt::xfunction_base

Base class for multidimensional function operating on xexpression.

The xfunction_base class implements a multidimensional function operating on xexpression. Inheriting classes specify which kind of xexpression the xfunction_base operates on.

Template Parameters
  • F: the function type
  • R: the return type of the function
  • CT: the closure types for arguments of the function

Inherits from xt::xconst_iterable< xfunction_base< F, R, CT… > >

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… 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 function.

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 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

xfunction

Defined in xtensor/xfunction.hpp

template <class F, class R, class… CT>
class xt::xfunction

Multidimensional function operating on xtensor expressions.

The xfunction class implements a multidimensional function operating on xtensor expressions.

Template Parameters
  • F: the function type
  • R: the return type of the function
  • CT: the closure types for arguments of the function

Inherits from xt::xfunction_base< F, R, CT… >, xt::xexpression< xfunction< F, R, CT… > >

Public Functions

template <class Func, class U = std::enable_if<!std::is_base_of<Func, self_type>::value>>
xfunction(Func &&f, CT... e)

Constructs an xfunction applying the specified function to the given arguments.

Parameters
  • f: the function to apply
  • e: the xexpression arguments

xoptional_function

Defined in xtensor/xoptional.hpp

template <class F, class R, class… CT>
class xt::xoptional_function

Multidimensional function operating on xoptional expressions.

The xoptional_function class implements a multidimensional function operating on xoptional expressions.

Template Parameters
  • F: the function type
  • R: the return type of the function
  • CT: the closure types for arguments of the function

Inherits from xt::xfunction_base< F, R, CT… >, xt::xexpression< xoptional_function< F, R, CT… > >

Public Functions

template <class Func, class U = std::enable_if<!std::is_base_of<Func, self_type>::value>>
xoptional_function(Func &&func, CT... e)

Constructs an xoptional_function applying the specified function to the given arguments.

Parameters
  • func: the function to apply
  • e: the xexpression arguments