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
>
autoxt
::
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
e
: an xexpression
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpression or a scalare2
: an xexpression or a scalar
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpression or a scalare2
: an xexpression or a scalar
-
template<class
E1
, classE2
, classE3
>
autoxt
::
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.
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpressione2
: an xexpression
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpressione2
: an xexpression
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpression or a scalare2
: an xexpression or a scalar
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpression or a scalare2
: an xexpression or a scalar
-
template<class
E1
, classE2
>
autoxt
::
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
e1
: an xexpression or a scalare2
: an xexpression or a scalar
-
template<class
E1
, classE2
, classE3
>
autoxt
::
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
- Parameters
e1
: an xexpression or a scalarlo
: a scalarhi
: 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)