vsip_scalar_f vsip_vmaxmgval_f(const vsip_vview_f *a, vsip_scalar_vi *index);
This function finds the maximum 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 largest absolute value, returning this value and storing
its index in the output parameter.
const vsip_vview_p* a: Input vector to search for the maximum magnitude value.
vsip_scalar_vi* index: Pointer to an integer that will store the index of the element with the maximum magnitude.
Returns the maximum magnitude (absolute) value found in the vector.
vsip_vview_f *signal; vsip_scalar_f max_magnitude; vsip_scalar_vi max_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) + 2.0f * ((float)rand()/RAND_MAX - 0.5f); vsip_vput_f(signal, i, val); } // Add a spike at position 42 for demonstration vsip_vput_f(signal, 42, 15.0f); // Find the maximum magnitude value and its index max_magnitude = vsip_vmaxmgval_f(signal, &max_index); printf("Maximum magnitude value: %.4f\n", max_magnitude); printf("Found at index: %ld\n", max_index); // Clean up vsip_valldestroy_f(signal);