simd_batch¶

template <class X>
classsimd_batch
¶ Base class for batch of integer or floating point values.
The simd_batch class is the base class for all classes representing a batch of integer or floating point values. Each type of batch (i.e. a class inheriting from simd_batch) has its dedicated type of boolean batch (i.e. a class inheriting from simd_batch_bool) for logical operations.
 See
 simd_batch_bool
 Template Parameters
X
: The derived type
Static downcast functions

X &
operator()
()¶ Returns a reference to the actual derived type of the simd_batch_bool.

const X &
operator()
() const¶ Returns a constant reference to the actual derived type of the simd_batch_bool.
Arithmetic computed assignment

X &
operator+=
(const X &rhs)¶ Adds the batch
rhs
tothis
. Return
 a reference to
this
.  Parameters
rhs
: the batch to add.

X &
operator+=
(const value_type &rhs)¶ Adds the scalar
rhs
to each value contained inthis
. Return
 a reference to
this
.  Parameters
rhs
: the scalar to add.

X &
operator=
(const X &rhs)¶ Substracts the batch
rhs
tothis
. Return
 a reference to
this
.  Parameters
rhs
: the batch to substract.

X &
operator=
(const value_type &rhs)¶ Substracts the scalar
rhs
to each value contained inthis
. Return
 a reference to
this
.  Parameters
rhs
: the scalar to substract.

X &
operator*=
(const X &rhs)¶ Multiplies
this
with the batchrhs
. Return
 a reference to
this
.  Parameters
rhs
: the batch involved in the multiplication.

X &
operator*=
(const value_type &rhs)¶ Multiplies each scalar contained in
this
with the scalarrhs
. Return
 a reference to
this
.  Parameters
rhs
: the scalar involved in the multiplication.

X &
operator/=
(const X &rhs)¶ Divides
this
by the batchrhs
. Return
 a reference to
this
.  Parameters
rhs
: the batch involved in the division.

X &
operator/=
(const value_type &rhs)¶ Divides each scalar contained in
this
by the scalarrhs
. Return
 a reference to
this
.  Parameters
rhs
: the scalar involved in the division.
Bitwise computed assignment

X &
operator&=
(const X &rhs)¶ Assigns the bitwise and of
rhs
andthis
. Return
 a reference to
this
.  Parameters
rhs
: the batch involved in the operation.

X &
operator=
(const X &rhs)¶ Assigns the bitwise or of
rhs
andthis
. Return
 a reference to
this
.  Parameters
rhs
: the batch involved in the operation.

X &
operator^=
(const X &rhs)¶ Assigns the bitwise xor of
rhs
andthis
. Return
 a reference to
this
.  Parameters
rhs
: the batch involved in the operation.
Increment and decrement operators

X &
operator++
()¶ Preincrement operator.
 Return
 a reference to
this
.

X &
operator++
(int)¶ Postincrement operator.
 Return
 a reference to
this
.

X &
operator
()¶ Predecrement operator.
 Return
 a reference to
this
.

X &
operator
(int)¶ Postdecrement operator.
 Return
 a reference to
this
.
Arithmetic operators¶

template <class X>
Xxsimd
::
operator
(const simd_batch<X> &rhs)¶ Computes the opposite of the batch
rhs
. Return
 the opposite of
rhs
.  Template Parameters
X
: the actual type of batch.
 Parameters
rhs
: batch involved in the operation.

template <class X>
Xxsimd
::
operator+
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the sum of the batches
lhs
andrhs
. Return
 the result of the addition.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the addition.rhs
: batch involved in the addition.

