1.4.2.94 DSP_VectorSumSquares16 Function
Computes the sum of squares of a vector, and scales the output by a binary factor.
Description
int16_t DSP_VectorSumSquares16(int16_t *indata, int N, int scale);
Calculates the sum of the squares of each element of an input vector, 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(indata^2)
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
indata 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_ int Num = 8; int scaleVal = 3; int16_t outScalar; outScalar = DSP_VectorSumSquares16(inBufMultA, Num, scaleVal); _// outScalar = 1/(2\^scaleVal)* sum(inBufMultA[i]\^2) =_ _// (1/8) * (1 + 1 + 0.81 + 0.64 + 0.04 + 0.25 + 1 + 0.36) = 0.125 * 5.1 = 0.6375_ _// = (int16_t)0x5199_
C
int16_t DSP_VectorSumSquares16 (int16_t * indata , int N , int scale );