Arithmetic operators

template<class T, class Tp>
inline auto add(T const &x, Tp const &y) noexcept -> decltype(x + y)

Computes the sum of the batches x and y.

Parameters
  • x – batch or scalar involved in the addition.

  • y – batch or scalar involved in the addition.

Returns

the sum of x and y

template<class T, class Tp>
inline auto div(T const &x, Tp const &y) noexcept -> decltype(x / y)

Computes the division of the batch x by the batch y.

Parameters
  • x – scalar or batch of scalars

  • y – scalar or batch of scalars

Returns

the result of the division.

template<class T, class A>
inline batch<T, A> fma(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &z) noexcept

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 T, class A>
inline batch<T, A> fms(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &z) noexcept

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 T, class A>
inline batch<T, A> fnma(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &z) noexcept

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 T, class A>
inline batch<T, A> fnms(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &z) noexcept

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 T, class Tp>
inline auto mod(T const &x, Tp const &y) noexcept -> decltype(x % y)

Computes the integer modulo of the batch x by the batch y.

Parameters
  • x – batch involved in the modulo.

  • y – batch involved in the modulo.

Returns

the result of the modulo.

template<class T, class Tp>
inline auto mul(T const &x, Tp const &y) noexcept -> decltype(x * y)

Computes the product of the batches x and y.

Template Parameters

X – the actual type of batch.

Parameters
  • x – batch involved in the product.

  • y – batch involved in the product.

Returns

the result of the product.

template<class T, class A>
inline batch<T, A> neg(batch<T, A> const &x) noexcept

Computes the opposite of the batch x.

Parameters

x – batch involved in the operation.

Returns

the opposite of x.

template<class T, class A>
inline batch<T, A> pos(batch<T, A> const &x) noexcept

No-op on x.

Parameters

x – batch involved in the operation.

Returns

x.

template<class T, class A, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
inline batch<T, A> reciprocal(batch<T, A> const &x) noexcept

Computes the approximate reciprocal of the batch x.

The maximum relative error for this approximation is less than 1.5*2^-12.

Parameters

x – batch of floating point numbers.

Returns

the reciprocal.

template<class T, class Tp>
inline auto sadd(T const &x, Tp const &y) noexcept -> decltype(x + y)

Computes the saturate sum of the batch x and the batch y.

x.

Template Parameters

X – the actual type of batch.

Parameters
  • x – batch involved in the saturated addition.

  • y – batch involved in the saturated addition.

Returns

the result of the saturated addition.

template<class T, class Tp>
inline auto ssub(T const &x, Tp const &y) noexcept -> decltype(x - y)

Computes the saturate difference of the batch x and the batch y.

x.

Template Parameters

X – the actual type of batch.

Parameters
  • x – batch involved in the saturated difference.

  • y – batch involved in the saturated difference.

Returns

the result of the saturated difference.

template<class T, class Tp>
inline auto sub(T const &x, Tp const &y) noexcept -> decltype(x - y)

Computes the difference between x and y.

Template Parameters

X – the actual type of batch.

Parameters
  • x – scalar or batch of scalars

  • y – scalar or batch of scalars

Returns

the difference between x and y

Comparison operators

