Arithmetic operators
Binary operations:
per slot addition |
|
per slot subtraction |
|
per slot multiply |
|
per slot division |
|
per slot modulo |
Unary operations:
per slot negate |
|
per slot positive |
|
per slot reciprocal |
|
per slot decrement |
|
per slot decrement, based on a mask |
|
per slot increment |
|
per slot increment, based on a mask |
Saturated arithmetic:
per slot saturated addition |
|
per slot saturated subtraction |
Fused operations:
fused multiply add |
|
fused multiply sub |
|
fused negate multiply add |
|
fused negate multiply sub |
Average computation:
per slot average |
|
per slot rounded average |
-
template<class T, class A>
inline auto add(batch<T, A> const &x, batch<T, A> 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 A>
inline batch<T, A> decr(batch<T, A> const &x) noexcept Subtract 1 to batch
x
.- Parameters:
x – batch involved in the decrement.
- Returns:
the subtraction of
x
and 1.
-
template<class T, class A, class Mask>
inline batch<T, A> decr_if(batch<T, A> const &x, Mask const &mask) noexcept Subtract 1 to batch
x
for each element wheremask
is true.- Parameters:
x – batch involved in the increment.
mask – whether to perform the increment or not. Can be a
batch_bool
or abatch_bool_constant
.
- Returns:
the subtraction of
x
and 1 whenmask
is true.
-
template<class T, class A>
inline auto div(batch<T, A> const &x, batch<T, A> 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 A>
inline batch<T, A> incr(batch<T, A> const &x) noexcept Add 1 to batch
x
.- Parameters:
x – batch involved in the increment.
- Returns:
the sum of
x
and 1.
-
template<class T, class A, class Mask>
inline batch<T, A> incr_if(batch<T, A> const &x, Mask const &mask) noexcept Add 1 to batch
x
for each element wheremask
is true.- Parameters:
x – batch involved in the increment.
mask – whether to perform the increment or not. Can be a
batch_bool
or abatch_bool_constant
.
- Returns:
the sum of
x
and 1 whenmask
is true.
-
template<class T, class A>
inline auto mod(batch<T, A> const &x, batch<T, A> 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 A>
inline auto mul(batch<T, A> const &x, batch<T, A> 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 A>
inline batch<T, A> sadd(batch<T, A> const &x, batch<T, A> const &y) noexcept Computes the saturate sum of the batch
x
and the batchy
.- 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 A>
inline batch<T, A> ssub(batch<T, A> const &x, batch<T, A> const &y) noexcept Computes the saturate difference of the batch
x
and the batchy
.- 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 A>
inline auto sub(batch<T, A> const &x, batch<T, A> const &y) noexcept -> decltype(x - y) Computes the difference between
x
andy
.- 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
andy