ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_dotprod_s16_ansi.c File Reference
#include "dsps_dotprod.h"
Include dependency graph for dsps_dotprod_s16_ansi.c:

Go to the source code of this file.

Functions

esp_err_t dsps_dotprod_s16_ansi (const int16_t *src1, const int16_t *src2, int16_t *dest, int len, int8_t shift)
 dot product of two 16 bit vectors Dot product calculation for two signed 16 bit arrays: *dest += (src1[i] * src2[i]) >> (15-shift); i= [0..N) The extension (_ansi) use ANSI C and could be compiled and run on any platform. The extension (_ae32) is optimized for ESP32 chip.

Function Documentation

◆ dsps_dotprod_s16_ansi()

esp_err_t dsps_dotprod_s16_ansi ( const int16_t * src1,
const int16_t * src2,
int16_t * dest,
int len,
int8_t shift )

dot product of two 16 bit vectors Dot product calculation for two signed 16 bit arrays: *dest += (src1[i] * src2[i]) >> (15-shift); i= [0..N) The extension (_ansi) use ANSI C and could be compiled and run on any platform. The extension (_ae32) is optimized for ESP32 chip.

Parameters
[in]src1source array 1
[in]src2source array 2
destdestination pointer
[in]lenlength of input arrays
[in]shiftshift of the result.
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 17 of file dsps_dotprod_s16_ansi.c.

18{
19 // To make correct round operation we have to shift round value
20 long long acc = 0x7fff >> shift;
21
22 for (int i = 0 ; i < len ; i++) {
23 acc += (int32_t)src1[i] * (int32_t)src2[i];
24 }
25
26 int final_shift = shift - 15;
27 if (final_shift > 0) {
28 *dest = (acc << final_shift);
29 } else {
30 *dest = (acc >> (-final_shift));
31 }
32 return ESP_OK;
33}
#define ESP_OK
Definition esp_err.h:23

References ESP_OK.