DSP_dotp_sqr
4-58
4.5 Math
Vector Dot Product and Square
DSP_dotp_sqr
Function int DSP_dotp_sqr(int G, const short * restrict x, const short * restrict y, int *
restrict r, int nx)
Arguments G Calculated value of G (used in the VSELP coder).
x[nx] First vector array
y[nx] Second vector array
r Result of vector dot product of x and y.
nx Number of elements. Must be multiple of 4, and ≥12.
return int New value of G.
Description This routine performs an nx element dot product of x[ ] and y[ ] and stores it
in r. It also squares each element of y[ ] and accumulates it in G. G is passed
back to the calling function in register A4. This computation of G is used in the
VSELP coder.
Algorithm This is the C equivalent of the assembly code without restrictions. Note that
the assembly code is hand optimized and restrictions may apply.
int DSP_dotp_sqr (int G,short *x,short *y,int *r,
int nx)
{
short *y2;
short *endPtr2;
y2 = x;
for (endPtr2 = y2 + nx; y2 < endPtr2; y2++){
*r += *y * *y2;
G += *y * *y;
y++;
}
return(G);
}