Miscellaneous

Sign manipulation:

sign()

per slot sign extraction

signnz()

per slot sign extraction on non null elements

bitofsign()

per slot sign bit extraction

copysign()

per slot sign copy

Stream operation:

operator<<()

batch pretty-printing


template <class T, class A>
batch<T, A> xsimd::bitofsign(batch<T, A> const &x)

Computes the bit of sign of x.

Return

bit of sign of x

Parameters
  • x: batch of scalar

template <class T, class A>
batch<T, A> xsimd::copysign(batch<T, A> const &x, batch<T, A> const &y)

Computes a value whose absolute value matches that of x, but whose sign bit matches that of y.

Return

batch whose absolute value matches that of x, but whose sign bit matches that of y.

Parameters
  • x: batch of scalars

  • y: batch of scalars

template <class T, class A>
batch<T, A> xsimd::select(batch_bool<T, A> const &cond, batch<T, A> const &true_br, batch<T, A> const &false_br)

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];
Return

the result of the selection.

Parameters
  • cond: batch condition.

  • true_br: batch values for truthy condition.

  • false_br: batch value for falsy condition.

template <class T, class A>
batch<std::complex<T>, A> xsimd::select(batch_bool<T, A> const &cond, batch<std::complex<T>, A> const &true_br, batch<std::complex<T>, A> const &false_br)

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];
Return

the result of the selection.

Parameters
  • cond: batch condition.

  • true_br: batch values for truthy condition.

  • false_br: batch value for falsy condition.

template <class T, class A, bool… Values>
batch<T, A> xsimd::select(batch_bool_constant<batch<T, A>, Values...> const &cond, batch<T, A> const &true_br, batch<T, A> const &false_br)

Ternary operator for batches: selects values from the batches true_br or false_br depending on the boolean values in the constant batch cond.

Equivalent to

for(std::size_t i = 0; i < N; ++i)
    res[i] = cond[i] ? true_br[i] : false_br[i];
Return

the result of the selection.

Parameters
  • cond: constant batch condition.

  • true_br: batch values for truthy condition.

  • false_br: batch value for falsy condition.

template <class T, class A>
batch<T, A> xsimd::sign(batch<T, A> const &x)

Computes the sign of x.

Return

-1 for each negative element, -1 or +1 for each null element and +1 for each element

Parameters
  • x: batch

template <class T, class A>
batch<T, A> xsimd::signnz(batch<T, A> const &x)

Computes the sign of x, assuming x doesn’t have any zero.

Return

-1 for each negative element, -1 or +1 for each null element and +1 for each element

Parameters
  • x: batch

template <class T, class A>
std::ostream &xsimd::operator<<(std::ostream &o, batch<T, A> const &x)

Dump the content of batch x to stream o.

Return

a reference to o

Parameters
  • o: the stream where the batch is dumped

  • x: batch to dump.

template <class T, class A>
std::ostream &xsimd::operator<<(std::ostream &o, batch_bool<T, A> const &x)

Dump the content of batch x to stream o.

Return

a reference to o

Parameters
  • o: the stream where the batch is dumped

  • x: batch to dump.