Basic functions

template <class T, std::size_t N>
batch<T, N> xsimd::abs(const batch<T, N> &x)

Computes the absolute values of each scalar in the batch x.

Return
the asbolute values of x.
Parameters
  • x: batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fabs(const batch<T, N> &x)

Computes the absolute values of each scalar in the batch x.

Return
the asbolute values of x.
Parameters
  • x: batch floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fmod(const batch<T, N> &x, const batch<T, N> &y)

Computes the floating-point remainder of the division operation x/y.

The floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y, where n is x/y with its fractional part truncated. The returned value has the same sign as x and is less than y in magnitude.

Return
the floating-point remainder of the division.
Parameters
  • x: batch of floating point values.
  • y: batch of floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::remainder(const batch<T, N> &x, const batch<T, N> &y)

Computes the IEEE remainder of the floating point division operation x/y.

The IEEE floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y, where the value n is the integral value nearest the exact value x/y. When |n-x/y| = 0.5, the value n is chosen to be even. In contrast to fmod, the returned value is not guaranteed to have the same sign as x. If the returned value is 0, it will have the same sign as x.

Return
the IEEE remainder remainder of the floating point division.
Parameters
  • x: batch of floating point values.
  • y: batch of floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fma(const batch<T, N> &x, const batch<T, N> &y, const batch<T, N> &z)

Computes (x*y) + z in a single instruction when possible.

Return
the result of the fused multiply-add operation.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.
  • z: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fms(const batch<T, N> &x, const batch<T, N> &y, const batch<T, N> &z)

Computes (x*y) - z in a single instruction when possible.

Return
the result of the fused multiply-sub operation.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.
  • z: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fnma(const batch<T, N> &x, const batch<T, N> &y, const batch<T, N> &z)

Computes -(x*y) + z in a single instruction when possible.

Return
the result of the fused negated multiply-add operation.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.
  • z: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fnms(const batch<T, N> &x, const batch<T, N> &y, const batch<T, N> &z)

Computes -(x*y) - z in a single instruction when possible.

Return
the result of the fused negated multiply-sub operation.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.
  • z: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::min(const batch<T, N> &x, const batch<T, N> &y)

Returns the smaller values of the batches x and y.

Return
a batch of the smaller values.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::max(const batch<T, N> &x, const batch<T, N> &y)

Returns the larger values of the batches x and y.

Return
a batch of the larger values.
Parameters
  • x: a batch of integer or floating point values.
  • y: a batch of integer or floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fmin(const batch<T, N> &x, const batch<T, N> &y)

Returns the smaller values of the batches x and y.

Return
a batch of the smaller values.
Parameters
  • x: a batch of floating point values.
  • y: a batch of floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fmax(const batch<T, N> &x, const batch<T, N> &y)

Returns the larger values of the batches x and y.

Return
a batch of the larger values.
Parameters
  • x: a batch of floating point values.
  • y: a batch of floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::fdim(const batch<T, N> &x, const batch<T, N> &y)

Computes the positive difference between x and y, that is, max(0, x-y).

Return
the positive difference.
Parameters
  • x: batch of floating point values.
  • y: batch of floating point values.

template <class T, std::size_t N>
batch<T, N> xsimd::clip(const batch<T, N> &x, const batch<T, N> &lo, const batch<T, N> &hi)

Clips the values of the batch x between those of the batches lo and hi.

Return
the result of the clipping.
Parameters
  • x: batch of floating point values.
  • lo: batch of floating point values.
  • hi: batch of floating point values.