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

This manual is preliminary and incomplete.
While our Core implementation implements all functions given in the standard we are still working on completing this documentation.

Please refer to the VSIPL standard for a complete function reference of the Core profile until we have completed work on this documentation.

4.5.6 vsip_vanytrue_p - Check if Any Element in Boolean Vector is True

vsip_scalar_bl vsip_vanytrue_bl(const vsip_vview_bl *a);
Description

This function checks whether any element in a boolean vector is true. It returns a single boolean value that is true if at least one element in the input vector is true.

The function performs the following logical operation:

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

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

Parameters
Return Value
Example

vsip_vview_bl *flags; 
vsip_length n = 100; 
vsip_scalar_bl any_flag_set; 
 
// Create and initialize a boolean vector 
flags = vsip_vcreate_bl(n, VSIP_MEM_NONE); 
 
// Set all elements to false initially 
vsip_vfill_bl(flags, false); 
 
// Set some flags based on your algorithm's conditions 
// For example, set flag at index 42 to true 
vsip_vput_bl(flags, 42, true); 
 
// Check if any flag is set 
any_flag_set = vsip_vanytrue_bl(flags); 
if (any_flag_set) { 
    printf("At least one flag is set. Processing required.\n"); 
    // Perform necessary processing for your application 
} else { 
    printf("No flags are set. Skipping processing.\n"); 
} 
 
// For a more practical example with actual conditions: 
for (vsip_length i = 0; i < n; i++) { 
    // Set based on some actual conditions in your algorithm 
    vsip_vput_bl(flags, i, (i % 7) == 0);  // Set flags for indices divisible by 7 
} 
 
any_flag_set = vsip_vanytrue_bl(flags); 
// any_flag_set will be true in this case 
 
// Clean up 
vsip_valldestroy_bl(flags);