Count the number of non-zero elements in the input. More...

Functions

AFAPI array count (const array &in, const int dim=-1)
 C++ Interface for counting non-zero values in an array. More...
 
template<typename T >
count (const array &in)
 C++ Interface for counting total number of non-zero values in an array. More...
 
AFAPI af_err af_count (af_array *out, const af_array in, const int dim)
 C Interface for counting non-zero values in an array. More...
 
AFAPI af_err af_count_all (double *real, double *imag, const af_array in)
 C Interface for counting total number of non-zero values in an array. More...
 

Detailed Description

Count the number of non-zero elements in the input.

Return type is u32 for all input types

This function performs the operation across all batches present in the input simultaneously.

Function Documentation

◆ af_count()

AFAPI af_err af_count ( af_array out,
const af_array  in,
const int  dim 
)

C Interface for counting non-zero values in an array.

Parameters
[out]outwill contain the number of non-zero values in in along dim
[in]inis the input array
[in]dimThe dimension along which the non-zero values are counted
Returns
AF_SUCCESS if the execution completes properly

◆ af_count_all()

AFAPI af_err af_count_all ( double *  real,
double *  imag,
const af_array  in 
)

C Interface for counting total number of non-zero values in an array.

Parameters
[out]realwill contain the number of non-zero values in in.
[out]imagis always set to 0.
[in]inis the input array
Returns
AF_SUCCESS if the execution completes properly
Note
imag is always set to 0.

◆ count() [1/2]

AFAPI array af::count ( const array in,
const int  dim = -1 
)

C++ Interface for counting non-zero values in an array.

Parameters
[in]inis the input array
[in]dimThe dimension along which the the number of non-zero values are counted
Returns
the number of non-zero values along dimension dim
Note
dim is -1 by default. -1 denotes the first non-singleton dimension.
NaN values are treated as non zero.
Examples:
benchmarks/pi.cpp.

◆ count() [2/2]

T af::count ( const array in)

C++ Interface for counting total number of non-zero values in an array.

Parameters
[in]inis the input array
Returns
the number of non-zero values in in
Note
NaN values are treated as non zero