home *** CD-ROM | disk | FTP | other *** search
- /*
- * remezfg.c is a C version of the front end for the Remez Filter Design
- * Program
- */
- #include "mex.h"
-
- #ifdef __STDC__
- void mexFunction(
- int nlhs,
- Matrix *plhs[],
- int nrhs,
- Matrix *prhs[]
- )
- #else
- mexFunction(nlhs, plhs, nrhs, prhs)
- int nlhs, nrhs;
- Matrix *plhs[], *prhs[];
- #endif
- {
- int nfilt, jtype, nbands, lgrid, nfcns;
- double *edge, *fx, *wtx, *h;
- int m, n, mm, nn;
-
- if (nrhs != 5)
- mexErrMsgTxt("REMEZF requires five input arguments");
-
- if (nlhs != 1)
- mexErrMsgTxt("REMEZF requires one output argument");
-
- nfilt = (int)*mxGetPr(prhs[0]);
-
- jtype = (int)*mxGetPr(prhs[4]);
-
- m = mxGetM(prhs[2]);
- n = mxGetN(prhs[2]);
-
- if (m > n)
- nbands = m;
- else
- nbands = n;
-
- if (m != 1 && n != 1)
- mexErrMsgTxt("REMEZF requires vector inputs");
-
- lgrid = 16;
-
- mm = mxGetM(prhs[2]);
- nn = mxGetN(prhs[2]);
-
- if (mm != m || nn != n)
- mexErrMsgTxt("REMEZF requires that FX and WTX be consistent");
-
- mm = mxGetM(prhs[1]);
- nn = mxGetN(prhs[1]);
-
- if (mm != 2*m && nn != 2*n)
- mexErrMsgTxt("REMEZF requires that EDGE be consistent with FX");
-
- edge = mxGetPr(prhs[1]);
- fx = mxGetPr(prhs[2]);
- wtx = mxGetPr(prhs[3]);
-
- nfcns = nfilt/2;
- if ((nfilt - 2*nfcns) == 1)
- nfcns++;
-
- plhs[0] = mxCreateFull(nfcns, 1, 0);
-
- h = mxGetPr(prhs[0]);
-
- remezf_(&nfilt, &jtype, &nbands, &lgrid, edge, fx, wtx, h);
- }
-