batch

template <class T, std::size_t N>
class xsimd::batch

Batch of integer or floating point values.

The batch class represents a batch of integer or floating point values. Types supported are int32_t, int64_t, float and double.

Template Parameters
  • T: The value type.
  • N: The number of scalar in the batch.

Inherits from xsimd::simd_batch< batch< T, N > >

Public Functions

batch()

Builds an uninitialized batch.

batch(T f)

Initializes all the values of the batch to b.

xsimd::batch::batch(T f0, ..., T f3)

Initializes a batch with the specified boolean values.

batch(const T *src, aligned_mode)

Initializes a batch to the N contiguous values pointed by src; src is not required to be aligned.

batch(const T *src, unaligned_mode)

Initializes a batch to the values pointed by src; src must be aligned.

batch(const simd_data &rhs)

Initializes a batch with the specified SIMD value.

batch &operator=(const simd_data &rhs)

Assigns the specified SIMD value to the batch.

operator simd_data() const

Converts this to a SIMD value.

batch &load_aligned(const T *src)

Loads the N contiguous values pointed by src into the batch.

src must be aligned.

batch &load_unaligned(const T *src)

Loads the N contiguous values pointed by src into the batch.

src is not required to be aligned.

void store_aligned(T *dst) const

Stores the N values of the batch into a contiguous array pointed by dst.

dst must be aligned.

void store_unaligned(T *dst) const

Stores the N values of the batch into a contiguous array pointed by dst.

dst is not required to be aligned.

T operator[](std::size_t i) const

Return the i-th scalar in the batch.

Arithmeric operators

template <class T, std::size_t N>
batch<T, N> xsimd::operator-(const batch<T, N> &rhs)

Computes the opposite of the batch rhs.

Return
the opposite of rhs.
Parameters
  • rhs: batch involved in the operation.

template <class T, std::size_t N>
batch<T, N> xsimd::operator+(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the sum of the batches lhs and rhs.

Return
the result of the addition.
Parameters
  • lhs: batch involved in the addition.
  • rhs: batch involved in the addition.

template <class T, std::size_t N>
batch<T, N> xsimd::operator-(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the difference of the batches lhs and rhs.

Return
the result of the difference.
Parameters
  • lhs: batch involved in the difference.
  • rhs: batch involved in the difference.

template <class T, std::size_t N>
batch<T, N> xsimd::operator*(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the product of the batches lhs and rhs.

Return
the result of the product.
Parameters
  • lhs: batch involved in the product.
  • rhs: batch involved in the product.

template <class T, std::size_t N>
batch<T, N> xsimd::operator/(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the division of the batch lhs by the batch rhs.

Return
the result of the division.
Parameters
  • lhs: batch involved in the division.
  • rhs: batch involved in the division.

Comparison operators

template <class T, std::size_t N>
batch_bool<T, 4> xsimd::operator==(const batch<T, N> &lhs, const batch<T, N> &rhs)

Element-wise equality comparison of batches lhs and rhs.

Return
a boolean batch.
Parameters
  • lhs: batch involved in the comparison.
  • rhs: batch involved in the comparison.

template <class T, std::size_t N>
batch_bool<T, 4> xsimd::operator!=(const batch<T, N> &lhs, const batch<T, N> &rhs)

Element-wise inequality comparison of batches lhs and rhs.

Return
a boolean batch.
Parameters
  • lhs: batch involved in the comparison.
  • rhs: batch involved in the comparison.

template <class T, std::size_t N>
batch_bool<T, 4> xsimd::operator<(const batch<T, N> &lhs, const batch<T, N> &rhs)

Element-wise lesser than comparison of batches lhs and rhs.

Return
a boolean batch.
Parameters
  • lhs: batch involved in the comparison.
  • rhs: batch involved in the comparison.

template <class T, std::size_t N>
batch_bool<T, 4> xsimd::operator<=(const batch<T, N> &lhs, const batch<T, N> &rhs)

Element-wise lesser or equal to comparison of batches lhs and rhs.

Return
a boolean batch.
Parameters
  • lhs: batch involved in the comparison.
  • rhs: batch involved in the comparison.

Logical operators

template <class T, std::size_t N>
batch<T, N> xsimd::operator&(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the bitwise and of the batches lhs and rhs.

Return
the result of the bitwise and.
Parameters
  • lhs: batch involved in the operation.
  • rhs: batch involved in the operation.

template <class T, std::size_t N>
batch<T, N> xsimd::operator|(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the bitwise or of the batches lhs and rhs.

Return
the result of the bitwise or.
Parameters
  • lhs: batch involved in the operation.
  • rhs: batch involved in the operation.

template <class T, std::size_t N>
batch<T, N> xsimd::operator^(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the bitwise xor of the batches lhs and rhs.

Return
the result of the bitwise xor.
Parameters
  • lhs: batch involved in the operation.
  • rhs: batch involved in the operation.

template <class T, std::size_t N>
batch<T, N> xsimd::operator~(const batch<T, N> &rhs)

Computes the bitwise not of the batches lhs and rhs.

Return
the result of the bitwise not.
Parameters
  • rhs: batch involved in the operation.

template <class T, std::size_t N>
batch<T, N> xsimd::bitwise_andnot(const batch<T, N> &lhs, const batch<T, N> &rhs)

Computes the bitwise andnot of the batches lhs and rhs.

Return
the result of the bitwise andnot.
Parameters
  • lhs: batch involved in the operation.
  • rhs: batch involved in the operation.

Miscellaneous

template <class T, std::size_t N>
batch<T, N> xsimd::select(const batch_bool<T, N> &cond, const batch<T, N> &a, const batch<T, N> &b)

Ternary operator for batches: selects values from the batches a or b depending on the boolean values in cond.

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.