void vsip_vclip_i(const vsip_vview_i *a, vsip_scalar_i t1, vsip_scalar_i t2, vsip_scalar_i c1, vsip_scalar_i c2, const vsip_vview_i *r); void vsip_vclip_f(const vsip_vview_f *a, vsip_scalar_f t1, vsip_scalar_f t2, vsip_scalar_f c1, vsip_scalar_f c2, const vsip_vview_f *r);
This function clips the elements of a vector between specified thresholds, replacing values outside the threshold range with corresponding clip values. The clipping operation is defined as:

for all
from 0 to
, where
is the length of the vectors.
const vsip_vview_p* a: Input vector containing the elements to clip.
vsip_scalar_p t1: Lower threshold value.
vsip_scalar_p t2: Upper threshold value.
vsip_scalar_p c1: Value to substitute for elements below the lower threshold.
vsip_scalar_p c2: Value to substitute for elements above the upper threshold.
const vsip_vview_p* r: Output vector that will store the clipped results.
vsip_vview_f *signal, *clipped_signal; vsip_length n = 1024; // Create vectors signal = vsip_vcreate_f(n, VSIP_MEM_NONE); clipped_signal = vsip_vcreate_f(n, VSIP_MEM_NONE); // Initialize signal with some values (e.g., sine wave with noise) for (vsip_length i = 0; i < n; i++) { float val = 10.0f * sin(2 * M_PI * i / n) + 5.0f * ((float)rand()/RAND_MAX - 0.5f); vsip_vput_f(signal, i, val); } // Clip the signal between -5.0 and 5.0, replacing outliers with these bounds vsip_vclip_f(signal, -5.0f, 5.0f, -5.0f, 5.0f, clipped_signal); // The clipped_signal vector now contains the original values where they were // within [-5.0, 5.0], and -5.0 or 5.0 where they were outside this range // Clean up vsip_valldestroy_f(signal); vsip_valldestroy_f(clipped_signal);
The input and output vectors must have the same length.
The thresholds and clip values can be in any order, but typically
and
.