C CODE FOR A CANONICAL IMPLEMENTATION


/* filter.c - IIR example routine */

double filter(double x, double* w) {

   double y;

   w[0] = 0.8 * w[1] + x;        // internal state

   y = 5 * w[0] + 2 * w[1];      // compute output

   w[1] = w[0];                  // update internal state

   return y;
}

main:

   w = (double*) calloc(2, sizeof(double));

   for (n=0; n < N; n++) {

      y[n] = filter(x[n], w);

   }