XCORE SDK
XCORE Software Development Kit
bfp_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_types.h"
7 
8 
9 
10 /*
11  Saturation Logic:
12 
13  Where specified, the VPU-enhanced arithmetic functions apply symmetric saturation logic, which
14  is applied where results would otherwise overflow.
15 
16  The resulting integer range for N-bit saturation is -(2^(N-1))+1 to (2^(N-1))-1.
17 
18  8-bit: (-127, 127) 16-bit: (-65535, 65535) 32-bit: (-2147483647, 2147483647)
19 */
20 
53 C_API
54 void bfp_s16_set(
55  bfp_s16_t* a,
56  const int16_t b,
57  const exponent_t exp);
58 
59 
88 C_API
90  bfp_s16_t* b);
91 
92 
143 C_API
145  bfp_s16_t* a,
146  const exponent_t exp);
147 
148 
183 C_API
184 void bfp_s16_shl(
185  bfp_s16_t* a,
186  const bfp_s16_t* b,
187  const left_shift_t b_shl);
188 
189 
210 C_API
211 void bfp_s16_add(
212  bfp_s16_t* a,
213  const bfp_s16_t* b,
214  const bfp_s16_t* c);
215 
216 
237 C_API
238 void bfp_s16_add_scalar(
239  bfp_s16_t* a,
240  const bfp_s16_t* b,
241  const float c);
242 
243 
264 C_API
265 void bfp_s16_sub(
266  bfp_s16_t* a,
267  const bfp_s16_t* b,
268  const bfp_s16_t* c);
269 
270 
293 C_API
294 void bfp_s16_mul(
295  bfp_s16_t* a,
296  const bfp_s16_t* b,
297  const bfp_s16_t* c);
298 
299 
316 C_API
317 void bfp_s16_macc(
318  bfp_s16_t* acc,
319  const bfp_s16_t* b,
320  const bfp_s16_t* c);
321 
322 
339 C_API
340 void bfp_s16_nmacc(
341  bfp_s16_t* acc,
342  const bfp_s16_t* b,
343  const bfp_s16_t* c);
344 
345 
369 C_API
370 void bfp_s16_scale(
371  bfp_s16_t* a,
372  const bfp_s16_t* b,
373  const float alpha);
374 
375 
397 C_API
398 void bfp_s16_abs(
399  bfp_s16_t* a,
400  const bfp_s16_t* b);
401 
402 
422 C_API
424  const bfp_s16_t* b);
425 
426 
448 C_API
450  const bfp_s16_t* b,
451  const bfp_s16_t* c);
452 
453 
483 C_API
484 void bfp_s16_clip(
485  bfp_s16_t* a,
486  const bfp_s16_t* b,
487  const int16_t lower_bound,
488  const int16_t upper_bound,
489  const int bound_exp);
490 
491 
516 C_API
517 void bfp_s16_rect(
518  bfp_s16_t* a,
519  const bfp_s16_t* b);
520 
521 
541 C_API
542 void bfp_s16_to_s32(
543  bfp_s32_t* a,
544  const bfp_s16_t* b);
545 
546 
576 C_API
577 void bfp_s16_sqrt(
578  bfp_s16_t* a,
579  const bfp_s16_t* b);
580 
581 
603 C_API
604 void bfp_s16_inverse(
605  bfp_s16_t* a,
606  const bfp_s16_t* b);
607 
608 
628 C_API
630  const bfp_s16_t* b);
631 
632 
652 C_API
653 float bfp_s16_mean(
654  const bfp_s16_t* b);
655 
656 
676 C_API
678  const bfp_s16_t* b);
679 
680 
702 C_API
704  const bfp_s16_t* b);
705 
706 
726 C_API
727 float bfp_s16_max(
728  const bfp_s16_t* b);
729 
730 
754 C_API
756  bfp_s16_t* a,
757  const bfp_s16_t* b,
758  const bfp_s16_t* c);
759 
760 
780 C_API
781 float bfp_s16_min(
782  const bfp_s16_t* b);
783 
784 
808 C_API
810  bfp_s16_t* a,
811  const bfp_s16_t* b,
812  const bfp_s16_t* c);
813 
814 
840 C_API
841 unsigned bfp_s16_argmax(
842  const bfp_s16_t* b);
843 
844 
870 C_API
871 unsigned bfp_s16_argmin(
872  const bfp_s16_t* b);
float_s32_t bfp_s16_sum(const bfp_s16_t *b)
Sum the elements of a 16-bit BFP vector.
Definition: bfp_s16.c:181
void bfp_s16_macc(bfp_s16_t *acc, const bfp_s16_t *b, const bfp_s16_t *c)
Multiply one 16-bit BFP vector by another element-wise and add the result to a third vector.
Definition: bfp_s16.c:492
void bfp_s16_max_elementwise(bfp_s16_t *a, const bfp_s16_t *b, const bfp_s16_t *c)
Get the element-wise maximum of two 16-bit BFP vectors.
Definition: bfp_s16.c:392
float_s64_t bfp_s16_dot(const bfp_s16_t *b, const bfp_s16_t *c)
Compute the inner product of two 16-bit BFP vectors.
Definition: bfp_s16.c:195
void bfp_s16_sub(bfp_s16_t *a, const bfp_s16_t *b, const bfp_s16_t *c)
Subtract one 16-bit BFP vector from another.
Definition: bfp_s16.c:105
unsigned bfp_s16_argmin(const bfp_s16_t *b)
Get the index of the minimum value of a 16-bit BFP vector.
Definition: bfp_s16.c:463
void bfp_s16_mul(bfp_s16_t *a, const bfp_s16_t *b, const bfp_s16_t *c)
Multiply one 16-bit BFP vector by another element-wise.
Definition: bfp_s16.c:124
float bfp_s16_min(const bfp_s16_t *b)
Get the minimum value of a 16-bit BFP vector.
Definition: bfp_s16.c:416
void bfp_s16_add(bfp_s16_t *a, const bfp_s16_t *b, const bfp_s16_t *c)
Add two 16-bit BFP vectors together.
Definition: bfp_s16.c:60
float_s64_t bfp_s16_energy(const bfp_s16_t *b)
Get the energy (sum of squared of elements) of a 16-bit BFP vector.
Definition: bfp_s16.c:345
void bfp_s16_inverse(bfp_s16_t *a, const bfp_s16_t *b)
Get the inverses of elements of a 16-bit BFP vector.
Definition: bfp_s16.c:288
void bfp_s16_clip(bfp_s16_t *a, const bfp_s16_t *b, const int16_t lower_bound, const int16_t upper_bound, const int bound_exp)
Definition: bfp_s16.c:211
float bfp_s16_mean(const bfp_s16_t *b)
Get the mean value of a 16-bit BFP vector.
Definition: bfp_s16.c:321
void bfp_s16_sqrt(bfp_s16_t *a, const bfp_s16_t *b)
Get the square roots of elements of a 16-bit BFP vector.
Definition: bfp_s16.c:271
void bfp_s16_use_exponent(bfp_s16_t *a, const exponent_t exp)
Modify a 16-bit BFP vector to use a specified exponent.
Definition: bfp_s16.c:28
void bfp_s16_add_scalar(bfp_s16_t *a, const bfp_s16_t *b, const float c)
Add a scalar to a 16-bit BFP vector.
Definition: bfp_s16.c:79
void bfp_s16_to_s32(bfp_s32_t *a, const bfp_s16_t *b)
Convert a 16-bit BFP vector into a 32-bit BFP vector.
Definition: bfp_s16.c:474
void bfp_s16_min_elementwise(bfp_s16_t *a, const bfp_s16_t *b, const bfp_s16_t *c)
Get the element-wise minimum of two 16-bit BFP vectors.
Definition: bfp_s16.c:428
float_s32_t bfp_s16_abs_sum(const bfp_s16_t *b)
Sum the absolute values of elements of a 16-bit BFP vector.
Definition: bfp_s16.c:307
headroom_t bfp_s16_headroom(bfp_s16_t *b)
Get the headroom of a 16-bit BFP vector.
Definition: bfp_s16.c:15
void bfp_s16_scale(bfp_s16_t *a, const bfp_s16_t *b, const float alpha)
Multiply a 16-bit BFP vector by a scalar.
Definition: bfp_s16.c:144
void bfp_s16_set(bfp_s16_t *a, const int16_t b, const exponent_t exp)
Set all elements of a 16-bit BFP vector to a specified value.
Definition: bfp_init.c:85
void bfp_s16_shl(bfp_s16_t *a, const bfp_s16_t *b, const left_shift_t b_shl)
Apply a left-shift to the mantissas of a 16-bit BFP vector.
Definition: bfp_s16.c:45
void bfp_s16_nmacc(bfp_s16_t *acc, const bfp_s16_t *b, const bfp_s16_t *c)
Multiply one 16-bit BFP vector by another element-wise and subtract the result from a third vector.
Definition: bfp_s16.c:511
unsigned bfp_s16_argmax(const bfp_s16_t *b)
Get the index of the maximum value of a 16-bit BFP vector.
Definition: bfp_s16.c:452
float_s32_t bfp_s16_rms(const bfp_s16_t *b)
Get the RMS value of elements of a 16-bit BFP vector.
Definition: bfp_s16.c:359
void bfp_s16_rect(bfp_s16_t *a, const bfp_s16_t *b)
Rectify a 16-bit BFP vector.
Definition: bfp_s16.c:257
float bfp_s16_max(const bfp_s16_t *b)
Get the maximum value of a 16-bit BFP vector.
Definition: bfp_s16.c:380
void bfp_s16_abs(bfp_s16_t *a, const bfp_s16_t *b)
Get the absolute values of elements of a 16-bit BFP vector.
Definition: bfp_s16.c:167
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
unsigned headroom_t
Headroom of some integer or integer array.
Definition: xs3_math_types.h:86
[bfp_s32_t]
Definition: xs3_math_types.h:309
A block floating-point vector of 32-bit elements.
Definition: xs3_math_types.h:276
A floating-point scalar with a 32-bit mantissa.
Definition: xs3_math_types.h:167
A floating-point scalar with a 64-bit mantissa.
Definition: xs3_math_types.h:190