XS/construction.xs

filter: Statementstmt 84.2% 32 / 38 Branchbran 58.3% 21 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 71.6% 53 / 74 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« const-xs.inc ↑ Summary XS.xs »
1 MODULE = Math::SimpleHisto::XS PACKAGE = Math::SimpleHisto::XS
2  
3 simple_histo_1d*
4 _new_histo(CLASS, nbins, min, max)
5 char *CLASS
6 unsigned int nbins;
7 double min;
8 double max;
9 CODE:
10 16 RETVAL = histo_alloc_new_fixed_bins(aTHX_ nbins, min, max);
11 OUTPUT:
12 RETVAL
13  
14  
15 simple_histo_1d*
16 _new_histo_bins(CLASS, bins)
17 char *CLASS
18 AV* bins;
19 PREINIT:
20 unsigned int nbins, i;
21 double* bins_ary;
22 SV** elem;
23 CODE:
24 10 nbins = av_len(bins); /* av_len is like $#{}, but bins has nbins+1 elements */
25 10 Newx(RETVAL, 1, simple_histo_1d);
26 10 ▶ if( RETVAL == NULL ){
Branch: 1 branch
BranchTrueFalseTotal
if( RETVAL == NULL ){ 0 10 10
27 0 warn("unable to malloc simple_histo_1d");
28 0 XSRETURN_UNDEF;
29 }
30  
31 10 RETVAL->nbins = nbins;
32 10 Newx(bins_ary, nbins+1, double);
33 10 RETVAL->bins = bins_ary;
34  
35 75 ▶ for (i = 0; i <= nbins; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= nbins; ++i) { 65 10 75
36 65 elem = av_fetch(bins, i, 0);
37 65 ▶ if (elem == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (elem == NULL) { 0 65 65
38 0 croak("Shouldn't happen");
39 }
40 65 bins_ary[i] = SvNV(*elem);
41 65 ▶ if (i != 0 && bins_ary[i-1] >= bins_ary[i]) {
Branch: 2 branches
BranchTrueFalseTotal
if (i != 0 && bins_ary[i-1] >= bins_ary[i]) { 55 10 65
if (i != 0 && bins_ary[i-1] >= bins_ary[i]) { 0 55 55
42 0 Safefree(bins_ary);
43 0 Safefree(RETVAL);
44 0 croak("Bin edge %u is higher than bin edge %u. Must be strictly monotonically increasing", i-1, i);
45 }
46 }
47 10 RETVAL->min = bins_ary[0];
48 10 RETVAL->max = bins_ary[nbins];
49 10 RETVAL->width = RETVAL->max - RETVAL->min;
50 10 RETVAL->binsize = 0.;
51 10 RETVAL->overflow = 0.;
52 10 RETVAL->underflow = 0.;
53 10 RETVAL->total = 0.;
54 10 RETVAL->nfills = 0;
55 10 RETVAL->cumulative_hist = 0;
56 10 Newxz(RETVAL->data, (int)RETVAL->nbins, double);
57 OUTPUT:
58 RETVAL
59  
60  
61 simple_histo_1d*
62 clone(self)
63 SV* self
64 ALIAS:
65 new_alike = 1
66 PREINIT:
67 const char* CLASS;
68 INIT:
69 17 ▶ HS_CLONE_GET_CLASS(CLASS, self, clone);
Branch: 3 branches
BranchTrueFalseTotal
HS_CLONE_GET_CLASS(CLASS, self, clone); 0 17 17
HS_CLONE_GET_CLASS(CLASS, self, clone); 17 0 17
HS_CLONE_GET_CLASS(CLASS, self, clone); 0 17 17
70 CODE:
71 17 RETVAL = histo_clone(aTHX_ (simple_histo_1d*)SvIV((SV*)SvRV(self)), ix);
72 OUTPUT: RETVAL
73  
74  
75 simple_histo_1d*
76 cumulative(self, normalization = 0.)
77 SV* self
78 double normalization
79 PREINIT:
80 const char* CLASS;
81 INIT:
82 6 ▶ HS_CLONE_GET_CLASS(CLASS, self, cumulative);
Branch: 3 branches
BranchTrueFalseTotal
HS_CLONE_GET_CLASS(CLASS, self, cumulative); 0 6 6
HS_CLONE_GET_CLASS(CLASS, self, cumulative); 6 0 6
HS_CLONE_GET_CLASS(CLASS, self, cumulative); 0 6 6
83 CODE:
84 6 RETVAL = histo_cumulative(aTHX_ (simple_histo_1d*)SvIV((SV*)SvRV(self)), normalization);
85 OUTPUT: RETVAL
86  
87  
88 simple_histo_1d*
89 new_from_bin_range(self, bin_start, bin_end)
90 SV* self
91 unsigned int bin_start
92 unsigned int bin_end
93 ALIAS:
94 new_alike_from_bin_range = 1
95 PREINIT:
96 const char* CLASS;
97 INIT:
98 2 ▶ HS_CLONE_GET_CLASS(CLASS, self, clone);
Branch: 3 branches
BranchTrueFalseTotal
HS_CLONE_GET_CLASS(CLASS, self, clone); 0 2 2
HS_CLONE_GET_CLASS(CLASS, self, clone); 2 0 2
HS_CLONE_GET_CLASS(CLASS, self, clone); 0 2 2
99 CODE:
100 2 RETVAL = histo_clone_from_bin_range(aTHX_ (simple_histo_1d*)SvIV((SV*)SvRV(self)), ix, bin_start, bin_end);
101 OUTPUT: RETVAL
102  
103 simple_histo_1d*
104 rebin(self, new_nbins)
105 SV *self;
106 unsigned int new_nbins;
107 PREINIT:
108 const char* CLASS;
109 INIT:
110 5 ▶ HS_CLONE_GET_CLASS(CLASS, self, rebin);
Branch: 3 branches
BranchTrueFalseTotal
HS_CLONE_GET_CLASS(CLASS, self, rebin); 0 5 5
HS_CLONE_GET_CLASS(CLASS, self, rebin); 5 0 5
HS_CLONE_GET_CLASS(CLASS, self, rebin); 0 5 5
111 CODE:
112 5 RETVAL = histo_rebin(aTHX_ (simple_histo_1d*)SvIV((SV*)SvRV(self)), new_nbins);
113 5 ▶ if (RETVAL == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == NULL) 2 3 5
114 2 croak("Could not rebin histogram: New bin number not a divisor of the old");
115 OUTPUT: RETVAL
116  
« const-xs.inc ↑ Summary XS.xs »