Loading...
Searching...
No Matches
volk_16i_x2_add_saturated_16i

Overview

Adds two int16_t vectors element-wise with saturation. Results are clamped to the range [-32768, 32767] to prevent overflow wraparound.

Dispatcher Prototype

void volk_16i_x2_add_saturated_16i(int16_t* outVector, const int16_t* inVectorA, const
int16_t* inVectorB, unsigned int num_points)

Inputs

- inVectorA: First input vector.
- inVectorB: Second input vector.
- num_points: Vector length.

Outputs

- outVector: Saturated sum output.

Example

unsigned int N = 8;
unsigned int align = volk_get_alignment();
int16_t* a = (int16_t*)volk_malloc(N * sizeof(int16_t), align);
int16_t* b = (int16_t*)volk_malloc(N * sizeof(int16_t), align);
int16_t* result = (int16_t*)volk_malloc(N * sizeof(int16_t), align);
// Values that will cause saturation
a[0] = 30000; b[0] = 10000; // 40000 -> saturates to 32767
a[1] = -30000; b[1] = -10000; // -40000 -> saturates to -32768
volk_16i_x2_add_saturated_16i(result, a, b, N);
// result[0] == 32767, result[1] == -32768
volk_free(a);
volk_free(b);
volk_free(result);