The C++ interface for where. More...

array where (const array &input)
 Indices where nonzero (zero-based indexing). More...
 
void where (array &row, array &column, const array &input)
 row and column indices of nonzero elements in input More...
 

Detailed Description

The C++ interface for where.

Returns the indicies of the non-zero values in an set of elements.

These functions can also be used with conditions as parameters. In such a case, the input array to the function is a boolean array.

Function Documentation

array af::where ( const array &  input)

Indices where nonzero (zero-based indexing).

array a = randu(20e6);
array ind = where(a > .5);
array b = a(ind); // pull out non-zero elements
array c = a(a > .5); // implicitly uses where()
Parameters
[in]input
Returns
[out] indices of nonzero elements
void af::where ( array &  row,
array &  column,
const array &  input 
)

row and column indices of nonzero elements in input

array a = randu(1000,1000);
array row, col;
where(row, col, a > .5);
array b = a(row,col); // pull out nonzero elements
Parameters
[in]input
[out]row
[out]column