Basic functions¶
xtensor provides the following basic functions for xexpressions and scalars:
Defined in xtensor/xmath.hpp
-
template<class
E
>
autoxt
::
abs
(E &&e) Absolute value function.
Returns an xfunction for the element-wise absolute value of e.
- Return
an xfunction
- Parameters
e
: an xexpression
-
template<class
E
>
autoxt
::
fabs
(E &&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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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
-
template<class
E
>
autoxt
::
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
e
: an xexpression