Count non-zero values in an array, according to an array of keys. More...
Functions | |
AFAPI void | countByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1) |
C++ Interface to count non-zero values in an array, according to an array of keys. More... | |
AFAPI af_err | af_count_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim) |
C Interface to count non-zero values in an array, according to an array of keys. More... | |
Count non-zero values in an array, according to an array of keys.
All non-zero values corresponding to each group of consecutive equal keys will be counted. Keys can repeat; however, only consecutive key values will be considered for each reduction. If a key value is repeated somewhere else in the keys array it will be considered the start of a new reduction. There are two outputs: the reduced set of consecutive keys and the corresponding final set of reduced values.
An example demonstrating the reduction behavior can be seen in the following snippet.
The keys' input type must be integer (s32 or u32).
The output type is u32
.
The keys array must be 1-dimenstional matching the size of the reduced dimension. An example of multi-dimensional reduce-by-key can be seen below:
AFAPI af_err af_count_by_key | ( | af_array * | keys_out, |
af_array * | vals_out, | ||
const af_array | keys, | ||
const af_array | vals, | ||
const int | dim | ||
) |
C Interface to count non-zero values in an array, according to an array of keys.
NaN values are treated as non-zero.
[out] | keys_out | reduced keys |
[out] | vals_out | count |
[in] | keys | keys array |
[in] | vals | input array |
[in] | dim | dimension along which the count occurs |
AFAPI void countByKey | ( | array & | keys_out, |
array & | vals_out, | ||
const array & | keys, | ||
const array & | vals, | ||
const int | dim = -1 |
||
) |
C++ Interface to count non-zero values in an array, according to an array of keys.
NaN values are treated as non-zero.
[out] | keys_out | reduced keys |
[out] | vals_out | count |
[in] | keys | keys array |
[in] | vals | input array |
[in] | dim | dimension along which the count occurs, -1 denotes the first non-singleton dimension |