/*
 * This is like mem_initialize
 */
void
dram_page_initialize(iter_t iterations, void* cookie)
{
	int i;
	struct mem_state* state = (struct mem_state*)cookie;
	struct dram_page_state*	dstate = (struct dram_page_state*)cookie;

	if (iterations) return; 

	mem_initialize(iterations, cookie);

	for (i = 0; i < state->npages; i += dstate->group) {
		int	groupsize = dstate->group;
		if (groupsize > state->npages - i) {
			groupsize = state->npages - i;
		}
		regroup(state->pages + i, groupsize, cookie);
	}

	benchmark_loads(1, cookie);
}
Exemple #2
0
static double refine_clusters(
				 /* Computes ML clustering of data using Gaussian Mixture model.  */
				 /* Returns the values of the Rissen constant for the clustering. */
				 /* If all clusters are singular, the Sig data structure is       */
				 /* returned with Sig->nsubclasses==0 .                           */
				 struct ClassSig *Sig, int nbands)
{
    int nparams_clust;
    int num_params;
    int ndata_points;
    int singular;
    int repeat = 0;
    double rissanen_const;
    double change, ll_new, ll_old;
    double epsilon;

    G_debug(1, "refine_clusters()");

    /* compute number of parameters per cluster */
    nparams_clust = 1 + nbands + 0.5 * (nbands + 1) * nbands;

    /* compute number of data points */
    ndata_points = Sig->ClassData.npixels * nbands - total_nulls;

    /* compute epsilon */
    epsilon = nparams_clust * log((double)ndata_points);
    epsilon *= 0.01;

    /* Perform initial regrouping */
    ll_new = regroup(Sig, nbands);

    /* Perform EM algorithm */
    change = 2 * epsilon;
    do {
	ll_old = ll_new;
	singular = reestimate(Sig, nbands);

	if (singular == 0) {
	    ll_new = regroup(Sig, nbands);
	    change = ll_new - ll_old;
	    repeat = change > epsilon;
	}
	if (singular == 1) {
	    ll_new = regroup(Sig, nbands);
	    repeat = 1;
	}
	if (singular == 2) {
	    repeat = 0;
	}

    } while (repeat);

    /* compute Rissanens expression */
    if (Sig->nsubclasses > 0) {
	num_params = Sig->nsubclasses * nparams_clust - 1;
	rissanen_const =
	    -ll_new + 0.5 * num_params * log((double)ndata_points);
	rissanen_const /= ndata_points;
	return (rissanen_const);
    }
    else {
	return ((double)0);
    }
}
Exemple #3
0
void scanMusic(voice_index voice_, short *left_over)
{
  struct LOC_scanMusic V;
  Char buf[256], enote[256], xnote[256];
  boolean has_next = false, done = false;
  Char dur1, lastdur;
  music_word nscan;
  Char STR1[256];

  V.voice = voice_;
  strcpy(terminators, "d.x");
  resetInfo(V.voice, buf);
  *left_over = 0;
  V.store_macro = false;
  V.bar = full_bar;
  V.bar_length = 0;
  V.ngrace = 0;
  V.nmulti = 0;
  if (meternum == 0)
    V.bar = 32000;
  dur1 = duration(V.voice);
  lastdur = dur1;
  do {
    getNextMusWord(buf, V.note, &nscan);
    if (*V.note == '\0')
      break;
    V.count = 0;
    /*    if isNoteOrRest(note) and not (isPause(note) or isMultibarRest(note))
          then note:=toStandard(note); */
    V.doublex = (pos1('D', V.note) > 0);
    if (nscan == mword) {
      if (*V.note == '\0')
	error3(V.voice, "You may not end a line with a meter change");
      if (V.bar_length > 0)
	error3(V.voice, "Meter change only allowed at start of bar");
      else
	V.bar = barLength(V.note);
    } else if (nscan == rword) {
      if (!(isPause(V.note) || isMultiBarRest(V.note))) {
	processNote(V.note, xnote, dur1, &lastdur, &V.count);
	checkSticky(V.note, rest_attrib[V.voice-1]);
      }
    }
    if (*V.note != '\0')
      appendNote(V.voice, nscan);
    strcpy(enote, V.note);
    if (nscan == macro || nscan == endmacro)
      examineMacro(&V);
    if (nscan == abcdefg) {
      if (!multi_bar_rest && V.ngrace + V.nmulti == 0) {
	processNote(enote, xnote, dur1, &lastdur, &V.count);
	if (*xnote != '\0') {
	  checkSticky(enote, note_attrib[V.voice-1]);
	  appendToLine(V.voice, enote);
	  appendNote(V.voice, nscan);
	  strcpy(enote, xnote);
	}
	checkSticky(enote, note_attrib[V.voice-1]);
      }
    }
    appendToLine(V.voice, enote);
    if (*V.note == '\0')   /* !!! else word_bound[here]:=length(line); */
      done = true;
    sprintf(STR1, "%c", barsym);
    if (!strcmp(V.note, STR1)) {
      if (meternum == 0)
	error3(V.voice, "You may not use bar lines in barless music");
      else if (V.bar_length == 0)
	markBar(V.voice);
      else if (numberOfBars(V.voice) == 0 && V.bar_length < V.bar) {
	if (has_next)
	  has_next = false;   /*Should check whether pickups are equal*/
	else if (*left_over > 0)
	  error3(V.voice, "Bar is too short");
	*left_over = V.bar_length;
	V.bar_length = 0;
      }
    }
    if (nscan == nextvoice) {
      if (V.bar_length > 0)
	error3(V.voice, "Next voice before bar is full");
      else
	barForward(V.voice, -1);
      has_next = true;
    } else if (isPause(V.note))
      V.bar_length += V.bar;
    else if (!multi_bar_rest) {   /*do nothing*/
      if (!done && isNoteOrRest(V.note))
	countIt(&V);
      else
	maybeGroup(&V);
    }
    dur1 = lastdur;
    if (V.bar_length >= V.bar && V.ngrace + V.nmulti == 0 && !V.store_macro) {
      if (debugMode())
	printf("%d %d\n", V.voice, V.bar_length);
      barForward(V.voice, V.bar_length / V.bar);
      V.bar_length %= V.bar;
/* p2c: mtx.pas, line 268:
 * Note: Using % for possibly-negative arguments [317] */
    }
  } while (!done);
  setExtraLength(V.voice, V.bar_length);
  resetDuration(V.voice, dur1);
  regroup(V.voice);
}