1.4.2.70 DSP_VectorDotp16 Function
Computes the dot product of two vectors, and scales the output by a binary factor.
Description
int16_t DSP_VectorDotp16(int16_t *indata1, int16_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 accumulation in a 32 bit register. All calculations are done in Q15 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 eight and a multiple of eight.
Parameters
indata1 pointer to input array of 16-bit elements (int16_t)
indata2 pointer to input array of 16-bit elements (int16_t)
scale number of bits to shift return right (int)
N number of samples (int)
Returns
int16_t - scaled output of calculation, Q15 format
Remarks
This must be assembled with .set microMIPS.
Example
int16_t inBufMultA[8]={0x7FFF, 0x8000, 0x7333, 0x6666, 0x1999, 0x4000, 0x7FFF, 0xB334}; _// 1, -1, 0.9, 0.8, 0.2, 0.5, 1, -0.6_ int16_t inBufMultB[8]={0x0CCD, 0x0CCD, 0x4000, 0xC000, 0xE667, 0x4000, 0x0000, 0x0CCD}; _// 0.1, 0.1, 0.5, -0.5, -0.2, 0.5, 0, 0.1_ int Num = 8; int scaleVal = 2; int16_t outScalar; int Num = 8; outScalar = DSP_VectorDotp16(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_ _// = (int16_t)0x0666_
C
int16_t DSP_VectorDotp16 (int16_t * indata1 , int16_t * indata2 , int N , int scale );