/** ConvertToInterpolationCoefficients @param c Input samples --> output coefficients @param DataLength Number of samples or coefficients @param z Poles @param NbPoles Number of poles @param Tolerance Admissible relative error */ static void ConvertToInterpolationCoefficients(double *c, long DataLength, double *z, long NbPoles, double Tolerance) { double Lambda = 1; long n, k; // special case required by mirror boundaries if(DataLength == 1L) { return; } // compute the overall gain for(k = 0L; k < NbPoles; k++) { Lambda = Lambda * (1.0 - z[k]) * (1.0 - 1.0 / z[k]); } // apply the gain for (n = 0L; n < DataLength; n++) { c[n] *= Lambda; } // loop over all poles for (k = 0L; k < NbPoles; k++) { // causal initialization c[0] = InitialCausalCoefficient(c, DataLength, z[k], Tolerance); // causal recursion for (n = 1L; n < DataLength; n++) { c[n] += z[k] * c[n - 1L]; } // anticausal initialization c[DataLength - 1L] = InitialAntiCausalCoefficient(c, DataLength, z[k]); // anticausal recursion for (n = DataLength - 2L; 0 <= n; n--) { c[n] = z[k] * (c[n + 1L] - c[n]); } } }
/*--------------------------------------------------------------------------*/ static void ConvertToInterpolationCoefficients ( double c[], /* input samples --> output coefficients */ long DataLength, /* number of samples or coefficients */ double z[], /* poles */ long NbPoles, /* number of poles */ double Tolerance /* admissible relative error */ ) { /* begin ConvertToInterpolationCoefficients */ double Lambda = 1.0; long n, k; /* special case required by mirror boundaries */ if (DataLength == 1L) { return; } /* compute the overall gain */ for (k = 0L; k < NbPoles; k++) { Lambda = Lambda * (1.0 - z[k]) * (1.0 - 1.0 / z[k]); } /* apply the gain */ for (n = 0L; n < DataLength; n++) { c[n] *= Lambda; } /* loop over all poles */ for (k = 0L; k < NbPoles; k++) { /* causal initialization */ c[0] = InitialCausalCoefficient(c, DataLength, z[k], Tolerance); /* causal recursion */ for (n = 1L; n < DataLength; n++) { c[n] += z[k] * c[n - 1L]; } /* anticausal initialization */ c[DataLength - 1L] = InitialAntiCausalCoefficient(c, DataLength, z[k]); /* anticausal recursion */ for (n = DataLength - 2L; 0 <= n; n--) { c[n] = z[k] * (c[n + 1L] - c[n]); } } } /* end ConvertToInterpolationCoefficients */