void compute_C2() { struct individual *focal, *neighbour; double distance; double x1,x2,y1,y2; int dx,dy; double bin; int bin_no; int spp1, spp2; int i,j, p,q, x,y,k; double norm; double C2[spp_no][spp_no][2*bin_max-1][2*bin_max-1]; int num=0; double area, area1; for(i=0;ispecies!=environment)*/ if(graphic_output==1) spot(focal->xpos*4.0, focal->ypos*4.0, focal->species); { x1 = focal->xpos; y1 = focal->ypos; spp1 = focal->species; for(;;) { x2 = neighbour->xpos; y2 = neighbour->ypos; spp2 = neighbour->species; /***Compute smallest distance to neighbour inc. periodic boundaries***/ distance = get_distance(x1,y1, x2,y2, (double)bin_max*binwidth); bin = distance/binwidth; bin_no = (int)bin; bin = x1 - x2; bin = bin - 0.5 * binwidth; bin = bin/(binwidth); bin = ceil(bin); x = (int)bin; bin = y1 - y2; bin = bin - 0.5 * binwidth; bin = bin/(binwidth); bin = ceil(bin); y = (int)bin; x = x + bin_max-1; y = y + bin_max-1; /***If distance within the maximum radius of the second moment increment C2 bin***/ if(x>=0 && y>=0 && x<2*bin_max-1 && y<2*bin_max-1) if(neighbour!= focal) { /* if(x==bin_max-1) printf("x1: %lf\tx2: %lf\tx: %d\n", x1,x2,x);*/ C2[spp1][spp2][x][y]+=1.0; } if(neighbour->next == NULL) break; else neighbour = neighbour->next; } } focal = focal->next; }while(focal!=NULL); /*if(graphic_output==1) swapbuffers(); */ for(i=0; i<2*bin_max-1; i++) for(j=0; j<2*bin_max-1; j++) { if(i==bin_max-1 && j>=bin_max-1) { fprintf(C2_file, "\n%lf\t%d\t%d\t", elapsed, i-bin_max+1, j-bin_max+1); } for(spp1=0; spp1=bin_max-1) { fprintf(C2_file, "%lf\t", C2[spp1][spp2][i][j]); fflush(C2_file); } } /* fprintf(C2_file, "\n"); */ } fprintf(C2_file, "\n\n"); printf("GETSHERE\n"); }