File Coverage

pp-plvect.c
Criterion Covered Total %
statement 49 51 96.0
branch 34 58 58.6
condition n/a
subroutine n/a
pod n/a
total 83 109 76.1


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 plplot.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_Graphics_PLplot
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "pp-plvect.c"
23             #include
24             #include
25             #include
26             #include
27              
28             #ifndef PDL /* this is needed for PDL pre-2.058 */
29             #define PDL PDL_Graphics_PLplot
30             Core* PDL = NULL; PDL_COMMENT("Structure hold core C functions")
31             #endif
32              
33             #define PLPTR_DEFINE(t) typedef t *t ## Ptr; typedef t *t ## Ptr__OUT;
34             PLPTR_DEFINE(PLcGrid)
35             PLPTR_DEFINE(PLcGrid2)
36             #define PLPTR_RECEIVE_IN(t, v, v_in) t *v = (t *)v_in;
37             #define PLPTR_RECEIVE_SV(v) ((PLPointer) (SvROK(v) ? SvIV((SV*)SvRV(v)) : (IV)NULL))
38              
39             void pltr_iv_set(IV iv0, IV iv1, IV iv2);
40             void pltr_callback_set(SV *sv, char *msg);
41             void pltr_callback(PLFLT x, PLFLT y, PLFLT* tx, PLFLT* ty, PLPointer pltr_data);
42             void* get_standard_pltrcb(SV* cb);
43             void defined_callback_set(SV *sv, char *msg);
44             PLINT defined_callback(PLFLT x, PLFLT y);
45             void default_magic(pdl *p, size_t pa);
46             void mapform_callback_set(SV *sv, char *msg);
47             void mapform_callback(PLINT n, PLFLT* x, PLFLT* y);
48             void xform_callback_set(SV *sv, char *msg);
49             void xform_callback(PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data);
50             void labelfunc_callback_set(SV *sv, char *msg);
51             void labelfunc_callback(PLINT axis, PLFLT value, char *label_text, PLINT length, void *data);
52              
53             #line 1846 "lib/PDL/PP.pm"
54             typedef struct pdl_params_plvect {
55             #line 56 "pp-plvect.c"
56             SV *pltr;
57             SV *pltr_data;
58             } pdl_params_plvect;
59              
60              
61             #line 1857 "lib/PDL/PP.pm"
62             pdl_error pdl_plvect_readdata(pdl_trans *__privtrans) {
63             pdl_error PDL_err = {0, NULL, 0};
64             #line 65 "pp-plvect.c"
65 5           pdl_params_plvect *__params = __privtrans->params; (void)__params;
66 5 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plvect:" "broadcast.incs NULL");
67             /* broadcastloop declarations */
68             int __brcloopval;
69             register PDL_Indx __tind0,__tind1; /* counters along dim */
70 5           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
71             /* dims here are how many steps along those dims */
72 5           register PDL_Indx __tinc0_u = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
73 5           register PDL_Indx __tinc0_v = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
74 5           register PDL_Indx __tinc0_scale = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
75 5           register PDL_Indx __tinc1_u = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
76 5           register PDL_Indx __tinc1_v = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
77 5           register PDL_Indx __tinc1_scale = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
78             #define PDL_BROADCASTLOOP_START_plvect_readdata PDL_BROADCASTLOOP_START( \
79             readdata, \
80             __privtrans->broadcast, \
81             __privtrans->vtable, \
82             u_datap += __offsp[0]; \
83             v_datap += __offsp[1]; \
84             scale_datap += __offsp[2]; \
85             , \
86             ( ,u_datap += __tinc1_u - __tinc0_u * __tdims0 \
87             ,v_datap += __tinc1_v - __tinc0_v * __tdims0 \
88             ,scale_datap += __tinc1_scale - __tinc0_scale * __tdims0 \
89             ), \
90             ( ,u_datap += __tinc0_u \
91             ,v_datap += __tinc0_v \
92             ,scale_datap += __tinc0_scale \
93             ) \
94             )
95             #define PDL_BROADCASTLOOP_END_plvect_readdata PDL_BROADCASTLOOP_END( \
96             __privtrans->broadcast, \
97             u_datap -= __tinc1_u * __tdims1 + __offsp[0]; \
98             v_datap -= __tinc1_v * __tdims1 + __offsp[1]; \
99             scale_datap -= __tinc1_scale * __tdims1 + __offsp[2]; \
100             )
101 5           register PDL_Indx __inc_u_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_u_nx;register PDL_Indx __inc_u_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_u_ny;
102 5           register PDL_Indx __inc_v_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_v_nx;register PDL_Indx __inc_v_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_v_ny;
103             #ifndef PDL_DECLARE_PARAMS_plvect_1
104             #define PDL_DECLARE_PARAMS_plvect_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
105             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, u, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
106             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, v, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
107             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, scale, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
108             #endif
109             #define PDL_IF_BAD(t,f) f
110 5 50         switch (__privtrans->__datatype) { /* Start generic switch */
111 5           case PDL_D: {
112 5 100         PDL_DECLARE_PARAMS_plvect_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
113 20 50         PDL_BROADCASTLOOP_START_plvect_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
114             int i, j, size_x, size_y;
115             PLFLT** u;
116             PLFLT** v;
117             void (*pltrcb) ();
118             PLPointer pltrdt;
119              
120 5           size_x = __privtrans->ind_sizes[0];
121 5           size_y = __privtrans->ind_sizes[1];
122              
123 5           plAlloc2dGrid (&u, size_x, size_y);
124 5           plAlloc2dGrid (&v, size_x, size_y);
125              
126 105 100         for (i = 0; i < size_x; i++)
127 2100 100         for (j = 0; j < size_y; j++) {
128 2000           u[i][j] = (u_datap)[0+(__inc_u_nx*(i))+(__inc_u_ny*(j))];
129 2000           v[i][j] = (v_datap)[0+(__inc_v_nx*(i))+(__inc_v_ny*(j))];
130             }
131              
132 5           pltr_callback_set(__params->pltr,
133             "plvect: pltr must be either 0 or a subroutine pointer");
134              
135 5           pltrcb = get_standard_pltrcb (__params->pltr);
136 5 50         if (pltrcb != pltr_callback)
137 5 50         pltrdt = PLPTR_RECEIVE_SV(__params->pltr_data);
138             else
139 0           pltrdt = __params->pltr_data;
140              
141 5           plvect ((const PLFLT **)u, (const PLFLT **)v, size_x, size_y, (scale_datap)[0], pltrcb, pltrdt);
142              
143 5           plFree2dGrid (u, size_x, size_y);
144 10 50         plFree2dGrid (v, size_x, size_y);}PDL_BROADCASTLOOP_END_plvect_readdata
    50          
145 5           } break;
146 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plvect: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
147             }
148             #undef PDL_IF_BAD
149 5           return PDL_err;
150             }
151              
152              
153             #line 1857 "lib/PDL/PP.pm"
154             pdl_error pdl_plvect_free(pdl_trans *__privtrans, char destroy) {
155             pdl_error PDL_err = {0, NULL, 0};
156             #line 157 "pp-plvect.c"
157 5           pdl_params_plvect *__params = __privtrans->params; (void)__params;
158 5 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->pltr); /* CType.get_free */
159             SvREFCNT_dec(__params->pltr_data); /* CType.get_free */
160 5           , ) return PDL_err;
161             }
162              
163             static pdl_datatypes pdl_plvect_vtable_gentypes[] = { PDL_D, -1 };
164             static PDL_Indx pdl_plvect_vtable_realdims[] = { 2, 2, 0 };
165             static char *pdl_plvect_vtable_parnames[] = { "u","v","scale" };
166             static short pdl_plvect_vtable_parflags[] = {
167             0,
168             0,
169             0
170             };
171             static pdl_datatypes pdl_plvect_vtable_partypes[] = { -1, -1, -1 };
172             static PDL_Indx pdl_plvect_vtable_realdims_starts[] = { 0, 2, 4 };
173             static PDL_Indx pdl_plvect_vtable_realdims_ind_ids[] = { 0, 1, 0, 1 };
174             static char *pdl_plvect_vtable_indnames[] = { "nx","ny" };
175             pdl_transvtable pdl_plvect_vtable = {
176             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plvect_vtable_gentypes, 3, 3, NULL /*CORE21*/,
177             pdl_plvect_vtable_realdims, pdl_plvect_vtable_parnames,
178             pdl_plvect_vtable_parflags, pdl_plvect_vtable_partypes,
179             pdl_plvect_vtable_realdims_starts, pdl_plvect_vtable_realdims_ind_ids, 4,
180             2, pdl_plvect_vtable_indnames,
181             NULL, pdl_plvect_readdata, NULL,
182             pdl_plvect_free,
183             sizeof(pdl_params_plvect),"PDL::Graphics::PLplot::plvect"
184             };
185              
186              
187 5           pdl_error pdl_run_plvect(pdl *u,pdl *v,pdl *scale,SV *pltr,SV *pltr_data) {
188 5           pdl_error PDL_err = {0, NULL, 0};
189 5 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
190 5           pdl_trans *__privtrans = PDL->create_trans(&pdl_plvect_vtable);
191 5 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
192 5           pdl_params_plvect *__params = __privtrans->params;
193 5           __privtrans->pdls[0] = u;
194 5           __privtrans->pdls[1] = v;
195 5           __privtrans->pdls[2] = scale;
196 5 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
197 5           (__params->pltr) = newSVsv(pltr); /* CType.get_copy */
198 5           (__params->pltr_data) = newSVsv(pltr_data); /* CType.get_copy */
199 5 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
200 5           return PDL_err;
201             }