count

The C++ interface for count. More...

unsigned count (const array &input)
 Count nonzero elements in input. More...
 

Detailed Description

The C++ interface for count.

Returns the number of the non-zero values in an set of elements

Function Documentation

unsigned af::count ( const array &  input)

Count nonzero elements in input.

float ha[] = { 0, 1, 0, 3, -3, 0.2, 0 };
array a(7,ha);
unsigned nnz = count(a);
printf("nonzero: %d\n", nnz); // 'nonzero: 4'
Parameters
[in]input
Returns
The number of nonzero elements in input
Examples:
examples/benchmarks/pi.cpp, and examples/machine_learning/kmeans.cpp.