Remez exchange algorithm for the weighted chebyshev approximation of a continuous function with a sum of cosines.
an=remez(guess,mag,fgrid,weight)
:guess real array of size n+2 the`initial guess : :fgrid real array of size `ng: the grid of normalized frequency
points in [0,.5[
: :mag real array of size ng: the desired magnitude on grid fg : :weight real array of size ng: weighting function on error on grid
fg
: :an real array of size n: cosine coefficients :
Minimax approximation of a frequency domain magnitude response. The approximation takes the form
h = `sum`_[a(i)*`cos`_(weight)], i=1:n
An FIR, linear-phase filter can be obtained from the output of remez by using the following commands:
hn(1:nc-1)=an(nc:-1:2)/2;
hn(nc)=an(1);
hn(nc+1:2*nc-1)=an(2:nc)/2;
This function is mainly intended to be called by the `remezb function`_.
E.W. Cheney, Introduction to Approximation Theory, McGraw-Hill, 1966
This function is based on the fortran code remez.f written by:
nc=21;
ngrid=nc*250;
fgrid=.5*(0:(ngrid-1))/(ngrid-1);
mag(1:ngrid/2)=`ones`_(1:ngrid/2);
mag(ngrid/2+1:ngrid)=0*`ones`_(1:ngrid/2);
weight=`ones`_(fgrid);
guess=`round`_(1:ngrid/nc:ngrid);
guess(nc+1)=ngrid;
guess(nc+2)=ngrid;
an=remez(guess,mag,fgrid,weight);