XS/bins.xs

filter: Statementstmt 100% 52 / 52 Branchbran 82.5% 33 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 92.3% 85 / 92 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« histogram.c ↑ Summary _mt.c »
1 MODULE = Math::SimpleHisto::XS PACKAGE = Math::SimpleHisto::XS
2  
3  
4 void
5 bin_centers(self)
6 simple_histo_1d* self
7 PREINIT:
8 AV* av;
9 SV* rv;
10 int i, n;
11 double x;
12 PPCODE:
13 34 av = newAV();
14 34 rv = (SV*)newRV((SV*)av);
15 34 SvREFCNT_dec(av);
16 34 n = self->nbins;
17 34 av_fill(av, n-1);
18 34 ▶ if (self->bins == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (self->bins == NULL) { 18 16 34
19 18 double binsize = self->binsize;
20 18 x = self->min + 0.5*binsize;
21 381 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 363 18 381
22 363 av_store(av, i, newSVnv(x));
23 363 x += binsize;
24 }
25 }
26 else {
27 double* bins = self->bins;
28 101 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 85 16 101
29 85 x = 0.5*(bins[i] + bins[i+1]);
30 85 av_store(av, i, newSVnv(x));
31 }
32 }
33 34 ▶ XPUSHs(sv_2mortal(rv));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(rv)); 0 34 34
34  
35  
36 double
37 bin_center(self, ibin)
38 simple_histo_1d* self
39 unsigned int ibin
40 CODE:
41 42 ▶ HS_ASSERT_BIN_RANGE(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
HS_ASSERT_BIN_RANGE(self, ibin); 0 42 42
42 42 ▶ RETVAL = HS_BIN_CENTER(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = HS_BIN_CENTER(self, ibin); 18 24 42
43 OUTPUT: RETVAL
44  
45  
46 double
47 bin_lower_boundary(self, ibin)
48 simple_histo_1d* self
49 unsigned int ibin
50 CODE:
51 40 ▶ HS_ASSERT_BIN_RANGE(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
HS_ASSERT_BIN_RANGE(self, ibin); 0 40 40
52 40 ▶ RETVAL = HS_BIN_LOWER_BOUNDARY(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = HS_BIN_LOWER_BOUNDARY(self, ibin); 18 22 40
53 OUTPUT: RETVAL
54  
55  
56 double
57 bin_upper_boundary(self, ibin)
58 simple_histo_1d* self
59 unsigned int ibin
60 CODE:
61 44 ▶ HS_ASSERT_BIN_RANGE(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
HS_ASSERT_BIN_RANGE(self, ibin); 0 44 44
62 44 ▶ RETVAL = HS_BIN_UPPER_BOUNDARY(self, ibin);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = HS_BIN_UPPER_BOUNDARY(self, ibin); 18 26 44
63 OUTPUT: RETVAL
64  
65  
66 void
67 bin_lower_boundaries(self)
68 simple_histo_1d* self
69 PREINIT:
70 AV* av;
71 SV* rv;
72 int i, n;
73 PPCODE:
74 /* inlines HS_BIN_LOWER_BOUNDARY somewhat for unrolling */
75 2 av = newAV();
76 2 rv = (SV*)newRV((SV*)av);
77 2 SvREFCNT_dec(av);
78 2 n = self->nbins;
79 2 av_fill(av, n-1);
80 2 ▶ if (self->bins == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (self->bins == NULL) { 1 1 2
81 1 double binsize = self->binsize;
82 1 double x = self->min;
83 11 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 10 1 11
84 10 av_store(av, i, newSVnv(x));
85 10 x += binsize;
86 }
87 }
88 else {
89 double* bins = self->bins;
90 11 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 10 1 11
91 10 av_store(av, i, newSVnv(bins[i]));
92 }
93 }
94 2 ▶ XPUSHs(sv_2mortal(rv));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(rv)); 0 2 2
95  
96  
97 void
98 bin_upper_boundaries(self)
99 simple_histo_1d* self
100 PREINIT:
101 AV* av;
102 SV* rv;
103 int i, n;
104 double x, binsize;
105 PPCODE:
106 /* inlines HS_BIN_UPPER_BOUNDARY somewhat for unrolling */
107 2 av = newAV();
108 2 rv = (SV*)newRV((SV*)av);
109 2 SvREFCNT_dec(av);
110 2 n = self->nbins;
111 2 av_fill(av, n-1);
112 2 ▶ if (self->bins == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (self->bins == NULL) { 1 1 2
113 1 binsize = self->binsize;
114 1 x = self->min;
115 11 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 10 1 11
116 10 x += binsize;
117 10 av_store(av, i, newSVnv(x));
118 }
119 }
120 else {
121 double* bins = self->bins;
122 11 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 10 1 11
123 10 av_store(av, i, newSVnv(bins[i+1]));
124 }
125 }
126 2 ▶ XPUSHs(sv_2mortal(rv));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(rv)); 0 2 2
127  
128  
129 unsigned int
130 find_bin(self, x)
131 simple_histo_1d* self
132 double x
133 CODE:
134 78 ▶ if (x >= self->max || x < self->min) {
Branch: 2 branches
BranchTrueFalseTotal
if (x >= self->max || x < self->min) { 77 1 78
if (x >= self->max || x < self->min) { 0 77 77
135 1 XSRETURN_UNDEF;
136 }
137 77 RETVAL = histo_find_bin(self, x);
138 OUTPUT: RETVAL
139  
140  
« histogram.c ↑ Summary _mt.c »