Motorola DSP Developer's Kit | ![]() ![]() |
C=mot###_xcorr(A,B, MAXLAG, 'flag')
Description
This function returns the length 2*M-1 cross-correlation sequence in a column vector where A and B are length N real vectors
Input/Output
Input: Vector A, vector B, int MAXLAG, and int 'flag'
Algorithm
N = LengthA; //The following are algorithm of xcorr for (i = Max(1, (N - MAXLAG)); i <= N - 1; i ++) { for (j = 0; j < = i - 1; j ++) { C[i ] += B[j+1] * A[j + N - i + 1]; } if (flag == "biased") C[i] /= N; else if (flag == "unbiased") C[i] /= i ; } for (i = N; i <= Min((2 * N - 1), (N + MAXLAG)); i ++) { for (j = 0; j <= 2 * N - i - 1; j ++) { C[i] += A[j+1] * B[j + i - N + 1]; } if (flag == "biased") C[i] /= N; else if (flag == "unbiased") C[i] /= (2 * N - i); } if (flag == "coeff") { for (i = Max(1, (N - MAXLAG)); i <= Min((2 * N - 1), (N + MAXLAG)); i ++) { C[i] / = C[N]; } } // Format vector C if (MAXLAG >= N) { LengthC = 2 * MAXLAG + 1; df = MAXLAG - N + 1; for (i = LengthC; i >= 1 ; i --) { if ( i > df && i <= LengthC - df ) { C[i] = C[i - df]; } else { C[i] = 0; } } } else { C = C(N - MAXLAG : LengthC); }
Memory & Register
'flag'
'none'
'biased
''coeff'
Status Register
The assembly function xcorr-r.asm
does not explicitly set any status registers/bits during the function execution.
Data Size Limit
The total size of all vectors can't be larger than the continuous available data memory size.
Data Range Limit
The value of input vectors must be between -1.0 and +1.0.
Precision
In the case of DSP563, precision is 18 bits.
In the case of DSP566, precision is 10 bits.
Perfumes Limit
![]() | sum-c.asm | xcorr-c.asm | ![]() |