File Coverage

lib/PDL/Slices-pp-mv.c
Criterion Covered Total %
statement 30 30 100.0
branch 12 18 66.6
condition n/a
subroutine n/a
pod n/a
total 42 48 87.5


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/Slices.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_Slices
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Slices-pp-mv.c"
23             #define EQUIVDIM(dima,dimb,cdim,inc) \
24             ((cdim < PDLMIN(dima,dimb) || cdim > PDLMAX(dima,dimb)) ? \
25             cdim : ((cdim == dimb) ? dima : cdim + inc))
26              
27              
28              
29             #line 1846 "lib/PDL/PP.pm"
30             typedef struct pdl_params_mv {
31             #line 32 "lib/PDL/Slices-pp-mv.c"
32             PDL_Indx n1;
33             PDL_Indx n2;
34             } pdl_params_mv;
35              
36              
37             #line 1857 "lib/PDL/PP.pm"
38             pdl_error pdl_mv_redodims(pdl_trans *__privtrans) {
39             pdl_error PDL_err = {0, NULL, 0};
40             #line 41 "lib/PDL/Slices-pp-mv.c"
41 12451           pdl_params_mv *__params = __privtrans->params; (void)__params;
42 12451           pdl *__it = __privtrans->pdls[1]; (void) __it;
43 12451 100         PDL->hdr_childcopy(__privtrans); __privtrans->dims_redone = 1;
44             PDL_Indx i,cor;
45            
46             #line 1593 "lib/PDL/Slices.pd"
47             if (__params->n1 <0)
48             __params->n1 += __privtrans->pdls[0]->broadcastids[0];
49             if (__params->n2 <0)
50             __params->n2 += __privtrans->pdls[0]->broadcastids[0];
51             if (PDLMIN(__params->n1,__params->n2) <0 ||
52             PDLMAX(__params->n1,__params->n2) >= __privtrans->pdls[0]->broadcastids[0])
53             return PDL->make_error(PDL_EUSERERROR, "Error in mv:" "One of dims %"IND_FLAG", %"IND_FLAG" out of range: should be 0<=dim<%"IND_FLAG"",__params->n1,__params->n2,__privtrans->pdls[0]->broadcastids[0]);
54             #line 55 "lib/PDL/Slices-pp-mv.c"
55              
56 12451 50         PDL_RETERROR(PDL_err, PDL->reallocdims(__it,__privtrans->pdls[0]->ndims));;
57 12451           __privtrans->incs = malloc(sizeof(*__privtrans->incs) * __privtrans->pdls[1]->ndims); /* CType.get_malloc */
58             ;
59 12451           __privtrans->offs = 0;
60 25841 100         for(i=0; i<__privtrans->pdls[1]->ndims; i++) {
61 13390           cor =
62             #line 1603 "lib/PDL/Slices.pd"
63             (
64             __params->n1 == __params->n2 ? i :
65             __params->n1 < __params->n2 ? EQUIVDIM(__params->n1,__params->n2,i,1) :
66             EQUIVDIM(__params->n1,__params->n2,i,-1)
67             )
68             #line 69 "lib/PDL/Slices-pp-mv.c"
69             ;
70 13390           __privtrans->pdls[1]->dims[i] = __privtrans->pdls[0]->dims[cor];
71 13390           __privtrans->incs[i] = __privtrans->pdls[0]->dimincs[cor];
72             }
73 12451 50         PDL_RETERROR(PDL_err, PDL->setdims_careful(__it));;
74            
75             #line 384 "lib/PDL/PP.pm"
76             {int __ind; PDL_RETERROR(PDL_err, PDL->reallocbroadcastids(__privtrans->pdls[1], __privtrans->pdls[0]->nbroadcastids));
77             for(__ind=0; __ind<__privtrans->pdls[0]->nbroadcastids; __ind++)
78             __privtrans->pdls[1]->broadcastids[__ind] = __privtrans->pdls[0]->broadcastids[__ind] + (0);
79             }
80             #line 81 "lib/PDL/Slices-pp-mv.c"
81             ;
82 12451           __privtrans->dims_redone = 1;
83 12451           return PDL_err;
84             }
85              
86              
87             #line 1857 "lib/PDL/PP.pm"
88             pdl_error pdl_mv_free(pdl_trans *__privtrans, char destroy) {
89             pdl_error PDL_err = {0, NULL, 0};
90             #line 91 "lib/PDL/Slices-pp-mv.c"
91 12456           pdl_params_mv *__params = __privtrans->params; (void)__params;
92 12456           pdl *__it = __privtrans->pdls[1]; (void) __it;
93 12456 100         PDL_FREE_CODE(__privtrans, destroy, , free(__privtrans->incs); /* CType.get_free */
94 12456           ) return PDL_err;
95             }
96              
97             static pdl_datatypes pdl_mv_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, PDL_F, PDL_D, PDL_LD, PDL_CF, PDL_CD, PDL_CLD, -1 };
98             static PDL_Indx pdl_mv_vtable_realdims[] = { 0, 0 };
99             static char *pdl_mv_vtable_parnames[] = { "PARENT","CHILD" };
100             static short pdl_mv_vtable_parflags[] = {
101             0,
102             PDL_PARAM_ISCREAT|PDL_PARAM_ISCREATEALWAYS|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
103             };
104             static pdl_datatypes pdl_mv_vtable_partypes[] = { -1, -1 };
105             static PDL_Indx pdl_mv_vtable_realdims_starts[] = { 0, 0 };
106             static PDL_Indx pdl_mv_vtable_realdims_ind_ids[] = { 0 };
107             static char *pdl_mv_vtable_indnames[] = { "" };
108             pdl_transvtable pdl_mv_vtable = {
109             0, PDL_ITRANS_ISAFFINE|PDL_ITRANS_TWOWAY|PDL_ITRANS_DO_DATAFLOW_ANY, pdl_mv_vtable_gentypes, 1, 2, NULL /*CORE21*/,
110             pdl_mv_vtable_realdims, pdl_mv_vtable_parnames,
111             pdl_mv_vtable_parflags, pdl_mv_vtable_partypes,
112             pdl_mv_vtable_realdims_starts, pdl_mv_vtable_realdims_ind_ids, 0,
113             0, pdl_mv_vtable_indnames,
114             pdl_mv_redodims, NULL, NULL,
115             pdl_mv_free,
116             sizeof(pdl_params_mv),"PDL::Slices::mv"
117             };
118              
119              
120 12456           pdl_error pdl_run_mv(pdl *PARENT,pdl *CHILD,PDL_Indx n1,PDL_Indx n2) {
121 12456           pdl_error PDL_err = {0, NULL, 0};
122 12456 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
123 12456           pdl_trans *__privtrans = PDL->create_trans(&pdl_mv_vtable);
124 12456 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
125 12456           pdl_params_mv *__params = __privtrans->params;
126 12456           __privtrans->pdls[0] = PARENT;
127 12456           __privtrans->pdls[1] = CHILD;
128 12456 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
129 12456           (__params->n1) = (n1); /* CType.get_copy */
130 12456           (__params->n2) = (n2); /* CType.get_copy */
131 12456 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
132 12456           return PDL_err;
133             }