Basic functions

template<class X>
inline real_batch_type_t<X> xsimd::abs(const simd_base<X> &rhs)

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

Parameters

rhs – batch of integer or floating point values.

Returns

the asbolute values of rhs.

template<class X>
inline batch_type_t<X> xsimd::fabs(const simd_base<X> &rhs)

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

Parameters

rhs – batch floating point values.

Returns

the asbolute values of rhs.

template<class B>
inline batch_type_t<B> xsimd::fmod(const simd_base<B> &x, const simd_base<B> &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.

Parameters
  • x – batch of floating point values.

  • y – batch of floating point values.

Returns

the floating-point remainder of the division.

template<class B>
inline batch_type_t<B> xsimd::remainder(const simd_base<B> &x, const simd_base<B> &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.

Parameters
  • x – batch of floating point values.

  • y – batch of floating point values.

Returns

the IEEE remainder remainder of the floating point division.

template<class X>
inline batch_type_t<X> xsimd::fma(const simd_base<X> &x, const simd_base<X> &y, const simd_base<X> &z)

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

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.

Returns

the result of the fused multiply-add operation.

template<class X>
inline batch_type_t<X> xsimd::fms(const simd_base<X> &x, const simd_base<X> &y, const simd_base<X> &z)

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

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.

Returns

the result of the fused multiply-sub operation.

template<class X>
inline batch_type_t<X> xsimd::fnma(const simd_base<X> &x, const simd_base<X> &y, const simd_base<X> &z)

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

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.

Returns

the result of the fused negated multiply-add operation.

template<class X>
inline batch_type_t<X> xsimd::fnms(const simd_base<X> &x, const simd_base<X> &y, const simd_base<X> &z)

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

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.

Returns

the result of the fused negated multiply-sub operation.

template<class X>
inline batch_type_t<X> xsimd::min(const simd_base<X> &lhs, const simd_base<X> &rhs)

Returns the smaller values of the batches lhs and rhs.

Parameters
  • lhs – a batch of integer or floating point values.

  • rhs – a batch of integer or floating point values.

Returns

a batch of the smaller values.

template<class X>
inline batch_type_t<X> xsimd::max(const simd_base<X> &lhs, const simd_base<X> &rhs)

Returns the larger values of the batches lhs and rhs.

Parameters
  • lhs – a batch of integer or floating point values.

  • rhs – a batch of integer or floating point values.

Returns

a batch of the larger values.

template<class X>
batch_type_t<X> xsimd::fmin(const simd_base<X> &lhs, const simd_base<X> &rhs)
template<class X>
batch_type_t<X> xsimd::fmax(const simd_base<X> &lhs, const simd_base<X> &rhs)

Warning

doxygenfunction: Unable to resolve function “fdim” with arguments (const batch<T, N>&, const batch<T, N>&) in doxygen xml output for project “xsimd” from directory: ../xml. Potential matches:

- template<class B> batch_type_t<B> fdim(const simd_base<B> &x, const simd_base<B> &y)

Warning

doxygenfunction: Unable to resolve function “sadd” with arguments (const simd_base<B>&, const simd_base<B>&) in doxygen xml output for project “xsimd” from directory: ../xml. Potential matches:

- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- batch_type sadd(const batch_type &lhs, const batch_type &rhs)
- template<class X> batch_type_t<X> sadd(const simd_base<X> &lhs, const simd_base<X> &rhs)
- template<class X> batch_type_t<X> sadd(const simd_base<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)
- template<class X> batch_type_t<X> sadd(const typename simd_batch_traits<X>::value_type &lhs, const simd_base<X> &rhs)
- template<typename T, class = typename std::enable_if<std::is_scalar<T>::value>::type> T sadd(const T &lhs, const T &rhs)
- template<typename T, class = typename std::enable_if<std::is_scalar<T>::value>::type> T sadd(const T &lhs, const T &rhs)

Warning

doxygenfunction: Unable to resolve function “ssub” with arguments (const simd_base<B>&, const simd_base<B>&) in doxygen xml output for project “xsimd” from directory: ../xml. Potential matches:

- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- batch_type ssub(const batch_type &lhs, const batch_type &rhs)
- template<class X> batch_type_t<X> ssub(const simd_base<X> &lhs, const simd_base<X> &rhs)
- template<class X> batch_type_t<X> ssub(const simd_base<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)
- template<class X> batch_type_t<X> ssub(const typename simd_batch_traits<X>::value_type &lhs, const simd_base<X> &rhs)
- template<typename T, class = typename std::enable_if<std::is_scalar<T>::value>::type> T ssub(const T &lhs, const T &rhs)
- template<typename T, class = typename std::enable_if<std::is_scalar<T>::value>::type> T ssub(const T &lhs, const T &rhs)
template<class B>
inline batch_type_t<B> xsimd::clip(const simd_base<B> &x, const simd_base<B> &lo, const simd_base<B> &hi)

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

Parameters
  • x – batch of floating point values.

  • lo – batch of floating point values.

  • hi – batch of floating point values.

Returns

the result of the clipping.