The C++ interface for anytrue. More...

array anytrue (const array &input, int dim=-1)
 Test if all elements are false (zero) along a dimension in input. More...
 
template<typename ty >
ty anytrue (const array &input)
 Test if all elements are false (zero) in entire array. More...
 

Detailed Description

The C++ interface for anytrue.

Verify if any of the elements are non zero.

These functions can also be used with conditions as parameters.
In such a case, the input array to the function is a boolean array.
bool hx[] = { true,true,false,true };
array x1(4,1, hx); // 4x1 vector
printf("%d,%d\n", anytrue<bool>(x1))// 0,0
array y1 = randu(100, 1);
array y2 = anytrue(y1 > 0.5); // y2 is 1 where all values in the
// dimension are true, otherwise 0.

Function Documentation

array af::anytrue ( const array &  input,
int  dim = -1 
)

Test if all elements are false (zero) along a dimension in input.

int in[] = {10,4,1,51,0,3};
array input(2,3,in); // [10 1 0]
// [4 51 3]
array result = anytrue(input); //equivalent to \c anytrue(input,0);
// result = [true true false]
Parameters
[in]input
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
Returns
boolean array with test results along the dimension dim in the input
ty af::anytrue ( const array &  input)

Test if all elements are false (zero) in entire array.

Parameters
[in]input
Returns
true if all elements in input are false (zero), false if any true (nonzero)