Operators and related functions
Defined in xtensor/xmath.hpp
and xtensor/xoperation.hpp
-
template<class E>
inline auto xt::operator+(E &&e) noexcept -> detail::xfunction_type_t<detail::identity, E> Identity.
Returns an xfunction for the element-wise identity of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E>
inline auto xt::operator-(E &&e) noexcept -> detail::xfunction_type_t<detail::negate, E> Opposite.
Returns an xfunction for the element-wise opposite of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator+(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::plus, E1, E2> Addition.
Returns an xfunction for the element-wise addition of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator-(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::minus, E1, E2> Substraction.
Returns an xfunction for the element-wise substraction of e2 to e1.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator*(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::multiplies, E1, E2> Multiplication.
Returns an xfunction for the element-wise multiplication of e1 by e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator/(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::divides, E1, E2> Division.
Returns an xfunction for the element-wise division of e1 by e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator||(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::logical_or, E1, E2> Or.
Returns an xfunction for the element-wise or of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator&&(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::logical_and, E1, E2> And.
Returns an xfunction for the element-wise and of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E>
inline auto xt::operator!(E &&e) noexcept -> detail::xfunction_type_t<detail::logical_not, E> Not.
Returns an xfunction for the element-wise not of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2, class E3>
inline auto xt::where(E1 &&e1, E2 &&e2, E3 &&e3) noexcept -> detail::xfunction_type_t<detail::conditional_ternary, E1, E2, E3> Ternary selection.
Returns an xfunction for the element-wise ternary selection (i.e. operator ? :) of e1, e2 and e3.
- Parameters:
e1 – a boolean xexpression
e2 – an xexpression or a scalar
e3 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E>
inline bool xt::any(E &&e) Any.
Returns true if any of the values of e is truthy, false otherwise.
- Parameters:
e – an xexpression
- Returns:
a boolean
-
template<class E>
inline bool xt::all(E &&e) Any.
Returns true if all of the values of e are truthy, false otherwise.
- Parameters:
e – an xexpression
- Returns:
a boolean
-
template<class E1, class E2>
inline auto xt::operator<(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::less, E1, E2> Lesser than.
Returns an xfunction for the element-wise lesser than comparison of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator<=(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::less_equal, E1, E2> Lesser or equal.
Returns an xfunction for the element-wise lesser or equal comparison of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator>(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::greater, E1, E2> Greater than.
Returns an xfunction for the element-wise greater than comparison of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator>=(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::greater_equal, E1, E2> Greater or equal.
Returns an xfunction for the element-wise greater or equal comparison of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline std::enable_if_t<xoptional_comparable<E1, E2>::value, bool> xt::operator==(const xexpression<E1> &e1, const xexpression<E2> &e2) Equality.
Returns true if e1 and e2 have the same shape and hold the same values. Unlike other comparison operators, this does not return an xfunction.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
a boolean
-
template<class E1, class E2>
inline bool xt::operator!=(const xexpression<E1> &e1, const xexpression<E2> &e2) Inequality.
Returns true if e1 and e2 have different shapes or hold the different values. Unlike other comparison operators, this does not return an xfunction.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
a boolean
-
template<class E1, class E2>
inline auto xt::equal(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::equal_to, E1, E2> Element-wise equality.
Returns an xfunction for the element-wise equality of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::not_equal(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::not_equal_to, E1, E2> Element-wise inequality.
Returns an xfunction for the element-wise inequality of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::less(E1 &&e1, E2 &&e2) noexcept -> decltype(std::forward<E1>(e1) < std::forward<E2>(e2)) Lesser than.
Returns an xfunction for the element-wise lesser than comparison of e1 and e2. This function is equivalent to operator<(E1&&, E2&&).
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::less_equal(E1 &&e1, E2 &&e2) noexcept -> decltype(std::forward<E1>(e1) <= std::forward<E2>(e2)) Lesser or equal.
Returns an xfunction for the element-wise lesser or equal comparison of e1 and e2. This function is equivalent to operator<=(E1&&, E2&&).
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::greater(E1 &&e1, E2 &&e2) noexcept -> decltype(std::forward<E1>(e1) > std::forward<E2>(e2)) Greater than.
Returns an xfunction for the element-wise greater than comparison of e1 and e2. This function is equivalent to operator>(E1&&, E2&&).
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::greater_equal(E1 &&e1, E2 &&e2) noexcept -> decltype(std::forward<E1>(e1) >= std::forward<E2>(e2)) Greater or equal.
Returns an xfunction for the element-wise greater or equal comparison of e1 and e2. This function is equivalent to operator>=(E1&&, E2&&).
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator&(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::bitwise_and, E1, E2> Bitwise and.
Returns an xfunction for the element-wise bitwise and of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator|(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::bitwise_or, E1, E2> Bitwise or.
Returns an xfunction for the element-wise bitwise or of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator^(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::bitwise_xor, E1, E2> Bitwise xor.
Returns an xfunction for the element-wise bitwise xor of e1 and e2.
- Parameters:
e1 – an xexpression or a scalar
e2 – an xexpression or a scalar
- Returns:
an xfunction
-
template<class E>
inline auto xt::operator~(E &&e) noexcept -> detail::xfunction_type_t<detail::bitwise_not, E> Bitwise not.
Returns an xfunction for the element-wise bitwise not of e.
- Parameters:
e – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::left_shift(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::left_shift, E1, E2> Bitwise left shift.
Returns an xfunction for the element-wise bitwise left shift of e1 by e2.
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::right_shift(E1 &&e1, E2 &&e2) noexcept -> detail::xfunction_type_t<detail::right_shift, E1, E2> Bitwise left shift.
Returns an xfunction for the element-wise bitwise left shift of e1 by e2.
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator<<(E1 &&e1, E2 &&e2) noexcept -> detail::shift_return_type_t<detail::left_shift, E1, E2> Bitwise left shift.
Returns an xfunction for the element-wise bitwise left shift of e1 by e2.
See also
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction
-
template<class E1, class E2>
inline auto xt::operator>>(E1 &&e1, E2 &&e2) -> detail::shift_return_type_t<detail::right_shift, E1, E2> Bitwise right shift.
Returns an xfunction for the element-wise bitwise right shift of e1 by e2.
See also
- Parameters:
e1 – an xexpression
e2 – an xexpression
- Returns:
an xfunction