| 44 | } |
| 45 | |
| 46 | void compare_2d(unsigned n, int distrib) { |
| 47 | auto r = random_array(n, distrib); |
| 48 | |
| 49 | double best = std::numeric_limits<double>::max(); |
| 50 | for (unsigned k = 0; k < 20; ++k) { |
| 51 | gsl_histogram2d* h = gsl_histogram2d_alloc(100, 100); |
| 52 | gsl_histogram2d_set_ranges_uniform(h, 0, 1, 0, 1); |
| 53 | auto t = clock(); |
| 54 | for (unsigned i = 0; i < n / 2; ++i) |
| 55 | gsl_histogram2d_increment(h, r[2 * i], r[2 * i + 1]); |
| 56 | t = clock() - t; |
| 57 | best = std::min(best, double(t) / CLOCKS_PER_SEC); |
| 58 | gsl_histogram2d_free(h); |
| 59 | } |
| 60 | printf("gsl %.3f\n", best); |
| 61 | } |
| 62 | |
| 63 | int main(int argc, char** argv) { |
| 64 | constexpr unsigned nfill = 6000000; |