Basic functions
xtensor provides the following basic functions for xexpressions and scalars:
Defined in xtensor/xmath.hpp
-
template<class E>
inline auto xt::abs(E &&e) noexcept -> detail::xfunction_type_t<math::abs_fun, E> Absolute value function.
Returns an xfunction for the element-wise absolute value of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E>
inline auto xt::fabs(E &&e) noexcept -> detail::xfunction_type_t<math::fabs_fun, E> Absolute value function.
Returns an xfunction for the element-wise absolute value of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::fmod(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::fmod_fun, E1, E2> Remainder of the floating point division operation.
Returns an xfunction for the element-wise remainder of the floating point division operation e1 / e2.
Note
e1 and e2 can’t be both scalars.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::remainder(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::remainder_fun, E1, E2> Signed remainder of the division operation.
Returns an xfunction for the element-wise signed remainder of the floating point division operation e1 / e2.
Note
e1 and e2 can’t be both scalars.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2, class E3>
inline auto xt::fma(E1 &&e1, E2 &&e2, E3 &&e3) noexcept -> detail::xfunction_type_t<math::fma_fun, E1, E2, E3> Fused multiply-add operation.
Returns an xfunction for e1 * e2 + e3 as if to infinite precision and rounded only once to fit the result type.
Note
e1, e2 and e3 can’t be scalars every three.
-
template<class E1, class E2>
inline auto xt::maximum(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::maximum<void>, E1, E2> Elementwise maximum.
Returns an xfunction for the element-wise maximum between e1 and e2.
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::minimum(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::minimum<void>, E1, E2> Elementwise minimum.
Returns an xfunction for the element-wise minimum between e1 and e2.
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::fmax(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::fmax_fun, E1, E2> Maximum function.
Returns an xfunction for the element-wise maximum of e1 and e2.
Note
e1 and e2 can’t be both scalars.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::fmin(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::fmin_fun, E1, E2> Minimum function.
Returns an xfunction for the element-wise minimum of e1 and e2.
Note
e1 and e2 can’t be both scalars.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::fdim(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<math::fdim_fun, E1, E2> Positive difference function.
Returns an xfunction for the element-wise positive difference of e1 and e2.
Note
e1 and e2 can’t be both scalars.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2, class E3>
inline auto xt::clip(E1 &&e1, E2 &&lo, E3 &&hi) noexcept -> detail::xfunction_type_t<math::clamp_fun, E1, E2, E3> Clip values between hi and lo.
Returns an xfunction for the element-wise clipped values between lo and hi
- Parameters:
e1 – an xexpression or a scalar
lo – a scalar
hi – a scalar
- Returns:
-
template<class E>
inline auto xt::sign(E &&e) noexcept -> detail::xfunction_type_t<math::sign_fun, E> Returns an element-wise indication of the sign of a number.
If the number is positive, returns +1. If negative, -1. If the number is zero, returns 0.
- Parameters:
e – an xexpression
- Returns:
an xfunction