1.4.2.88 DSP_VectorRMS16 Function

Computes the root mean square (RMS) value of a vector.

Description

int16_t DSP_VectorRMS16(int16_t *inVector, int N);

Computes the root mean square value of the first N values of inVector. Both input and output are Q15 fractional values. The function will saturate if maximum or minimum values are exceeded.

Preconditions

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

Parameters

indata pointer to input array of 16-bit elements (int16_t)

N number of samples (int)

Returns

int16_t - RMS function output, Q15 format

Remarks

This function is optimized with microMIPS and M14KCe ASE DSP instructions. This function is dependent on the LibQ library, and uses the _LIBQ_Q16Sqrt external function call.

Example

int16_t vecRMSIn[32]={0x1999, 0xD99A, 0x4000, 0x2666,0x1999,0x1999,0x2666, 0x3333};

_// 0.2, -0.3, 0.5, 0.3, 0.2, 0.2, 0.3, 0.4_

int16_t RMSOut=0;

int Nrms = 8;

RMSOut = DSP_VectorRMS16(vecRMSIn, Nrms);

_// RMSOut = 0x287C (= 0.31628)_

C

int16_t DSP_VectorRMS16 (int16_t * inVector , int  N );