-
Notifications
You must be signed in to change notification settings - Fork 4
/
binning.c
50 lines (41 loc) · 1.03 KB
/
binning.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @file binning.c
* @author Seung Woo Son
* @date July 2019
* @brief helper routines for binning mechanisms
* (C) 2019 University of Massachusetts Lowell.
See LICENSE in the top-level directory.
*/
#include "dctz.h"
void gen_bins(double min, double max, double *bin_center, int nbins, double error_bound)
{
double bin_width;
int i;
bin_width = error_bound*2*BRSF;
bin_center[0] = 0.0;
for (i=1; i<nbins; i++) {
int tmp_i = (i%2) ? ((i/2)+1) : -(i/2);
bin_center[i] = tmp_i*bin_width;
}
#ifdef DEBUG
for (i=0; i<nbins; i++)
printf("bin_center[%d]: %e, ", i, bin_center[i]);
printf("\n");
#endif
}
void gen_bins_f(float min, float max, float *bin_center, int nbins, float error_bound)
{
float bin_width;
int i;
bin_width = error_bound*2*BRSF;
bin_center[0] = 0.0;
for (i=1; i<nbins; i++) {
int tmp_i = (i%2) ? ((i/2)+1) : -(i/2);
bin_center[i] = tmp_i*bin_width;
}
#ifdef DEBUG
for (i=0; i<nbins; i++)
printf("bin_center[%d]: %e, ", i, bin_center[i]);
printf("\n");
#endif
}