Basic functions

xtensor provides the following basic functions for xexpressions and scalars:

Defined in xtensor/xmath.hpp

Warning

doxygenfunction: Unable to resolve multiple matches for function “abs” with arguments ((E&&)) in doxygen xml output for project “xtensor” from directory: ../xml. Potential matches:

- constexpr unsigned char abs(const unsigned char &x)
- constexpr unsigned int abs(const unsigned int &x)
- constexpr unsigned long abs(const unsigned long &x)
- constexpr unsigned long long abs(const unsigned long long &x)
- constexpr unsigned short abs(const unsigned short &x)
- template<class E> auto abs(E &&e) noexcept -> detail::xfunction_type_t<math::abs_fun, E>
template<class E>
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.

Return

an xfunction

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Note

e1 and e2 can’t be both scalars.

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Note

e1 and e2 can’t be both scalars.

Parameters

template<class E1, class E2, class E3>
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.

Return

an xfunction

Note

e1, e2 and e3 can’t be scalars every three.

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Note

e1 and e2 can’t be both scalars.

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Note

e1 and e2 can’t be both scalars.

Parameters

template<class E1, class E2>
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.

Return

an xfunction

Note

e1 and e2 can’t be both scalars.

Parameters

template<class E1, class E2, class E3>
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

Return

a xfunction

Parameters
  • e1: an xexpression or a scalar

  • lo: a scalar

  • hi: a scalar

Warning

doxygenfunction: Unable to resolve multiple matches for function “sign” with arguments ((E&&)) in doxygen xml output for project “xtensor” from directory: ../xml. Potential matches:

- template<class E> auto sign(E &&e) noexcept -> detail::xfunction_type_t<math::sign_fun, E>
- template<class T, class B> auto sign(const xtl::xoptional<T, B> &e)