示例#1
0
/*called with start_autocorrelations == 1 at beginning and after burn 
AUTOCTERMS is a list of the different lag values in steps for which autocorrelations are recorded

nextstepcalc[AUTOCTERMS] for each lag value, the next step number at which another term is accumulated for the autocorrelation term for that lag
nextpossave[AUTOCTERMS] for each lag value, the position in the autoc_pointer[][].vals array that should get the next value to be recorded
nextposcalc[AUTOCTERMS] for each lag value, the position in the autoc_pointer[][].vals array that is involved in the next autocorrelation calculation
maxpos[AUTOCTERMS] for each lag value, the length of the autoc_pointer[][].vals array 
*/
void
checkautoc (int start_autocorrelations, int burndone, int burnsteps, int currentid)
{
  int i, j;
  int autoc_vals_recorded = 0;
  static int nextstepcalc[AUTOCTERMS],
    nextpossave[AUTOCTERMS], nextposcalc[AUTOCTERMS], maxpos[AUTOCTERMS];
  if (start_autocorrelations == 1)
  {
    for (i = 0; i < num_autoc; i++)
      iautoc (autoc_pointer[i]);

    /* For ASSIGNMENT */
    if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
    {
      for (i = 0; i < num_autoc_a; i++)
        iautoc (autoc_a_pointer[i]);
    }

    for (i = 0; i < AUTOCTERMS; i++)
    {
      nextstepcalc[i] = CHECKAUTOCWAIT + AUTOCINT * AUTOCSTEPSCALAR + autoc_checkstep[i] * AUTOCSTEPSCALAR + (burndone * burnsteps);
      nextpossave[i] = 0;
      nextposcalc[i] = 0;
      if (autoc_checkstep[i] <= AUTOCINT)
        maxpos[i] = 0;
      else
        maxpos[i] = (autoc_checkstep[i] / AUTOCINT) - 1;
      assert (maxpos[i] < AUTOCNEXTARRAYLENGTH);
    }

  }
  else
  {
    for (i = 0; i < AUTOCTERMS; i++)
    {
      if (step == nextstepcalc[i])
      {
       if (!autoc_vals_recorded)
       {
         set_autoc_vals (autoc_vals, currentid);
	///AS: Now if these values are on different processors, I need to broadcast them
	/*if (numprocesses > 1) {
		try {
			MPI::COMM_WORLD.Bcast(autoc_vals, num_autoc, MPI::DOUBLE, currentid);
		} catch (MPI::Exception e) {
			std::cout << "Bcast in autoc failed\n";
			MPI::COMM_WORLD.Abort(-1);
		}
	}*/
         if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
           set_autoc_a_vals (autoc_a_vals); 
         autoc_vals_recorded = 1;
       }
        for (j = 0; j < num_autoc; j++)
        {
          fillautoc (&autoc_pointer[j][i], nextposcalc[i], autoc_vals[j]);
        }

        /* For ASSIGNMENT */
        if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
        {
          set_autoc_a_vals (autoc_a_vals);      // must define this function or something like it
          for (j = 0; j < num_autoc_a; j++)
          {
            fillautoc (&autoc_a_pointer[j][i], nextposcalc[i], autoc_a_vals[j]);
            //fillautoc (&(L[li].a_rec->v->ac[i]), nextposcalc[i],IMA_assignment2value (0, li));
          }
        }

        nextposcalc[i]++;
        if (nextposcalc[i] > maxpos[i])
          nextposcalc[i] = 0;
        nextstepcalc[i] += AUTOCINT * AUTOCSTEPSCALAR;
      }
    }
    if ((long) AUTOCINT * AUTOCSTEPSCALAR * (long) (step / (AUTOCINT * AUTOCSTEPSCALAR)) == step)
    {
      // JH 9/30/09 bad bug here,  this next line should have been included but wasn't, also maybe two lines
      //  after that for assignment 
      if (!autoc_vals_recorded)
      {
        set_autoc_vals (autoc_vals, currentid);
        if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
          set_autoc_a_vals (autoc_a_vals);    
      }

      for (i = 0; i < AUTOCTERMS; i++)
      {
        for (j = 0; j < num_autoc; j++)
          autoc_pointer[j][i].vals[nextpossave[i]] = autoc_vals[j];
        /* For ASSIGNMENT */
        if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
        {
          for (j = 0; j < num_autoc_a; j++)
          {
            autoc_a_pointer[j][i].vals[nextpossave[i]] = autoc_a_vals[j];
            //L[li].a_rec->v->ac[i].vals[nextpossave[i]] = IMA_assignment2value (0, li);
          }
        }

        nextpossave[i]++;
        if (nextpossave[i] > maxpos[i])
          nextpossave[i] = 0;
      }
    }
  }
}                               /*checkautoc */
示例#2
0
/*called with start_autocorrelations == 1 at beginning and after burn 
AUTOCTERMS is a list of the different lag values in steps for which autocorrelations are recorded

nextstepsave[AUTOCTERMS] for each lag value, the next step number at which a value is recorded 
nextstepcalc[AUTOCTERMS] for each lag value, the next step number at which another term is accumulated for the autocorrelation term for that lag
nextpossave[AUTOCTERMS] for each lag value, the position in the autoc_pointer[][].vals array that should get the next value to be recorded
nextposcalc[AUTOCTERMS] for each lag value, the position in the autoc_pointer[][].vals array that is involved in the next autocorrelation calculation
maxpos[AUTOCTERMS] for each lag value, the length of the autoc_pointer[][].vals array 
*/
void
checkautoc (int start_autocorrelations, int burndone, int burnsteps)
{
  int i, j;
  static int nextstepsave[AUTOCTERMS], nextstepcalc[AUTOCTERMS],
    nextpossave[AUTOCTERMS], nextposcalc[AUTOCTERMS], maxpos[AUTOCTERMS];
  static int autocintuse;
  if (start_autocorrelations == 1)
  {
    for (i = 0; i < num_autoc; i++)
      iautoc (autoc_pointer[i]);

    /* For ASSIGNMENT */
    if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
    {
      for (i = 0; i < num_autoc_a; i++)
        iautoc (autoc_a_pointer[i]);
    }

    autocintuse = AUTOCINT;
    for (i = 0; i < AUTOCTERMS; i++)
    {
      nextstepsave[i] = CHECKAUTOCWAIT + AUTOCINT * AUTOCSTEPSCALAR;
      nextstepcalc[i] = CHECKAUTOCWAIT + AUTOCINT * AUTOCSTEPSCALAR + autoc_checkstep[i] * AUTOCSTEPSCALAR + (burndone * burnsteps);
      nextpossave[i] = 0;
      nextposcalc[i] = 0;
      if (autoc_checkstep[i] <= AUTOCINT)
        maxpos[i] = 0;
      else
        maxpos[i] = (autoc_checkstep[i] / AUTOCINT) - 1;
      assert (maxpos[i] < AUTOCNEXTARRAYLENGTH);
    }

  }
  else
  {
    for (i = 0; i < AUTOCTERMS; i++)
    {
      if (step == nextstepcalc[i])
      {
        set_autoc_vals (autoc_vals);
        for (j = 0; j < num_autoc; j++)
        {
          fillautoc (&autoc_pointer[j][i], nextposcalc[i], autoc_vals[j]);
        }

        /* For ASSIGNMENT */
        if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
        {
          set_autoc_a_vals (autoc_a_vals);      // must define this function or something like it
          for (j = 0; j < num_autoc_a; j++)
          {
            fillautoc (&autoc_a_pointer[j][i], nextposcalc[i], autoc_a_vals[j]);
            //fillautoc (&(L[li].a_rec->v->ac[i]), nextposcalc[i],IMA_assignment2value (0, li));
          }
        }

        nextposcalc[i]++;
        if (nextposcalc[i] > maxpos[i])
          nextposcalc[i] = 0;
        nextstepcalc[i] += AUTOCINT * AUTOCSTEPSCALAR;
      }
    }
    if ((long) AUTOCINT * AUTOCSTEPSCALAR * (long) (step / (AUTOCINT * AUTOCSTEPSCALAR)) == step)
    {
      for (i = 0; i < AUTOCTERMS; i++)
      {
        for (j = 0; j < num_autoc; j++)
          autoc_pointer[j][i].vals[nextpossave[i]] = autoc_vals[j];
        /* For ASSIGNMENT */
        if (assignmentoptions[POPULATIONASSIGNMENT] == 1)
        {
          for (j = 0; j < num_autoc_a; j++)
          {
            autoc_a_pointer[j][i].vals[nextpossave[i]] = autoc_a_vals[j];
            //L[li].a_rec->v->ac[i].vals[nextpossave[i]] = IMA_assignment2value (0, li);
          }
        }

        nextpossave[i]++;
        if (nextpossave[i] > maxpos[i])
          nextpossave[i] = 0;
      }
    }
  }
}                               /*checkautoc */