Basic functions

xtensor provides the following basic functions for xexpressions and scalars:

Defined in xtensor/xmath.hpp

template<class E>
auto xt::abs(E &&e)

Absolute value function.

Returns an xfunction for the element-wise absolute value of e.

Return

an xfunction

Parameters

template<class E>
auto xt::fabs(E &&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)

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)

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)

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)

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)

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)

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)

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)

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)

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

template<class E>
auto xt::sign(E &&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.

Return

an xfunction

Parameters