vsip_length vsip_vindexbool(const vsip_vview_bl *a, vsip_vview_vi *index);
This function finds the indices of all true elements in a boolean vector and stores them in an integer index vector. It returns the number of true elements found.
The function scans the input boolean vector
and records the positions of all elements that are true in the output index
vector. The function returns the count of true elements found.
const vsip_vview_bl* a: Input boolean vector to search.
vsip_vview_vi* index: Output integer vector that will store the indices of true elements. This vector must be large enough to hold all potential true indices (i.e., its length should be at least equal to the length of the input boolean vector).
Returns the number of true elements found in the input vector.
Returns 0 if no true elements are found or if the input vector is empty.
vsip_vview_bl *conditions; vsip_vview_vi *indices; vsip_length n = 100; vsip_length true_count; // Create boolean vector conditions = vsip_vcreate_bl(n, VSIP_MEM_NONE); // Create index vector (same length as conditions) indices = vsip_vcreate_vi(n, VSIP_MEM_NONE); // Set some conditions to true (for example, every 5th element) for (vsip_length i = 0; i < n; i++) { vsip_vput_bl(conditions, i, (i % 5) == 0); } // Find indices of true elements true_count = vsip_vindexbool(conditions, indices); printf("Found %lu true elements at positions:\n", true_count); for (vsip_length i = 0; i < true_count; i++) { printf("%ld ", vsip_vget_vi(indices, i)); } printf("\n"); // Use the indices for further processing in your algorithms // For example, you could use these indices to select specific elements // from another vector that corresponds to your conditions // Clean up vsip_valldestroy_bl(conditions); vsip_valldestroy_vi(indices);