diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-05-14 09:41:17 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-05-14 09:41:17 +0100 |
commit | e03859170afb1c0cc262924f8685039869782691 (patch) | |
tree | a1a6d3b4c7f8856ca1b6f97cbd4a1c6dbdde3972 | |
parent | 15788d264e9804a876c88167cb18ad506c7ede05 (diff) |
better-overlap
-rw-r--r-- | ministat.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -125,8 +125,8 @@ double student [NSTUDENT + 1][NCONF] = { /* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 } }; -#define MAX_DS 8 -static char symbol[MAX_DS] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' }; +#define MAX_DS 3 +static char symbol[] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' }; struct dataset { char *name; @@ -218,7 +218,7 @@ static void Vitals(struct dataset *ds, int flag) { - printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", symbol[flag], + printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", symbol[1 << flag], ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds)); printf("\n"); } @@ -261,7 +261,7 @@ struct plot { double x0, dx; int height; - char *data; + unsigned char *data; char **bar; int separate_bars; int num_datasets; @@ -322,7 +322,7 @@ PlotSet(struct dataset *ds, int val) return; if (pl->separate_bars) - bar = val-1; + bar = val; else bar = 0; @@ -365,7 +365,7 @@ PlotSet(struct dataset *ds, int val) j = 1; i = x; } - pl->data[j * pl->width + x] |= val; + pl->data[j * pl->width + x] |= 1 << val; } if (!isnan(Stddev(ds))) { x = floor(((Avg(ds) - Stddev(ds)) - pl->x0) / pl->dx); @@ -403,10 +403,7 @@ DumpPlot(void) putchar('|'); for (j = 0; j < pl->width; j++) { k = pl->data[(pl->height - i) * pl->width + j]; - if (k >= 0 && k < MAX_DS) - putchar(symbol[k]); - else - printf("[%02x]", k); + putchar(symbol[k]); } putchar('|'); putchar('\n'); @@ -603,7 +600,7 @@ main(int argc, char **argv) ds[0] = ReadSet("-", column, delim); nds = 1; } else { - if (argc > (MAX_DS - 1)) + if (argc > MAX_DS) usage("Too many datasets."); nds = argc; for (i = 0; i < nds; i++) @@ -611,20 +608,20 @@ main(int argc, char **argv) } for (i = 0; i < nds; i++) - printf("%c %s\n", symbol[i+1], ds[i]->name); + printf("%c %s\n", symbol[1 << i], ds[i]->name); if (!flag_n && !flag_q) { SetupPlot(termwidth, flag_s, nds); for (i = 0; i < nds; i++) DimPlot(ds[i]); for (i = 0; i < nds; i++) - PlotSet(ds[i], i + 1); + PlotSet(ds[i], i); DumpPlot(); } VitalsHead(); - Vitals(ds[0], 1); + Vitals(ds[0], 0); for (i = 1; i < nds; i++) { - Vitals(ds[i], i + 1); + Vitals(ds[i], i); if (!flag_n) Relative(ds[i], ds[0], ci); } |