diff --git a/ex-3/main.c b/ex-3/main.c index d5312ef..df87931 100644 --- a/ex-3/main.c +++ b/ex-3/main.c @@ -85,16 +85,12 @@ int main(int argc, char **argv) { fputs("# event sampling\n\n", stderr); fprintf(stderr, "generating %ld events...", opts.num_events); struct event *e; -// for (size_t i = 0; i < s.size; i++){ -// e = &s.events[i]; -// do { -// e->th = acos(1 - 2*gsl_rng_uniform(r)); -// e->ph = 2 * M_PI * gsl_rng_uniform(r); -// } while(0.2 * gsl_rng_uniform(r) > distr(def_par, e)); for (size_t i = 0; i < s.size; i++){ e = &s.events[i]; - e->th = acos(1 - 2*gsl_rng_uniform(r)); - e->ph = 2 * M_PI * gsl_rng_uniform(r); + do { + e->th = acos(1 - 2*gsl_rng_uniform(r)); + e->ph = 2 * M_PI * gsl_rng_uniform(r); + } while(0.2 * gsl_rng_uniform(r) > distr(def_par, e)); // update the histogram gsl_histogram2d_increment(hist, e->th, e->ph);