- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

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

Replace elements of an array based on an conditional array. More...

## Functions
AFAPI void | replace (array &a, const array &cond, const array &b)
AFAPI void | replace (array &a, const array &cond, const double &b)
AFAPI af_err | af_replace (af_array a, const af_array cond, const af_array b)
AFAPI af_err | af_replace_scalar (af_array a, const af_array cond, const double b)

## Detailed Description

Replace elements of an array based on an conditional array.

If the condition array has an element as true, then the element is replaced by the array/value, otherwise no change.

## Function Documentation

AFAPI af_err af_replace | ( | af_array | a,
|  | const af_array | cond,
|  | const af_array | b
| ) |  |

Parameters

  [in,out] | a | is the array whose values are replaced by `b` when `cond` is true
  [in] | cond | is the conditional array
  [in] | b | is the array containing elements that replaces elements of a where `cond` is false

AFAPI af_err af_replace_scalar | ( | af_array | a,
|  | const af_array | cond,
|  | const double | b
| ) |  |

Parameters

  [in,out] | a | is the array whose values are replaced by `b` when `cond` is true
  [in] | cond | is the conditional array
  [in] | b | is the scalar that replaces the false parts of `a`

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

Parameters

  [in,out] | a | is the array whose values are replaced with values from `b` when `cond` is true
  [in] | cond | is the conditional array
  [in] | b | is the array containing elements which replace elements in `a` when `cond` is true

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

Parameters

  [in,out] | a | is the array whose values are replaced with values from `b` when `cond` is true
  [in] | cond | is the conditional array
  [in] | b | is value that replaces elements in `a` when `cond` is true