XCORE SDK
XCORE Software Development Kit
xs3_vect_s16.h
1 // Copyright 2020-2021 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
4 #pragma once
5 
6 #include "xs3_math_conf.h"
7 #include "xs3_math_types.h"
8 #include "xs3_util.h"
9 
10 #ifdef __XC__
11 extern "C" {
12 #endif
13 
14 
15 
32 #define XS3_VECT_SQRT_S16_MAX_DEPTH (15)
33 
34 
65 C_API
67  int16_t a[],
68  const int16_t b[],
69  const unsigned length);
70 
71 
99 C_API
100 int32_t xs3_vect_s16_abs_sum(
101  const int16_t b[],
102  const unsigned length);
103 
104 
154 C_API
156  int16_t a[],
157  const int16_t b[],
158  const int16_t c[],
159  const unsigned length,
160  const right_shift_t b_shr,
161  const right_shift_t c_shr);
162 
163 
176 #define xs3_vect_s16_add_prepare xs3_vect_s32_add_prepare
177 
178 
179 
232 C_API
234  int16_t a[],
235  const int16_t b[],
236  const int16_t c,
237  const unsigned length,
238  const right_shift_t b_shr);
239 
240 
253 #define xs3_vect_s16_add_scalar_prepare xs3_vect_s32_add_prepare
254 
255 
278 C_API
279 unsigned xs3_vect_s16_argmax(
280  const int16_t b[],
281  const unsigned length);
282 
283 
306 C_API
307 unsigned xs3_vect_s16_argmin(
308  const int16_t b[],
309  const unsigned length);
310 
311 
358 C_API
360  int16_t a[],
361  const int16_t b[],
362  const unsigned length,
363  const int16_t lower_bound,
364  const int16_t upper_bound,
365  const right_shift_t b_shr);
366 
367 
403 C_API
405  exponent_t* a_exp,
406  right_shift_t* b_shr,
407  int16_t* lower_bound,
408  int16_t* upper_bound,
409  const exponent_t b_exp,
410  const exponent_t bound_exp,
411  const headroom_t b_hr);
412 
456 C_API
457 int64_t xs3_vect_s16_dot(
458  const int16_t b[],
459  const int16_t c[],
460  const unsigned length);
461 
462 
512 C_API
513 int32_t xs3_vect_s16_energy(
514  const int16_t b[],
515  const unsigned length,
516  const right_shift_t b_shr);
517 
518 
551 C_API
553  const int16_t b[],
554  const unsigned length);
555 
556 
592 C_API
594  int16_t a[],
595  const int16_t b[],
596  const unsigned length,
597  const unsigned scale);
598 
599 
634 C_API
636  exponent_t* a_exp,
637  unsigned* scale,
638  const int16_t b[],
639  const exponent_t b_exp,
640  const unsigned length);
641 
642 
670 C_API
671 int16_t xs3_vect_s16_max(
672  const int16_t b[],
673  const unsigned length);
674 
675 
727 C_API
729  int16_t a[],
730  const int16_t b[],
731  const int16_t c[],
732  const unsigned length,
733  const right_shift_t b_shr,
734  const right_shift_t c_shr);
735 
736 
764 C_API
765 int16_t xs3_vect_s16_min(
766  const int16_t b[],
767  const unsigned length);
768 
769 
821 C_API
823  int16_t a[],
824  const int16_t b[],
825  const int16_t c[],
826  const unsigned length,
827  const right_shift_t b_shr,
828  const right_shift_t c_shr);
829 
830 
889 C_API
891  int16_t acc[],
892  const int16_t b[],
893  const int16_t c[],
894  const unsigned length,
895  const right_shift_t acc_shr,
896  const right_shift_t bc_sat);
897 
898 
958 C_API
960  int16_t acc[],
961  const int16_t b[],
962  const int16_t c[],
963  const unsigned length,
964  const right_shift_t acc_shr,
965  const right_shift_t bc_sat);
966 
967 
1044 C_API
1046  exponent_t* new_acc_exp,
1047  right_shift_t* acc_shr,
1048  right_shift_t* bc_sat,
1049  const exponent_t acc_exp,
1050  const exponent_t b_exp,
1051  const exponent_t c_exp,
1052  const headroom_t acc_hr,
1053  const headroom_t b_hr,
1054  const headroom_t c_hr);
1055 
1056 
1069 #define xs3_vect_s16_nmacc_prepare xs3_vect_s16_macc_prepare
1070 
1111 C_API
1113  int16_t a[],
1114  const int16_t b[],
1115  const int16_t c[],
1116  const unsigned length,
1117  const right_shift_t a_shr);
1119 
1120 
1184 C_API
1186  exponent_t* a_exp,
1187  right_shift_t* a_shr,
1188  const exponent_t b_exp,
1189  const exponent_t c_exp,
1190  const headroom_t b_hr,
1191  const headroom_t c_hr);
1192 
1193 
1232 C_API
1234  int16_t a[],
1235  const int16_t b[],
1236  const unsigned length);
1237 
1238 
1280 C_API
1282  int16_t a[],
1283  const int16_t b[],
1284  const unsigned length,
1285  const int16_t c,
1286  const right_shift_t a_shr);
1287 
1288 
1353 C_API
1355  exponent_t* a_exp,
1356  right_shift_t* a_shr,
1357  const exponent_t b_exp,
1358  const exponent_t c_exp,
1359  const headroom_t b_hr,
1360  const headroom_t c_hr);
1361 
1391 C_API
1392 void xs3_vect_s16_set(
1393  int16_t a[],
1394  const int16_t b,
1395  const unsigned length);
1396 
1397 
1432 C_API
1434  int16_t a[],
1435  const int16_t b[],
1436  const unsigned length,
1437  const left_shift_t b_shl);
1438 
1439 
1474 C_API
1476  int16_t a[],
1477  const int16_t b[],
1478  const unsigned length,
1479  const right_shift_t b_shr);
1480 
1481 
1536 C_API
1538  int16_t a[],
1539  const int16_t b[],
1540  const unsigned length,
1541  const right_shift_t b_shr,
1542  const unsigned depth);
1543 
1544 
1599 C_API
1601  exponent_t* a_exp,
1602  right_shift_t* b_shr,
1603  const exponent_t b_exp,
1604  const right_shift_t b_hr);
1605 
1606 
1656 C_API
1658  int16_t a[],
1659  const int16_t b[],
1660  const int16_t c[],
1661  const unsigned length,
1662  const right_shift_t b_shr,
1663  const right_shift_t c_shr);
1664 
1665 
1678 #define xs3_vect_s16_sub_prepare xs3_vect_s32_add_prepare
1679 
1680 
1708 C_API
1709 int32_t xs3_vect_s16_sum(
1710  const int16_t b[],
1711  const unsigned length);
1712 
1713 
1714 
1715 #ifdef __XC__
1716 } //extern "C"
1717 #endif
1718 
int exponent_t
An exponent.
Definition: xs3_math_types.h:76
int left_shift_t
A leftwards arithmetic bit-shift.
Definition: xs3_math_types.h:110
int right_shift_t
A rightwards arithmetic bit-shift.
Definition: xs3_math_types.h:98
unsigned headroom_t
Headroom of some integer or integer array.
Definition: xs3_math_types.h:86
headroom_t xs3_vect_s16_abs(int16_t a[], const int16_t b[], const unsigned length)
Compute the element-wise absolute value of a 16-bit vector.
Definition: xs3_vect_abs_clip_rect.c:14
headroom_t xs3_vect_s16_max_elementwise(int16_t a[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)
Get the element-wise maximum of two 16-bit vectors.
Definition: xs3_vect_stats.c:26
headroom_t xs3_vect_s16_scale(int16_t a[], const int16_t b[], const unsigned length, const int16_t c, const right_shift_t a_shr)
Multiply a 16-bit vector by a 16-bit scalar.
Definition: xs3_vect_mul.c:54
headroom_t xs3_vect_s16_add(int16_t a[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)
Add one 16-bit BFP vector to another.
Definition: xs3_vect_add_sub.c:13
headroom_t xs3_vect_s16_macc(int16_t acc[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t acc_shr, const right_shift_t bc_sat)
Multiply one 16-bit vector element-wise by another, and add the result to an accumulator.
Definition: xs3_vect_macc.c:17
headroom_t xs3_vect_s16_rect(int16_t a[], const int16_t b[], const unsigned length)
Rectify the elements of a 16-bit vector.
Definition: xs3_vect_abs_clip_rect.c:78
headroom_t xs3_vect_s16_shr(int16_t a[], const int16_t b[], const unsigned length, const right_shift_t b_shr)
Right-shift the elements of a 16-bit vector by a specified number of bits.
Definition: xs3_vect.c:121
void xs3_vect_s16_inverse(int16_t a[], const int16_t b[], const unsigned length, const unsigned scale)
Compute the inverse of elements of a 16-bit vector.
Definition: xs3_vect_inverse.c:16
headroom_t xs3_vect_s16_headroom(const int16_t b[], const unsigned length)
Calculate the headroom of a 16-bit vector.
Definition: xs3_vect_headroom.c:13
void xs3_vect_s16_set(int16_t a[], const int16_t b, const unsigned length)
Set all elements of a 16-bit vector to the specified value.
Definition: xs3_vect_set.c:13
int32_t xs3_vect_s16_abs_sum(const int16_t b[], const unsigned length)
Compute the sum of the absolute values of elements of a 16-bit vector.
Definition: xs3_vect_stats.c:176
headroom_t xs3_vect_s16_sqrt(int16_t a[], const int16_t b[], const unsigned length, const right_shift_t b_shr, const unsigned depth)
Compute the square roots of elements of a 16-bit vector.
Definition: xs3_vect_sqrt.c:15
headroom_t xs3_vect_s16_mul(int16_t a[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t a_shr)
Multiply two 16-bit vectors together element-wise.
Definition: xs3_vect_mul.c:16
headroom_t xs3_vect_s16_nmacc(int16_t acc[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t acc_shr, const right_shift_t bc_sat)
Multiply one 16-bit vector element-wise by another, and subtract the result from an accumulator.
Definition: xs3_vect_macc.c:34
int16_t xs3_vect_s16_min(const int16_t b[], const unsigned length)
Find the minimum value in a 16-bit vector.
Definition: xs3_vect_stats.c:70
headroom_t xs3_vect_s16_sub(int16_t a[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)
Subtract one 16-bit BFP vector from another.
Definition: xs3_vect_add_sub.c:54
headroom_t xs3_vect_s16_add_scalar(int16_t a[], const int16_t b[], const int16_t c, const unsigned length, const right_shift_t b_shr)
Add a scalar to a 16-bit vector.
Definition: xs3_vect.c:216
unsigned xs3_vect_s16_argmin(const int16_t b[], const unsigned length)
Obtain the array index of the minimum element of a 16-bit vector.
Definition: xs3_vect_stats.c:150
int64_t xs3_vect_s16_dot(const int16_t b[], const int16_t c[], const unsigned length)
Compute the inner product of two 16-bit vectors.
Definition: xs3_vect_dot.c:13
unsigned xs3_vect_s16_argmax(const int16_t b[], const unsigned length)
Obtain the array index of the maximum element of a 16-bit vector.
Definition: xs3_vect_stats.c:126
headroom_t xs3_vect_s16_clip(int16_t a[], const int16_t b[], const unsigned length, const int16_t lower_bound, const int16_t upper_bound, const right_shift_t b_shr)
Clamp the elements of a 16-bit vector to a specified range.
Definition: xs3_vect_abs_clip_rect.c:42
int32_t xs3_vect_s16_energy(const int16_t b[], const unsigned length, const right_shift_t b_shr)
Calculate the energy (sum of squares of elements) of a 16-bit vector.
Definition: xs3_vect_stats.c:219
headroom_t xs3_vect_s16_shl(int16_t a[], const int16_t b[], const unsigned length, const left_shift_t b_shl)
Left-shift the elements of a 16-bit vector by a specified number of bits.
Definition: xs3_vect_shl.c:13
int32_t xs3_vect_s16_sum(const int16_t b[], const unsigned length)
Get the sum of elements of a 16-bit vector.
Definition: xs3_vect_sum.c:15
int16_t xs3_vect_s16_max(const int16_t b[], const unsigned length)
Find the maximum value in a 16-bit vector.
Definition: xs3_vect_stats.c:15
headroom_t xs3_vect_s16_min_elementwise(int16_t a[], const int16_t b[], const int16_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)
Get the element-wise minimum of two 16-bit vectors.
Definition: xs3_vect_stats.c:81
void xs3_vect_s16_inverse_prepare(exponent_t *a_exp, unsigned *scale, const int16_t b[], const exponent_t b_exp, const unsigned length)
Obtain the output exponent and scaling parameter used by xs3_vect_s16_inverse().
Definition: xs3_prepare.c:334
void xs3_vect_s16_mul_prepare(exponent_t *a_exp, right_shift_t *a_shr, const exponent_t b_exp, const exponent_t c_exp, const headroom_t b_hr, const headroom_t c_hr)
[xs3_vect_s16_mul]
Definition: xs3_prepare.c:67
void xs3_vect_s16_macc_prepare(exponent_t *new_acc_exp, right_shift_t *acc_shr, right_shift_t *bc_sat, const exponent_t acc_exp, const exponent_t b_exp, const exponent_t c_exp, const headroom_t acc_hr, const headroom_t b_hr, const headroom_t c_hr)
Obtain the output exponent and shifts needed by xs3_vect_s16_macc().
Definition: xs3_prepare.c:19
void xs3_vect_s16_scale_prepare(exponent_t *a_exp, right_shift_t *a_shr, const exponent_t b_exp, const exponent_t c_exp, const headroom_t b_hr, const headroom_t c_hr)
Obtain the output exponent and output shift used by xs3_vect_s16_scale().
Definition: xs3_prepare.c:247
void xs3_vect_s16_sqrt_prepare(exponent_t *a_exp, right_shift_t *b_shr, const exponent_t b_exp, const right_shift_t b_hr)
Obtain the output exponent and shift parameter used by xs3_vect_s16_sqrt().
Definition: xs3_prepare.c:282
void xs3_vect_s16_clip_prepare(exponent_t *a_exp, right_shift_t *b_shr, int16_t *lower_bound, int16_t *upper_bound, const exponent_t b_exp, const exponent_t bound_exp, const headroom_t b_hr)
Obtain the output exponent, input shift and modified bounds used by xs3_vect_s16_clip().
Definition: xs3_prepare.c:90