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

4.6.2 vsip_vinvclip_p - Inverse Clip Vector Elements

void vsip_vinvclip_i(const vsip_vview_i *a, vsip_scalar_i t1, vsip_scalar_i t2, 
                    vsip_scalar_i t3, vsip_scalar_i c1, vsip_scalar_i c2, 
                    const vsip_vview_i *r); 
void vsip_vinvclip_f(const vsip_vview_f *a, vsip_scalar_f t1, vsip_scalar_f t2, 
                    vsip_scalar_f t3, vsip_scalar_f c1, vsip_scalar_f c2, 
                    const vsip_vview_f *r);
Description

This function performs an inverse clipping operation on a vector, replacing values within a specified range with corresponding clip values while preserving values outside this range. The inverse clipping operation is defined as:

   ꎧ
   || ai ifai< t1 orai> t3
ri=   c1  ift1≤ai <t2
   |⎩ c2  ift2≤a  ≤t3
               i

for all i from 0 to n-1, where n is the length of the vectors.

Parameters
Example

vsip_vview_f *signal, *processed_signal; 
vsip_length n = 1024; 
 
// Create vectors 
signal = vsip_vcreate_f(n, VSIP_MEM_NONE); 
processed_signal = vsip_vcreate_f(n, VSIP_MEM_NONE); 
 
// Initialize signal with some values (e.g., audio signal with noise) 
for (vsip_length i = 0; i < n; i++) { 
    float val = 10.0f * sin(2 * M_PI * i / n) + 3.0f * sin(20 * 2 * M_PI * i / n); 
    vsip_vput_f(signal, i, val); 
} 
 
// Apply inverse clipping to remove values in the [-1.0, 1.0] range, 
// replacing them with -2.0 and 2.0 respectively 
vsip_vinvclip_f(signal, -1.0f, 0.0f, 1.0f, -2.0f, 2.0f, processed_signal); 
 
// The processed_signal vector now contains: 
// - Original values where they were < -1.0 or > 1.0 
// - -2.0 where values were between -1.0 and 0.0 
// - 2.0 where values were between 0.0 and 1.0 
 
// Clean up 
vsip_valldestroy_f(signal); 
vsip_valldestroy_f(processed_signal);
Notes