template<class T, class A>
inline batch_bool<T, A> eq(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise equality comparison of batches x and y.

Parameters
  • x – batch of scalars

  • y – batch of scalars

Returns

a boolean batch.

template<class T, class A>
inline batch_bool<T, A> ge(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise greater or equal comparison of batches x and y.

Template Parameters

X – the actual type of batch.

Parameters
  • x – batch involved in the comparison.

  • y – batch involved in the comparison.

Returns

a boolean batch.

template<class T, class A>
inline batch_bool<T, A> gt(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise greater than comparison of batches x and y.

Template Parameters

X – the actual type of batch.

Parameters
  • x – batch involved in the comparison.

  • y – batch involved in the comparison.

Returns

a boolean batch.

template<class T, class A>
inline batch_bool<T, A> is_even(batch<T, A> const &x) noexcept

Determines if the scalars in the given batch x represent an even integer value.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch_bool<T, A> is_flint(batch<T, A> const &x) noexcept

Determines if the floating-point scalars in the given batch x represent integer value.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch_bool<T, A> is_odd(batch<T, A> const &x) noexcept

Determines if the scalars in the given batch x represent an odd integer value.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch_bool<T, A> isinf(batch<T, A> const &x) noexcept

Determines if the scalars in the given batch x are inf values.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch_bool<T, A> isfinite(batch<T, A> const &x) noexcept

Determines if the scalars in the given batch x are finite values.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch<T, A>::batch_bool_type isnan(batch<T, A> const &x) noexcept

Determines if the scalars in the given batch x are NaN values.

Parameters

x – batch of floating point values.

Returns

a batch of booleans.

template<class T, class A>
inline batch_bool<T, A> le(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise lesser or equal to comparison of batches x and y.

Parameters
  • x – batch involved in the comparison.

  • y – batch involved in the comparison.

Returns

a boolean batch.

template<class T, class A>
inline batch_bool<T, A> lt(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise lesser than comparison of batches x and y.

Parameters
  • x – batch involved in the comparison.

  • y – batch involved in the comparison.

Returns

a boolean batch.

template<class T, class A>
inline batch_bool<T, A> neq(batch<T, A> const &x, batch<T, A> const &y) noexcept

Element-wise inequality comparison of batches x and y.

Parameters
  • x – batch involved in the comparison.

  • y – batch involved in the comparison.

Returns

a boolean batch.

Bitwise operators

template<class T, class Tp>
inline auto bitwise_and(T const &x, Tp const &y) noexcept -> decltype(x & y)

Computes the bitwise and of the batches x and y.

Parameters
  • x – batch involved in the operation.

  • y – batch involved in the operation.

Returns

the result of the bitwise and.

template<class T, class A>
inline batch<T, A> bitwise_andnot(batch<T, A> const &x, batch<T, A> const &y) noexcept

Computes the bitwise and not of batches x and y.

Parameters
  • x – batch involved in the operation.

  • y – batch involved in the operation.

Returns

the result of the bitwise and not.

template<class T, class A>
inline batch<T, A> bitwise_not(batch<T, A> const &x) noexcept

Computes the bitwise not of batch x.

Parameters

x – batch involved in the operation.

Returns

the result of the bitwise not.

template<class T, class Tp>
inline auto bitwise_or(T const &x, Tp const &y) noexcept -> decltype(x | y)

Computes the bitwise or of the batches x and y.

Parameters
  • x – scalar or batch of scalars

  • y – scalar or batch of scalars

Returns

the result of the bitwise or.

template<class T, class Tp>
inline auto bitwise_xor(T const &x, Tp const &y) noexcept -> decltype(x ^ y)

Computes the bitwise xor of the batches x and y.

Parameters
  • x – scalar or batch of scalars

  • y – scalar or batch of scalars

Returns

the result of the bitwise xor.

Mathematical functions

abs

absolute value

fabs

absolute value

fmod

remainder of the floating point division operation

remainder

signed remainder of the division operation

fma

fused multiply-add operation

fms

fused multiply-sub operation

fnma

fused negated multiply-add operation

fnms

fused negated multiply-sub operation

min

smaller of two batches

max

larger of two batches

fmin

smaller of two batches of floating point values

fmax

larger of two batches of floating point values

fdim

positive difference

sadd

saturated addition

ssub

saturated subtraction

clip

clipping operation

exp

natural exponential function

exp2

base 2 exponential function

exp10

base 10 exponential function

expm1

natural exponential function, minus one

log

natural logarithm function

log2

base 2 logarithm function

log10

base 10 logarithm function

log1p

natural logarithm of one plus function

pow

power function

rsqrt

reciprocal square root function

sqrt

square root function

cbrt

cubic root function

hypot

hypotenuse function

sin

sine function

cos

cosine function

sincos

sine and cosine function

tan

tangent function

asin

arc sine function

acos

arc cosine function

atan

arc tangent function

atan2

arc tangent function, determining quadrants

sinh

hyperbolic sine function

cosh

hyperbolic cosine function

tanh

hyperbolic tangent function

asinh

inverse hyperbolic sine function

acosh

inverse hyperbolic cosine function

atanh

inverse hyperbolic tangent function

erf

error function

erfc

complementary error function

tgamma

gamma function

lgamma

natural logarithm of the gamma function

ceil

nearest integers not less

floor

nearest integers not greater

trunc

nearest integers not greater in magnitude

round

nearest integers, rounding away from zero

nearbyint

nearest integers using current rounding mode

rint

nearest integers using current rounding mode

isfinite

Checks for finite values

isinf

Checks for infinite values

isnan

Checks for NaN values

Reducers

template<class T, class A>
inline T hadd(batch<T, A> const &x) noexcept

Adds all the scalars of the batch x.

Parameters

x – batch involved in the reduction

Returns

the result of the reduction.

template<class T, class A>
inline batch<T, A> haddp(batch<T, A> const *row) noexcept

Parallel horizontal addition: adds the scalars of each batch in the array pointed by row and store them in a returned batch.

Parameters

row – an array of N batches

Returns

the result of the reduction.

Miscellaneous

template<class T, class A>
inline batch<T, A> bitofsign(batch<T, A> const &x) noexcept

Computes the bit of sign of x.

Parameters

x – batch of scalar

Returns

bit of sign of x

template<class A, class T>
inline batch<T, A> copysign(batch<T, A> const &x, batch<T, A> const &y) noexcept

Computes a value whose absolute value matches that of x, but whose sign bit matches that of y.

Parameters
  • x – batch of scalars

  • y – batch of scalars

Returns

batch whose absolute value matches that of x, but whose sign bit matches that of y.

template<class T, class A>
inline batch<T, A> select(batch_bool<T, A> const &cond, batch<T, A> const &true_br, batch<T, A> const &false_br) noexcept

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];

Parameters
  • cond – constant batch condition.

  • true_br – batch values for truthy condition.

  • false_br – batch value for falsy condition.

Returns

the result of the selection.

template<class T, class A>
inline batch<std::complex<T>, A> select(batch_bool<T, A> const &cond, batch<std::complex<T>, A> const &true_br, batch<std::complex<T>, A> const &false_br) noexcept

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];

Parameters
  • cond – constant batch condition.

  • true_br – batch values for truthy condition.

  • false_br – batch value for falsy condition.

Returns

the result of the selection.

template<class T, class A, bool... Values>
inline batch<T, A> select(batch_bool_constant<batch<T, A>, Values...> const &cond, batch<T, A> const &true_br, batch<T, A> const &false_br) noexcept

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];

Parameters
  • cond – constant batch condition.

  • true_br – batch values for truthy condition.

  • false_br – batch value for falsy condition.

Returns

the result of the selection.

template<class T, class A>
inline batch<T, A> sign(batch<T, A> const &x) noexcept

Computes the sign of x.

Parameters

x – batch

Returns

-1 for each negative element, -1 or +1 for each null element and +1 for each element

template<class T, class A>
inline batch<T, A> signnz(batch<T, A> const &x) noexcept

Computes the sign of x, assuming x doesn’t have any zero.

Parameters

x – batch

Returns

-1 for each negative element, -1 or +1 for each null element and +1 for each element

template<class T, class A>
inline std::ostream &operator<<(std::ostream &o, batch<T, A> const &x) noexcept

Dump the content of batch x to stream o.

Parameters
  • o – the stream where the batch is dumped

  • x – batch to dump.

Returns

a reference to o