NaN functions¶
xtensor provides the following functions that deal with NaNs in xexpressions:
Defined in xtensor/xmath.hpp
- template <class E>
-
auto
xt::nan_to_num(E &&e)¶ Convert nan or +/- inf to numbers.
This functions converts nan to 0, and +inf to the highest, -inf to the lowest floating point value of the same type.
- Return
- an xexpression
- Parameters
e: input xexpression
- template <class T = void, class E, class X, class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< X > > > = 0>
-
auto
xt::nansum(E &&e, X &&axes, EVS es = EVS()) Sum of elements over given axes, replacing nan with 0.
Returns an xreducer for the sum of elements over given axes, replacing nan with 0.
- Return
- an xreducer
- Parameters
e: an xexpressionaxes: the axes along which the sum is performed (optional)es: evaluation strategy of the reducer (optional)
- template <class T = void, class E, class X, class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< X > > > = 0>
-
auto
xt::nanprod(E &&e, X &&axes, EVS es = EVS()) Product of elements over given axes, replacing nan with 1.
Returns an xreducer for the sum of elements over given axes, replacing nan with 1.
- Return
- an xreducer
- Parameters
e: an xexpressionaxes: the axes along which the sum is performed (optional)es: evaluation strategy of the reducer (optional)
- template <class E>
-
auto
xt::nancumsum(E &&e)
- template <class E>
-
auto
xt::nancumsum(E &&e, std::ptrdiff_t axis) Cumulative sum, replacing nan with 0.
Returns an xaccumulator for the sum of elements over given axis, replacing nan with 0.
- Return
- an xaccumulator
- Parameters
e: an xexpressionaxis: the axis along which the elements are accumulated (optional)
- template <class E>
-
auto
xt::nancumprod(E &&e)
- template <class E>
-
auto
xt::nancumprod(E &&e, std::ptrdiff_t axis) Cumulative product, replacing nan with 1.
Returns an xaccumulator for the product of elements over given axis, replacing nan with 1.
- Return
- an xaccumulator
- Parameters
e: an xexpressionaxis: the axis along which the elements are accumulated (optional)