| 1 |
|
| #ifndef histo_perl_interf_h_ |
| 2 |
|
| #define histo_perl_interf_h_ |
| 3 |
|
| |
| 4 |
|
| /* This file is purely for inclusion in the XS and defines |
| 5 |
|
| * (STATIC) functions for C-histogram <=> Perl interfacing |
| 6 |
|
| */ |
| 7 |
|
| |
| 8 |
|
| STATIC |
| 9 |
|
| SV* |
| 10 |
62 |
| histo_ary_to_AV_internal(pTHX_ unsigned int n, double* ary) { |
| 11 |
|
| AV* av; |
| 12 |
|
| unsigned int i; |
| 13 |
|
| SV* rv; |
| 14 |
|
| |
| 15 |
62 |
| av = newAV(); |
| 16 |
62 |
| rv = (SV*)newRV((SV*)av); |
| 17 |
62 |
| SvREFCNT_dec(av); |
| 18 |
|
| |
| 19 |
62 |
| av_fill(av, n-1); |
| 20 |
820 |
▶ | for (i = 0; i < n; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; ++i) { |
758 |
62 |
820 |
|
| 21 |
758 |
| av_store(av, (int)i, newSVnv(ary[i])); |
| 22 |
|
| } |
| 23 |
|
| |
| 24 |
62 |
| return rv; |
| 25 |
|
| } |
| 26 |
|
| |
| 27 |
|
| STATIC |
| 28 |
|
| SV* |
| 29 |
|
| histo_data_av(pTHX_ simple_histo_1d* self) { |
| 30 |
57 |
| return histo_ary_to_AV_internal(aTHX_ self->nbins, self->data); |
| 31 |
|
| } |
| 32 |
|
| |
| 33 |
|
| STATIC |
| 34 |
|
| SV* |
| 35 |
|
| histo_bins_av(pTHX_ simple_histo_1d* self) { |
| 36 |
5 |
| return histo_ary_to_AV_internal(aTHX_ self->nbins+1, self->bins); |
| 37 |
|
| } |
| 38 |
|
| |
| 39 |
|
| |
| 40 |
|
| #endif |