1 / 9

Przykład zastąpienia m-pliku na C

Przykład zastąpienia m-pliku na C. Funkcja sqcum w m-pliku. Funkcja sqcum w C. #include <math.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { double *x, *y ; double sqsum ; int i, m, n, N ; if(nrhs != 1) {

nieve
Download Presentation

Przykład zastąpienia m-pliku na C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Przykład zastąpienia m-pliku na C Funkcja sqcum w m-pliku

  2. Funkcja sqcum w C #include <math.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { double *x, *y ; double sqsum ; int i, m, n, N ; if(nrhs != 1) { mexErrMsgTxt("SQCUM: Only one input argument allowed.") ; } if(nlhs != 1) { mexErrMsgTxt("SQCUM: Only one output argument allowed.") ; } m = mxGetM(prhs[0]) ; n = mxGetN(prhs[0]) ; if(((m > 1) && (n > 1)) || !mxIsDouble(prhs[0])) { mexErrMsgTxt("TRGtest: Only one dimension input vector allowed.") ; } N = m*n ; x = mxGetPr(prhs[0]); plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL) ; y = mxGetPr(plhs[0],y) ; sqsum = x[0] ; y[0] = x[0] ; for(i = 1 ; i < N ; i++) { sqsum = sqsum - x[i]*(sqsum > 0 ? 1 : -1) ; y[i] = sqsum ; } }

  3. Funkcja sqcum w C #include <math.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { double *x, *y ; double sqsum ; int i, m, n, N ; if(nrhs != 1) { mexErrMsgTxt("SQCUM: Only one input argument allowed.") ; } if(nlhs != 1) { mexErrMsgTxt("SQCUM: Only one output argument allowed.") ; } m = mxGetM(prhs[0]) ; n = mxGetN(prhs[0]) ; if(((m > 1) && (n > 1)) || !mxIsDouble(prhs[0])) { mexErrMsgTxt("TRGtest: Only one dimension input vector allowed.") ; } N = m*n ; x = mxGetPr(prhs[0]); plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL) ; y = mxGetPr(plhs[0],y) ; sqsum = x[0] ; y[0] = x[0] ; for(i = 1 ; i < N ; i++) { sqsum = sqsum - x[i]*(sqsum > 0 ? 1 : -1) ; y[i] = sqsum ; } }

  4. Funkcja sqcum w C #include <math.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { double *x, *y ; double sqsum ; int i, m, n, N ; if(nrhs != 1) { mexErrMsgTxt("SQCUM: Only one input argument allowed.") ; } if(nlhs != 1) { mexErrMsgTxt("SQCUM: Only one output argument allowed.") ; } m = mxGetM(prhs[0]) ; n = mxGetN(prhs[0]) ; if(((m > 1) && (n > 1)) || !mxIsDouble(prhs[0])) { mexErrMsgTxt("TRGtest: Only one dimension input vector allowed.") ; } N = m*n ; x = mxGetPr(prhs[0]); plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL) ; y = mxGetPr(plhs[0],y) ; sqsum = x[0] ; y[0] = x[0] ; for(i = 1 ; i < N ; i++) { sqsum = sqsum - x[i]*(sqsum > 0 ? 1 : -1) ; y[i] = sqsum ; } }

  5. Funkcja sqcum w C #include <math.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { double *x, *y ; double sqsum ; int i, m, n, N ; if(nrhs != 1) { mexErrMsgTxt("SQCUM: Only one input argument allowed.") ; } if(nlhs != 1) { mexErrMsgTxt("SQCUM: Only one output argument allowed.") ; } m = mxGetM(prhs[0]) ; n = mxGetN(prhs[0]) ; if(((m > 1) && (n > 1)) || !mxIsDouble(prhs[0])) { mexErrMsgTxt("TRGtest: Only one dimension input vector allowed.") ; } N = m*n ; x = mxGetPr(prhs[0]); plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL) ; y = mxGetPr(plhs[0],y) ; sqsum = x[0] ; y[0] = x[0] ; for(i = 1 ; i < N ; i++) { sqsum = sqsum - x[i]*(sqsum > 0 ? 1 : -1) ; y[i] = sqsum ; } }

More Related