MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuale Utente Pagina 92

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 408
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 91
2 Creating C Language MEX-Files
2-32
if(IsNonZero(pr[i]) || (cmplx && IsNonZero(pi[i]))) {
/* Check to see if non-zero element will fit in
* allocated output array. If not, increase
* percent_sparse by 10%, recalculate nzmax, and augment
* the sparse array.
*/
if(k >= nzmax) {
int oldnzmax = nzmax;
percent_sparse += 0.1;
nzmax = (int)ceil((double)m*(double)n*percent_sparse);
/* Make sure nzmax increases atleast by 1. */
if(oldnzmax == nzmax)
nzmax++;
mxSetNzmax(plhs[0], nzmax);
mxSetPr(plhs[0], mxRealloc(sr, nzmax*sizeof(double)));
if(si != NULL)
mxSetPi(plhs[0], mxRealloc(si, nzmax*sizeof(double)));
mxSetIr(plhs[0], mxRealloc(irs, nzmax*sizeof(int)));
sr = mxGetPr(plhs[0]);
si = mxGetPi(plhs[0]);
irs = mxGetIr(plhs[0]);
}
sr[k] = pr[i];
if(cmplx) {
si[k] = pi[i];
}
irs[k] = i;
k++;
}
}
pr += m;
pi += m;
}
jcs[n] = k;
}
Vedere la pagina 91
1 2 ... 87 88 89 90 91 92 93 94 95 96 97 ... 407 408

Commenti su questo manuale

Nessun commento