simd_batch_bool

template<class X>
class xsimd::simd_batch_bool

Base class for batch of boolean values.

The simd_batch_bool class is the base class for all classes representing a batch of boolean values. Batch of boolean values is meant for operations that may involve batches of integer or floating point values. Thus, the boolean values are stored as integer or floating point values, and each type of batch has its dedicated type of boolean batch.

See

simd_batch

tparam X

The derived type

Subclassed by xsimd::batch_bool_avx512< __mmask8, batch_bool< int64_t, 8 > >, xsimd::batch_bool_avx512< __mmask16, batch_bool< float, 16 > >, xsimd::batch_bool_avx512< __mmask16, batch_bool< int32_t, 16 > >, xsimd::batch_bool_avx512< __mmask8, batch_bool< uint64_t, 8 > >, xsimd::batch_bool_avx512< __mmask16, batch_bool< uint32_t, 16 > >, xsimd::batch_bool_avx512< __mmask8, batch_bool< double, 8 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< double >, 2 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< T >, N > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< float >, 8 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< double >, 8 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< float >, 4 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< float >, 16 > >, xsimd::simd_complex_batch_bool< batch_bool< std::complex< double >, 4 > >, xsimd::simd_complex_batch_bool< X >

Bitwise computed assignement

inline X &operator&=(const X &rhs)

Assigns the bitwise and of rhs and this.

Parameters

rhs – the batch involved in the operation.

Returns

a reference to this.

inline X &operator|=(const X &rhs)

Assigns the bitwise or of rhs and this.

Parameters

rhs – the batch involved in the operation.

Returns

a reference to this.

inline X &operator^=(const X &rhs)

Assigns the bitwise xor of rhs and this.

Parameters

rhs – the batch involved in the operation.

Returns

a reference to this.

Static downcast functions

inline 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.

Bitwise operators

template<class X>
inline X operator&(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the bitwise and of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the bitwise and.

template<class X>
inline X operator|(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the bitwise or of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the bitwise or.

template<class X>
inline X operator^(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the bitwise xor of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the bitwise xor.

template<class X>
inline X operator~(const simd_batch_bool<X> &rhs)

Computes the bitwise not of batch rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters

rhs – batch involved in the operation.

Returns

the result of the bitwise not.

template<class X>
X bitwise_andnot(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the bitwise and not of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the bitwise and not.

template<class X>
inline X operator==(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Element-wise equality of batches lhs and rhs.

Parameters
  • lhs – batch involved in the comparison.

  • rhs – batch involved in the comparison.

Returns

the result of the equality comparison.

template<class X>
inline X operator!=(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Element-wise inequality of batches lhs and rhs.

Parameters
  • lhs – batch involved in the comparison.

  • rhs – batch involved in the comparison.

Returns

the result of the inequality comparison.

template<class X>
inline bool all(const simd_batch_bool<X> &rhs)

Returns true if all the boolean values in the batch are true, false otherwise.

Parameters

rhs – the batch to reduce.

Returns

a boolean scalar.

template<class X>
inline bool any(const simd_batch_bool<X> &rhs)

Return true if any of the boolean values in the batch is true, false otherwise.

Parameters

rhs – the batch to reduce.

Returns

a boolean scalar.

template<class X>
inline X operator&&(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the logical and of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator&&(const simd_batch_bool<X> &lhs, bool rhs)

Computes the logical and of the batch lhs and the scalar rhs.

Equivalent to the logical and of two boolean batches, where all the values of the second one are initialized to rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – boolean involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator&&(bool lhs, const simd_batch_bool<X> &rhs)

Computes the logical and of the scalar lhs and the batch rhs.

Equivalent to the logical and of two boolean batches, where all the values of the first one are initialized to lhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – boolean involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator||(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the logical or of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical or.

template<class X>
inline X operator||(const simd_batch_bool<X> &lhs, bool rhs)

Computes the logical or of the batch lhs and the scalar rhs.

Equivalent to the logical or of two boolean batches, where all the values of the second one are initialized to rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – boolean involved in the operation.

Returns

the result of the logical or.

template<class X>
inline X operator||(bool lhs, const simd_batch_bool<X> &rhs)

Computes the logical or of the scalar lhs and the batch rhs.

Equivalent to the logical or of two boolean batches, where all the values of the first one are initialized to lhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – boolean involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical or.

template<class X>
inline X operator!(const simd_batch_bool<X> &rhs)
template<class X>
inline std::ostream &operator<<(std::ostream &out, const simd_batch_bool<X> &rhs)

Insert the batch rhs into the stream out.

Template Parameters

X – the actual type of batch.

Parameters
  • out – the output stream.

  • rhs – the batch to output.

Returns

the output stream.

Logical operators

template<class X>
inline X operator&&(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the logical and of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator&&(const simd_batch_bool<X> &lhs, bool rhs)

Computes the logical and of the batch lhs and the scalar rhs.

Equivalent to the logical and of two boolean batches, where all the values of the second one are initialized to rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – boolean involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator&&(bool lhs, const simd_batch_bool<X> &rhs)

Computes the logical and of the scalar lhs and the batch rhs.

Equivalent to the logical and of two boolean batches, where all the values of the first one are initialized to lhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – boolean involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical and.

template<class X>
inline X operator||(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Computes the logical or of batches lhs and rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical or.

template<class X>
inline X operator||(const simd_batch_bool<X> &lhs, bool rhs)

Computes the logical or of the batch lhs and the scalar rhs.

Equivalent to the logical or of two boolean batches, where all the values of the second one are initialized to rhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – batch involved in the operation.

  • rhs – boolean involved in the operation.

Returns

the result of the logical or.

template<class X>
inline X operator||(bool lhs, const simd_batch_bool<X> &rhs)

Computes the logical or of the scalar lhs and the batch rhs.

Equivalent to the logical or of two boolean batches, where all the values of the first one are initialized to lhs.

Template Parameters

X – the actual type of boolean batch.

Parameters
  • lhs – boolean involved in the operation.

  • rhs – batch involved in the operation.

Returns

the result of the logical or.

Comparison operators

template<class X>
inline X operator==(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Element-wise equality of batches lhs and rhs.

Parameters
  • lhs – batch involved in the comparison.

  • rhs – batch involved in the comparison.

Returns

the result of the equality comparison.

template<class X>
inline X operator!=(const simd_batch_bool<X> &lhs, const simd_batch_bool<X> &rhs)

Element-wise inequality of batches lhs and rhs.

Parameters
  • lhs – batch involved in the comparison.

  • rhs – batch involved in the comparison.

Returns

the result of the inequality comparison.

Reducers

template<class X>
inline bool all(const simd_batch_bool<X> &rhs)

Returns true if all the boolean values in the batch are true, false otherwise.

Parameters

rhs – the batch to reduce.

Returns

a boolean scalar.

template<class X>
inline bool any(const simd_batch_bool<X> &rhs)

Return true if any of the boolean values in the batch is true, false otherwise.

Parameters

rhs – the batch to reduce.

Returns

a boolean scalar.