diff options
Diffstat (limited to 'misc/examples/gauss1.c')
| -rw-r--r-- | misc/examples/gauss1.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/misc/examples/gauss1.c b/misc/examples/gauss1.c index 675ff338..519a7895 100644 --- a/misc/examples/gauss1.c +++ b/misc/examples/gauss1.c @@ -29,27 +29,27 @@ int main() stc64_normalf_t dist = stc64_normalf_new(Mean, StdDev); // Create and init histogram vec and map with defered destructors: - c_auto (cvec_ii, histvec) - c_auto (cmap_ii, histmap) + c_AUTO (cvec_ii, histvec) + c_AUTO (cmap_ii, histmap) { - c_forrange (N) { - int index = (int) round( stc64_normalf(&rng, &dist) ); + c_FORRANGE (N) { + int index = (int)round( stc64_normalf(&rng, &dist) ); cmap_ii_insert(&histmap, index, 0).ref->second += 1; } // Transfer map to vec and sort it by map keys. - c_foreach (i, cmap_ii, histmap) + c_FOREACH (i, cmap_ii, histmap) cvec_ii_push(&histvec, (cmap_ii_value){i.ref->first, i.ref->second}); cvec_ii_sort(&histvec); // Print the gaussian bar chart - c_auto (cstr, bar) - c_foreach (i, cvec_ii, histvec) { - size_t n = (size_t) (i.ref->second * StdDev * Scale * 2.5 / (float)N); + c_FOREACH (i, cvec_ii, histvec) { + int n = (int)(i.ref->second * StdDev * Scale * 2.5 / N); if (n > 0) { - cstr_resize(&bar, n, '*'); - printf("%4d %s\n", i.ref->first, cstr_str(&bar)); + printf("%4d ", i.ref->first); + c_FORRANGE (n) printf("*"); + puts(""); } } } |
