1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double*ind,*t1,*t2,*size,*L,*sr;
mxArray *inda,*t1a,*t2a,*sizea,*La,*sparse;
mwIndex *irs,*jcs;
inda=mxDuplicateArray(prhs[0]);
t1a=mxDuplicateArray(prhs[1]);
t2a=mxDuplicateArray(prhs[2]);
La=mxDuplicateArray(prhs[3]);
sizea=mxDuplicateArray(prhs[4]);
ind=mxGetPr(inda);
t1=mxGetPr(t1a);
t2=mxGetPr(t2a);
L=mxGetPr(La);
size=mxGetPr(sizea);
mxComplexity cmplx=mxREAL;
sparse=plhs[0]=mxCreateSparse(size[0],size[1]*size[2],size[0],cmplx);
sr = mxGetPr(sparse);
irs = mxGetIr(sparse);
jcs = mxGetJc(sparse);
int k;
k=0;
for(int j=0;j<size[0];j++)
{
jcs[j] = k;
if(1-t2[j]>0)
{
printf("\n 1-t2[%d]=%f",j,1-t2[j]);
sr[k]=1-t2[j];
irs[k]=ind[j];
k++;
}
if(t1[j]>0)
{
printf("\n t1[%d]=%f",j,t1[j]);
sr[k]=t1[j];
irs[k]=ind[j]+size[2]+1;
k++;
}
if(t2[j]-t1[j]>0)
{
printf("\n t2[%d]-t1[%d]=%f",j,j,t2[j]-t1[j]);
sr[k]=t2[j]-t1[j];
irs[k]=ind[j]+L[j];
k++;
}
}
jcs[(int)size[0]]=k;
mexCallMATLAB(0,NULL,0,NULL,"pause");
} |
Partager