xtensor

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
  • SFINAE
  • xsimd
  • 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

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
  • Docs »
  • Mathematical functions »
  • Operators and related functions
  • View page source

Operators and related functions¶

Defined in xtensor/xmath.hpp and xtensor/xoperation.hpp

template <class E>
auto xt::operator+(E &&e)

Identity.

Returns an xfunction for the element-wise identity of e.

Return
an xfunction
Parameters
  • e: an xexpression

template <class E>
auto xt::operator-(E &&e)

Opposite.

Returns an xfunction for the element-wise opposite of e.

Return
an xfunction
Parameters
  • e: an xexpression

template <class E1, class E2>
auto xt::operator+(E1 &&e1, E2 &&e2)

Addition.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator-(E1 &&e1, E2 &&e2)

Substraction.

Returns an xfunction for the element-wise substraction of e2 to e1.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator*(E1 &&e1, E2 &&e2)

Multiplication.

Returns an xfunction for the element-wise multiplication of e1 by e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator/(E1 &&e1, E2 &&e2)¶

Division.

Returns an xfunction for the element-wise division of e1 by e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator||(E1 &&e1, E2 &&e2)¶

Or.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator&&(E1 &&e1, E2 &&e2)¶

And.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E>
auto xt::operator!(E &&e)¶

Not.

Returns an xfunction for the element-wise not of e.

Return
an xfunction
Parameters
  • e: an xexpression

template <class E1, class E2, class E3>
auto xt::where(E1 &&e1, E2 &&e2, E3 &&e3)

Ternary selection.

Returns an xfunction for the element-wise ternary selection (i.e. operator ? :) of e1, e2 and e3.

Return
an xfunction
Parameters
  • e1: a boolean xexpression
  • e2: an xexpression or a scalar
  • e3: an xexpression or a scalar

template <class E>
bool xt::any(E &&e)¶

Any.

Returns true if any of the values of e is truthy, false otherwise.

Return
a boolean
Parameters
  • e: an xexpression

template <class E>
bool xt::all(E &&e)

Any.

Returns true if all of the values of e are truthy, false otherwise.

Return
a boolean
Parameters
  • e: an xexpression

template <class E1, class E2>
auto xt::operator<(E1 &&e1, E2 &&e2)

Lesser than.

Returns an xfunction for the element-wise lesser than comparison of e1 and e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator<=(E1 &&e1, E2 &&e2)

Lesser or equal.

Returns an xfunction for the element-wise lesser or equal comparison of e1 and e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator>(E1 &&e1, E2 &&e2)

Greater than.

Returns an xfunction for the element-wise greater than comparison of e1 and e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator>=(E1 &&e1, E2 &&e2)

Greater or equal.

Returns an xfunction for the element-wise greater or equal comparison of e1 and e2.

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
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.

Return
a boolean
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
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.

Return
a boolean
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::equal(E1 &&e1, E2 &&e2)

Element-wise equality.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::not_equal(E1 &&e1, E2 &&e2)¶

Element-wise inequality.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::less(E1 &&e1, 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&&).

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::less_equal(E1 &&e1, 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&&).

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::greater(E1 &&e1, 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&&).

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::greater_equal(E1 &&e1, 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&&).

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator&(E1 &&e1, E2 &&e2)

Bitwise and.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator|(E1 &&e1, E2 &&e2)

Bitwise or.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E1, class E2>
auto xt::operator^(E1 &&e1, E2 &&e2)¶

Bitwise xor.

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

Return
an xfunction
Parameters
  • e1: an xexpression or a scalar
  • e2: an xexpression or a scalar

template <class E>
auto xt::operator~(E &&e)¶

Bitwise not.

Returns an xfunction for the element-wise bitwise not of e.

Return
an xfunction
Parameters
  • e: an xexpression

template <class E1, class E2>
auto xt::left_shift(E1 &&e1, E2 &&e2)¶

Bitwise left shift.

Returns an xfunction for the element-wise bitwise left shift of e1 by e2.

Return
an xfunction
Parameters
  • e1: an xexpression
  • e2: an xexpression

template <class E1, class E2>
auto xt::right_shift(E1 &&e1, E2 &&e2)¶

Bitwise left shift.

Returns an xfunction for the element-wise bitwise left shift of e1 by e2.

Return
an xfunction
Parameters
  • e1: an xexpression
  • e2: an xexpression

template <class E1, class E2>
auto xt::operator<<(E1 &&e1, E2 &&e2)

Bitwise left shift.

Returns an xfunction for the element-wise bitwise left shift of e1 by e2.

Return
an xfunction
See
left_shift
Parameters
  • e1: an xexpression
  • e2: an xexpression

template <class E1, class E2>
auto xt::operator>>(E1 &&e1, E2 &&e2)¶

Bitwise right shift.

Returns an xfunction for the element-wise bitwise right shift of e1 by e2.

Return
an xfunction
See
right_shift
Parameters
  • e1: an xexpression
  • e2: an xexpression

template <class R, class E>
auto xt::cast(E &&e)

Element-wise static_cast.

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

Return
an xfunction
Parameters
  • e: an xexpression or a scalar

Next Previous

© Copyright 2021, Johan Mabille, Sylvain Corlay and Wolf Vollprecht.

Built with Sphinx using a theme provided by Read the Docs.