PROGRAMMING CONSIDERATIONS


/* conv.c - convolution of x[n] with h[n], resulting in y[n] */

void conv(int M, double* h, int L, double *x, double *y) {

 for (int n=0; n< L+M; n++) {
  for (y[n]=0, m=max(0, n-L+1);
       m <= min(n,M); m++) {
   y[n] += h[m] * x[n-m];
  }
 }
}

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))