vsip_scalar_f vsip_vminmgval_f(const vsip_vview_f *a, vsip_scalar_vi *index);
This function finds the minimum magnitude (absolute) value in a vector and returns its value while storing its index in the provided output parameter.
The function scans the input vector
and finds the element with the smallest absolute value, returning this value and
storing its index in the output parameter.
const vsip_vview_p* a: Input vector to search for the minimum magnitude value.
vsip_scalar_vi* index: Pointer to an integer that will store the index of the element with the minimum magnitude.
Returns the minimum magnitude (absolute) value found in the vector.
vsip_vview_f *signal; vsip_scalar_f min_magnitude; vsip_scalar_vi min_index; vsip_length n = 1024; // Create vector signal = vsip_vcreate_f(n, VSIP_MEM_NONE); // Initialize signal with some values (e.g., a sine wave with noise) for (vsip_length i = 0; i < n; i++) { float val = 10.0f * sin(2 * M_PI * i / n) + 0.1f * ((float)rand()/RAND_MAX - 0.5f); vsip_vput_f(signal, i, val); } // Add a near-zero value at position 123 for demonstration vsip_vput_f(signal, 123, 0.001f); // Find the minimum magnitude value and its index min_magnitude = vsip_vminmgval_f(signal, &min_index); printf("Minimum magnitude value: %.6f\n", min_magnitude); printf("Found at index: %ld\n", min_index); // Clean up vsip_valldestroy_f(signal);