void vsip_vgather_i(const vsip_vview_i *a, const vsip_vview_vi *b, const vsip_vview_i *r); void vsip_vgather_f(const vsip_vview_f *a, const vsip_vview_vi *b, const vsip_vview_f *r); void vsip_cvgather_f(const vsip_cvview_f *a, const vsip_vview_vi *b, const vsip_cvview_f *r);
This function gathers elements from an input integer vector
according to the indices specified in vector
, and stores the
results in output vector
. The operation performs:

for all
from 0 to
, where
is the length of the index and output vectors.
const vsip_dvview_p* a: Input integer vector from which elements are gathered.
const vsip_vview_vi* b: Index vector containing the positions of elements to gather from
.
const vsip_dvview_p* r: Output integer vector that will store the gathered elements.
vsip_vview_i *data, *result; vsip_vview_vi *indices; vsip_length n = 10; // Number of elements to gather vsip_length data_size = 100; // Size of input data vector // Create vectors data = vsip_vcreate_i(data_size, VSIP_MEM_NONE); result = vsip_vcreate_i(n, VSIP_MEM_NONE); indices = vsip_vcreate_vi(n, VSIP_MEM_NONE); // Initialize data vector with some values for (vsip_length i = 0; i < data_size; i++) { vsip_vput_i(data, i, i * 10); // Example data } // Set up indices to gather (e.g., every 10th element) for (vsip_length i = 0; i < n; i++) { vsip_vput_vi(indices, i, i * 10); } // Gather elements from data vector vsip_vgather_i(data, indices, result); // The result vector now contains elements from data at positions: // 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 // Print results printf("Gathered elements:\n"); for (vsip_length i = 0; i < n; i++) { printf("%d ", vsip_vget_i(result, i)); } printf("\n"); // Clean up vsip_valldestroy_i(data); vsip_valldestroy_i(result); vsip_valldestroy_vi(indices);
The index vector
must contain valid indices for the input vector
(i.e.,
).
The output vector
must have the same length as the index vector
.