#ifndef FAST_H #define FAST_H #define PROD5(A,B,R) \ { typeof (R) __x,__y,__t; \ typeof (&A[0]) __pa=A; \ typeof (&B[0]) __pb=B; \ __x=*__pa++;__y=*__pb++; \ R=R-R; __t=__x*__y; __x=*__pa++;__y=*__pb++; \ R+=__t; __t=__x*__y; __x=*__pa++;__y=*__pb++; \ R+=__t; __t=__x*__y; __x=*__pa++;__y=*__pb++; \ R+=__t; __t=__x*__y; __x=*__pa++;__y=*__pb++; \ R+=__t; __t=__x*__y; \ R+=__t;} /* Autocorrelation : R[0:K] is autocorrelation of X[M:N-1] i.e. R[k] = Sum X[i]*X[i-k] for M<=i= 2. computes sum(x[i]*y[i]) **/ /** Hacked this so that it only works with reals. This is necessary because the non-GNU C compiler has trouble with typeof() **/ #define DOTPROD(X,Y,N,Z) \ { int __i; \ real __r=0, __t; \ real __x1; \ real __y1; \ real* __xp = &(X)[0]; \ real* __yp = &(Y)[0]; \ __x1=*__xp++; __y1=*__yp++; \ __t=__x1*__y1; __x1=*__xp++; __y1=*__yp++; \ for(__i=0; __i<(N)-2; __i++) { \ __r+=__t; __t=__x1*__y1; __x1=*__xp++; __y1=*__yp++; } \ __r+=__t; __t=__x1*__y1; \ __r+=__t; *Z=__r;} #endif /*FAST_H*/