Exemple #1
0
// We use the set steps to find out where the cursor goes in the overview.
void OverviewVis::setSteps(float start, float stop, bool jump)
{
    Q_UNUSED(jump);

    if (!visProcessed)
        return;

    if (changeSource) {
        changeSource = false;
        return;
    }
    int startStep = roundeven(start);
    int stopStep = roundeven(stop);
    if (startStep < 0)
        startStep = 0;
    if (stopStep > maxStep)
        stopStep = maxStep;

    int width = size().width() - 2*border;
    startCursor = floor(width * start / 1.0 / maxStep);
    stopCursor = ceil(width * stop / 1.0 / maxStep);
    /* Pre-VIS when this was done with time rather than steps
    startCursor = stepPositions[startStep].first;
    while (startCursor >= rect().width()) // For no-data steps
    {
        startStep -= 2;
        startCursor = stepPositions[startStep].second;
    }
    stopCursor = stepPositions[stopStep].second;
    while (stopCursor < 0) // For no-data steps
    {
        stopStep += 2;
        stopCursor = stepPositions[stopStep].second;
    }
    startTime = (startCursor / 1.0  / (size().width() - 2 * border)) * (maxTime - minTime) + minTime;
    stopTime = (stopCursor / 1.0  / (size().width() - 2 * border)) * (maxTime - minTime) + minTime;
    //std::cout << startCursor << ", " << stopCursor << std::endl;
    */

    if (!closed)
        repaint();
}
Exemple #2
0
void unbiasround( double *mat, int *imat, int * imat1, int * rowparity,int *nrow, int *ncol, gsl_rng *r) {
  int i,j,k,k1;
  int  nr,nc;
  static int first_use = 1;
  gsl_rng *rng;
  if (r) rng = r;
  else {
      if (first_use){
          gsl_rng_env_setup();
          first_use=0;
      }
      rng  =  gsl_rng_alloc(gsl_rng_taus2);
  }
  gsl_rng_set(rng, 27);
  /*  Rprintf("Entering unbiasround, nrow = %d , ncol = %d \n",*nrow,*ncol); */

  nr = (*nrow) + 1;
  nc = (*ncol) + 1;

  /* Make an integer array
    Also  add an extra column so there are an even number of 1's in each row */
    for (i=0; i < *nrow; i++) {
      k1 = i + nr * *ncol;
      imat[k1] = 0;
      for (j=0; j < *ncol; j++) {
        imat[i + nr * j] = lrint( mat[i + *nrow * j]*(twobits));
      }
    }
    /* Add an extra row so there will be an even number of 1's in each column */
    for (j=0; j <= *ncol; j++) { //don't forget the lower-right corner.
        k1 = *nrow +j * nr ;
        imat[k1] = 0;
    }  

    for (k1=0; k1< bits; k1++) {
        roundeven(imat,imat1,rowparity,&nr,&nc, rng); 
        for (k=0, i=0; i < nr; i++) {
            for (j=0; j < nc; j++, k++) {
                imat[k] >>= 1;   /* Divide entire matrix by 2 using right shift 1 bit */
            }
        }
    }
}