#include #include #include #include #include /* USAGE: i) compile with: gcc -lm bootstrap.c -o bootstrap ii) run with: ./bootstrap N p n_runs print_images */ /* first define some random number generators*/ float randomf(void) { float x = (float)rand()/(float)(RAND_MAX); return x; } int randomi(int N) { int x = rand()%N; return x; } /* system initializer */ int initialize(int N, float p, int* grid, int* active_x, int* active_y) { int n_active =0; int n_alive =p*N*N; int i,j; while (n_active0) { if (print_images) print_grid(N, grid); /*collect the sites that become active at the current step and save them for the next step */ changes = 0; for (int i=0; i=2 ) { *(changes_x+changes) = *(nbrs+j); *(changes_y+changes) = *(nbrs+j+4); changes++; } } } /* then activate the collected sites */ for (int i=0; i