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
andy
.- Parameters
x – batch or scalar involved in the addition.
y – batch or scalar involved in the addition.
- Returns
the sum of
x
andy
-
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 batchy
.- 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 batchy
.- 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
andy
.- 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 batchy
.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 batchy
.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.
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
andy
.- 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
andy
.- 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
andy
.- 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
andy
.- 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
andy
.- 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
andy
.- 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.
Mathematical functions¶
absolute value |
|
absolute value |
|
remainder of the floating point division operation |
|
signed remainder of the division operation |
|
fused multiply-add operation |
|
fused multiply-sub operation |
|
fused negated multiply-add operation |
|
fused negated multiply-sub operation |
|
smaller of two batches |
|
larger of two batches |
|
smaller of two batches of floating point values |
|
larger of two batches of floating point values |
|
positive difference |
|
saturated addition |
|
saturated subtraction |
|
clipping operation |
natural exponential function |
|
base 2 exponential function |
|
base 10 exponential function |
|
natural exponential function, minus one |
|
natural logarithm function |
|
base 2 logarithm function |
|
base 10 logarithm function |
|
natural logarithm of one plus function |
power function |
|
reciprocal square root function |
|
square root function |
|
cubic root function |
|
hypotenuse function |
sine function |
|
cosine function |
|
sine and cosine function |
|
tangent function |
|
arc sine function |
|
arc cosine function |
|
arc tangent function |
|
arc tangent function, determining quadrants |
hyperbolic sine function |
|
hyperbolic cosine function |
|
hyperbolic tangent function |
|
inverse hyperbolic sine function |
|
inverse hyperbolic cosine function |
|
inverse hyperbolic tangent function |
error function |
|
complementary error function |
|
gamma function |
|
natural logarithm of the gamma function |
nearest integers not less |
|
nearest integers not greater |
|
nearest integers not greater in magnitude |
|
nearest integers, rounding away from zero |
|
nearest integers using current rounding mode |
|
nearest integers using current rounding mode |
Checks for finite values |
|
Checks for infinite values |
|
Checks for NaN values |
Reducers¶
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 ofy
.- Parameters
x – batch of scalars
y – batch of scalars
- Returns
batch whose absolute value matches that of
x
, but whose sign bit matches that ofy
.
-
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
orfalse_br
depending on the boolean values in the constant batchcond
.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
orfalse_br
depending on the boolean values in the constant batchcond
.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
orfalse_br
depending on the boolean values in the constant batchcond
.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