summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/gauss2.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
committerTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
commite35036deef4fc8f17cc9221e2e666dfdb832ba78 (patch)
treeb41e45015be7454ef3f82092b558da6b365d6a57 /misc/examples/gauss2.c
parentede39bc98a758674485796174ea860515ec281e6 (diff)
downloadSTC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.tar.gz
STC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.zip
More RAII cleanup in examples. Also removed gauss1.c and new_deq.c
Diffstat (limited to 'misc/examples/gauss2.c')
-rw-r--r--misc/examples/gauss2.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/misc/examples/gauss2.c b/misc/examples/gauss2.c
index 79397f0c..be514c12 100644
--- a/misc/examples/gauss2.c
+++ b/misc/examples/gauss2.c
@@ -6,7 +6,7 @@
// Declare int -> int sorted map.
#define i_key int
-#define i_val size_t
+#define i_val int
#include <stc/csmap.h>
int main()
@@ -22,16 +22,16 @@ int main()
stc64_normalf_t dist = stc64_normalf_new(Mean, StdDev);
// Create and init histogram map with defered destruct
- csmap_int mhist = {0};
+ csmap_int hist = {0};
cstr bar = {0};
c_forrange (N) {
- int index = (int) round( stc64_normalf(&rng, &dist) );
- csmap_int_insert(&mhist, index, 0).ref->second += 1;
+ int index = (int)round( stc64_normalf(&rng, &dist) );
+ csmap_int_insert(&hist, index, 0).ref->second += 1;
}
// Print the gaussian bar chart
- c_forpair (index, count, csmap_int, mhist) {
+ c_forpair (index, count, csmap_int, hist) {
int n = (int)((float)*_.count * StdDev * Scale * 2.5f / (float)N);
if (n > 0) {
cstr_resize(&bar, n, '*');
@@ -39,5 +39,5 @@ int main()
}
}
cstr_drop(&bar);
- csmap_int_drop(&mhist);
+ csmap_int_drop(&hist);
}