Digital Signal Processing Reference
In-Depth Information
Up to this point in the program, we did not have the necessary information to
determine the number of coefficients in each of the acoefs and bcoefs arrays.
But since we now have the order of the filter, we can determine the number of
coefficients exactly in the following manner. Each quadratic factor of the
approximation function will require three coefficients (the s 2 -term coefficient, the
s- term coefficient, and the constant term coefficient). In addition, we will treat any
odd-order approximation first-order factor as a quadratic. We can make use of the
integer math in C to simplify the calculation for the number of coefficients based
on the order of the filter.
Once the correct number of coefficients has been determined, malloc is
used to allocate memory for that number of double s, and if an error occurs, we
leave the function. The coefficient arrays are organized in the following manner.
The acoefs array stores the coefficients for the numerator factors while the
bcoefs array will store the coefficients for the denominator factors. ( acoefs
and bcoefs will take on different meanings in the digital filter design so for now
we can remember A for above the line and B for below the line.) If the
approximation function has an odd-order, the first-order coefficients are stored as
a quadratic in the first three coefficients of each array with the s 2 -term set to zero.
The next three coefficients are for the first true quadratic, and then all other
quadratics follow. If the approximation function has an even-order, then the first
three coefficients are for the first quadratic, the next three coefficients for the
second quadratic, and so on. Within the three coefficients, the first coefficient
always refers to the s 2 -term, the second refers to the s- term coefficients, and the
last coefficient is the constant term in the quadratic factor.
The Calc_Butter_Coefs function shown in Listing D.4 is an example of
the approximation calculation function. The function first checks for valid pointers
and order values, and then proceeds to make the calculations outlined in Section
D.2. If the order is odd, the first order coefficients are calculated followed by all
coefficients for quadratic factors. The other individual functions for calculating
the normalized coefficients for the four approximation methods can be found on
the software disc in the \C_CODE\FILTER\F_DESIGN.C module. They all
determine the coefficients in a manner consistent with our development earlier in
this chapter.
There are a number of advanced math functions required by our
approximation functions. These functions are not contained in F_DESIGN.C as
are the rest of the functions discussed in this appendix, but are instead a part of the
\C_CODE\FILTER\ADV_MATH.C module. These include the asinh and acosh
functions used in the Chebyshev functions as well as the elliptic integral and
Jacobian elliptic functions necessary to define the elliptic approximation. The
values of these functions are typically calculated by the arithmetic-geometric mean
method of iteration. A detailed discussion of this method and the elliptic functions
in general is beyond the scope of this text, but references have been provided in
the analog and digital filter design sections of Appendix A.
Search WWH ::




Custom Search