/*--------------------------------------------------------------- */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { double *pdf ; double *indice; int N , M , n; /* Check input */ if(nrhs != 1) { mexErrMsgTxt("indice = multinomiale_resampling(p)"); } /* On récupère la taille du vecteurs u_ord */ M = mxGetM(prhs[0]); N = mxGetN(prhs[0]); if( ((N != 1) & (M > 1) ) | ((M != 1) & (N > 1) ) ) { mexErrMsgTxt("p must be (N x 1) or (1 x N)."); } n = max(M , N); /* Input 1 */ pdf = mxGetPr(prhs[0]); /* ---------- Output 1 ----------- */ plhs[0] = mxCreateDoubleMatrix(M , N , mxREAL); indice = mxGetPr(plhs[0]); /* Rand ~U[0,1] Seed initialization */ randini(); /*------ Main Call --------*/ particle_resampling(pdf , indice , n); }
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { double *pdf , *cdf , *uu; double *indice; int N , M , n; /* Check input */ if(nrhs != 1) { mexErrMsgTxt("indice = multinomiale_resampling(p)"); } /* On récupère la taille du vecteurs u_ord */ M = mxGetM(prhs[0]); N = mxGetN(prhs[0]); if( ((N != 1) & (M > 1) ) | ((M != 1) & (N > 1) ) ) { mexErrMsgTxt("p must be (N x 1) or (1 x N)."); } n = max(M , N); /* Input 1 */ pdf = mxGetPr(prhs[0]); /* Output 1 */ plhs[0] = mxCreateDoubleMatrix(M , N , mxREAL); indice = mxGetPr(plhs[0]); /* vecteur temporaire */ cdf = (double *)mxMalloc(n*sizeof(double)); uu = (double *)mxMalloc(n*sizeof(double)); /* Rand ~U[0,1] Seed initialization */ randini(); /* Resampling */ particle_resampling(pdf , cdf , uu , indice , n); /* Free ressources */ mxFree(uu); mxFree(cdf); }