void vsip_vpolar_f(const vsip_cvview_f *a, const vsip_vview_f *r, const vsip_vview_f *s);
This function converts complex numbers from a complex vector into their polar coordinate representation (magnitude and phase). The operation performs element-wise conversion from Cartesian to polar coordinates:


for all
from 0 to
, where
is the length of the vectors,
is the magnitude, and
is the phase (angle in radians) of
the complex number
.
const vsip_cvview_p* a: Input complex vector.
const vsip_vview_p* r: Output vector that will store the magnitudes.
const vsip_vview_p* s: Output vector that will store the phases (in radians).
vsip_cvview_f *complex_signal; vsip_vview_f *magnitudes, *phases; vsip_length n = 10; // Create vectors complex_signal = vsip_cvcreate_f(n, VSIP_MEM_NONE); magnitudes = vsip_vcreate_f(n, VSIP_MEM_NONE); phases = vsip_vcreate_f(n, VSIP_MEM_NONE); // Initialize complex signal (e.g., with some complex values) for (vsip_length i = 0; i < n; i++) { float real = cos(2 * M_PI * i / n); float imag = sin(2 * M_PI * i / n); vsip_cvput_f(complex_signal, i, VSIP_CMPLX_F(real, imag)); } // Convert to polar coordinates vsip_vpolar_f(complex_signal, magnitudes, phases); // The magnitudes and phases vectors now contain the polar representation // of your complex signal // Print some results printf("Magnitude and Phase (first 3 elements):\n"); for (vsip_length i = 0; i < 3; i++) { printf("Element %ld: Magnitude = %.4f, Phase = %.4f radians\n", i, vsip_vget_f(magnitudes, i), vsip_vget_f(phases, i)); } // Clean up vsip_cvalldestroy_f(complex_signal); vsip_valldestroy_f(magnitudes); vsip_valldestroy_f(phases);
All three vectors must have the same length.
The phase values are returned in radians in the range
.
This operation is the inverse of vsip_vrect_p which converts from Cartesian to polar coordinates.