diff options
Diffstat (limited to 'misc/examples/gauss2.c')
| -rw-r--r-- | misc/examples/gauss2.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/misc/examples/gauss2.c b/misc/examples/gauss2.c index c531e5e3..79397f0c 100644 --- a/misc/examples/gauss2.c +++ b/misc/examples/gauss2.c @@ -22,21 +22,22 @@ int main() stc64_normalf_t dist = stc64_normalf_new(Mean, StdDev); // Create and init histogram map with defered destruct - c_auto (csmap_int, mhist) - { - c_forrange (N) { - int index = (int) round( stc64_normalf(&rng, &dist) ); - csmap_int_insert(&mhist, index, 0).ref->second += 1; - } + csmap_int mhist = {0}; + cstr bar = {0}; + + c_forrange (N) { + int index = (int) round( stc64_normalf(&rng, &dist) ); + csmap_int_insert(&mhist, index, 0).ref->second += 1; + } - // Print the gaussian bar chart - c_auto (cstr, bar) - c_forpair (index, count, csmap_int, mhist) { - int n = (int)((float)*_.count * StdDev * Scale * 2.5f / (float)N); - if (n > 0) { - cstr_resize(&bar, n, '*'); - printf("%4d %s\n", *_.index, cstr_str(&bar)); - } + // Print the gaussian bar chart + c_forpair (index, count, csmap_int, mhist) { + int n = (int)((float)*_.count * StdDev * Scale * 2.5f / (float)N); + if (n > 0) { + cstr_resize(&bar, n, '*'); + printf("%4d %s\n", *_.index, cstr_str(&bar)); } } + cstr_drop(&bar); + csmap_int_drop(&mhist); } |
