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 |
- template <class T, class A>
-
auto
xsimd
::
add
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the sum of the batches
x
andy
.- Return
the sum of
x
andy
- Parameters
x
: batch or scalar involved in the addition.y
: batch or scalar involved in the addition.
- template <class T, class A>
-
batch<T, A>
xsimd
::
decr
(batch<T, A> const &x)¶ Subtract 1 to batch
x
.- Return
the subtraction of
x
and 1.- Parameters
x
: batch involved in the decrement.
- template <class T, class A, class Mask>
-
batch<T, A>
xsimd
::
decr_if
(batch<T, A> const &x, Mask const &mask)¶ Subtract 1 to batch
x
for each element wheremask
is true.- Return
the subtraction of
x
and 1 whenmask
is true.- Parameters
x
: batch involved in the increment.mask
: whether to perform the increment or not. Can be abatch_bool
or abatch_bool_constant
.
- template <class T, class A>
-
auto
xsimd
::
div
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the division of the batch
x
by the batchy
.- Return
the result of the division.
- Parameters
x
: scalar or batch of scalarsy
: scalar or batch of scalars
- template <class T, class A>
-
batch<T, A>
xsimd
::
fma
(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &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, class A>
-
batch<T, A>
xsimd
::
fms
(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &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, class A>
-
batch<T, A>
xsimd
::
fnma
(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &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, class A>
-
batch<T, A>
xsimd
::
fnms
(batch<T, A> const &x, batch<T, A> const &y, batch<T, A> const &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, class A>
-
batch<T, A>
xsimd
::
incr
(batch<T, A> const &x)¶ Add 1 to batch
x
.- Return
the sum of
x
and 1.- Parameters
x
: batch involved in the increment.
- template <class T, class A, class Mask>
-
batch<T, A>
xsimd
::
incr_if
(batch<T, A> const &x, Mask const &mask)¶ Add 1 to batch
x
for each element wheremask
is true.- Return
the sum of
x
and 1 whenmask
is true.- Parameters
x
: batch involved in the increment.mask
: whether to perform the increment or not. Can be abatch_bool
or abatch_bool_constant
.
- template <class T, class A>
-
auto
xsimd
::
mod
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the integer modulo of the batch
x
by the batchy
.- Return
the result of the modulo.
- Parameters
x
: batch involved in the modulo.y
: batch involved in the modulo.
- template <class T, class A>
-
auto
xsimd
::
mul
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the product of the batches
x
andy
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
x
: batch involved in the product.y
: batch involved in the product.
- template <class T, class A>
-
batch<T, A>
xsimd
::
neg
(batch<T, A> const &x)¶ Computes the opposite of the batch
x
.- Return
the opposite of
x
.- Parameters
x
: batch involved in the operation.
- template <class T, class A>
-
batch<T, A>
xsimd
::
pos
(batch<T, A> const &x)¶ No-op on
x
.- Return
x
.- Parameters
x
: batch involved in the operation.
- template <class T, class A, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
-
batch<T, A>
xsimd
::
reciprocal
(batch<T, A> const &x)¶ Computes the approximate reciprocal of the batch
x
.The maximum relative error for this approximation is less than 1.5*2^-12.
- Return
the reciprocal.
- Parameters
x
: batch of floating point numbers.
- template <class T, class A>
-
batch<T, A>
xsimd
::
sadd
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the saturate sum of the batch
x
and the batchy
.- Return
the result of the saturated addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
x
: batch involved in the saturated addition.y
: batch involved in the saturated addition.
- template <class T, class A>
-
batch<T, A>
xsimd
::
ssub
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the saturate difference of the batch
x
and the batchy
.- Return
the result of the saturated difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
x
: batch involved in the saturated difference.y
: batch involved in the saturated difference.
- template <class T, class A>
-
auto
xsimd
::
sub
(batch<T, A> const &x, batch<T, A> const &y)¶ Computes the difference between
x
andy
.- Return
the difference between
x
andy
- Template Parameters
X
: the actual type of batch.
- Parameters
x
: scalar or batch of scalarsy
: scalar or batch of scalars