Пример #1
0
int main (int argc, char * argv[]) {
  FILE * fp=NULL;
  int nsteps = 10000;
  vec * L=NULL;
  double * dist;
  int i, w;
  int nwalkers = 100;

  L=(vec*)malloc(nsteps*sizeof(vec));
  dist=(double*)malloc(nsteps*sizeof(vec));

  for (i=1;i<nsteps;i++) {
    dist[i]=0.0;
  }

  L[0].x=L[0].y=L[0].z=0.0;
  for (w=0;w<nwalkers;w++) {
    fprintf(stdout,"Walker %d...\n",w);
    for (i=1;i<nsteps;i++) {
      random_step(L,i,1.0);
      dist[i]+=diffnorm(&L[i],&L[0]);
    }
  }

  for (i=1;i<nsteps;i++) {
    dist[i]/=nwalkers;
  }

  fp=fopen("out.dat","w");
  for (i=0;i<nsteps;i++) {
    fprintf(fp,"%i %.5lf\n",i,dist[i]);
  }
  fclose(fp);

}
Пример #2
0
/**
 * Take one step.
 *
 * @throw CException should any of the following occur:
 *        1. Loop Walker has not started a walk.
 */
void CLoopWalker::step(void) {
	if (!m_started) {
		throw CException("Error! Loop Walker has not started a walk.");
	}

	// last position becomes the previous position
	m_last_step.p1.x = m_last_step.p2.x;
	m_last_step.p1.y = m_last_step.p2.y;

	if (m_correlated) {
		correlated_step();
	}
	else {
		random_step();
	}

	m_step_cnt++;
}