1.4.2.71 DSP_VectorDotp32 Function

Computes the dot product of two vectors, and scales the output by a binary factor

Description

int32_t DSP_VectorDotp32(int32_t *indata1, int32_t *indata2, int N, int scale);

Calculates the dot product of two input vectors, and scales the output. Function will saturate if it exceeds maximum or minimum values. Scaling is done by binary shifting, after calculation of the result. All calculations are done in Q31 fractional format.

return = 1/(2^scale) * sum(indata1 * indata2)

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. N must be greater than or equal to four and a multiple of four.

Parameters

indata1 pointer to input array of 16-bit elements (int32_t)

indata2 pointer to input array of 16-bit elements (int32_t)

scale number of bits to shift return right (int)

N number of samples (int)

Returns

int16_t - scaled output of calculation, Q31 format

Remarks

This must be assembled with .set microMIPS.

Example

int32_t inBufMultA[8]={0x7FFFFFFF, 0x80000000, 0x73333333, 0x66666666,

0x19999999, 0x40000000, 0x7FFFFFFF, 0xB3333334};

_// 1, -1, 0.9, 0.8, 0.2, 0.5, 1, -0.6_

int32_t inBufMultB[8]={0x0CCCCCCD, 0x0CCCCCCD, 0x40000000, 0xC0000000,

0xE6666667, 0x40000000, 0x00000000, 0x0CCCCCCD};

_// 0.1, 0.1, 0.5, -0.5, -0.2, 0.5, 0, 0.1_

int Num = 8;

int scaleVal = 2;

int32_t outScalar;

int Num = 8;

outScalar = DSP_VectorDotp32(inBufMultA, inBufMultB, Num, scaleVal);

_// outScalar = 1/(2\^scaleVal)*(inBufMultA[] dot inBufMultB[]) =_

_// (1/4) * (0.1 + -0.1 + 0.45 + -0.4 + -0.04 + 0.25 + 0 + -0.06) = 0.25 * 0.20 = 0.05_

_// = (int32_t)0x06666666_

C

int32_t DSP_VectorDotp32 (int32_t * indata1 , int32_t * indata2 , int  N , int  scale );