O

C0

Yes

W sinc(W(m — 3)/2m)d3

/*_____________________________________________________________________*/

void GetlnterpolationCoefficients (

double c[], /* input samples—> output coefficients */

int DataLength, /* number of samples or coefficients */

/*_____________________________________________________________________*/

void GetlnterpolationCoefficients (

double c[], /* input samples—> output coefficients */

int DataLength, /* number of samples or coefficients */

double Tolerance /* admissible relative error */

/* special case required by mirror boundaries */ if (DataLength == 1)

return; /* compute the overall gain */ for ( k = 0; k < NbPoles; k = k + 1)

Lambda = Lambda * (1.0 - z[k]) * (1.0 - 1.0/z[k]); /* apply the gain */

for ( n = 0; n < DataLength; n = n + 1) c[n] =c[n] * Lambda;

/* causal initialization */

c[0] =lnitialCausalCoefficient(c, DataLength, z[k]. Tolerance);

/* causal recursion */ for ( n = 1; n < DataLength; n = n + 1) c[n] = c[n] + z[k] * c[n-1];

/* anticausal initialization */

c[DataLength-1] =initialAntiCausalCoefficient (c, DataLength, z[k]),

/* anticausal recursion */ for ( n = DataLength - 2;n> = 0;n = n-1) c[n] = z[k] * (c[n+1] - c[n]);

/*----------------------------------------------------------

double initialCausalCoefficient (

int DataLength, /* number of coefñcients */

double Tolerance /* admissible relative error */

int TruncatedSum;

/* this initialization corresponds to mirror boundaries */ TruncatedSum = 0; if (Tolerance >0.0) {

Horizon= (int)ceil(log(Tolerance) / log(fabs(z))); TruncatedSum = (Horizon < DataLength);

if (TruncatedSum) {

for (n = 1; n < Horizon; n = n + 1) { Sum = Sum + zn * c[n]; zn = zn * z;

return(Sum);

for (n = 1; n < = DataLength - 2;n = n+1) { Sum = Sum + (zn + z2n) * c[n]; zn = zn * z; z2n = z2n * iz;

/*_____________________________________________________________________*/

double initialAntiCausalCoefficient (

int DataLength, /* number of samples or coefficients */

/* this initialization corresponds to mirror boundaries */

return((z / (z * z - 1.0)) * (z* c[DataLength-2] + c[DataLength-1]));

Interpolation coefficients. (Hopefully) didactic and efficient C-code. This code is available for download at the URL http://bigwww.epfl.ch/

0 0

Post a comment