File Coverage

lib/PDL/Compression-pp-rice_expand.c
Criterion Covered Total %
statement 47 64 73.4
branch 48 164 29.2
condition n/a
subroutine n/a
pod n/a
total 95 228 41.6


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Compression.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Compression
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Compression-pp-rice_expand.c"
23             #include "ricecomp.h"
24              
25              
26              
27             #line 1846 "lib/PDL/PP.pm"
28             typedef struct pdl_params_rice_expand {
29             #line 30 "lib/PDL/Compression-pp-rice_expand.c"
30             IV dim0;
31             int blocksize;
32             } pdl_params_rice_expand;
33              
34              
35             #line 1857 "lib/PDL/PP.pm"
36             pdl_error pdl_rice_expand_redodims(pdl_trans *__privtrans) {
37             pdl_error PDL_err = {0, NULL, 0};
38             #line 39 "lib/PDL/Compression-pp-rice_expand.c"
39 10           pdl_params_rice_expand *__params = __privtrans->params; (void)__params;
40 10           __privtrans->ind_sizes[0] = __params->dim0;
41 10 50         PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
42 10           return PDL_err;
43             }
44              
45              
46             #line 1857 "lib/PDL/PP.pm"
47             pdl_error pdl_rice_expand_readdata(pdl_trans *__privtrans) {
48             pdl_error PDL_err = {0, NULL, 0};
49             #line 50 "lib/PDL/Compression-pp-rice_expand.c"
50 10           pdl_params_rice_expand *__params = __privtrans->params; (void)__params;
51 10 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in rice_expand:" "broadcast.incs NULL");
52             /* broadcastloop declarations */
53             int __brcloopval;
54             register PDL_Indx __tind0,__tind1; /* counters along dim */
55 10           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
56             /* dims here are how many steps along those dims */
57 10           register PDL_Indx __tinc0_in = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
58 10           register PDL_Indx __tinc0_len = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
59 10           register PDL_Indx __tinc0_out = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
60 10           register PDL_Indx __tinc1_in = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
61 10           register PDL_Indx __tinc1_len = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
62 10           register PDL_Indx __tinc1_out = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
63             #define PDL_BROADCASTLOOP_START_rice_expand_readdata PDL_BROADCASTLOOP_START( \
64             readdata, \
65             __privtrans->broadcast, \
66             __privtrans->vtable, \
67             in_datap += __offsp[0]; \
68             len_datap += __offsp[1]; \
69             out_datap += __offsp[2]; \
70             , \
71             ( ,in_datap += __tinc1_in - __tinc0_in * __tdims0 \
72             ,len_datap += __tinc1_len - __tinc0_len * __tdims0 \
73             ,out_datap += __tinc1_out - __tinc0_out * __tdims0 \
74             ), \
75             ( ,in_datap += __tinc0_in \
76             ,len_datap += __tinc0_len \
77             ,out_datap += __tinc0_out \
78             ) \
79             )
80             #define PDL_BROADCASTLOOP_END_rice_expand_readdata PDL_BROADCASTLOOP_END( \
81             __privtrans->broadcast, \
82             in_datap -= __tinc1_in * __tdims1 + __offsp[0]; \
83             len_datap -= __tinc1_len * __tdims1 + __offsp[1]; \
84             out_datap -= __tinc1_out * __tdims1 + __offsp[2]; \
85             )
86 10           register PDL_Indx __inc_in_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_in_n;
87 10           register PDL_Indx __inc_out_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_out_m;
88             #ifndef PDL_DECLARE_PARAMS_rice_expand_1
89             #define PDL_DECLARE_PARAMS_rice_expand_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_len,PDL_PPSYM_PARAM_len) \
90             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, in, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
91             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_len, len, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_len) \
92             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, out, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
93             #endif
94             #define PDL_IF_BAD(t,f) f
95 10           switch (__privtrans->__datatype) { /* Start generic switch */
96 2           case PDL_B: {
97 2 50         PDL_DECLARE_PARAMS_rice_expand_1(PDL_Byte,B,PDL_Indx,N)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
98 8 50         PDL_BROADCASTLOOP_START_rice_expand_readdata {char *err = fits_rdecomp_byte( (void *)in_datap,
    50          
    50          
    50          
    50          
    100          
    100          
99 2           (len_datap)[0],
100             (void *)out_datap,
101 2           __privtrans->ind_sizes[0],
102             __params->blocksize
103             );
104 2 50         if (err) return PDL->make_error(PDL_EUSERERROR, "Error in rice_expand:" "%s",err);
105 2 50         }PDL_BROADCASTLOOP_END_rice_expand_readdata
    50          
106 2           } break;
107 0           case PDL_S: {
108 0 0         PDL_DECLARE_PARAMS_rice_expand_1(PDL_Short,S,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
109 0 0         PDL_BROADCASTLOOP_START_rice_expand_readdata {char *err = fits_rdecomp_short( (void *)in_datap,
    0          
    0          
    0          
    0          
    0          
    0          
110 0           (len_datap)[0],
111             (void *)out_datap,
112 0           __privtrans->ind_sizes[0],
113             __params->blocksize
114             );
115 0 0         if (err) return PDL->make_error(PDL_EUSERERROR, "Error in rice_expand:" "%s",err);
116 0 0         }PDL_BROADCASTLOOP_END_rice_expand_readdata
    0          
117 0           } break;
118 0           case PDL_US: {
119 0 0         PDL_DECLARE_PARAMS_rice_expand_1(PDL_Ushort,U,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
120 0 0         PDL_BROADCASTLOOP_START_rice_expand_readdata {char *err = fits_rdecomp_short( (void *)in_datap,
    0          
    0          
    0          
    0          
    0          
    0          
121 0           (len_datap)[0],
122             (void *)out_datap,
123 0           __privtrans->ind_sizes[0],
124             __params->blocksize
125             );
126 0 0         if (err) return PDL->make_error(PDL_EUSERERROR, "Error in rice_expand:" "%s",err);
127 0 0         }PDL_BROADCASTLOOP_END_rice_expand_readdata
    0          
128 0           } break;
129 8           case PDL_L: {
130 8 50         PDL_DECLARE_PARAMS_rice_expand_1(PDL_Long,L,PDL_Indx,N)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
131 3864 50         PDL_BROADCASTLOOP_START_rice_expand_readdata {char *err = fits_rdecomp( (void *)in_datap,
    50          
    50          
    50          
    50          
    100          
    100          
132 3840           (len_datap)[0],
133             (void *)out_datap,
134 3840           __privtrans->ind_sizes[0],
135             __params->blocksize
136             );
137 3840 50         if (err) return PDL->make_error(PDL_EUSERERROR, "Error in rice_expand:" "%s",err);
138 8 50         }PDL_BROADCASTLOOP_END_rice_expand_readdata
    50          
139 8           } break;
140 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rice_expand: unhandled datatype(%d), only handles (BSUL)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
141             }
142             #undef PDL_IF_BAD
143 10           return PDL_err;
144             }
145              
146             static pdl_datatypes pdl_rice_expand_vtable_gentypes[] = { PDL_B, PDL_S, PDL_US, PDL_L, -1 };
147             static PDL_Indx pdl_rice_expand_vtable_realdims[] = { 1, 0, 1 };
148             static char *pdl_rice_expand_vtable_parnames[] = { "in","len","out" };
149             static short pdl_rice_expand_vtable_parflags[] = {
150             PDL_PARAM_ISPHYS,
151             PDL_PARAM_ISTYPED,
152             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE
153             };
154             static pdl_datatypes pdl_rice_expand_vtable_partypes[] = { -1, PDL_IND, -1 };
155             static PDL_Indx pdl_rice_expand_vtable_realdims_starts[] = { 0, 1, 1 };
156             static PDL_Indx pdl_rice_expand_vtable_realdims_ind_ids[] = { 1, 0 };
157             static char *pdl_rice_expand_vtable_indnames[] = { "m","n" };
158             pdl_transvtable pdl_rice_expand_vtable = {
159             PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADIGNORE, 0, pdl_rice_expand_vtable_gentypes, 2, 3, NULL /*CORE21*/,
160             pdl_rice_expand_vtable_realdims, pdl_rice_expand_vtable_parnames,
161             pdl_rice_expand_vtable_parflags, pdl_rice_expand_vtable_partypes,
162             pdl_rice_expand_vtable_realdims_starts, pdl_rice_expand_vtable_realdims_ind_ids, 2,
163             2, pdl_rice_expand_vtable_indnames,
164             pdl_rice_expand_redodims, pdl_rice_expand_readdata, NULL,
165             NULL,
166             sizeof(pdl_params_rice_expand),"PDL::Compression::rice_expand"
167             };
168              
169              
170 10           pdl_error pdl_run_rice_expand(pdl *in,pdl *len,pdl *out,IV dim0,int blocksize) {
171 10           pdl_error PDL_err = {0, NULL, 0};
172 10 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
173 10           pdl_trans *__privtrans = PDL->create_trans(&pdl_rice_expand_vtable);
174 10 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
175 10           pdl_params_rice_expand *__params = __privtrans->params;
176 10           __privtrans->pdls[0] = in;
177 10           __privtrans->pdls[1] = len;
178 10           __privtrans->pdls[2] = out;
179 10 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
180 10           (__params->dim0) = (dim0); /* CType.get_copy */
181 10           (__params->blocksize) = (blocksize); /* CType.get_copy */
182 10 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
183 10           return PDL_err;
184             }