select

Functions
select
Complete List of ArrayFire Functions ArrayFire Functions by Category » Functions to create and modify Arrays » | Move and Reorder array content

Select elements from two arrays based on an conditional array. More...

## Functions
AFAPI array | select (const array &cond, const array &a, const array &b)
AFAPI array | select (const array &cond, const array &a, const double &b)
AFAPI array | select (const array &cond, const double &a, const array &b)
AFAPI af_err | af_select (af_array *out, const af_array cond, const af_array a, const af_array b)
AFAPI af_err | af_select_scalar_r (af_array *out, const af_array cond, const af_array a, const double b)
AFAPI af_err | af_select_scalar_l (af_array *out, const af_array cond, const double a, const af_array b)

## Detailed Description

Select elements from two arrays based on an conditional array.

If the condition array has an element as true, then the element from the lhs array/value is selected, otherwise the element from the rhs array/value is selected.

## Function Documentation

## ◆ af_select()

AFAPI af_err af_select | ( | af_array * | out,
|  | const af_array | cond,
|  | const af_array | a,
|  | const af_array | b
| ) |  |

Parameters

  [out] | out | is the output containing elements of `a` when `cond` is true else elements from `b`
  [in] | cond | is the conditional array
  [in] | a | is the array containing elements from the true part of the condition
  [in] | b | is the array containing elements from the false part of the condition

## ◆ af_select_scalar_l()

AFAPI af_err af_select_scalar_l | ( | af_array * | out,
|  | const af_array | cond,
|  | const double | a,
|  | const af_array | b
| ) |  |

Parameters

  [out] | out | is the output containing elements of `a` when `cond` is true else elements from `b`
  [in] | cond | is the conditional array
  [in] | a | is a scalar assigned to `out` when `cond` is true
  [in] | b | is the array containing elements from the false part of the condition

## ◆ af_select_scalar_r()

AFAPI af_err af_select_scalar_r | ( | af_array * | out,
|  | const af_array | cond,
|  | const af_array | a,
|  | const double | b
| ) |  |

Parameters

  [out] | out | is the output containing elements of `a` when `cond` is true else elements from `b`
  [in] | cond | is the conditional array
  [in] | a | is the array containing elements from the true part of the condition
  [in] | b | is a scalar assigned to `out` when `cond` is false

## ◆ select() [1/3]

AFAPI array af::select | ( | const array & | cond,
|  | const array & | a,
|  | const array & | b
| ) |  |

Parameters

  [in] | cond | is the conditional array
  [in] | a | is the array containing elements from the true part of the condition
  [in] | b | is the array containing elements from the false part of the condition

Returns
  the output containing elements of `a` when `cond` is true else elements from `b`

## ◆ select() [2/3]

AFAPI array af::select | ( | const array & | cond,
|  | const array & | a,
|  | const double & | b
| ) |  |

Parameters

  [in] | cond | is the conditional array
  [in] | a | is the array containing elements from the true part of the condition
  [in] | b | is a scalar assigned to `out` when `cond` is false

Returns
  the output containing elements of `a` when `cond` is true else the value `b`

## ◆ select() [3/3]

AFAPI array af::select | ( | const array & | cond,
|  | const double & | a,
|  | const array & | b
| ) |  |

Parameters

  [in] | cond | is the conditional array
  [in] | a | is a scalar assigned to `out` when `cond` is true
  [in] | b | is the array containing elements from the false part of the condition

Returns
  the output containing the value `a` when `cond` is true else elements from `b`