vsip_scalar_f vsip_vcmaxmgsqval_f(const vsip_cvview_f *a, vsip_scalar_vi *index);
This function finds the maximum magnitude squared value in a complex vector and returns its value while storing its index in the provided output parameter.
The function scans the input complex vector
and finds the element with the largest magnitude squared
value (real part squared plus imaginary part squared), returning this value and storing its index in the output
parameter.
The magnitude squared is calculated as:

const vsip_cvview_p* a: Input complex vector to search for the maximum magnitude squared value.
vsip_scalar_vi* index: Pointer to an integer that will store the index of the element with the maximum magnitude squared.
Returns the maximum magnitude squared value found in the vector.
vsip_cvview_f *spectrum; vsip_scalar_f max_magnitude_sq; vsip_scalar_vi max_index; vsip_length n = 1024; // Create complex vector for spectrum data spectrum = vsip_cvcreate_f(n, VSIP_MEM_NONE); // Initialize with some complex spectrum data (e.g., FFT results) for (vsip_length i = 0; i < n; i++) { // Simulate a spectrum with a peak at position 42 float magnitude = (i == 42) ? 10.0f : 0.1f + 0.9f * (float)rand()/RAND_MAX; float phase = 2 * M_PI * (float)rand()/RAND_MAX; vsip_cscalar_f val = VSIP_CMPLX_F(magnitude * cos(phase), magnitude * sin(phase)); vsip_cvput_f(spectrum, i, val); } // Find the maximum magnitude squared value and its index max_magnitude_sq = vsip_vcmaxmgsqval_f(spectrum, &max_index); printf("Maximum magnitude squared value: %.4f\n", max_magnitude_sq); printf("Found at index: %ld\n", max_index); printf("Actual magnitude: %.4f\n", sqrt(max_magnitude_sq)); // Clean up vsip_cvalldestroy_f(spectrum);