template <class X>
Xxsimd
::
operator+
(const simd_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the sum of the batch
lhs
and the scalarrhs
.Equivalent to the sum of two batches where all the values of the second one are initialized to
rhs
. Return
 the result of the addition.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the addition.rhs
: scalar involved in the addition.

template <class X>
Xxsimd
::
operator+
(const typename simd_batch<X>::value_type &lhs, const simd_batch<X> &rhs)¶ Computes the sum of the scalar
lhs
and the batchrhs
.Equivalent to the sum of two batches where all the values of the first one are initialized to
rhs
. Return
 the result of the addition.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: scalar involved in the addition.rhs
: batch involved in the addition.

template <class X>
Xxsimd
::
operator
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the difference of the batches
lhs
andrhs
. Return
 the result of the difference.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the difference.rhs
: batch involved in the difference.

template <class X>
Xxsimd
::
operator
(const simd_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the difference of the batch
lhs
and the scalarrhs
.Equivalent to the difference of two batches where all the values of the second one are initialized to
rhs
. Return
 the result of the difference.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the difference.rhs
: scalar involved in the difference.

template <class X>
Xxsimd
::
operator
(const typename simd_batch<X>::value_type &lhs, const simd_batch<X> &rhs)¶ Computes the difference of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
. Return
 the result of the difference.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: scalar involved in the difference.rhs
: batch involved in the difference.

template <class X>
Xxsimd
::
operator*
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the product of the batches
lhs
andrhs
. Return
 the result of the product.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the product.rhs
: batch involved in the product.

template <class X>
Xxsimd
::
operator*
(const simd_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the product of the batch
lhs
and the scalarrhs
.Equivalent to the product of two batches where all the values of the second one are initialized to
rhs
. Return
 the result of the product.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the product.rhs
: scalar involved in the product.

template <class X>
Xxsimd
::
operator*
(const typename simd_batch<X>::value_type &lhs, const simd_batch<X> &rhs)¶ Computes the product of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
. Return
 the result of the product.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: scalar involved in the product.rhs
: batch involved in the product.

template <class X>
Xxsimd
::
operator/
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the division of the batch
lhs
by the batchrhs
. Return
 the result of the division.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the division.rhs
: batch involved in the division.

template <class X>
Xxsimd
::
operator/
(const simd_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the division of the batch
lhs
by the scalarrhs
.Equivalent to the division of two batches where all the values of the second one are initialized to
rhs
. Return
 the result of the division.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the division.rhs
: scalar involved in the division.

template <class X>
Xxsimd
::
operator/
(const typename simd_batch<X>::value_type &lhs, const simd_batch<X> &rhs)¶ Computes the division of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
. Return
 the result of the division.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: scalar involved in the division.rhs
: batch involved in the division.

template <class X>
Xxsimd
::
operator%
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the integer modulo of the batch
lhs
by the batchrhs
. Return
 the result of the modulo.
 Parameters
lhs
: batch involved in the modulo.rhs
: batch involved in the modulo.

template <class X>
Xxsimd
::
operator%
(const simd_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the integer modulo of the batch
lhs
by the scalarrhs
.Equivalent to the modulo of two batches where all the values of the second one are initialized to
rhs
. Return
 the result of the modulo.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the modulo.rhs
: scalar involved in the modulo.

template <class X>
Xxsimd
::
operator%
(const typename simd_batch<X>::value_type &lhs, const simd_batch<X> &rhs)¶ Computes the integer modulo of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
. Return
 the result of the modulo.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: scalar involved in the modulo.rhs
: batch involved in the modulo.
Comparison operators¶

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator==
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise equality comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator!=
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise inequality comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator<
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise lesser than comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator<=
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise lesser or equal to comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator>
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise greater than comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator>=
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Elementwise greater or equal comparison of batches
lhs
andrhs
. Return
 a boolean batch.
 Template Parameters
X
: the actual type of batch.
 Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.
Bitwise operators¶

template <class X>
Xxsimd
::
operator&
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the bitwise and of the batches
lhs
andrhs
. Return
 the result of the bitwise and.
 Parameters
lhs
: batch involved in the operation.rhs
: batch involved in the operation.

template <class X>
Xxsimd
::
operator
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the bitwise or of the batches
lhs
andrhs
. Return
 the result of the bitwise or.
 Parameters
lhs
: batch involved in the operation.rhs
: batch involved in the operation.

template <class X>
Xxsimd
::
operator^
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the bitwise xor of the batches
lhs
andrhs
. Return
 the result of the bitwise xor.
 Parameters
lhs
: batch involved in the operation.rhs
: batch involved in the operation.

template <class X>
Xxsimd
::
operator~
(const simd_batch<X> &rhs)¶ Computes the bitwise not of the batches
lhs
andrhs
. Return
 the result of the bitwise not.
 Parameters
rhs
: batch involved in the operation.

template <class X>
Xxsimd
::
bitwise_andnot
(const simd_batch<X> &lhs, const simd_batch<X> &rhs)¶ Computes the bitwise andnot of the batches
lhs
andrhs
. Return
 the result of the bitwise andnot.
 Parameters
lhs
: batch involved in the operation.rhs
: batch involved in the operation.
Reducers¶

template <class X>
simd_batch_traits<X>::value_typexsimd
::
hadd
(const simd_batch<X> &rhs)¶ Adds all the scalars of the batch
rhs
. Return
 the result of the reduction.
 Parameters
rhs
: batch involved in the reduction

template <class X>
Xxsimd
::
haddp
(const simd_batch<X> *row)¶ Parallel horizontal addition: adds the scalars of each batch in the array pointed by
row
and store them in a returned batch. Return
 the result of the reduction.
 Parameters
row
: an array ofN
batches
Miscellaneous¶

template <class X>
Xxsimd
::
select
(const typename simd_batch_traits<X>::batch_bool_type &cond, const simd_batch<X> &a, const simd_batch<X> &b)¶ Ternary operator for batches: selects values from the batches
a
orb
depending on the boolean values incond
.Equivalent to
for(std::size_t i = 0; i < N; ++i) res[i] = cond[i] ? a[i] : b[i];
 Return
 the result of the selection.
 Parameters
cond
: batch condition.a
: batch values for truthy condition.b
: batch value for falsy condition.
Other operators¶

template <class X>
simd_batch_traits<X>::batch_bool_typexsimd
::
operator!
(const simd_batch<X> &rhs) Elementwise not of
rhs
. Return
 boolean batch.
 Template Parameters
X
: the actual type of batch.
 Parameters
rhs
: batch involved in the logical not operation.

template <class X>
std::ostream &xsimd
::
operator<<
(std::ostream &out, const simd_batch<X> &rhs) Insert the batch
rhs
into the streamout
. Return
 the output stream.
 Template Parameters
X
: the actual type of batch.
 Parameters
out
: the output stream.rhs
: the batch to output.