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.6.11 vsip_vminmgval_p - Find Minimum Magnitude Value in Vector

vsip_scalar_f vsip_vminmgval_f(const vsip_vview_f *a, vsip_scalar_vi *index);
Description

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 a and finds the element with the smallest absolute value, returning this value and storing its index in the output parameter.

Parameters
Return Value
Example

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);