Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Vector Dot Product

Functions

void zdsp_dot_prod_f32 (const float32_t *src_a, const float32_t *src_b, uint32_t block_size, float32_t *result)
 Dot product of floating-point vectors.
 
void zdsp_dot_prod_q7 (const q7_t *src_a, const q7_t *src_b, uint32_t block_size, q31_t *result)
 Dot product of Q7 vectors.
 
void zdsp_dot_prod_q15 (const q15_t *src_a, const q15_t *src_b, uint32_t block_size, q63_t *result)
 Dot product of Q15 vectors.
 
void zdsp_dot_prod_q31 (const q31_t *src_a, const q31_t *src_b, uint32_t block_size, q63_t *result)
 Dot product of Q31 vectors.
 
DSP_FUNC_SCOPE void zdsp_dot_prod_f16 (const float16_t *src_a, const float16_t *src_b, uint32_t block_size, float16_t *result)
 Dot product of floating-point vectors.
 

Detailed Description

Computes the dot product of two vectors. The vectors are multiplied element-by-element and then summed.

    sum = src_a[0]*src_b[0] + src_a[1]*src_b[1] + ... + src_a[block_size-1]*src_b[block_size-1]

There are separate functions for floating-point, Q7, Q15, and Q31 data types.

Function Documentation

◆ zdsp_dot_prod_f16()

DSP_FUNC_SCOPE void zdsp_dot_prod_f16 ( const float16_t * src_a,
const float16_t * src_b,
uint32_t block_size,
float16_t * result )

#include <zephyr/dsp/basicmath_f16.h>

Dot product of floating-point vectors.

Parameters
[in]src_apoints to the first input vector
[in]src_bpoints to the second input vector
[in]block_sizenumber of samples in each vector
[out]resultoutput result returned here

◆ zdsp_dot_prod_f32()

void zdsp_dot_prod_f32 ( const float32_t * src_a,
const float32_t * src_b,
uint32_t block_size,
float32_t * result )

#include <zephyr/dsp/basicmath.h>

Dot product of floating-point vectors.

Parameters
[in]src_apoints to the first input vector
[in]src_bpoints to the second input vector
[in]block_sizenumber of samples in each vector
[out]resultoutput result returned here

◆ zdsp_dot_prod_q15()

void zdsp_dot_prod_q15 ( const q15_t * src_a,
const q15_t * src_b,
uint32_t block_size,
q63_t * result )

#include <zephyr/dsp/basicmath.h>

Dot product of Q15 vectors.

Scaling and Overflow Behavior
The intermediate multiplications are in 1.15 x 1.15 = 2.30 format and these results are added to a 64-bit accumulator in 34.30 format. Nonsaturating additions are used and given that there are 33 guard bits in the accumulator there is no risk of overflow. The return result is in 34.30 format.
Parameters
[in]src_apoints to the first input vector
[in]src_bpoints to the second input vector
[in]block_sizenumber of samples in each vector
[out]resultoutput result returned here

◆ zdsp_dot_prod_q31()

void zdsp_dot_prod_q31 ( const q31_t * src_a,
const q31_t * src_b,
uint32_t block_size,
q63_t * result )

#include <zephyr/dsp/basicmath.h>

Dot product of Q31 vectors.

Scaling and Overflow Behavior
The intermediate multiplications are in 1.31 x 1.31 = 2.62 format and these are truncated to 2.48 format by discarding the lower 14 bits. The 2.48 result is then added without saturation to a 64-bit accumulator in 16.48 format. There are 15 guard bits in the accumulator and there is no risk of overflow as long as the length of the vectors is less than 2^16 elements. The return result is in 16.48 format.
Parameters
[in]src_apoints to the first input vector
[in]src_bpoints to the second input vector
[in]block_sizenumber of samples in each vector
[out]resultoutput result returned here

◆ zdsp_dot_prod_q7()

void zdsp_dot_prod_q7 ( const q7_t * src_a,
const q7_t * src_b,
uint32_t block_size,
q31_t * result )

#include <zephyr/dsp/basicmath.h>

Dot product of Q7 vectors.

Scaling and Overflow Behavior
The intermediate multiplications are in 1.7 x 1.7 = 2.14 format and these results are added to an accumulator in 18.14 format. Nonsaturating additions are used and there is no danger of wrap around as long as the vectors are less than 2^18 elements long. The return result is in 18.14 format.
Parameters
[in]src_apoints to the first input vector
[in]src_bpoints to the second input vector
[in]block_sizenumber of samples in each vector
[out]resultoutput result returned here