Skip to content
Prev 2108 / 21312 Next

[Bioc-devel] R_CheckUserInterrupt guidelines (was Re: R_CheckUserInterrupt in IRanges)

hi, let me take the chance that you're talking about this to check
whether anybody finds anything odd in the following strategy. in the
package i develop (qpgraph - devel version) for the computationally
intensive C-loops i calculate the percentage of progress and each time
this percentage changes in one integer unit i call
R_CheckUserInterrupt() and i also take the chance to process
window-system events with R_ProcessEvents() (if i understand correctly
this is what this function does). here is the code snippet:

ppct=-1;
k=0;

for (i = 0; i < l_int-1; i++) {
  int i2 = INTEGER(pairup_ij_int)[i] - 1;

  for (j = i+1; j < l_int; j++) {
    int j2 = INTEGER(pairup_ij_int)[j] - 1;

    REAL(nrrMatrix)[i2+j2*n_var] = qp_edge_nrr(REAL(S),n_var,
INTEGER(N)[0], i2, j2, q, INTEGER(nTests)[0],REAL(alpha)[0]);

    REAL(nrrMatrix)[j2+i2*n_var] = REAL(nrrMatrix)[i2+j2*n_var];
    k++;
    pct = (int) ((k * 100) / n_adj);
    if (pct != ppct) {
      if (INTEGER(verbose)[0]) { ## show progress when
        if (pct % 10 == 0)       ## verbose=TRUE
          Rprintf("%d",pct);
        else
          Rprintf(".",pct);
        R_FlushConsole();
      }
      R_CheckUserInterrupt();
#ifdef Win32
      R_ProcessEvents();
#endif
#ifdef HAVE_AQUA
      R_ProcessEvents();
#endif
      ppct = pct;
    }
  }
}

let me clarify that the double nested loop iterates more or less through
every pair of variables and thus this computation grows quadratically in
the number of input variables in the dataset.

robert.
On Mon, 2010-01-11 at 20:07 -0800, Henrik Bengtsson wrote: