Reducing functions¶
xtensor provides the following reducing functions for xexpressions:
Defined in xtensor/xmath.hpp
 template <class E, class X, class ES = evaluation_strategy::lazy, class = std::enable_if_t<!std::is_base_of<evaluation_strategy::base, std::decay_t<X>>::value, int>>

auto
xt::
sum
(E &&e, X &&axes, ES es = ES())¶ Sum of elements over given axes.
Returns an xreducer for the sum of elements over given axes.
 Return
 an xreducer
 Parameters
e
: an xexpressionaxes
: the axes along which the sum is performed (optional)es
: evaluation strategy of the reducer
 template <class E, class X, class ES = evaluation_strategy::lazy, class = std::enable_if_t<!std::is_base_of<evaluation_strategy::base, std::decay_t<X>>::value, int>>

auto
xt::
prod
(E &&e, X &&axes, ES es = ES())¶ Product of elements over given axes.
Returns an xreducer for the product of elements over given axes.
 Return
 an xreducer
 Parameters
e
: an xexpressionaxes
: the axes along which the product is computed (optional)es
: evaluation strategy of the reducer
 template <class E, class X>

auto
xt::
mean
(E &&e, X &&axes)¶ Mean of elements over given axes.
Returns an xreducer for the mean of elements over given axes.
 Return
 an xexpression
 Parameters
e
: an xexpressionaxes
: the axes along which the mean is computed (optional)
Defined in xtensor/xnorm.hpp
 template <class E, class X>

auto
xt::
norm_l0
(E &&e, X &&axes)¶ L0 (count) pseudonorm of an arraylike argument over given axes.
Returns an xreducer for the L0 pseudonorm of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionaxes
: the axes along which the norm is computed (optional)
 template <class E, class X>

auto
xt::
norm_l1
(E &&e, X &&axes)¶ L1 norm of an arraylike argument over given axes.
Returns an xreducer for the L1 norm of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionaxes
: the axes along which the norm is computed (optional)
 template <class E, class X>

auto
xt::
norm_sq
(E &&e, X &&axes)¶ Squared L2 norm of an arraylike argument over given axes.
Returns an xreducer for the squared L2 norm of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionaxes
: the axes along which the norm is computed (optional)
 template <class E, class X>

auto
xt::
norm_l2
(E &&e, X &&axes)¶ L2 norm of an arraylike argument over given axes.
Returns an xreducer for the L2 norm of the elements across given axes.
 Return
 an xreducer (specifically:
sqrt(norm_sq(e, axes))
)  Parameters
e
: an xexpressionaxes
: the axes along which the norm is computed
 template <class E, class X>

auto
xt::
norm_linf
(E &&e, X &&axes)¶ Infinity (maximum) norm of an arraylike argument over given axes.
Returns an xreducer for the infinity norm of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionaxes
: the axes along which the norm is computed (optional)
 template <class E, class X>

auto
xt::
norm_lp_to_p
(E &&e, double p, X &&axes)¶ pth power of the Lp norm of an arraylike argument over given axes.
Returns an xreducer for the pth power of the Lp norm of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionp
:axes
: the axes along which the norm is computed (optional)
 template <class E, class X>

auto
xt::
norm_lp
(E &&e, double p, X &&axes)¶ Lp norm of an arraylike argument over given axes.
Returns an xreducer for the Lp norm (p != 0) of the elements across given axes.
 Return
 an xreducer When no axes are provided, the norm is calculated over the entire array. In this case, the reducer represents a scalar result, otherwise an array of appropriate dimension.
 Parameters
e
: an xexpressionp
:axes
: the axes along which the norm is computed (optional)
 template <class E, typename = concept_check <is_xexpression<E>::value>>

auto
xt::
norm_induced_l1
(E &&e)¶ Induced L1 norm of a matrix.
Returns an xreducer for the induced L1 norm (i.e. the maximum of the L1 norms of e’s columns).
 Return
 an xreducer
 Parameters
e
: a 2D xexpression
 template <class E, typename = concept_check <is_xexpression<E>::value>>

auto
xt::
norm_induced_linf
(E &&e)¶ Induced Linfinity norm of a matrix.
Returns an xreducer for the induced Linfinity norm (i.e. the maximum of the L1 norms of e’s rows).
 Return
 an xreducer
 Parameters
e
: a 2D xexpression