Conditional

where

template<typename C, typename L, typename R, typename T = promoted_vector_value_type<L, R>, typename E = broadcast_vector_extent_type<C, L, R>>
inline vector<T, E> kernel_float::where(const C &cond, const L &true_values, const R &false_values)

Return elements chosen from true_values and false_values depending on cond.

This function broadcasts all arguments to the same size and then promotes the values of true_values and false_values into the same type. Next, it casts the values of cond to booleans and returns a vector where the values are taken from true_values where the condition is true and false_values otherwise.

Parameters:
  • cond – The condition used for selection.

  • true_values – The vector of values to choose from when the condition is true.

  • false_values – The vector of values to choose from when the condition is false.

Returns:

A vector containing selected elements as per the condition.

where

template<typename C, typename L, typename T = vector_value_type<L>, typename E = broadcast_vector_extent_type<C, L>>
inline vector<T, E> kernel_float::where(const C &cond, const L &true_values)

Selects elements from true_values depending on cond.

This function returns a vector where the values are taken from true_values where cond is true and 0 where cond isfalse`.

Parameters:
  • cond – The condition used for selection.

  • true_values – The vector of values to choose from when the condition is true.

Returns:

A vector containing selected elements as per the condition.

where

template<typename T = bool, typename C, typename E = vector_extent_type<C>>
inline vector<T, E> kernel_float::where(const C &cond)

Returns a vector having the value T(1) where cond is true and T(0) where cond is false.

Parameters:

cond – The condition used for selection.

Returns:

A vector containing elements as per the condition.