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.7 vsip_vrect_p - Convert Cartesian Coordinates to Complex Numbers

void vsip_vrect_f(const vsip_vview_f *a, const vsip_vview_f *b, const vsip_cvview_f *r);
Description

This function converts pairs of real vectors representing Cartesian coordinates (real and imaginary parts) into a complex vector.

The operation performs element-wise conversion:

ri= ai+j·bi

for all i from 0 to n-1, where n is the length of the vectors, ai is the real part, bi is the imaginary part, and ri is the resulting complex number.

Parameters
Example

vsip_vview_f *real_parts, *imag_parts; 
vsip_cvview_f *complex_numbers; 
vsip_length n = 10; 
 
// Create vectors 
real_parts = vsip_vcreate_f(n, VSIP_MEM_NONE); 
imag_parts = vsip_vcreate_f(n, VSIP_MEM_NONE); 
complex_numbers = vsip_cvcreate_f(n, VSIP_MEM_NONE); 
 
// Initialize real and imaginary parts 
// For example, create a complex signal 
for (vsip_length i = 0; i < n; i++) { 
    vsip_vput_f(real_parts, i, cos(2 * M_PI * i / n));  // Real parts 
    vsip_vput_f(imag_parts, i, sin(2 * M_PI * i / n));  // Imaginary parts 
} 
 
// Convert to complex numbers 
vsip_vrect_f(real_parts, imag_parts, complex_numbers); 
 
// The complex_numbers vector now contains the complex representation 
// of your signal, which can be used in further complex operations 
 
// Print some results 
printf("Complex numbers (first 3 elements):\n"); 
for (vsip_length i = 0; i < 3; i++) { 
    vsip_cscalar_f val = vsip_cvget_f(complex_numbers, i); 
    printf("(%.4f, %.4f) ", val.r, val.i); 
} 
printf("\n"); 
 
// Clean up 
vsip_valldestroy_f(real_parts); 
vsip_valldestroy_f(imag_parts); 
vsip_cvalldestroy_f(complex_numbers);
Notes