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
andfalse_values
depending oncond
.This function broadcasts all arguments to the same size and then promotes the values of
true_values
andfalse_values
into the same type. Next, it casts the values ofcond
to booleans and returns a vector where the values are taken fromtrue_values
where the condition is true andfalse_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 oncond
.This function returns a vector where the values are taken from
true_values
wherecond
istrue
and0
wherecond is
false`.- 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)
wherecond
istrue
andT(0)
wherecond
isfalse
.- Parameters:
cond – The condition used for selection.
- Returns:
A vector containing elements as per the condition.