Adelsbach/VSIPL
Core Programming Reference Guide
DD-00016-015
Core

4.6.12 vsip_vcmaxmg_p - Element-wise Maximum of Complex Vector Magnitudes

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

This function computes the element-wise maximum of the magnitudes of corresponding elements from two complex vectors, storing the results in a real output vector. The operation performs element-wise comparison of complex magnitudes:

ri= max(|ai|,| bi| )

for all i from 0 to n-1, where n is the length of the vectors, and |ai| and |bi| are the magnitudes of the complex numbers.

Parameters
Example

vsip_cvview_f *signal1, *signal2; 
vsip_vview_f *max_magnitudes; 
vsip_length n = 1024; 
 
// Create vectors 
signal1 = vsip_cvcreate_f(n, VSIP_MEM_NONE); 
signal2 = vsip_cvcreate_f(n, VSIP_MEM_NONE); 
max_magnitudes = vsip_vcreate_f(n, VSIP_MEM_NONE); 
 
// Initialize complex vectors with some signal data 
for (vsip_length i = 0; i < n; i++) { 
    // Create two different complex signals 
    float angle1 = 2 * M_PI * i / n; 
    float angle2 = 2 * M_PI * i / n + M_PI/4; 
    vsip_cscalar_f val1 = VSIP_CMPLX_F(5.0f * cos(angle1), 5.0f * sin(angle1)); 
    vsip_cscalar_f val2 = VSIP_CMPLX_F(3.0f * cos(angle2), 3.0f * sin(angle2)); 
 
    vsip_cvput_f(signal1, i, val1); 
    vsip_cvput_f(signal2, i, val2); 
} 
 
// Compute element-wise maximum of magnitudes 
vsip_vcmaxmg_f(signal1, signal2, max_magnitudes); 
 
// The max_magnitudes vector now contains the maximum magnitude at each position 
// from the two input complex signals 
 
// Clean up 
vsip_cvalldestroy_f(signal1); 
vsip_cvalldestroy_f(signal2); 
vsip_valldestroy_f(max_magnitudes);
Notes