xtensor
Loading...
Searching...
No Matches
Basic functions

Functions

template<class E >
auto xt::abs (E &&e) noexcept -> detail::xfunction_type_t< math::abs_fun, E >
 Absolute value function.
 
template<class E >
auto xt::fabs (E &&e) noexcept -> detail::xfunction_type_t< math::fabs_fun, E >
 Absolute value function.
 
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.
 
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.
 
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.
 
template<class E1 , class E2 >
auto xt::fmax (E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t< math::fmax_fun, E1, E2 >
 Maximum function.
 
template<class E1 , class E2 >
auto xt::fmin (E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t< math::fmin_fun, E1, E2 >
 Minimum function.
 
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.
 
template<class E >
auto xt::deg2rad (E &&e) noexcept -> detail::xfunction_type_t< math::deg2rad, E >
 Convert angles from degrees to radians.
 
template<class E >
auto xt::radians (E &&e) noexcept -> detail::xfunction_type_t< math::deg2rad, E >
 Convert angles from degrees to radians.
 
template<class E >
auto xt::rad2deg (E &&e) noexcept -> detail::xfunction_type_t< math::rad2deg, E >
 Convert angles from radians to degrees.
 
template<class E >
auto xt::degrees (E &&e) noexcept -> detail::xfunction_type_t< math::rad2deg, E >
 Convert angles from radians to degrees.
 
template<class E1 , class E2 >
auto xt::maximum (E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t< math::maximum< void >, E1, E2 >
 Elementwise maximum.
 
template<class E1 , class E2 >
auto xt::minimum (E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t< math::minimum< void >, E1, E2 >
 Elementwise minimum.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::amax (E &&e, X &&axes, EVS es=EVS())
 Maximum element along given axis.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::amin (E &&e, X &&axes, EVS es=EVS())
 Minimum element along given axis.
 
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.
 
template<class E >
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.
 
template<class E1 , class E2 , class E3 , typename T >
auto xt::interp (const E1 &x, const E2 &xp, const E3 &fp, T left, T right)
 Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.
 
template<class E1 , class E2 = xt::placeholders::xtuph, class E3 = double>
auto xt::unwrap (E1 &&p, E2 discontinuity=xnone(), std::ptrdiff_t axis=-1, E3 period=2.0 *xt::numeric_constants< double >::PI)
 Unwrap by taking the complement of large deltas with respect to the period.
 
template<class E1 , class E2 , class E3 >
auto xt::interp (const E1 &x, const E2 &xp, const E3 &fp)
 Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.
 

Detailed Description

Function Documentation

◆ abs()

template<class E >
auto xt::abs ( E && e) -> detail::xfunction_type_t<math::abs_fun, E>
inlinenoexcept

Absolute value function.

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

Parameters
ean xexpression
Returns
an xfunction

Definition at line 443 of file xmath.hpp.

◆ amax()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::amax ( E && e,
X && axes,
EVS es = EVS() )
inline

Maximum element along given axis.

Returns an xreducer for the maximum of elements over given axes.

Parameters
ean xexpression
axesthe axes along which the maximum is found (optional)
esevaluation strategy of the reducer
Returns
an xreducer

Definition at line 782 of file xmath.hpp.

◆ amin()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::amin ( E && e,
X && axes,
EVS es = EVS() )
inline

Minimum element along given axis.

Returns an xreducer for the minimum of elements over given axes.

Parameters
ean xexpression
axesthe axes along which the minimum is found (optional)
esevaluation strategy of the reducer
Returns
an xreducer

Definition at line 800 of file xmath.hpp.

◆ clip()

template<class E1 , class E2 , class E3 >
auto xt::clip ( E1 && e1,
E2 && lo,
E3 && hi ) -> detail::xfunction_type_t<math::clamp_fun, E1, E2, E3>
inlinenoexcept

Clip values between hi and lo.

Returns an xfunction for the element-wise clipped values between lo and hi

Parameters
e1an xexpression or a scalar
loa scalar
hia scalar
Returns
a xfunction

Definition at line 815 of file xmath.hpp.

◆ deg2rad()

template<class E >
auto xt::deg2rad ( E && e) -> detail::xfunction_type_t<math::deg2rad, E>
inlinenoexcept

Convert angles from degrees to radians.

Returns an xfunction for the element-wise corresponding angle in radians of e.

Parameters
ean xexpression
Returns
an xfunction

Definition at line 684 of file xmath.hpp.

◆ degrees()

template<class E >
auto xt::degrees ( E && e) -> detail::xfunction_type_t<math::rad2deg, E>
inlinenoexcept

Convert angles from radians to degrees.

Returns an xfunction for the element-wise corresponding angle in degrees of e.

Parameters
ean xexpression
Returns
an xfunction

Definition at line 729 of file xmath.hpp.

◆ fabs()

template<class E >
auto xt::fabs ( E && e) -> detail::xfunction_type_t<math::fabs_fun, E>
inlinenoexcept

Absolute value function.

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

Parameters
ean xexpression
Returns
an xfunction

Definition at line 458 of file xmath.hpp.

◆ fdim()

template<class E1 , class E2 >
auto xt::fdim ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::fdim_fun, E1, E2>
inlinenoexcept

Positive difference function.

Returns an xfunction for the element-wise positive difference of e1 and e2.

Parameters
e1an xexpression or a scalar
e2an xexpression or a scalar
Returns
an xfunction
Note
e1 and e2 can't be both scalars.

Definition at line 565 of file xmath.hpp.

◆ fma()

template<class E1 , class E2 , class E3 >
auto xt::fma ( E1 && e1,
E2 && e2,
E3 && e3 ) -> detail::xfunction_type_t<math::fma_fun, E1, E2, E3>
inlinenoexcept

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.

Parameters
e1an xfunction or a scalar
e2an xfunction or a scalar
e3an xfunction or a scalar
Returns
an xfunction
Note
e1, e2 and e3 can't be scalars every three.

Definition at line 510 of file xmath.hpp.

◆ fmax()

template<class E1 , class E2 >
auto xt::fmax ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::fmax_fun, E1, E2>
inlinenoexcept

Maximum function.

Returns an xfunction for the element-wise maximum of e1 and e2.

Parameters
e1an xexpression or a scalar
e2an xexpression or a scalar
Returns
an xfunction
Note
e1 and e2 can't be both scalars.

Definition at line 531 of file xmath.hpp.

◆ fmin()

template<class E1 , class E2 >
auto xt::fmin ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::fmin_fun, E1, E2>
inlinenoexcept

Minimum function.

Returns an xfunction for the element-wise minimum of e1 and e2.

Parameters
e1an xexpression or a scalar
e2an xexpression or a scalar
Returns
an xfunction
Note
e1 and e2 can't be both scalars.

Definition at line 548 of file xmath.hpp.

◆ fmod()

template<class E1 , class E2 >
auto xt::fmod ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::fmod_fun, E1, E2>
inlinenoexcept

Remainder of the floating point division operation.

Returns an xfunction for the element-wise remainder of the floating point division operation e1 / e2.

Parameters
e1an xexpression or a scalar
e2an xexpression or a scalar
Returns
an xfunction
Note
e1 and e2 can't be both scalars.

Definition at line 475 of file xmath.hpp.

◆ interp() [1/2]

template<class E1 , class E2 , class E3 >
auto xt::interp ( const E1 & x,
const E2 & xp,
const E3 & fp )
inline

Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.

Parameters
xThe x-coordinates at which to evaluate the interpolated values (sorted).
xpThe x-coordinates of the data points (sorted).
fpThe y-coordinates of the data points, same length as xp.
Returns
an one-dimensional xarray, same length as x.

Definition at line 3185 of file xmath.hpp.

◆ interp() [2/2]

template<class E1 , class E2 , class E3 , typename T >
auto xt::interp ( const E1 & x,
const E2 & xp,
const E3 & fp,
T left,
T right )
inline

Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.

Parameters
xThe x-coordinates at which to evaluate the interpolated values (sorted).
xpThe x-coordinates of the data points (sorted).
fpThe y-coordinates of the data points, same length as xp.
leftValue to return for x < xp[0].
rightValue to return for x > xp[-1]
Returns
an one-dimensional xarray, same length as x.

Definition at line 3020 of file xmath.hpp.

◆ maximum()

template<class E1 , class E2 >
auto xt::maximum ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::maximum<void>, E1, E2>
inlinenoexcept

Elementwise maximum.

Returns an xfunction for the element-wise maximum between e1 and e2.

Parameters
e1an xexpression
e2an xexpression
Returns
an xfunction

Definition at line 745 of file xmath.hpp.

◆ minimum()

template<class E1 , class E2 >
auto xt::minimum ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::minimum<void>, E1, E2>
inlinenoexcept

Elementwise minimum.

Returns an xfunction for the element-wise minimum between e1 and e2.

Parameters
e1an xexpression
e2an xexpression
Returns
an xfunction

Definition at line 761 of file xmath.hpp.

◆ rad2deg()

template<class E >
auto xt::rad2deg ( E && e) -> detail::xfunction_type_t<math::rad2deg, E>
inlinenoexcept

Convert angles from radians to degrees.

Returns an xfunction for the element-wise corresponding angle in degrees of e.

Parameters
ean xexpression
Returns
an xfunction

Definition at line 714 of file xmath.hpp.

◆ radians()

template<class E >
auto xt::radians ( E && e) -> detail::xfunction_type_t<math::deg2rad, E>
inlinenoexcept

Convert angles from degrees to radians.

Returns an xfunction for the element-wise corresponding angle in radians of e.

Parameters
ean xexpression
Returns
an xfunction

Definition at line 699 of file xmath.hpp.

◆ remainder()

template<class E1 , class E2 >
auto xt::remainder ( E1 && e1,
E2 && e2 ) -> detail::xfunction_type_t<math::remainder_fun, E1, E2>
inlinenoexcept

Signed remainder of the division operation.

Returns an xfunction for the element-wise signed remainder of the floating point division operation e1 / e2.

Parameters
e1an xexpression or a scalar
e2an xexpression or a scalar
Returns
an xfunction
Note
e1 and e2 can't be both scalars.

Definition at line 492 of file xmath.hpp.

◆ sign()

template<class E >
auto xt::sign ( E && e) -> detail::xfunction_type_t<math::sign_fun, E>
inlinenoexcept

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
ean xexpression
Returns
an xfunction

Definition at line 877 of file xmath.hpp.

◆ unwrap()

template<class E1 , class E2 = xt::placeholders::xtuph, class E3 = double>
auto xt::unwrap ( E1 && p,
E2 discontinuity = xnone(),
std::ptrdiff_t axis = -1,
E3 period = 2.0 * xt::numeric_constants<double>::PI )
inline

Unwrap by taking the complement of large deltas with respect to the period.

https://numpy.org/doc/stable/reference/generated/numpy.unwrap.html

Parameters
pInput array.
discontinuityMaximum discontinuity between values, default is period / 2. Values below period / 2 are treated as if they were period / 2. To have an effect different from the default, use discontinuity > period / 2.
axisAxis along which unwrap will operate, default: the last axis.
periodSize of the range over which the input wraps. Default: $ 2 \pi $.

Definition at line 3140 of file xmath.hpp.