1.4.2.63 DSP_VectorAutocorr16 Function

Computes the Autocorrelation of a Vector.

Description

void DSP_VectorAutocorr16(int16_t *outCorr, int16_t *inVector, int N, int K);

Calculates the autocorrelation, with a lag of 1 to K, on the first N elements of inVector and returns the 16-bit scalar result in outCorr. The autocorrelation is calculated from other statistical equations including mean and variance. While in some cases these equations exist inside the DSP library, the functions are executed in a serial fashion within this code to provide enhanced performance. The unbiased function has the form - mean (M) = sum(x(n) / N) variance (V) = sum((x(n) - M)^2) / (N-1) autocovariance (ACV) = sum((x(n) - M) * (x(n+k) - M) / (N-k)) autocorrelation (AC) = CV / V where N is the number of vector elements, n is the index of those elements x(n) is a single element in the input vector M is the mean of the N elements of the vector k is the lag or series index.

The output of the function will return K elements, and the outCorr array should be sized to accept those 16-bit results. The outputs correspond to k=1, k=2, .., k=K delay states. The function returns a 16-bit value in rounded, saturated Q15 format.

Input values of the vector and output scalar value is Q15 fractional format. This format has data that ranges from -1 to 1, and has internal saturation limits of those same values. Some care has been taken to reduce the impact of saturation by adding processing steps to effectively complete the processing in blocks. However, in some extreme cases of data variance it is still possible to reach the saturation limits.

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. outCorr must be an array with at least K values. N must be greater than or equal to four and a multiple of four.

Parameters

outCorr pointer to output array (int16_t)

inVector pointer to source array of elements (int16_t)

N number of samples (int)

K lag value, number of output elements (int)

Returns

None.

Remarks

This function is optimized with microMIPS and M14KCe ASE DSP instructions. This function is dependent on the LibQ library, and the _LIBQ_Q16Div specifically.

Example

int autocvN = 16; _// N value, number of samples in array_

int autocvLag = 4; _// Lag value, output shifts to observe_

int16_t outAC[16]={0};

int16_t CVIn16[16] = {0x1999, 0xD99A, 0x1000, 0x6000, 0x1999, 0x1999, 0x2666,

0x3333, 0x1000, 0x6000, 0x1999, 0x1999, 0x2666, 0x3333, 0x1999, 0x0CCC};

_// = { .2, -.3, .125, .75, .2, .2, .3, .4, .125, .75, .2, .2, .3, .4, .2, .1};_

DSP_VectorAutocorr16(outAC, CVIn16, autocvN, autocvLag);

_// outAC = {0xF406, D46C, 0x098F, 0x191A}_

_// = -0.093567, -0.34045, 0.07468, 0.19611_

C

void  DSP_VectorAutocorr16 (int16_t * outCorr , int16_t * inVector , int  N , int  K );