home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 8.ddi / SIGNAL.DI$ / REMEZFG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-07  |  1.3 KB  |  73 lines

  1. /*
  2.  * remezfg.c is a C version of the front end for the Remez Filter Design 
  3.  * Program
  4.  */
  5. #include "mex.h"
  6.  
  7. #ifdef __STDC__
  8. void mexFunction(
  9.     int        nlhs,
  10.     Matrix    *plhs[],
  11.     int        nrhs,
  12.     Matrix    *prhs[]
  13.     )
  14. #else
  15. mexFunction(nlhs, plhs, nrhs, prhs)
  16. int nlhs, nrhs;
  17. Matrix *plhs[], *prhs[];
  18. #endif
  19. {
  20.     int nfilt, jtype, nbands, lgrid, nfcns;
  21.     double *edge, *fx, *wtx, *h;
  22.     int m, n, mm, nn;
  23.  
  24.     if (nrhs != 5)
  25.         mexErrMsgTxt("REMEZF requires five input arguments");
  26.  
  27.     if (nlhs != 1)
  28.         mexErrMsgTxt("REMEZF requires one output argument");
  29.  
  30.     nfilt = (int)*mxGetPr(prhs[0]);
  31.  
  32.     jtype = (int)*mxGetPr(prhs[4]);
  33.  
  34.     m = mxGetM(prhs[2]);
  35.     n = mxGetN(prhs[2]);
  36.  
  37.     if (m > n)
  38.         nbands = m;
  39.     else
  40.         nbands = n;
  41.  
  42.     if (m != 1  &&  n != 1)
  43.         mexErrMsgTxt("REMEZF requires vector inputs");
  44.  
  45.     lgrid = 16;
  46.  
  47.     mm = mxGetM(prhs[2]);
  48.     nn = mxGetN(prhs[2]);
  49.  
  50.     if (mm != m  ||  nn != n)
  51.         mexErrMsgTxt("REMEZF requires that FX and WTX be consistent");
  52.  
  53.     mm = mxGetM(prhs[1]);
  54.     nn = mxGetN(prhs[1]);
  55.  
  56.     if (mm != 2*m  &&  nn != 2*n)
  57.         mexErrMsgTxt("REMEZF requires that EDGE be consistent with FX");
  58.  
  59.     edge = mxGetPr(prhs[1]);
  60.     fx   = mxGetPr(prhs[2]);
  61.     wtx  = mxGetPr(prhs[3]);
  62.  
  63.     nfcns = nfilt/2;
  64.     if ((nfilt - 2*nfcns) == 1)
  65.         nfcns++;
  66.  
  67.     plhs[0] = mxCreateFull(nfcns, 1, 0);
  68.  
  69.     h = mxGetPr(prhs[0]);
  70.  
  71.     remezf_(&nfilt, &jtype, &nbands, &lgrid, edge, fx, wtx, h);
  72. }
  73.