Do more. Code less. Free software for GPU computing.
<scroll to top>

Test if any/all true

Data Analysis

array alltrue (const array &input, int dim=-1)
 test if all elements are true (nonzero) along a dimension in input
template<typename ty >
ty alltrue (const array &input)
 test if all elements are true (nonzero) in entire array
array allfalse (const array &input, int dim=-1)
 test if all elements are false (zero) along a dimension in input
template<typename ty >
ty allfalse (const array &input)
 test if all elements are false (zero) in entire array

Function Documentation

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

test if all elements are true (nonzero) along a dimension in input

Parameters:
[in]input
[in]dimdimension along which to operate (-1 indicates first nonsingleton dimension)
Returns:
boolean array with test results along the dimension dim in the input
ty af::alltrue ( const array &  input)

test if all elements are true (nonzero) in entire array

       bool hx[] = { true,true,false,true };
       array x1(hx, 2,2); // 2x2 matrix
       array x2(hx, 4,1); // 4x1 vector
       printf("%d,%d\n", alltrue<bool>(x1), alltrue<bool>(x2)); // 0,0

       float hy[] = { 1,4,0,2 };
       array y1(hy, 2,2); // 2x2 matrix
       array y2(hy, 4,1); // 4x1 vector
       printf("%d,%d\n", alltrue<bool>(y1), alltrue<bool>(y2)); // 0,0
Parameters:
[in]input
Returns:
true iff all elements in array are true (false if any zeros)
array af::allfalse ( const array &  input,
int  dim = -1 
)

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

Parameters:
[in]input
[in]dimdimension along which to operate (-1 indicates first nonsingleton dimension)
Returns:
boolean array with test results along the dimension dim in the input
ty af::allfalse ( 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)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines