xtensor Logo
latest

INSTALLATION

  • Installation
  • Changelog

USAGE

  • Getting started
  • Expressions and lazy evaluation
  • Arrays and tensors
  • Scalars and 0-D expressions
  • Adapting 1-D containers
  • Operators and functions
  • Views
  • Indices
  • Expression builders
  • Missing values
  • Histogram
  • Random
  • Tensor Rank
  • File input and output
  • Build and configuration
  • Common pitfalls

QUICK REFERENCE

  • Basics
  • Builders
  • Operators
  • Mathematical functions
  • Reductions
  • Views
  • Iterators
  • Manipulation
  • Chunked arrays

API REFERENCE

  • Expressions and semantic
  • Containers and views
  • Iterators
  • Functions and generators
  • IO Operations
  • Mathematical functions
    • Operators and related functions
    • Index related functions
    • Basic functions
    • Exponential functions
    • Power functions
    • Trigonometric functions
    • Hyperbolic functions
    • Error and gamma functions
    • Nearest integer floating point operations
    • Classification functions
    • Reducing functions
    • Accumulating functions
    • NaN functions
  • xshape

DEVELOPER ZONE

  • Compiler workarounds
  • Build and configuration
  • Internals of xtensor
  • Extending xtensor
  • Releasing xtensor

MISCELLANEOUS

  • From NumPy to xtensor
  • Notable differences with numpy
  • Closure semantics
  • Related projects
  • Designing language bindings with xtensor
xtensor
  • Mathematical functions
  • Operators and related functions
  • Edit on GitHub

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

Warning

doxygenfunction: Cannot find function “operator&&” in doxygen xml output for project “xtensor” from directory: ../xml

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

Warning

doxygenfunction: Cannot find function “operator&” in doxygen xml output for project “xtensor” from directory: ../xml

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

left_shift

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

right_shift

Parameters
  • e1 – an xexpression

  • e2 – an xexpression

Returns

an xfunction

template<class R, class E>
inline auto xt::cast(E &&e) noexcept -> detail::xfunction_type_t<typename detail::cast<R>::functor, E>¶

Element-wise static_cast.

Returns an xfunction for the element-wise static_cast of e to type R.

Parameters

e – an xexpression or a scalar

Returns

an xfunction

Previous Next

© Copyright 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht. Revision 545dd7aa.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds