Adelsbach/VSIPL
Core Programming Reference Guide
DD-00016-015
Core

4.5.1 vsip_valltrue_p - Check if All Elements in Boolean Vector are True

vsip_scalar_bl vsip_valltrue_bl(const vsip_vview_bl *a);
Description

This function checks whether all elements in a boolean vector are true. It returns a single boolean value that is true if and only if every element in the input vector is true.

The function performs the following logical operation:

result= a0∧a1 ∧a2∧ ...∧an-1

where ai are the elements of the input vector and n is the length of the vector.

Parameters
Return Value
Example

vsip_vview_bl *conditions; 
vsip_length n = 10; 
vsip_scalar_bl all_valid; 
 
// Create and initialize a boolean vector 
conditions = vsip_vcreate_bl(n, VSIP_MEM_NONE); 
 
// Set all elements to true (for demonstration) 
vsip_vfill_bl(conditions, true); 
 
// Check if all conditions are true 
all_valid = vsip_valltrue_bl(conditions); 
if (all_valid) { 
    printf("All conditions are satisfied.\n"); 
} else { 
    printf("Some conditions are not satisfied.\n"); 
} 
 
// For a more practical example: 
for (vsip_length i = 0; i < n; i++) { 
    // Set based on some actual conditions in your algorithm 
    vsip_vput_bl(conditions, i, (i % 2) == 0);  // Only even indices are true 
} 
 
all_valid = vsip_valltrue_bl(conditions); 
// all_valid will be false in this case 
 
// Clean up 
vsip_valldestroy_bl(conditions);