Select elements based on a conditional array.
More...
|
AFAPI array | select (const array &cond, const array &a, const array &b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const array &a, const double &b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const double &a, const array &b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const array &a, const long long b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const array &a, const unsigned long long b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const long long a, const array &b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI array | select (const array &cond, const unsigned long long a, const array &b) |
| C++ Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select (af_array *out, const af_array cond, const af_array a, const af_array b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_r (af_array *out, const af_array cond, const af_array a, const double b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_l (af_array *out, const af_array cond, const double a, const af_array b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_r_long (af_array *out, const af_array cond, const af_array a, const long long b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_r_ulong (af_array *out, const af_array cond, const af_array a, const unsigned long long b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_l_long (af_array *out, const af_array cond, const long long a, const af_array b) |
| C Interface to select elements based on a conditional array. More...
|
|
AFAPI af_err | af_select_scalar_l_ulong (af_array *out, const af_array cond, const unsigned long long a, const af_array b) |
| C Interface to select elements based on a conditional array. More...
|
|
Select elements based on a conditional array.
Creates a new array that is composed of values either from array a
or array b
, based on a third conditional array. For all non-zero elements in the conditional array, the output array will contain values from a
. Otherwise the output will contain values from b
.
int elements = 9;
char hCond[] = {1, 0, 1, 0, 1, 0, 1, 0, 1};
float hA[] = {2, 2, 2, 2, 2, 2, 2, 2, 2};
float hB[] = {3, 3, 3, 3, 3, 3, 3, 3, 3};
array cond(elements, hCond);
array a(elements, hA);
array b(elements, hB);
array out =
select(cond, a, b);
AFAPI array select(const array &cond, const array &a, const array &b)
C++ Interface to select elements based on a conditional array.
is equivalent to:
vector<float> hOut(elements);
for (size_t i = 0; i < hOut.size(); i++) {
if (hCond[i]) {
hOut[i] = hA[i];
} else {
hOut[i] = hB[i];
}
}
The conditional array must be a b8 typed array.
The select function can perform batched operations based on the size of each of the inputs. The following table describes the input and output sizes for supported batched configurations.
Output | Condition Array | Array A | Array B |
(M, N) | (M, 1) | (M, 1) | (M, N) |
(M, N) | (M, 1) | (M, N) | (M, 1) |
(M, N) | (M, 1) | (M, N) | (M, N) |
(M, N) | (M, N) | (M, 1) | (M, N) |
(M, N) | (M, N) | (M, 1) | (M, N) |
◆ af_select()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select array element |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_l()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_l_long()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_l_ulong()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_r()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_r_long()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_select_scalar_r_ulong()
C Interface to select elements based on a conditional array.
- Parameters
-
[out] | out | a when cond is true, else b |
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ select() [1/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select array element |
- Returns
a
when cond
is true, else b
◆ select() [2/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
a
when cond
is true, else b
◆ select() [3/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
a
when cond
is true, else b
◆ select() [4/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select array element |
[in] | b | when false, select scalar value |
- Returns
a
when cond
is true, else b
◆ select() [5/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
a
when cond
is true, else b
◆ select() [6/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
a
when cond
is true, else b
◆ select() [7/7]
C++ Interface to select elements based on a conditional array.
- Parameters
-
[in] | cond | conditional array |
[in] | a | when true, select scalar value |
[in] | b | when false, select array element |
- Returns
a
when cond
is true, else b