Skip to main content

function

select

select[type: DType, simd_width: Int](cond: SIMD[bool, simd_width], true_case: SIMD[type, simd_width], false_case: SIMD[type, simd_width]) -> SIMD[$0, $1]

Selects the values of the true_case or the false_case based on the input boolean values of the given SIMD vector.

Parameters:

  • type (DType): The element type of the input and output SIMD vectors.
  • simd_width (Int): Width of the SIMD vectors we are comparing.

Args:

  • cond (SIMD[bool, simd_width]): The vector of bools to check.
  • true_case (SIMD[type, simd_width]): The values selected if the positional value is True.
  • false_case (SIMD[type, simd_width]): The values selected if the positional value is False.

Returns:

A new vector of the form [true_case[i] if cond[i] else false_case[i] in enumerate(self)].