Classification functions

xtensor provides the following classification functions for xexpressions and scalars:

Defined in xtensor/xmath.hpp

Warning

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

- template<class E> auto isfinite(E &&e) noexcept -> detail::xfunction_type_t<math::isfinite_fun, E>
- template<class T> bool isfinite(const std::complex<T> &c)
- template<class T> std::enable_if_t<xtl::is_arithmetic<T>::value, bool> isfinite(const T &t)

Warning

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

- template<class E> auto isinf(E &&e) noexcept -> detail::xfunction_type_t<math::isinf_fun, E>
- template<class T> bool isinf(const std::complex<T> &c)
- template<class T> std::enable_if_t<xtl::is_arithmetic<T>::value, bool> isinf(const T &t)

Warning

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

- template<class E> auto isnan(E &&e) noexcept -> detail::xfunction_type_t<math::isnan_fun, E>
- template<class T> bool isnan(const std::complex<T> &c)
- template<class T> std::enable_if_t<xtl::is_arithmetic<T>::value, bool> isnan(const T &t)
template<class E1, class E2>
auto xt::isclose(E1 &&e1, E2 &&e2, double rtol = 1e-05, double atol = 1e-08, bool equal_nan = false) noexcept

Element-wise closeness detection.

Returns an xfunction that evaluates to true if the elements in e1 and e2 are close to each other according to parameters atol and rtol. The equation is: std::abs(a - b) <= (m_atol + m_rtol * std::abs(b)).

Return

an xfunction

Parameters
  • e1: input array to compare

  • e2: input array to compare

  • rtol: the relative tolerance parameter (default 1e-05)

  • atol: the absolute tolerance parameter (default 1e-08)

  • equal_nan: if true, isclose returns true if both elements of e1 and e2 are NaN

template<class E1, class E2>
auto xt::allclose(E1 &&e1, E2 &&e2, double rtol = 1e-05, double atol = 1e-08) noexcept

Check if all elements in e1 are close to the corresponding elements in e2.

Returns true if all elements in e1 and e2 are close to each other according to parameters atol and rtol.

Return

a boolean

Parameters
  • e1: input array to compare

  • e2: input arrays to compare

  • rtol: the relative tolerance parameter (default 1e-05)

  • atol: the absolute tolerance parameter (default 1e-08)