File Coverage

lib/PDL/Slices-pp-rangeb.c
Criterion Covered Total %
statement 75 280 26.7
branch 88 1072 8.2
condition n/a
subroutine n/a
pod n/a
total 163 1352 12.0


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              
23             #line 1846 "lib/PDL/PP.pm"
24             typedef struct pdl_params_rangeb {
25             #line 26 "lib/PDL/Slices-pp-rangeb.c"
26             pdl *ind_pdl;
27             SV *size_sv;
28             SV *boundary_sv;
29             PDL_Indx rdim;
30             PDL_Indx nitems;
31             PDL_Indx itdim;
32             PDL_Indx ntsize;
33             PDL_Indx bsize;
34             PDL_Indx nsizes;
35             PDL_Indx *sizes;
36             PDL_Indx *itdims;
37             PDL_Indx *corners;
38             char *boundary;
39             char size_pdl_destroy;
40             char ind_pdl_destroy;
41             } pdl_params_rangeb;
42              
43              
44             #line 1857 "lib/PDL/PP.pm"
45             pdl_error pdl_rangeb_redodims(pdl_trans *__privtrans) {
46             pdl_error PDL_err = {0, NULL, 0};
47             #line 48 "lib/PDL/Slices-pp-rangeb.c"
48 83           pdl_params_rangeb *__params = __privtrans->params; (void)__params;
49 83           pdl *__it = __privtrans->pdls[1]; (void) __it;
50 83 50         PDL->hdr_childcopy(__privtrans); __privtrans->dims_redone = 1;
51              
52             #line 815 "lib/PDL/Slices.pd"
53             PDL_Indx stdim = __privtrans->pdls[0]->ndims - __params->rdim;
54             PDL_Indx dim,inc;
55             PDL_Indx i,rdvalid;
56              
57             // Speed bump for ludicrous cases
58             if( __params->rdim > __privtrans->pdls[0]->ndims+5 && __params->nsizes != __params->rdim) {
59             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Ludicrous number of extra dims in range index; leaving child null.\n"" (%"IND_FLAG" implicit dims is > 5; index has %"IND_FLAG" dims; source has %"IND_FLAG" dim%s.)\n"" This often means that your index PDL is incorrect.\n"" To avoid this message, allocate dummy dims in\n"" the source or use %"IND_FLAG" dims in range's size field.\n",__params->rdim-__privtrans->pdls[0]->ndims,__params->rdim,__privtrans->pdls[0]->ndims,__privtrans->pdls[0]->ndims>1?"s":"",__params->rdim);
60             }
61              
62             if(stdim < 0)
63             stdim = 0;
64              
65             /* Set dimensionality of child */
66             PDL_RETERROR(PDL_err, PDL->reallocdims(__it,__params->itdim+__params->ntsize+stdim));;
67              
68             inc = 1;
69             /* Copy size dimensions to child, crunching as we go. */
70             dim = __params->itdim;
71             for(i=rdvalid=0;i<__params->rdim;i++) {
72             if(__params->sizes[i]) {
73             rdvalid++;
74             __privtrans->pdls[1]->dimincs[dim] = inc;
75             inc *= (__privtrans->pdls[1]->dims[dim++] = __params->sizes[i]); /* assignment */
76             }
77             }
78              
79             /* Copy index broadcast dimensions to child */
80             for(dim=0; dim<__params->itdim; dim++) {
81             __privtrans->pdls[1]->dimincs[dim] = inc;
82             inc *= (__privtrans->pdls[1]->dims[dim] = __params->itdims[dim]); /* assignment */
83             }
84              
85             /* Copy source broadcast dimensions to child */
86             dim = __params->itdim + rdvalid;
87             for(i=0;i
88             __privtrans->pdls[1]->dimincs[dim] = inc;
89             inc *= (__privtrans->pdls[1]->dims[dim++] = __privtrans->pdls[0]->dims[i+__params->rdim]); /* assignment */
90             }
91              
92             /* Cover bizarre case where the source PDL is empty - in that case, change */
93             /* all non-barfing boundary conditions to truncation, since we have no data */
94             /* to reflect, extend, or mirror. */
95             if(__privtrans->pdls[0]->dims[0] == 0) {
96             for(dim=0; dim<__params->rdim; dim++) {
97             if(__params->boundary[dim])
98             __params->boundary[dim] = 1; // force truncation
99             }
100             }
101              
102             __privtrans->pdls[1]->datatype = __privtrans->pdls[0]->datatype;
103             PDL_RETERROR(PDL_err, PDL->setdims_careful(__it));;
104             #line 105 "lib/PDL/Slices-pp-rangeb.c"
105 83           return PDL_err;
106             }
107              
108              
109             #line 1857 "lib/PDL/PP.pm"
110             pdl_error pdl_rangeb_readdata(pdl_trans *__privtrans) {
111             pdl_error PDL_err = {0, NULL, 0};
112             #line 113 "lib/PDL/Slices-pp-rangeb.c"
113 87           pdl_params_rangeb *__params = __privtrans->params; (void)__params;
114 87           pdl *__it = __privtrans->pdls[1]; (void) __it;
115             #ifndef PDL_DECLARE_PARAMS_rangeb_1
116             #define PDL_DECLARE_PARAMS_rangeb_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
117             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, PARENT, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
118             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, CHILD, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
119             #endif
120 87 100         if ( __privtrans->bvalflag ) { /* ** do 'bad' Code ** */
121             #define PDL_BAD_CODE
122             #define PDL_IF_BAD(t,f) t
123 3           switch (__privtrans->__datatype) { /* Start generic switch */
124 0           case PDL_SB: {
125 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
126 0           {
127             #line 877 "lib/PDL/Slices.pd"
128             PDL_Indx *ip; /* vector iterator */
129             PDL_Indx *sp; /* size vector including stdims */
130             PDL_Indx *coords; /* current coordinates */
131              
132             PDL_Indx k; /* index */
133             PDL_Indx item; /* index broadcast iterator */
134             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
135             PDL_Indx rdim = __params->rdim;
136             PDL_Indx prdim = PDLMIN(rdim,pdim);
137             PDL_Indx iter2[pdim * 2 + rdim];
138             PDL_Indx *sizes = iter2 + pdim;
139             coords = sizes + pdim;
140              
141             /* Figure out size vector */
142             for(ip = __params->sizes, sp = sizes, k=0; k
143             *(sp++) = *(ip++);
144             for(; k < pdim; k++)
145             *(sp++) = __privtrans->pdls[0]->dims[k];
146              
147              
148             /* Loop over all the ranges in the index list */
149             for(item=0; item<__params->nitems; item++) {
150              
151             /* initialize in-range iterator to loop within each range */
152             for(ip = iter2, k=0; k
153             *(ip++) = 0;
154              
155             do {
156             PDL_Indx poff = 0;
157             PDL_Indx coff;
158             PDL_Indx k2;
159             char trunc = 0; /* Flag used to skip truncation case */
160              
161             /* Collect and boundary-check the current N-D coords */
162             for(k=0; k < prdim; k++){
163              
164             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
165              
166             /* normal case */
167             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
168             switch(__params->boundary[k]) {
169             case 0: /* no boundary breakage allowed */
170             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
171             break;
172             case 1: /* truncation */
173             trunc = 1;
174             break;
175             case 2: /* extension -- crop */
176             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
177             break;
178             case 3: /* periodic -- mod it */
179             ck %= __privtrans->pdls[0]->dims[k];
180             if(ck < 0) /* Fix mod breakage in C */
181             ck += __privtrans->pdls[0]->dims[k];
182             break;
183             case 4: /* mirror -- reflect off the edges */
184             ck += __privtrans->pdls[0]->dims[k];
185             ck %= (__privtrans->pdls[0]->dims[k] * 2);
186             if(ck < 0) /* Fix mod breakage in C */
187             ck += __privtrans->pdls[0]->dims[k]*2;
188             ck -= __privtrans->pdls[0]->dims[k];
189             if(ck < 0) {
190             ck *= -1;
191             ck -= 1;
192             }
193             break;
194             default:
195             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
196             break;
197             }
198             }
199              
200             coords[k] = ck;
201              
202             }
203              
204             /* Check extra dimensions -- pick up where k left off... */
205             for( ; k < rdim ; k++) {
206             /* Check for indexing off the end of the dimension list */
207              
208             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
209              
210             switch(__params->boundary[k]) {
211             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
212             if(ck != 0)
213             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
214             break;
215             case 1: /* truncation - just truncate if the corner is nonzero */
216             trunc |= (ck != 0);
217             break;
218             case 2: /* extension -- ignore the corner (same as 3) */
219             case 3: /* periodic -- ignore the corner */
220             case 4: /* mirror -- ignore the corner */
221             ck = 0;
222             break;
223             default:
224             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
225             break;
226             }
227             }
228              
229             /* Find offsets into the child and parent arrays, from the N-D coords */
230             /* Note we only loop over real source dims (prdim) to accumulate -- */
231             /* because the offset is trivial and/or we're truncating for virtual */
232             /* dims caused by permissive ranging. */
233             coff = __privtrans->pdls[1]->dimincs[0] * item;
234             for(k2 = __params->itdim, poff = k = 0;
235             k < prdim;
236             k++) {
237             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
238             if(__params->sizes[k])
239             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
240             }
241              
242             /* Loop the copy over all the source broadcast dims (above rdim). */
243             do {
244             PDL_Indx poff1 = poff;
245             PDL_Indx coff1 = coff;
246              
247             /* Accumulate the offset due to source broadcasting */
248             for(k2 = __params->itdim + __params->ntsize, k = rdim;
249             k < pdim;
250             k++) {
251             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
252             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
253             }
254              
255             /* Finally -- make the copy
256             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
257             * out-of-bounds conditions.
258             */
259             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,A,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
260              
261             /* Increment the source broadcast iterator */
262             for( k=__params->rdim;
263             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
264             k++)
265             iter2[k] = 0;
266             } while(k < pdim); /* end of source-broadcast iteration */
267              
268             /* Increment the in-range iterator */
269             for(k = 0;
270             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
271             k++)
272             iter2[k] = 0;
273             } while(k < __params->rdim); /* end of main iteration */
274             } /* end of item do loop */
275             #line 276 "lib/PDL/Slices-pp-rangeb.c"
276             }
277 0           } break;
278 0           case PDL_B: {
279 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
280 0           {
281             #line 877 "lib/PDL/Slices.pd"
282             PDL_Indx *ip; /* vector iterator */
283             PDL_Indx *sp; /* size vector including stdims */
284             PDL_Indx *coords; /* current coordinates */
285              
286             PDL_Indx k; /* index */
287             PDL_Indx item; /* index broadcast iterator */
288             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
289             PDL_Indx rdim = __params->rdim;
290             PDL_Indx prdim = PDLMIN(rdim,pdim);
291             PDL_Indx iter2[pdim * 2 + rdim];
292             PDL_Indx *sizes = iter2 + pdim;
293             coords = sizes + pdim;
294              
295             /* Figure out size vector */
296             for(ip = __params->sizes, sp = sizes, k=0; k
297             *(sp++) = *(ip++);
298             for(; k < pdim; k++)
299             *(sp++) = __privtrans->pdls[0]->dims[k];
300              
301              
302             /* Loop over all the ranges in the index list */
303             for(item=0; item<__params->nitems; item++) {
304              
305             /* initialize in-range iterator to loop within each range */
306             for(ip = iter2, k=0; k
307             *(ip++) = 0;
308              
309             do {
310             PDL_Indx poff = 0;
311             PDL_Indx coff;
312             PDL_Indx k2;
313             char trunc = 0; /* Flag used to skip truncation case */
314              
315             /* Collect and boundary-check the current N-D coords */
316             for(k=0; k < prdim; k++){
317              
318             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
319              
320             /* normal case */
321             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
322             switch(__params->boundary[k]) {
323             case 0: /* no boundary breakage allowed */
324             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
325             break;
326             case 1: /* truncation */
327             trunc = 1;
328             break;
329             case 2: /* extension -- crop */
330             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
331             break;
332             case 3: /* periodic -- mod it */
333             ck %= __privtrans->pdls[0]->dims[k];
334             if(ck < 0) /* Fix mod breakage in C */
335             ck += __privtrans->pdls[0]->dims[k];
336             break;
337             case 4: /* mirror -- reflect off the edges */
338             ck += __privtrans->pdls[0]->dims[k];
339             ck %= (__privtrans->pdls[0]->dims[k] * 2);
340             if(ck < 0) /* Fix mod breakage in C */
341             ck += __privtrans->pdls[0]->dims[k]*2;
342             ck -= __privtrans->pdls[0]->dims[k];
343             if(ck < 0) {
344             ck *= -1;
345             ck -= 1;
346             }
347             break;
348             default:
349             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
350             break;
351             }
352             }
353              
354             coords[k] = ck;
355              
356             }
357              
358             /* Check extra dimensions -- pick up where k left off... */
359             for( ; k < rdim ; k++) {
360             /* Check for indexing off the end of the dimension list */
361              
362             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
363              
364             switch(__params->boundary[k]) {
365             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
366             if(ck != 0)
367             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
368             break;
369             case 1: /* truncation - just truncate if the corner is nonzero */
370             trunc |= (ck != 0);
371             break;
372             case 2: /* extension -- ignore the corner (same as 3) */
373             case 3: /* periodic -- ignore the corner */
374             case 4: /* mirror -- ignore the corner */
375             ck = 0;
376             break;
377             default:
378             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
379             break;
380             }
381             }
382              
383             /* Find offsets into the child and parent arrays, from the N-D coords */
384             /* Note we only loop over real source dims (prdim) to accumulate -- */
385             /* because the offset is trivial and/or we're truncating for virtual */
386             /* dims caused by permissive ranging. */
387             coff = __privtrans->pdls[1]->dimincs[0] * item;
388             for(k2 = __params->itdim, poff = k = 0;
389             k < prdim;
390             k++) {
391             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
392             if(__params->sizes[k])
393             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
394             }
395              
396             /* Loop the copy over all the source broadcast dims (above rdim). */
397             do {
398             PDL_Indx poff1 = poff;
399             PDL_Indx coff1 = coff;
400              
401             /* Accumulate the offset due to source broadcasting */
402             for(k2 = __params->itdim + __params->ntsize, k = rdim;
403             k < pdim;
404             k++) {
405             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
406             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
407             }
408              
409             /* Finally -- make the copy
410             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
411             * out-of-bounds conditions.
412             */
413             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,B,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
414              
415             /* Increment the source broadcast iterator */
416             for( k=__params->rdim;
417             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
418             k++)
419             iter2[k] = 0;
420             } while(k < pdim); /* end of source-broadcast iteration */
421              
422             /* Increment the in-range iterator */
423             for(k = 0;
424             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
425             k++)
426             iter2[k] = 0;
427             } while(k < __params->rdim); /* end of main iteration */
428             } /* end of item do loop */
429             #line 430 "lib/PDL/Slices-pp-rangeb.c"
430             }
431 0           } break;
432 0           case PDL_S: {
433 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
434 0           {
435             #line 877 "lib/PDL/Slices.pd"
436             PDL_Indx *ip; /* vector iterator */
437             PDL_Indx *sp; /* size vector including stdims */
438             PDL_Indx *coords; /* current coordinates */
439              
440             PDL_Indx k; /* index */
441             PDL_Indx item; /* index broadcast iterator */
442             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
443             PDL_Indx rdim = __params->rdim;
444             PDL_Indx prdim = PDLMIN(rdim,pdim);
445             PDL_Indx iter2[pdim * 2 + rdim];
446             PDL_Indx *sizes = iter2 + pdim;
447             coords = sizes + pdim;
448              
449             /* Figure out size vector */
450             for(ip = __params->sizes, sp = sizes, k=0; k
451             *(sp++) = *(ip++);
452             for(; k < pdim; k++)
453             *(sp++) = __privtrans->pdls[0]->dims[k];
454              
455              
456             /* Loop over all the ranges in the index list */
457             for(item=0; item<__params->nitems; item++) {
458              
459             /* initialize in-range iterator to loop within each range */
460             for(ip = iter2, k=0; k
461             *(ip++) = 0;
462              
463             do {
464             PDL_Indx poff = 0;
465             PDL_Indx coff;
466             PDL_Indx k2;
467             char trunc = 0; /* Flag used to skip truncation case */
468              
469             /* Collect and boundary-check the current N-D coords */
470             for(k=0; k < prdim; k++){
471              
472             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
473              
474             /* normal case */
475             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
476             switch(__params->boundary[k]) {
477             case 0: /* no boundary breakage allowed */
478             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
479             break;
480             case 1: /* truncation */
481             trunc = 1;
482             break;
483             case 2: /* extension -- crop */
484             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
485             break;
486             case 3: /* periodic -- mod it */
487             ck %= __privtrans->pdls[0]->dims[k];
488             if(ck < 0) /* Fix mod breakage in C */
489             ck += __privtrans->pdls[0]->dims[k];
490             break;
491             case 4: /* mirror -- reflect off the edges */
492             ck += __privtrans->pdls[0]->dims[k];
493             ck %= (__privtrans->pdls[0]->dims[k] * 2);
494             if(ck < 0) /* Fix mod breakage in C */
495             ck += __privtrans->pdls[0]->dims[k]*2;
496             ck -= __privtrans->pdls[0]->dims[k];
497             if(ck < 0) {
498             ck *= -1;
499             ck -= 1;
500             }
501             break;
502             default:
503             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
504             break;
505             }
506             }
507              
508             coords[k] = ck;
509              
510             }
511              
512             /* Check extra dimensions -- pick up where k left off... */
513             for( ; k < rdim ; k++) {
514             /* Check for indexing off the end of the dimension list */
515              
516             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
517              
518             switch(__params->boundary[k]) {
519             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
520             if(ck != 0)
521             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
522             break;
523             case 1: /* truncation - just truncate if the corner is nonzero */
524             trunc |= (ck != 0);
525             break;
526             case 2: /* extension -- ignore the corner (same as 3) */
527             case 3: /* periodic -- ignore the corner */
528             case 4: /* mirror -- ignore the corner */
529             ck = 0;
530             break;
531             default:
532             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
533             break;
534             }
535             }
536              
537             /* Find offsets into the child and parent arrays, from the N-D coords */
538             /* Note we only loop over real source dims (prdim) to accumulate -- */
539             /* because the offset is trivial and/or we're truncating for virtual */
540             /* dims caused by permissive ranging. */
541             coff = __privtrans->pdls[1]->dimincs[0] * item;
542             for(k2 = __params->itdim, poff = k = 0;
543             k < prdim;
544             k++) {
545             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
546             if(__params->sizes[k])
547             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
548             }
549              
550             /* Loop the copy over all the source broadcast dims (above rdim). */
551             do {
552             PDL_Indx poff1 = poff;
553             PDL_Indx coff1 = coff;
554              
555             /* Accumulate the offset due to source broadcasting */
556             for(k2 = __params->itdim + __params->ntsize, k = rdim;
557             k < pdim;
558             k++) {
559             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
560             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
561             }
562              
563             /* Finally -- make the copy
564             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
565             * out-of-bounds conditions.
566             */
567             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,S,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
568              
569             /* Increment the source broadcast iterator */
570             for( k=__params->rdim;
571             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
572             k++)
573             iter2[k] = 0;
574             } while(k < pdim); /* end of source-broadcast iteration */
575              
576             /* Increment the in-range iterator */
577             for(k = 0;
578             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
579             k++)
580             iter2[k] = 0;
581             } while(k < __params->rdim); /* end of main iteration */
582             } /* end of item do loop */
583             #line 584 "lib/PDL/Slices-pp-rangeb.c"
584             }
585 0           } break;
586 0           case PDL_US: {
587 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
588 0           {
589             #line 877 "lib/PDL/Slices.pd"
590             PDL_Indx *ip; /* vector iterator */
591             PDL_Indx *sp; /* size vector including stdims */
592             PDL_Indx *coords; /* current coordinates */
593              
594             PDL_Indx k; /* index */
595             PDL_Indx item; /* index broadcast iterator */
596             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
597             PDL_Indx rdim = __params->rdim;
598             PDL_Indx prdim = PDLMIN(rdim,pdim);
599             PDL_Indx iter2[pdim * 2 + rdim];
600             PDL_Indx *sizes = iter2 + pdim;
601             coords = sizes + pdim;
602              
603             /* Figure out size vector */
604             for(ip = __params->sizes, sp = sizes, k=0; k
605             *(sp++) = *(ip++);
606             for(; k < pdim; k++)
607             *(sp++) = __privtrans->pdls[0]->dims[k];
608              
609              
610             /* Loop over all the ranges in the index list */
611             for(item=0; item<__params->nitems; item++) {
612              
613             /* initialize in-range iterator to loop within each range */
614             for(ip = iter2, k=0; k
615             *(ip++) = 0;
616              
617             do {
618             PDL_Indx poff = 0;
619             PDL_Indx coff;
620             PDL_Indx k2;
621             char trunc = 0; /* Flag used to skip truncation case */
622              
623             /* Collect and boundary-check the current N-D coords */
624             for(k=0; k < prdim; k++){
625              
626             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
627              
628             /* normal case */
629             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
630             switch(__params->boundary[k]) {
631             case 0: /* no boundary breakage allowed */
632             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
633             break;
634             case 1: /* truncation */
635             trunc = 1;
636             break;
637             case 2: /* extension -- crop */
638             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
639             break;
640             case 3: /* periodic -- mod it */
641             ck %= __privtrans->pdls[0]->dims[k];
642             if(ck < 0) /* Fix mod breakage in C */
643             ck += __privtrans->pdls[0]->dims[k];
644             break;
645             case 4: /* mirror -- reflect off the edges */
646             ck += __privtrans->pdls[0]->dims[k];
647             ck %= (__privtrans->pdls[0]->dims[k] * 2);
648             if(ck < 0) /* Fix mod breakage in C */
649             ck += __privtrans->pdls[0]->dims[k]*2;
650             ck -= __privtrans->pdls[0]->dims[k];
651             if(ck < 0) {
652             ck *= -1;
653             ck -= 1;
654             }
655             break;
656             default:
657             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
658             break;
659             }
660             }
661              
662             coords[k] = ck;
663              
664             }
665              
666             /* Check extra dimensions -- pick up where k left off... */
667             for( ; k < rdim ; k++) {
668             /* Check for indexing off the end of the dimension list */
669              
670             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
671              
672             switch(__params->boundary[k]) {
673             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
674             if(ck != 0)
675             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
676             break;
677             case 1: /* truncation - just truncate if the corner is nonzero */
678             trunc |= (ck != 0);
679             break;
680             case 2: /* extension -- ignore the corner (same as 3) */
681             case 3: /* periodic -- ignore the corner */
682             case 4: /* mirror -- ignore the corner */
683             ck = 0;
684             break;
685             default:
686             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
687             break;
688             }
689             }
690              
691             /* Find offsets into the child and parent arrays, from the N-D coords */
692             /* Note we only loop over real source dims (prdim) to accumulate -- */
693             /* because the offset is trivial and/or we're truncating for virtual */
694             /* dims caused by permissive ranging. */
695             coff = __privtrans->pdls[1]->dimincs[0] * item;
696             for(k2 = __params->itdim, poff = k = 0;
697             k < prdim;
698             k++) {
699             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
700             if(__params->sizes[k])
701             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
702             }
703              
704             /* Loop the copy over all the source broadcast dims (above rdim). */
705             do {
706             PDL_Indx poff1 = poff;
707             PDL_Indx coff1 = coff;
708              
709             /* Accumulate the offset due to source broadcasting */
710             for(k2 = __params->itdim + __params->ntsize, k = rdim;
711             k < pdim;
712             k++) {
713             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
714             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
715             }
716              
717             /* Finally -- make the copy
718             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
719             * out-of-bounds conditions.
720             */
721             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,U,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
722              
723             /* Increment the source broadcast iterator */
724             for( k=__params->rdim;
725             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
726             k++)
727             iter2[k] = 0;
728             } while(k < pdim); /* end of source-broadcast iteration */
729              
730             /* Increment the in-range iterator */
731             for(k = 0;
732             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
733             k++)
734             iter2[k] = 0;
735             } while(k < __params->rdim); /* end of main iteration */
736             } /* end of item do loop */
737             #line 738 "lib/PDL/Slices-pp-rangeb.c"
738             }
739 0           } break;
740 2           case PDL_L: {
741 2 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Long,L)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
742 2           {
743             #line 877 "lib/PDL/Slices.pd"
744             PDL_Indx *ip; /* vector iterator */
745             PDL_Indx *sp; /* size vector including stdims */
746             PDL_Indx *coords; /* current coordinates */
747              
748             PDL_Indx k; /* index */
749             PDL_Indx item; /* index broadcast iterator */
750             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
751             PDL_Indx rdim = __params->rdim;
752             PDL_Indx prdim = PDLMIN(rdim,pdim);
753             PDL_Indx iter2[pdim * 2 + rdim];
754             PDL_Indx *sizes = iter2 + pdim;
755             coords = sizes + pdim;
756              
757             /* Figure out size vector */
758             for(ip = __params->sizes, sp = sizes, k=0; k
759             *(sp++) = *(ip++);
760             for(; k < pdim; k++)
761             *(sp++) = __privtrans->pdls[0]->dims[k];
762              
763              
764             /* Loop over all the ranges in the index list */
765             for(item=0; item<__params->nitems; item++) {
766              
767             /* initialize in-range iterator to loop within each range */
768             for(ip = iter2, k=0; k
769             *(ip++) = 0;
770              
771             do {
772             PDL_Indx poff = 0;
773             PDL_Indx coff;
774             PDL_Indx k2;
775             char trunc = 0; /* Flag used to skip truncation case */
776              
777             /* Collect and boundary-check the current N-D coords */
778             for(k=0; k < prdim; k++){
779              
780             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
781              
782             /* normal case */
783             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
784             switch(__params->boundary[k]) {
785             case 0: /* no boundary breakage allowed */
786             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
787             break;
788             case 1: /* truncation */
789             trunc = 1;
790             break;
791             case 2: /* extension -- crop */
792             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
793             break;
794             case 3: /* periodic -- mod it */
795             ck %= __privtrans->pdls[0]->dims[k];
796             if(ck < 0) /* Fix mod breakage in C */
797             ck += __privtrans->pdls[0]->dims[k];
798             break;
799             case 4: /* mirror -- reflect off the edges */
800             ck += __privtrans->pdls[0]->dims[k];
801             ck %= (__privtrans->pdls[0]->dims[k] * 2);
802             if(ck < 0) /* Fix mod breakage in C */
803             ck += __privtrans->pdls[0]->dims[k]*2;
804             ck -= __privtrans->pdls[0]->dims[k];
805             if(ck < 0) {
806             ck *= -1;
807             ck -= 1;
808             }
809             break;
810             default:
811             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
812             break;
813             }
814             }
815              
816             coords[k] = ck;
817              
818             }
819              
820             /* Check extra dimensions -- pick up where k left off... */
821             for( ; k < rdim ; k++) {
822             /* Check for indexing off the end of the dimension list */
823              
824             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
825              
826             switch(__params->boundary[k]) {
827             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
828             if(ck != 0)
829             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
830             break;
831             case 1: /* truncation - just truncate if the corner is nonzero */
832             trunc |= (ck != 0);
833             break;
834             case 2: /* extension -- ignore the corner (same as 3) */
835             case 3: /* periodic -- ignore the corner */
836             case 4: /* mirror -- ignore the corner */
837             ck = 0;
838             break;
839             default:
840             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
841             break;
842             }
843             }
844              
845             /* Find offsets into the child and parent arrays, from the N-D coords */
846             /* Note we only loop over real source dims (prdim) to accumulate -- */
847             /* because the offset is trivial and/or we're truncating for virtual */
848             /* dims caused by permissive ranging. */
849             coff = __privtrans->pdls[1]->dimincs[0] * item;
850             for(k2 = __params->itdim, poff = k = 0;
851             k < prdim;
852             k++) {
853             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
854             if(__params->sizes[k])
855             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
856             }
857              
858             /* Loop the copy over all the source broadcast dims (above rdim). */
859             do {
860             PDL_Indx poff1 = poff;
861             PDL_Indx coff1 = coff;
862              
863             /* Accumulate the offset due to source broadcasting */
864             for(k2 = __params->itdim + __params->ntsize, k = rdim;
865             k < pdim;
866             k++) {
867             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
868             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
869             }
870              
871             /* Finally -- make the copy
872             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
873             * out-of-bounds conditions.
874             */
875             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,L,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
876              
877             /* Increment the source broadcast iterator */
878             for( k=__params->rdim;
879             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
880             k++)
881             iter2[k] = 0;
882             } while(k < pdim); /* end of source-broadcast iteration */
883              
884             /* Increment the in-range iterator */
885             for(k = 0;
886             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
887             k++)
888             iter2[k] = 0;
889             } while(k < __params->rdim); /* end of main iteration */
890             } /* end of item do loop */
891             #line 892 "lib/PDL/Slices-pp-rangeb.c"
892             }
893 2           } break;
894 0           case PDL_UL: {
895 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
896 0           {
897             #line 877 "lib/PDL/Slices.pd"
898             PDL_Indx *ip; /* vector iterator */
899             PDL_Indx *sp; /* size vector including stdims */
900             PDL_Indx *coords; /* current coordinates */
901              
902             PDL_Indx k; /* index */
903             PDL_Indx item; /* index broadcast iterator */
904             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
905             PDL_Indx rdim = __params->rdim;
906             PDL_Indx prdim = PDLMIN(rdim,pdim);
907             PDL_Indx iter2[pdim * 2 + rdim];
908             PDL_Indx *sizes = iter2 + pdim;
909             coords = sizes + pdim;
910              
911             /* Figure out size vector */
912             for(ip = __params->sizes, sp = sizes, k=0; k
913             *(sp++) = *(ip++);
914             for(; k < pdim; k++)
915             *(sp++) = __privtrans->pdls[0]->dims[k];
916              
917              
918             /* Loop over all the ranges in the index list */
919             for(item=0; item<__params->nitems; item++) {
920              
921             /* initialize in-range iterator to loop within each range */
922             for(ip = iter2, k=0; k
923             *(ip++) = 0;
924              
925             do {
926             PDL_Indx poff = 0;
927             PDL_Indx coff;
928             PDL_Indx k2;
929             char trunc = 0; /* Flag used to skip truncation case */
930              
931             /* Collect and boundary-check the current N-D coords */
932             for(k=0; k < prdim; k++){
933              
934             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
935              
936             /* normal case */
937             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
938             switch(__params->boundary[k]) {
939             case 0: /* no boundary breakage allowed */
940             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
941             break;
942             case 1: /* truncation */
943             trunc = 1;
944             break;
945             case 2: /* extension -- crop */
946             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
947             break;
948             case 3: /* periodic -- mod it */
949             ck %= __privtrans->pdls[0]->dims[k];
950             if(ck < 0) /* Fix mod breakage in C */
951             ck += __privtrans->pdls[0]->dims[k];
952             break;
953             case 4: /* mirror -- reflect off the edges */
954             ck += __privtrans->pdls[0]->dims[k];
955             ck %= (__privtrans->pdls[0]->dims[k] * 2);
956             if(ck < 0) /* Fix mod breakage in C */
957             ck += __privtrans->pdls[0]->dims[k]*2;
958             ck -= __privtrans->pdls[0]->dims[k];
959             if(ck < 0) {
960             ck *= -1;
961             ck -= 1;
962             }
963             break;
964             default:
965             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
966             break;
967             }
968             }
969              
970             coords[k] = ck;
971              
972             }
973              
974             /* Check extra dimensions -- pick up where k left off... */
975             for( ; k < rdim ; k++) {
976             /* Check for indexing off the end of the dimension list */
977              
978             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
979              
980             switch(__params->boundary[k]) {
981             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
982             if(ck != 0)
983             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
984             break;
985             case 1: /* truncation - just truncate if the corner is nonzero */
986             trunc |= (ck != 0);
987             break;
988             case 2: /* extension -- ignore the corner (same as 3) */
989             case 3: /* periodic -- ignore the corner */
990             case 4: /* mirror -- ignore the corner */
991             ck = 0;
992             break;
993             default:
994             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
995             break;
996             }
997             }
998              
999             /* Find offsets into the child and parent arrays, from the N-D coords */
1000             /* Note we only loop over real source dims (prdim) to accumulate -- */
1001             /* because the offset is trivial and/or we're truncating for virtual */
1002             /* dims caused by permissive ranging. */
1003             coff = __privtrans->pdls[1]->dimincs[0] * item;
1004             for(k2 = __params->itdim, poff = k = 0;
1005             k < prdim;
1006             k++) {
1007             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1008             if(__params->sizes[k])
1009             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1010             }
1011              
1012             /* Loop the copy over all the source broadcast dims (above rdim). */
1013             do {
1014             PDL_Indx poff1 = poff;
1015             PDL_Indx coff1 = coff;
1016              
1017             /* Accumulate the offset due to source broadcasting */
1018             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1019             k < pdim;
1020             k++) {
1021             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1022             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1023             }
1024              
1025             /* Finally -- make the copy
1026             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1027             * out-of-bounds conditions.
1028             */
1029             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,K,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1030              
1031             /* Increment the source broadcast iterator */
1032             for( k=__params->rdim;
1033             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1034             k++)
1035             iter2[k] = 0;
1036             } while(k < pdim); /* end of source-broadcast iteration */
1037              
1038             /* Increment the in-range iterator */
1039             for(k = 0;
1040             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1041             k++)
1042             iter2[k] = 0;
1043             } while(k < __params->rdim); /* end of main iteration */
1044             } /* end of item do loop */
1045             #line 1046 "lib/PDL/Slices-pp-rangeb.c"
1046             }
1047 0           } break;
1048 0           case PDL_IND: {
1049 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1050 0           {
1051             #line 877 "lib/PDL/Slices.pd"
1052             PDL_Indx *ip; /* vector iterator */
1053             PDL_Indx *sp; /* size vector including stdims */
1054             PDL_Indx *coords; /* current coordinates */
1055              
1056             PDL_Indx k; /* index */
1057             PDL_Indx item; /* index broadcast iterator */
1058             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1059             PDL_Indx rdim = __params->rdim;
1060             PDL_Indx prdim = PDLMIN(rdim,pdim);
1061             PDL_Indx iter2[pdim * 2 + rdim];
1062             PDL_Indx *sizes = iter2 + pdim;
1063             coords = sizes + pdim;
1064              
1065             /* Figure out size vector */
1066             for(ip = __params->sizes, sp = sizes, k=0; k
1067             *(sp++) = *(ip++);
1068             for(; k < pdim; k++)
1069             *(sp++) = __privtrans->pdls[0]->dims[k];
1070              
1071              
1072             /* Loop over all the ranges in the index list */
1073             for(item=0; item<__params->nitems; item++) {
1074              
1075             /* initialize in-range iterator to loop within each range */
1076             for(ip = iter2, k=0; k
1077             *(ip++) = 0;
1078              
1079             do {
1080             PDL_Indx poff = 0;
1081             PDL_Indx coff;
1082             PDL_Indx k2;
1083             char trunc = 0; /* Flag used to skip truncation case */
1084              
1085             /* Collect and boundary-check the current N-D coords */
1086             for(k=0; k < prdim; k++){
1087              
1088             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1089              
1090             /* normal case */
1091             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1092             switch(__params->boundary[k]) {
1093             case 0: /* no boundary breakage allowed */
1094             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1095             break;
1096             case 1: /* truncation */
1097             trunc = 1;
1098             break;
1099             case 2: /* extension -- crop */
1100             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1101             break;
1102             case 3: /* periodic -- mod it */
1103             ck %= __privtrans->pdls[0]->dims[k];
1104             if(ck < 0) /* Fix mod breakage in C */
1105             ck += __privtrans->pdls[0]->dims[k];
1106             break;
1107             case 4: /* mirror -- reflect off the edges */
1108             ck += __privtrans->pdls[0]->dims[k];
1109             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1110             if(ck < 0) /* Fix mod breakage in C */
1111             ck += __privtrans->pdls[0]->dims[k]*2;
1112             ck -= __privtrans->pdls[0]->dims[k];
1113             if(ck < 0) {
1114             ck *= -1;
1115             ck -= 1;
1116             }
1117             break;
1118             default:
1119             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1120             break;
1121             }
1122             }
1123              
1124             coords[k] = ck;
1125              
1126             }
1127              
1128             /* Check extra dimensions -- pick up where k left off... */
1129             for( ; k < rdim ; k++) {
1130             /* Check for indexing off the end of the dimension list */
1131              
1132             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1133              
1134             switch(__params->boundary[k]) {
1135             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1136             if(ck != 0)
1137             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1138             break;
1139             case 1: /* truncation - just truncate if the corner is nonzero */
1140             trunc |= (ck != 0);
1141             break;
1142             case 2: /* extension -- ignore the corner (same as 3) */
1143             case 3: /* periodic -- ignore the corner */
1144             case 4: /* mirror -- ignore the corner */
1145             ck = 0;
1146             break;
1147             default:
1148             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1149             break;
1150             }
1151             }
1152              
1153             /* Find offsets into the child and parent arrays, from the N-D coords */
1154             /* Note we only loop over real source dims (prdim) to accumulate -- */
1155             /* because the offset is trivial and/or we're truncating for virtual */
1156             /* dims caused by permissive ranging. */
1157             coff = __privtrans->pdls[1]->dimincs[0] * item;
1158             for(k2 = __params->itdim, poff = k = 0;
1159             k < prdim;
1160             k++) {
1161             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1162             if(__params->sizes[k])
1163             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1164             }
1165              
1166             /* Loop the copy over all the source broadcast dims (above rdim). */
1167             do {
1168             PDL_Indx poff1 = poff;
1169             PDL_Indx coff1 = coff;
1170              
1171             /* Accumulate the offset due to source broadcasting */
1172             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1173             k < pdim;
1174             k++) {
1175             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1176             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1177             }
1178              
1179             /* Finally -- make the copy
1180             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1181             * out-of-bounds conditions.
1182             */
1183             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,N,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1184              
1185             /* Increment the source broadcast iterator */
1186             for( k=__params->rdim;
1187             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1188             k++)
1189             iter2[k] = 0;
1190             } while(k < pdim); /* end of source-broadcast iteration */
1191              
1192             /* Increment the in-range iterator */
1193             for(k = 0;
1194             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1195             k++)
1196             iter2[k] = 0;
1197             } while(k < __params->rdim); /* end of main iteration */
1198             } /* end of item do loop */
1199             #line 1200 "lib/PDL/Slices-pp-rangeb.c"
1200             }
1201 0           } break;
1202 0           case PDL_ULL: {
1203 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1204 0           {
1205             #line 877 "lib/PDL/Slices.pd"
1206             PDL_Indx *ip; /* vector iterator */
1207             PDL_Indx *sp; /* size vector including stdims */
1208             PDL_Indx *coords; /* current coordinates */
1209              
1210             PDL_Indx k; /* index */
1211             PDL_Indx item; /* index broadcast iterator */
1212             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1213             PDL_Indx rdim = __params->rdim;
1214             PDL_Indx prdim = PDLMIN(rdim,pdim);
1215             PDL_Indx iter2[pdim * 2 + rdim];
1216             PDL_Indx *sizes = iter2 + pdim;
1217             coords = sizes + pdim;
1218              
1219             /* Figure out size vector */
1220             for(ip = __params->sizes, sp = sizes, k=0; k
1221             *(sp++) = *(ip++);
1222             for(; k < pdim; k++)
1223             *(sp++) = __privtrans->pdls[0]->dims[k];
1224              
1225              
1226             /* Loop over all the ranges in the index list */
1227             for(item=0; item<__params->nitems; item++) {
1228              
1229             /* initialize in-range iterator to loop within each range */
1230             for(ip = iter2, k=0; k
1231             *(ip++) = 0;
1232              
1233             do {
1234             PDL_Indx poff = 0;
1235             PDL_Indx coff;
1236             PDL_Indx k2;
1237             char trunc = 0; /* Flag used to skip truncation case */
1238              
1239             /* Collect and boundary-check the current N-D coords */
1240             for(k=0; k < prdim; k++){
1241              
1242             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1243              
1244             /* normal case */
1245             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1246             switch(__params->boundary[k]) {
1247             case 0: /* no boundary breakage allowed */
1248             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1249             break;
1250             case 1: /* truncation */
1251             trunc = 1;
1252             break;
1253             case 2: /* extension -- crop */
1254             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1255             break;
1256             case 3: /* periodic -- mod it */
1257             ck %= __privtrans->pdls[0]->dims[k];
1258             if(ck < 0) /* Fix mod breakage in C */
1259             ck += __privtrans->pdls[0]->dims[k];
1260             break;
1261             case 4: /* mirror -- reflect off the edges */
1262             ck += __privtrans->pdls[0]->dims[k];
1263             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1264             if(ck < 0) /* Fix mod breakage in C */
1265             ck += __privtrans->pdls[0]->dims[k]*2;
1266             ck -= __privtrans->pdls[0]->dims[k];
1267             if(ck < 0) {
1268             ck *= -1;
1269             ck -= 1;
1270             }
1271             break;
1272             default:
1273             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1274             break;
1275             }
1276             }
1277              
1278             coords[k] = ck;
1279              
1280             }
1281              
1282             /* Check extra dimensions -- pick up where k left off... */
1283             for( ; k < rdim ; k++) {
1284             /* Check for indexing off the end of the dimension list */
1285              
1286             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1287              
1288             switch(__params->boundary[k]) {
1289             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1290             if(ck != 0)
1291             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1292             break;
1293             case 1: /* truncation - just truncate if the corner is nonzero */
1294             trunc |= (ck != 0);
1295             break;
1296             case 2: /* extension -- ignore the corner (same as 3) */
1297             case 3: /* periodic -- ignore the corner */
1298             case 4: /* mirror -- ignore the corner */
1299             ck = 0;
1300             break;
1301             default:
1302             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1303             break;
1304             }
1305             }
1306              
1307             /* Find offsets into the child and parent arrays, from the N-D coords */
1308             /* Note we only loop over real source dims (prdim) to accumulate -- */
1309             /* because the offset is trivial and/or we're truncating for virtual */
1310             /* dims caused by permissive ranging. */
1311             coff = __privtrans->pdls[1]->dimincs[0] * item;
1312             for(k2 = __params->itdim, poff = k = 0;
1313             k < prdim;
1314             k++) {
1315             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1316             if(__params->sizes[k])
1317             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1318             }
1319              
1320             /* Loop the copy over all the source broadcast dims (above rdim). */
1321             do {
1322             PDL_Indx poff1 = poff;
1323             PDL_Indx coff1 = coff;
1324              
1325             /* Accumulate the offset due to source broadcasting */
1326             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1327             k < pdim;
1328             k++) {
1329             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1330             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1331             }
1332              
1333             /* Finally -- make the copy
1334             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1335             * out-of-bounds conditions.
1336             */
1337             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,P,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1338              
1339             /* Increment the source broadcast iterator */
1340             for( k=__params->rdim;
1341             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1342             k++)
1343             iter2[k] = 0;
1344             } while(k < pdim); /* end of source-broadcast iteration */
1345              
1346             /* Increment the in-range iterator */
1347             for(k = 0;
1348             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1349             k++)
1350             iter2[k] = 0;
1351             } while(k < __params->rdim); /* end of main iteration */
1352             } /* end of item do loop */
1353             #line 1354 "lib/PDL/Slices-pp-rangeb.c"
1354             }
1355 0           } break;
1356 0           case PDL_LL: {
1357 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1358 0           {
1359             #line 877 "lib/PDL/Slices.pd"
1360             PDL_Indx *ip; /* vector iterator */
1361             PDL_Indx *sp; /* size vector including stdims */
1362             PDL_Indx *coords; /* current coordinates */
1363              
1364             PDL_Indx k; /* index */
1365             PDL_Indx item; /* index broadcast iterator */
1366             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1367             PDL_Indx rdim = __params->rdim;
1368             PDL_Indx prdim = PDLMIN(rdim,pdim);
1369             PDL_Indx iter2[pdim * 2 + rdim];
1370             PDL_Indx *sizes = iter2 + pdim;
1371             coords = sizes + pdim;
1372              
1373             /* Figure out size vector */
1374             for(ip = __params->sizes, sp = sizes, k=0; k
1375             *(sp++) = *(ip++);
1376             for(; k < pdim; k++)
1377             *(sp++) = __privtrans->pdls[0]->dims[k];
1378              
1379              
1380             /* Loop over all the ranges in the index list */
1381             for(item=0; item<__params->nitems; item++) {
1382              
1383             /* initialize in-range iterator to loop within each range */
1384             for(ip = iter2, k=0; k
1385             *(ip++) = 0;
1386              
1387             do {
1388             PDL_Indx poff = 0;
1389             PDL_Indx coff;
1390             PDL_Indx k2;
1391             char trunc = 0; /* Flag used to skip truncation case */
1392              
1393             /* Collect and boundary-check the current N-D coords */
1394             for(k=0; k < prdim; k++){
1395              
1396             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1397              
1398             /* normal case */
1399             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1400             switch(__params->boundary[k]) {
1401             case 0: /* no boundary breakage allowed */
1402             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1403             break;
1404             case 1: /* truncation */
1405             trunc = 1;
1406             break;
1407             case 2: /* extension -- crop */
1408             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1409             break;
1410             case 3: /* periodic -- mod it */
1411             ck %= __privtrans->pdls[0]->dims[k];
1412             if(ck < 0) /* Fix mod breakage in C */
1413             ck += __privtrans->pdls[0]->dims[k];
1414             break;
1415             case 4: /* mirror -- reflect off the edges */
1416             ck += __privtrans->pdls[0]->dims[k];
1417             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1418             if(ck < 0) /* Fix mod breakage in C */
1419             ck += __privtrans->pdls[0]->dims[k]*2;
1420             ck -= __privtrans->pdls[0]->dims[k];
1421             if(ck < 0) {
1422             ck *= -1;
1423             ck -= 1;
1424             }
1425             break;
1426             default:
1427             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1428             break;
1429             }
1430             }
1431              
1432             coords[k] = ck;
1433              
1434             }
1435              
1436             /* Check extra dimensions -- pick up where k left off... */
1437             for( ; k < rdim ; k++) {
1438             /* Check for indexing off the end of the dimension list */
1439              
1440             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1441              
1442             switch(__params->boundary[k]) {
1443             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1444             if(ck != 0)
1445             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1446             break;
1447             case 1: /* truncation - just truncate if the corner is nonzero */
1448             trunc |= (ck != 0);
1449             break;
1450             case 2: /* extension -- ignore the corner (same as 3) */
1451             case 3: /* periodic -- ignore the corner */
1452             case 4: /* mirror -- ignore the corner */
1453             ck = 0;
1454             break;
1455             default:
1456             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1457             break;
1458             }
1459             }
1460              
1461             /* Find offsets into the child and parent arrays, from the N-D coords */
1462             /* Note we only loop over real source dims (prdim) to accumulate -- */
1463             /* because the offset is trivial and/or we're truncating for virtual */
1464             /* dims caused by permissive ranging. */
1465             coff = __privtrans->pdls[1]->dimincs[0] * item;
1466             for(k2 = __params->itdim, poff = k = 0;
1467             k < prdim;
1468             k++) {
1469             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1470             if(__params->sizes[k])
1471             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1472             }
1473              
1474             /* Loop the copy over all the source broadcast dims (above rdim). */
1475             do {
1476             PDL_Indx poff1 = poff;
1477             PDL_Indx coff1 = coff;
1478              
1479             /* Accumulate the offset due to source broadcasting */
1480             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1481             k < pdim;
1482             k++) {
1483             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1484             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1485             }
1486              
1487             /* Finally -- make the copy
1488             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1489             * out-of-bounds conditions.
1490             */
1491             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,Q,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1492              
1493             /* Increment the source broadcast iterator */
1494             for( k=__params->rdim;
1495             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1496             k++)
1497             iter2[k] = 0;
1498             } while(k < pdim); /* end of source-broadcast iteration */
1499              
1500             /* Increment the in-range iterator */
1501             for(k = 0;
1502             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1503             k++)
1504             iter2[k] = 0;
1505             } while(k < __params->rdim); /* end of main iteration */
1506             } /* end of item do loop */
1507             #line 1508 "lib/PDL/Slices-pp-rangeb.c"
1508             }
1509 0           } break;
1510 0           case PDL_F: {
1511 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1512 0           {
1513             #line 877 "lib/PDL/Slices.pd"
1514             PDL_Indx *ip; /* vector iterator */
1515             PDL_Indx *sp; /* size vector including stdims */
1516             PDL_Indx *coords; /* current coordinates */
1517              
1518             PDL_Indx k; /* index */
1519             PDL_Indx item; /* index broadcast iterator */
1520             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1521             PDL_Indx rdim = __params->rdim;
1522             PDL_Indx prdim = PDLMIN(rdim,pdim);
1523             PDL_Indx iter2[pdim * 2 + rdim];
1524             PDL_Indx *sizes = iter2 + pdim;
1525             coords = sizes + pdim;
1526              
1527             /* Figure out size vector */
1528             for(ip = __params->sizes, sp = sizes, k=0; k
1529             *(sp++) = *(ip++);
1530             for(; k < pdim; k++)
1531             *(sp++) = __privtrans->pdls[0]->dims[k];
1532              
1533              
1534             /* Loop over all the ranges in the index list */
1535             for(item=0; item<__params->nitems; item++) {
1536              
1537             /* initialize in-range iterator to loop within each range */
1538             for(ip = iter2, k=0; k
1539             *(ip++) = 0;
1540              
1541             do {
1542             PDL_Indx poff = 0;
1543             PDL_Indx coff;
1544             PDL_Indx k2;
1545             char trunc = 0; /* Flag used to skip truncation case */
1546              
1547             /* Collect and boundary-check the current N-D coords */
1548             for(k=0; k < prdim; k++){
1549              
1550             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1551              
1552             /* normal case */
1553             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1554             switch(__params->boundary[k]) {
1555             case 0: /* no boundary breakage allowed */
1556             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1557             break;
1558             case 1: /* truncation */
1559             trunc = 1;
1560             break;
1561             case 2: /* extension -- crop */
1562             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1563             break;
1564             case 3: /* periodic -- mod it */
1565             ck %= __privtrans->pdls[0]->dims[k];
1566             if(ck < 0) /* Fix mod breakage in C */
1567             ck += __privtrans->pdls[0]->dims[k];
1568             break;
1569             case 4: /* mirror -- reflect off the edges */
1570             ck += __privtrans->pdls[0]->dims[k];
1571             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1572             if(ck < 0) /* Fix mod breakage in C */
1573             ck += __privtrans->pdls[0]->dims[k]*2;
1574             ck -= __privtrans->pdls[0]->dims[k];
1575             if(ck < 0) {
1576             ck *= -1;
1577             ck -= 1;
1578             }
1579             break;
1580             default:
1581             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1582             break;
1583             }
1584             }
1585              
1586             coords[k] = ck;
1587              
1588             }
1589              
1590             /* Check extra dimensions -- pick up where k left off... */
1591             for( ; k < rdim ; k++) {
1592             /* Check for indexing off the end of the dimension list */
1593              
1594             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1595              
1596             switch(__params->boundary[k]) {
1597             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1598             if(ck != 0)
1599             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1600             break;
1601             case 1: /* truncation - just truncate if the corner is nonzero */
1602             trunc |= (ck != 0);
1603             break;
1604             case 2: /* extension -- ignore the corner (same as 3) */
1605             case 3: /* periodic -- ignore the corner */
1606             case 4: /* mirror -- ignore the corner */
1607             ck = 0;
1608             break;
1609             default:
1610             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1611             break;
1612             }
1613             }
1614              
1615             /* Find offsets into the child and parent arrays, from the N-D coords */
1616             /* Note we only loop over real source dims (prdim) to accumulate -- */
1617             /* because the offset is trivial and/or we're truncating for virtual */
1618             /* dims caused by permissive ranging. */
1619             coff = __privtrans->pdls[1]->dimincs[0] * item;
1620             for(k2 = __params->itdim, poff = k = 0;
1621             k < prdim;
1622             k++) {
1623             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1624             if(__params->sizes[k])
1625             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1626             }
1627              
1628             /* Loop the copy over all the source broadcast dims (above rdim). */
1629             do {
1630             PDL_Indx poff1 = poff;
1631             PDL_Indx coff1 = coff;
1632              
1633             /* Accumulate the offset due to source broadcasting */
1634             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1635             k < pdim;
1636             k++) {
1637             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1638             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1639             }
1640              
1641             /* Finally -- make the copy
1642             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1643             * out-of-bounds conditions.
1644             */
1645             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,F,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1646              
1647             /* Increment the source broadcast iterator */
1648             for( k=__params->rdim;
1649             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1650             k++)
1651             iter2[k] = 0;
1652             } while(k < pdim); /* end of source-broadcast iteration */
1653              
1654             /* Increment the in-range iterator */
1655             for(k = 0;
1656             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1657             k++)
1658             iter2[k] = 0;
1659             } while(k < __params->rdim); /* end of main iteration */
1660             } /* end of item do loop */
1661             #line 1662 "lib/PDL/Slices-pp-rangeb.c"
1662             }
1663 0           } break;
1664 1           case PDL_D: {
1665 1 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
1666 1           {
1667             #line 877 "lib/PDL/Slices.pd"
1668             PDL_Indx *ip; /* vector iterator */
1669             PDL_Indx *sp; /* size vector including stdims */
1670             PDL_Indx *coords; /* current coordinates */
1671              
1672             PDL_Indx k; /* index */
1673             PDL_Indx item; /* index broadcast iterator */
1674             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1675             PDL_Indx rdim = __params->rdim;
1676             PDL_Indx prdim = PDLMIN(rdim,pdim);
1677             PDL_Indx iter2[pdim * 2 + rdim];
1678             PDL_Indx *sizes = iter2 + pdim;
1679             coords = sizes + pdim;
1680              
1681             /* Figure out size vector */
1682             for(ip = __params->sizes, sp = sizes, k=0; k
1683             *(sp++) = *(ip++);
1684             for(; k < pdim; k++)
1685             *(sp++) = __privtrans->pdls[0]->dims[k];
1686              
1687              
1688             /* Loop over all the ranges in the index list */
1689             for(item=0; item<__params->nitems; item++) {
1690              
1691             /* initialize in-range iterator to loop within each range */
1692             for(ip = iter2, k=0; k
1693             *(ip++) = 0;
1694              
1695             do {
1696             PDL_Indx poff = 0;
1697             PDL_Indx coff;
1698             PDL_Indx k2;
1699             char trunc = 0; /* Flag used to skip truncation case */
1700              
1701             /* Collect and boundary-check the current N-D coords */
1702             for(k=0; k < prdim; k++){
1703              
1704             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1705              
1706             /* normal case */
1707             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1708             switch(__params->boundary[k]) {
1709             case 0: /* no boundary breakage allowed */
1710             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1711             break;
1712             case 1: /* truncation */
1713             trunc = 1;
1714             break;
1715             case 2: /* extension -- crop */
1716             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1717             break;
1718             case 3: /* periodic -- mod it */
1719             ck %= __privtrans->pdls[0]->dims[k];
1720             if(ck < 0) /* Fix mod breakage in C */
1721             ck += __privtrans->pdls[0]->dims[k];
1722             break;
1723             case 4: /* mirror -- reflect off the edges */
1724             ck += __privtrans->pdls[0]->dims[k];
1725             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1726             if(ck < 0) /* Fix mod breakage in C */
1727             ck += __privtrans->pdls[0]->dims[k]*2;
1728             ck -= __privtrans->pdls[0]->dims[k];
1729             if(ck < 0) {
1730             ck *= -1;
1731             ck -= 1;
1732             }
1733             break;
1734             default:
1735             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1736             break;
1737             }
1738             }
1739              
1740             coords[k] = ck;
1741              
1742             }
1743              
1744             /* Check extra dimensions -- pick up where k left off... */
1745             for( ; k < rdim ; k++) {
1746             /* Check for indexing off the end of the dimension list */
1747              
1748             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1749              
1750             switch(__params->boundary[k]) {
1751             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1752             if(ck != 0)
1753             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1754             break;
1755             case 1: /* truncation - just truncate if the corner is nonzero */
1756             trunc |= (ck != 0);
1757             break;
1758             case 2: /* extension -- ignore the corner (same as 3) */
1759             case 3: /* periodic -- ignore the corner */
1760             case 4: /* mirror -- ignore the corner */
1761             ck = 0;
1762             break;
1763             default:
1764             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1765             break;
1766             }
1767             }
1768              
1769             /* Find offsets into the child and parent arrays, from the N-D coords */
1770             /* Note we only loop over real source dims (prdim) to accumulate -- */
1771             /* because the offset is trivial and/or we're truncating for virtual */
1772             /* dims caused by permissive ranging. */
1773             coff = __privtrans->pdls[1]->dimincs[0] * item;
1774             for(k2 = __params->itdim, poff = k = 0;
1775             k < prdim;
1776             k++) {
1777             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1778             if(__params->sizes[k])
1779             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1780             }
1781              
1782             /* Loop the copy over all the source broadcast dims (above rdim). */
1783             do {
1784             PDL_Indx poff1 = poff;
1785             PDL_Indx coff1 = coff;
1786              
1787             /* Accumulate the offset due to source broadcasting */
1788             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1789             k < pdim;
1790             k++) {
1791             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1792             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1793             }
1794              
1795             /* Finally -- make the copy
1796             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1797             * out-of-bounds conditions.
1798             */
1799             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,D,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1800              
1801             /* Increment the source broadcast iterator */
1802             for( k=__params->rdim;
1803             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1804             k++)
1805             iter2[k] = 0;
1806             } while(k < pdim); /* end of source-broadcast iteration */
1807              
1808             /* Increment the in-range iterator */
1809             for(k = 0;
1810             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1811             k++)
1812             iter2[k] = 0;
1813             } while(k < __params->rdim); /* end of main iteration */
1814             } /* end of item do loop */
1815             #line 1816 "lib/PDL/Slices-pp-rangeb.c"
1816             }
1817 1           } break;
1818 0           case PDL_LD: {
1819 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1820 0           {
1821             #line 877 "lib/PDL/Slices.pd"
1822             PDL_Indx *ip; /* vector iterator */
1823             PDL_Indx *sp; /* size vector including stdims */
1824             PDL_Indx *coords; /* current coordinates */
1825              
1826             PDL_Indx k; /* index */
1827             PDL_Indx item; /* index broadcast iterator */
1828             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1829             PDL_Indx rdim = __params->rdim;
1830             PDL_Indx prdim = PDLMIN(rdim,pdim);
1831             PDL_Indx iter2[pdim * 2 + rdim];
1832             PDL_Indx *sizes = iter2 + pdim;
1833             coords = sizes + pdim;
1834              
1835             /* Figure out size vector */
1836             for(ip = __params->sizes, sp = sizes, k=0; k
1837             *(sp++) = *(ip++);
1838             for(; k < pdim; k++)
1839             *(sp++) = __privtrans->pdls[0]->dims[k];
1840              
1841              
1842             /* Loop over all the ranges in the index list */
1843             for(item=0; item<__params->nitems; item++) {
1844              
1845             /* initialize in-range iterator to loop within each range */
1846             for(ip = iter2, k=0; k
1847             *(ip++) = 0;
1848              
1849             do {
1850             PDL_Indx poff = 0;
1851             PDL_Indx coff;
1852             PDL_Indx k2;
1853             char trunc = 0; /* Flag used to skip truncation case */
1854              
1855             /* Collect and boundary-check the current N-D coords */
1856             for(k=0; k < prdim; k++){
1857              
1858             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1859              
1860             /* normal case */
1861             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
1862             switch(__params->boundary[k]) {
1863             case 0: /* no boundary breakage allowed */
1864             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
1865             break;
1866             case 1: /* truncation */
1867             trunc = 1;
1868             break;
1869             case 2: /* extension -- crop */
1870             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
1871             break;
1872             case 3: /* periodic -- mod it */
1873             ck %= __privtrans->pdls[0]->dims[k];
1874             if(ck < 0) /* Fix mod breakage in C */
1875             ck += __privtrans->pdls[0]->dims[k];
1876             break;
1877             case 4: /* mirror -- reflect off the edges */
1878             ck += __privtrans->pdls[0]->dims[k];
1879             ck %= (__privtrans->pdls[0]->dims[k] * 2);
1880             if(ck < 0) /* Fix mod breakage in C */
1881             ck += __privtrans->pdls[0]->dims[k]*2;
1882             ck -= __privtrans->pdls[0]->dims[k];
1883             if(ck < 0) {
1884             ck *= -1;
1885             ck -= 1;
1886             }
1887             break;
1888             default:
1889             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1890             break;
1891             }
1892             }
1893              
1894             coords[k] = ck;
1895              
1896             }
1897              
1898             /* Check extra dimensions -- pick up where k left off... */
1899             for( ; k < rdim ; k++) {
1900             /* Check for indexing off the end of the dimension list */
1901              
1902             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
1903              
1904             switch(__params->boundary[k]) {
1905             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
1906             if(ck != 0)
1907             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
1908             break;
1909             case 1: /* truncation - just truncate if the corner is nonzero */
1910             trunc |= (ck != 0);
1911             break;
1912             case 2: /* extension -- ignore the corner (same as 3) */
1913             case 3: /* periodic -- ignore the corner */
1914             case 4: /* mirror -- ignore the corner */
1915             ck = 0;
1916             break;
1917             default:
1918             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
1919             break;
1920             }
1921             }
1922              
1923             /* Find offsets into the child and parent arrays, from the N-D coords */
1924             /* Note we only loop over real source dims (prdim) to accumulate -- */
1925             /* because the offset is trivial and/or we're truncating for virtual */
1926             /* dims caused by permissive ranging. */
1927             coff = __privtrans->pdls[1]->dimincs[0] * item;
1928             for(k2 = __params->itdim, poff = k = 0;
1929             k < prdim;
1930             k++) {
1931             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
1932             if(__params->sizes[k])
1933             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1934             }
1935              
1936             /* Loop the copy over all the source broadcast dims (above rdim). */
1937             do {
1938             PDL_Indx poff1 = poff;
1939             PDL_Indx coff1 = coff;
1940              
1941             /* Accumulate the offset due to source broadcasting */
1942             for(k2 = __params->itdim + __params->ntsize, k = rdim;
1943             k < pdim;
1944             k++) {
1945             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
1946             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
1947             }
1948              
1949             /* Finally -- make the copy
1950             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
1951             * out-of-bounds conditions.
1952             */
1953             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,E,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
1954              
1955             /* Increment the source broadcast iterator */
1956             for( k=__params->rdim;
1957             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
1958             k++)
1959             iter2[k] = 0;
1960             } while(k < pdim); /* end of source-broadcast iteration */
1961              
1962             /* Increment the in-range iterator */
1963             for(k = 0;
1964             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
1965             k++)
1966             iter2[k] = 0;
1967             } while(k < __params->rdim); /* end of main iteration */
1968             } /* end of item do loop */
1969             #line 1970 "lib/PDL/Slices-pp-rangeb.c"
1970             }
1971 0           } break;
1972 0           case PDL_CF: {
1973 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CFloat,G)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1974 0           {
1975             #line 877 "lib/PDL/Slices.pd"
1976             PDL_Indx *ip; /* vector iterator */
1977             PDL_Indx *sp; /* size vector including stdims */
1978             PDL_Indx *coords; /* current coordinates */
1979              
1980             PDL_Indx k; /* index */
1981             PDL_Indx item; /* index broadcast iterator */
1982             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
1983             PDL_Indx rdim = __params->rdim;
1984             PDL_Indx prdim = PDLMIN(rdim,pdim);
1985             PDL_Indx iter2[pdim * 2 + rdim];
1986             PDL_Indx *sizes = iter2 + pdim;
1987             coords = sizes + pdim;
1988              
1989             /* Figure out size vector */
1990             for(ip = __params->sizes, sp = sizes, k=0; k
1991             *(sp++) = *(ip++);
1992             for(; k < pdim; k++)
1993             *(sp++) = __privtrans->pdls[0]->dims[k];
1994              
1995              
1996             /* Loop over all the ranges in the index list */
1997             for(item=0; item<__params->nitems; item++) {
1998              
1999             /* initialize in-range iterator to loop within each range */
2000             for(ip = iter2, k=0; k
2001             *(ip++) = 0;
2002              
2003             do {
2004             PDL_Indx poff = 0;
2005             PDL_Indx coff;
2006             PDL_Indx k2;
2007             char trunc = 0; /* Flag used to skip truncation case */
2008              
2009             /* Collect and boundary-check the current N-D coords */
2010             for(k=0; k < prdim; k++){
2011              
2012             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2013              
2014             /* normal case */
2015             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2016             switch(__params->boundary[k]) {
2017             case 0: /* no boundary breakage allowed */
2018             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2019             break;
2020             case 1: /* truncation */
2021             trunc = 1;
2022             break;
2023             case 2: /* extension -- crop */
2024             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2025             break;
2026             case 3: /* periodic -- mod it */
2027             ck %= __privtrans->pdls[0]->dims[k];
2028             if(ck < 0) /* Fix mod breakage in C */
2029             ck += __privtrans->pdls[0]->dims[k];
2030             break;
2031             case 4: /* mirror -- reflect off the edges */
2032             ck += __privtrans->pdls[0]->dims[k];
2033             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2034             if(ck < 0) /* Fix mod breakage in C */
2035             ck += __privtrans->pdls[0]->dims[k]*2;
2036             ck -= __privtrans->pdls[0]->dims[k];
2037             if(ck < 0) {
2038             ck *= -1;
2039             ck -= 1;
2040             }
2041             break;
2042             default:
2043             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2044             break;
2045             }
2046             }
2047              
2048             coords[k] = ck;
2049              
2050             }
2051              
2052             /* Check extra dimensions -- pick up where k left off... */
2053             for( ; k < rdim ; k++) {
2054             /* Check for indexing off the end of the dimension list */
2055              
2056             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2057              
2058             switch(__params->boundary[k]) {
2059             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2060             if(ck != 0)
2061             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2062             break;
2063             case 1: /* truncation - just truncate if the corner is nonzero */
2064             trunc |= (ck != 0);
2065             break;
2066             case 2: /* extension -- ignore the corner (same as 3) */
2067             case 3: /* periodic -- ignore the corner */
2068             case 4: /* mirror -- ignore the corner */
2069             ck = 0;
2070             break;
2071             default:
2072             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2073             break;
2074             }
2075             }
2076              
2077             /* Find offsets into the child and parent arrays, from the N-D coords */
2078             /* Note we only loop over real source dims (prdim) to accumulate -- */
2079             /* because the offset is trivial and/or we're truncating for virtual */
2080             /* dims caused by permissive ranging. */
2081             coff = __privtrans->pdls[1]->dimincs[0] * item;
2082             for(k2 = __params->itdim, poff = k = 0;
2083             k < prdim;
2084             k++) {
2085             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2086             if(__params->sizes[k])
2087             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2088             }
2089              
2090             /* Loop the copy over all the source broadcast dims (above rdim). */
2091             do {
2092             PDL_Indx poff1 = poff;
2093             PDL_Indx coff1 = coff;
2094              
2095             /* Accumulate the offset due to source broadcasting */
2096             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2097             k < pdim;
2098             k++) {
2099             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2100             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2101             }
2102              
2103             /* Finally -- make the copy
2104             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2105             * out-of-bounds conditions.
2106             */
2107             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,G,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2108              
2109             /* Increment the source broadcast iterator */
2110             for( k=__params->rdim;
2111             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2112             k++)
2113             iter2[k] = 0;
2114             } while(k < pdim); /* end of source-broadcast iteration */
2115              
2116             /* Increment the in-range iterator */
2117             for(k = 0;
2118             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2119             k++)
2120             iter2[k] = 0;
2121             } while(k < __params->rdim); /* end of main iteration */
2122             } /* end of item do loop */
2123             #line 2124 "lib/PDL/Slices-pp-rangeb.c"
2124             }
2125 0           } break;
2126 0           case PDL_CD: {
2127 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CDouble,C)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2128 0           {
2129             #line 877 "lib/PDL/Slices.pd"
2130             PDL_Indx *ip; /* vector iterator */
2131             PDL_Indx *sp; /* size vector including stdims */
2132             PDL_Indx *coords; /* current coordinates */
2133              
2134             PDL_Indx k; /* index */
2135             PDL_Indx item; /* index broadcast iterator */
2136             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2137             PDL_Indx rdim = __params->rdim;
2138             PDL_Indx prdim = PDLMIN(rdim,pdim);
2139             PDL_Indx iter2[pdim * 2 + rdim];
2140             PDL_Indx *sizes = iter2 + pdim;
2141             coords = sizes + pdim;
2142              
2143             /* Figure out size vector */
2144             for(ip = __params->sizes, sp = sizes, k=0; k
2145             *(sp++) = *(ip++);
2146             for(; k < pdim; k++)
2147             *(sp++) = __privtrans->pdls[0]->dims[k];
2148              
2149              
2150             /* Loop over all the ranges in the index list */
2151             for(item=0; item<__params->nitems; item++) {
2152              
2153             /* initialize in-range iterator to loop within each range */
2154             for(ip = iter2, k=0; k
2155             *(ip++) = 0;
2156              
2157             do {
2158             PDL_Indx poff = 0;
2159             PDL_Indx coff;
2160             PDL_Indx k2;
2161             char trunc = 0; /* Flag used to skip truncation case */
2162              
2163             /* Collect and boundary-check the current N-D coords */
2164             for(k=0; k < prdim; k++){
2165              
2166             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2167              
2168             /* normal case */
2169             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2170             switch(__params->boundary[k]) {
2171             case 0: /* no boundary breakage allowed */
2172             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2173             break;
2174             case 1: /* truncation */
2175             trunc = 1;
2176             break;
2177             case 2: /* extension -- crop */
2178             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2179             break;
2180             case 3: /* periodic -- mod it */
2181             ck %= __privtrans->pdls[0]->dims[k];
2182             if(ck < 0) /* Fix mod breakage in C */
2183             ck += __privtrans->pdls[0]->dims[k];
2184             break;
2185             case 4: /* mirror -- reflect off the edges */
2186             ck += __privtrans->pdls[0]->dims[k];
2187             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2188             if(ck < 0) /* Fix mod breakage in C */
2189             ck += __privtrans->pdls[0]->dims[k]*2;
2190             ck -= __privtrans->pdls[0]->dims[k];
2191             if(ck < 0) {
2192             ck *= -1;
2193             ck -= 1;
2194             }
2195             break;
2196             default:
2197             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2198             break;
2199             }
2200             }
2201              
2202             coords[k] = ck;
2203              
2204             }
2205              
2206             /* Check extra dimensions -- pick up where k left off... */
2207             for( ; k < rdim ; k++) {
2208             /* Check for indexing off the end of the dimension list */
2209              
2210             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2211              
2212             switch(__params->boundary[k]) {
2213             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2214             if(ck != 0)
2215             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2216             break;
2217             case 1: /* truncation - just truncate if the corner is nonzero */
2218             trunc |= (ck != 0);
2219             break;
2220             case 2: /* extension -- ignore the corner (same as 3) */
2221             case 3: /* periodic -- ignore the corner */
2222             case 4: /* mirror -- ignore the corner */
2223             ck = 0;
2224             break;
2225             default:
2226             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2227             break;
2228             }
2229             }
2230              
2231             /* Find offsets into the child and parent arrays, from the N-D coords */
2232             /* Note we only loop over real source dims (prdim) to accumulate -- */
2233             /* because the offset is trivial and/or we're truncating for virtual */
2234             /* dims caused by permissive ranging. */
2235             coff = __privtrans->pdls[1]->dimincs[0] * item;
2236             for(k2 = __params->itdim, poff = k = 0;
2237             k < prdim;
2238             k++) {
2239             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2240             if(__params->sizes[k])
2241             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2242             }
2243              
2244             /* Loop the copy over all the source broadcast dims (above rdim). */
2245             do {
2246             PDL_Indx poff1 = poff;
2247             PDL_Indx coff1 = coff;
2248              
2249             /* Accumulate the offset due to source broadcasting */
2250             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2251             k < pdim;
2252             k++) {
2253             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2254             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2255             }
2256              
2257             /* Finally -- make the copy
2258             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2259             * out-of-bounds conditions.
2260             */
2261             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,C,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2262              
2263             /* Increment the source broadcast iterator */
2264             for( k=__params->rdim;
2265             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2266             k++)
2267             iter2[k] = 0;
2268             } while(k < pdim); /* end of source-broadcast iteration */
2269              
2270             /* Increment the in-range iterator */
2271             for(k = 0;
2272             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2273             k++)
2274             iter2[k] = 0;
2275             } while(k < __params->rdim); /* end of main iteration */
2276             } /* end of item do loop */
2277             #line 2278 "lib/PDL/Slices-pp-rangeb.c"
2278             }
2279 0           } break;
2280 0           case PDL_CLD: {
2281 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CLDouble,H)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2282 0           {
2283             #line 877 "lib/PDL/Slices.pd"
2284             PDL_Indx *ip; /* vector iterator */
2285             PDL_Indx *sp; /* size vector including stdims */
2286             PDL_Indx *coords; /* current coordinates */
2287              
2288             PDL_Indx k; /* index */
2289             PDL_Indx item; /* index broadcast iterator */
2290             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2291             PDL_Indx rdim = __params->rdim;
2292             PDL_Indx prdim = PDLMIN(rdim,pdim);
2293             PDL_Indx iter2[pdim * 2 + rdim];
2294             PDL_Indx *sizes = iter2 + pdim;
2295             coords = sizes + pdim;
2296              
2297             /* Figure out size vector */
2298             for(ip = __params->sizes, sp = sizes, k=0; k
2299             *(sp++) = *(ip++);
2300             for(; k < pdim; k++)
2301             *(sp++) = __privtrans->pdls[0]->dims[k];
2302              
2303              
2304             /* Loop over all the ranges in the index list */
2305             for(item=0; item<__params->nitems; item++) {
2306              
2307             /* initialize in-range iterator to loop within each range */
2308             for(ip = iter2, k=0; k
2309             *(ip++) = 0;
2310              
2311             do {
2312             PDL_Indx poff = 0;
2313             PDL_Indx coff;
2314             PDL_Indx k2;
2315             char trunc = 0; /* Flag used to skip truncation case */
2316              
2317             /* Collect and boundary-check the current N-D coords */
2318             for(k=0; k < prdim; k++){
2319              
2320             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2321              
2322             /* normal case */
2323             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2324             switch(__params->boundary[k]) {
2325             case 0: /* no boundary breakage allowed */
2326             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2327             break;
2328             case 1: /* truncation */
2329             trunc = 1;
2330             break;
2331             case 2: /* extension -- crop */
2332             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2333             break;
2334             case 3: /* periodic -- mod it */
2335             ck %= __privtrans->pdls[0]->dims[k];
2336             if(ck < 0) /* Fix mod breakage in C */
2337             ck += __privtrans->pdls[0]->dims[k];
2338             break;
2339             case 4: /* mirror -- reflect off the edges */
2340             ck += __privtrans->pdls[0]->dims[k];
2341             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2342             if(ck < 0) /* Fix mod breakage in C */
2343             ck += __privtrans->pdls[0]->dims[k]*2;
2344             ck -= __privtrans->pdls[0]->dims[k];
2345             if(ck < 0) {
2346             ck *= -1;
2347             ck -= 1;
2348             }
2349             break;
2350             default:
2351             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2352             break;
2353             }
2354             }
2355              
2356             coords[k] = ck;
2357              
2358             }
2359              
2360             /* Check extra dimensions -- pick up where k left off... */
2361             for( ; k < rdim ; k++) {
2362             /* Check for indexing off the end of the dimension list */
2363              
2364             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2365              
2366             switch(__params->boundary[k]) {
2367             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2368             if(ck != 0)
2369             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2370             break;
2371             case 1: /* truncation - just truncate if the corner is nonzero */
2372             trunc |= (ck != 0);
2373             break;
2374             case 2: /* extension -- ignore the corner (same as 3) */
2375             case 3: /* periodic -- ignore the corner */
2376             case 4: /* mirror -- ignore the corner */
2377             ck = 0;
2378             break;
2379             default:
2380             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2381             break;
2382             }
2383             }
2384              
2385             /* Find offsets into the child and parent arrays, from the N-D coords */
2386             /* Note we only loop over real source dims (prdim) to accumulate -- */
2387             /* because the offset is trivial and/or we're truncating for virtual */
2388             /* dims caused by permissive ranging. */
2389             coff = __privtrans->pdls[1]->dimincs[0] * item;
2390             for(k2 = __params->itdim, poff = k = 0;
2391             k < prdim;
2392             k++) {
2393             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2394             if(__params->sizes[k])
2395             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2396             }
2397              
2398             /* Loop the copy over all the source broadcast dims (above rdim). */
2399             do {
2400             PDL_Indx poff1 = poff;
2401             PDL_Indx coff1 = coff;
2402              
2403             /* Accumulate the offset due to source broadcasting */
2404             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2405             k < pdim;
2406             k++) {
2407             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2408             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2409             }
2410              
2411             /* Finally -- make the copy
2412             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2413             * out-of-bounds conditions.
2414             */
2415             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,H,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2416              
2417             /* Increment the source broadcast iterator */
2418             for( k=__params->rdim;
2419             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2420             k++)
2421             iter2[k] = 0;
2422             } while(k < pdim); /* end of source-broadcast iteration */
2423              
2424             /* Increment the in-range iterator */
2425             for(k = 0;
2426             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2427             k++)
2428             iter2[k] = 0;
2429             } while(k < __params->rdim); /* end of main iteration */
2430             } /* end of item do loop */
2431             #line 2432 "lib/PDL/Slices-pp-rangeb.c"
2432             }
2433 0           } break;
2434 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rangeb: unhandled datatype(%d), only handles (ABSULKNPQFDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
2435             }
2436             #undef PDL_BAD_CODE
2437             #undef PDL_IF_BAD
2438             } else { /* ** else do 'good' Code ** */
2439             #define PDL_IF_BAD(t,f) f
2440 84           switch (__privtrans->__datatype) { /* Start generic switch */
2441 0           case PDL_SB: {
2442 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2443 0           {
2444             #line 877 "lib/PDL/Slices.pd"
2445             PDL_Indx *ip; /* vector iterator */
2446             PDL_Indx *sp; /* size vector including stdims */
2447             PDL_Indx *coords; /* current coordinates */
2448              
2449             PDL_Indx k; /* index */
2450             PDL_Indx item; /* index broadcast iterator */
2451             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2452             PDL_Indx rdim = __params->rdim;
2453             PDL_Indx prdim = PDLMIN(rdim,pdim);
2454             PDL_Indx iter2[pdim * 2 + rdim];
2455             PDL_Indx *sizes = iter2 + pdim;
2456             coords = sizes + pdim;
2457              
2458             /* Figure out size vector */
2459             for(ip = __params->sizes, sp = sizes, k=0; k
2460             *(sp++) = *(ip++);
2461             for(; k < pdim; k++)
2462             *(sp++) = __privtrans->pdls[0]->dims[k];
2463              
2464              
2465             /* Loop over all the ranges in the index list */
2466             for(item=0; item<__params->nitems; item++) {
2467              
2468             /* initialize in-range iterator to loop within each range */
2469             for(ip = iter2, k=0; k
2470             *(ip++) = 0;
2471              
2472             do {
2473             PDL_Indx poff = 0;
2474             PDL_Indx coff;
2475             PDL_Indx k2;
2476             char trunc = 0; /* Flag used to skip truncation case */
2477              
2478             /* Collect and boundary-check the current N-D coords */
2479             for(k=0; k < prdim; k++){
2480              
2481             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2482              
2483             /* normal case */
2484             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2485             switch(__params->boundary[k]) {
2486             case 0: /* no boundary breakage allowed */
2487             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2488             break;
2489             case 1: /* truncation */
2490             trunc = 1;
2491             break;
2492             case 2: /* extension -- crop */
2493             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2494             break;
2495             case 3: /* periodic -- mod it */
2496             ck %= __privtrans->pdls[0]->dims[k];
2497             if(ck < 0) /* Fix mod breakage in C */
2498             ck += __privtrans->pdls[0]->dims[k];
2499             break;
2500             case 4: /* mirror -- reflect off the edges */
2501             ck += __privtrans->pdls[0]->dims[k];
2502             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2503             if(ck < 0) /* Fix mod breakage in C */
2504             ck += __privtrans->pdls[0]->dims[k]*2;
2505             ck -= __privtrans->pdls[0]->dims[k];
2506             if(ck < 0) {
2507             ck *= -1;
2508             ck -= 1;
2509             }
2510             break;
2511             default:
2512             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2513             break;
2514             }
2515             }
2516              
2517             coords[k] = ck;
2518              
2519             }
2520              
2521             /* Check extra dimensions -- pick up where k left off... */
2522             for( ; k < rdim ; k++) {
2523             /* Check for indexing off the end of the dimension list */
2524              
2525             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2526              
2527             switch(__params->boundary[k]) {
2528             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2529             if(ck != 0)
2530             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2531             break;
2532             case 1: /* truncation - just truncate if the corner is nonzero */
2533             trunc |= (ck != 0);
2534             break;
2535             case 2: /* extension -- ignore the corner (same as 3) */
2536             case 3: /* periodic -- ignore the corner */
2537             case 4: /* mirror -- ignore the corner */
2538             ck = 0;
2539             break;
2540             default:
2541             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2542             break;
2543             }
2544             }
2545              
2546             /* Find offsets into the child and parent arrays, from the N-D coords */
2547             /* Note we only loop over real source dims (prdim) to accumulate -- */
2548             /* because the offset is trivial and/or we're truncating for virtual */
2549             /* dims caused by permissive ranging. */
2550             coff = __privtrans->pdls[1]->dimincs[0] * item;
2551             for(k2 = __params->itdim, poff = k = 0;
2552             k < prdim;
2553             k++) {
2554             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2555             if(__params->sizes[k])
2556             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2557             }
2558              
2559             /* Loop the copy over all the source broadcast dims (above rdim). */
2560             do {
2561             PDL_Indx poff1 = poff;
2562             PDL_Indx coff1 = coff;
2563              
2564             /* Accumulate the offset due to source broadcasting */
2565             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2566             k < pdim;
2567             k++) {
2568             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2569             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2570             }
2571              
2572             /* Finally -- make the copy
2573             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2574             * out-of-bounds conditions.
2575             */
2576             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,A,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2577              
2578             /* Increment the source broadcast iterator */
2579             for( k=__params->rdim;
2580             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2581             k++)
2582             iter2[k] = 0;
2583             } while(k < pdim); /* end of source-broadcast iteration */
2584              
2585             /* Increment the in-range iterator */
2586             for(k = 0;
2587             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2588             k++)
2589             iter2[k] = 0;
2590             } while(k < __params->rdim); /* end of main iteration */
2591             } /* end of item do loop */
2592             #line 2593 "lib/PDL/Slices-pp-rangeb.c"
2593             }
2594 0           } break;
2595 1           case PDL_B: {
2596 1 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Byte,B)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
2597 1           {
2598             #line 877 "lib/PDL/Slices.pd"
2599             PDL_Indx *ip; /* vector iterator */
2600             PDL_Indx *sp; /* size vector including stdims */
2601             PDL_Indx *coords; /* current coordinates */
2602              
2603             PDL_Indx k; /* index */
2604             PDL_Indx item; /* index broadcast iterator */
2605             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2606             PDL_Indx rdim = __params->rdim;
2607             PDL_Indx prdim = PDLMIN(rdim,pdim);
2608             PDL_Indx iter2[pdim * 2 + rdim];
2609             PDL_Indx *sizes = iter2 + pdim;
2610             coords = sizes + pdim;
2611              
2612             /* Figure out size vector */
2613             for(ip = __params->sizes, sp = sizes, k=0; k
2614             *(sp++) = *(ip++);
2615             for(; k < pdim; k++)
2616             *(sp++) = __privtrans->pdls[0]->dims[k];
2617              
2618              
2619             /* Loop over all the ranges in the index list */
2620             for(item=0; item<__params->nitems; item++) {
2621              
2622             /* initialize in-range iterator to loop within each range */
2623             for(ip = iter2, k=0; k
2624             *(ip++) = 0;
2625              
2626             do {
2627             PDL_Indx poff = 0;
2628             PDL_Indx coff;
2629             PDL_Indx k2;
2630             char trunc = 0; /* Flag used to skip truncation case */
2631              
2632             /* Collect and boundary-check the current N-D coords */
2633             for(k=0; k < prdim; k++){
2634              
2635             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2636              
2637             /* normal case */
2638             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2639             switch(__params->boundary[k]) {
2640             case 0: /* no boundary breakage allowed */
2641             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2642             break;
2643             case 1: /* truncation */
2644             trunc = 1;
2645             break;
2646             case 2: /* extension -- crop */
2647             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2648             break;
2649             case 3: /* periodic -- mod it */
2650             ck %= __privtrans->pdls[0]->dims[k];
2651             if(ck < 0) /* Fix mod breakage in C */
2652             ck += __privtrans->pdls[0]->dims[k];
2653             break;
2654             case 4: /* mirror -- reflect off the edges */
2655             ck += __privtrans->pdls[0]->dims[k];
2656             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2657             if(ck < 0) /* Fix mod breakage in C */
2658             ck += __privtrans->pdls[0]->dims[k]*2;
2659             ck -= __privtrans->pdls[0]->dims[k];
2660             if(ck < 0) {
2661             ck *= -1;
2662             ck -= 1;
2663             }
2664             break;
2665             default:
2666             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2667             break;
2668             }
2669             }
2670              
2671             coords[k] = ck;
2672              
2673             }
2674              
2675             /* Check extra dimensions -- pick up where k left off... */
2676             for( ; k < rdim ; k++) {
2677             /* Check for indexing off the end of the dimension list */
2678              
2679             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2680              
2681             switch(__params->boundary[k]) {
2682             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2683             if(ck != 0)
2684             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2685             break;
2686             case 1: /* truncation - just truncate if the corner is nonzero */
2687             trunc |= (ck != 0);
2688             break;
2689             case 2: /* extension -- ignore the corner (same as 3) */
2690             case 3: /* periodic -- ignore the corner */
2691             case 4: /* mirror -- ignore the corner */
2692             ck = 0;
2693             break;
2694             default:
2695             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2696             break;
2697             }
2698             }
2699              
2700             /* Find offsets into the child and parent arrays, from the N-D coords */
2701             /* Note we only loop over real source dims (prdim) to accumulate -- */
2702             /* because the offset is trivial and/or we're truncating for virtual */
2703             /* dims caused by permissive ranging. */
2704             coff = __privtrans->pdls[1]->dimincs[0] * item;
2705             for(k2 = __params->itdim, poff = k = 0;
2706             k < prdim;
2707             k++) {
2708             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2709             if(__params->sizes[k])
2710             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2711             }
2712              
2713             /* Loop the copy over all the source broadcast dims (above rdim). */
2714             do {
2715             PDL_Indx poff1 = poff;
2716             PDL_Indx coff1 = coff;
2717              
2718             /* Accumulate the offset due to source broadcasting */
2719             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2720             k < pdim;
2721             k++) {
2722             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2723             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2724             }
2725              
2726             /* Finally -- make the copy
2727             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2728             * out-of-bounds conditions.
2729             */
2730             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,B,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2731              
2732             /* Increment the source broadcast iterator */
2733             for( k=__params->rdim;
2734             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2735             k++)
2736             iter2[k] = 0;
2737             } while(k < pdim); /* end of source-broadcast iteration */
2738              
2739             /* Increment the in-range iterator */
2740             for(k = 0;
2741             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2742             k++)
2743             iter2[k] = 0;
2744             } while(k < __params->rdim); /* end of main iteration */
2745             } /* end of item do loop */
2746             #line 2747 "lib/PDL/Slices-pp-rangeb.c"
2747             }
2748 1           } break;
2749 1           case PDL_S: {
2750 1 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Short,S)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
2751 1           {
2752             #line 877 "lib/PDL/Slices.pd"
2753             PDL_Indx *ip; /* vector iterator */
2754             PDL_Indx *sp; /* size vector including stdims */
2755             PDL_Indx *coords; /* current coordinates */
2756              
2757             PDL_Indx k; /* index */
2758             PDL_Indx item; /* index broadcast iterator */
2759             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2760             PDL_Indx rdim = __params->rdim;
2761             PDL_Indx prdim = PDLMIN(rdim,pdim);
2762             PDL_Indx iter2[pdim * 2 + rdim];
2763             PDL_Indx *sizes = iter2 + pdim;
2764             coords = sizes + pdim;
2765              
2766             /* Figure out size vector */
2767             for(ip = __params->sizes, sp = sizes, k=0; k
2768             *(sp++) = *(ip++);
2769             for(; k < pdim; k++)
2770             *(sp++) = __privtrans->pdls[0]->dims[k];
2771              
2772              
2773             /* Loop over all the ranges in the index list */
2774             for(item=0; item<__params->nitems; item++) {
2775              
2776             /* initialize in-range iterator to loop within each range */
2777             for(ip = iter2, k=0; k
2778             *(ip++) = 0;
2779              
2780             do {
2781             PDL_Indx poff = 0;
2782             PDL_Indx coff;
2783             PDL_Indx k2;
2784             char trunc = 0; /* Flag used to skip truncation case */
2785              
2786             /* Collect and boundary-check the current N-D coords */
2787             for(k=0; k < prdim; k++){
2788              
2789             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2790              
2791             /* normal case */
2792             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2793             switch(__params->boundary[k]) {
2794             case 0: /* no boundary breakage allowed */
2795             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2796             break;
2797             case 1: /* truncation */
2798             trunc = 1;
2799             break;
2800             case 2: /* extension -- crop */
2801             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2802             break;
2803             case 3: /* periodic -- mod it */
2804             ck %= __privtrans->pdls[0]->dims[k];
2805             if(ck < 0) /* Fix mod breakage in C */
2806             ck += __privtrans->pdls[0]->dims[k];
2807             break;
2808             case 4: /* mirror -- reflect off the edges */
2809             ck += __privtrans->pdls[0]->dims[k];
2810             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2811             if(ck < 0) /* Fix mod breakage in C */
2812             ck += __privtrans->pdls[0]->dims[k]*2;
2813             ck -= __privtrans->pdls[0]->dims[k];
2814             if(ck < 0) {
2815             ck *= -1;
2816             ck -= 1;
2817             }
2818             break;
2819             default:
2820             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2821             break;
2822             }
2823             }
2824              
2825             coords[k] = ck;
2826              
2827             }
2828              
2829             /* Check extra dimensions -- pick up where k left off... */
2830             for( ; k < rdim ; k++) {
2831             /* Check for indexing off the end of the dimension list */
2832              
2833             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2834              
2835             switch(__params->boundary[k]) {
2836             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2837             if(ck != 0)
2838             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2839             break;
2840             case 1: /* truncation - just truncate if the corner is nonzero */
2841             trunc |= (ck != 0);
2842             break;
2843             case 2: /* extension -- ignore the corner (same as 3) */
2844             case 3: /* periodic -- ignore the corner */
2845             case 4: /* mirror -- ignore the corner */
2846             ck = 0;
2847             break;
2848             default:
2849             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2850             break;
2851             }
2852             }
2853              
2854             /* Find offsets into the child and parent arrays, from the N-D coords */
2855             /* Note we only loop over real source dims (prdim) to accumulate -- */
2856             /* because the offset is trivial and/or we're truncating for virtual */
2857             /* dims caused by permissive ranging. */
2858             coff = __privtrans->pdls[1]->dimincs[0] * item;
2859             for(k2 = __params->itdim, poff = k = 0;
2860             k < prdim;
2861             k++) {
2862             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
2863             if(__params->sizes[k])
2864             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2865             }
2866              
2867             /* Loop the copy over all the source broadcast dims (above rdim). */
2868             do {
2869             PDL_Indx poff1 = poff;
2870             PDL_Indx coff1 = coff;
2871              
2872             /* Accumulate the offset due to source broadcasting */
2873             for(k2 = __params->itdim + __params->ntsize, k = rdim;
2874             k < pdim;
2875             k++) {
2876             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
2877             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
2878             }
2879              
2880             /* Finally -- make the copy
2881             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
2882             * out-of-bounds conditions.
2883             */
2884             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,S,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
2885              
2886             /* Increment the source broadcast iterator */
2887             for( k=__params->rdim;
2888             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
2889             k++)
2890             iter2[k] = 0;
2891             } while(k < pdim); /* end of source-broadcast iteration */
2892              
2893             /* Increment the in-range iterator */
2894             for(k = 0;
2895             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
2896             k++)
2897             iter2[k] = 0;
2898             } while(k < __params->rdim); /* end of main iteration */
2899             } /* end of item do loop */
2900             #line 2901 "lib/PDL/Slices-pp-rangeb.c"
2901             }
2902 1           } break;
2903 0           case PDL_US: {
2904 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2905 0           {
2906             #line 877 "lib/PDL/Slices.pd"
2907             PDL_Indx *ip; /* vector iterator */
2908             PDL_Indx *sp; /* size vector including stdims */
2909             PDL_Indx *coords; /* current coordinates */
2910              
2911             PDL_Indx k; /* index */
2912             PDL_Indx item; /* index broadcast iterator */
2913             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
2914             PDL_Indx rdim = __params->rdim;
2915             PDL_Indx prdim = PDLMIN(rdim,pdim);
2916             PDL_Indx iter2[pdim * 2 + rdim];
2917             PDL_Indx *sizes = iter2 + pdim;
2918             coords = sizes + pdim;
2919              
2920             /* Figure out size vector */
2921             for(ip = __params->sizes, sp = sizes, k=0; k
2922             *(sp++) = *(ip++);
2923             for(; k < pdim; k++)
2924             *(sp++) = __privtrans->pdls[0]->dims[k];
2925              
2926              
2927             /* Loop over all the ranges in the index list */
2928             for(item=0; item<__params->nitems; item++) {
2929              
2930             /* initialize in-range iterator to loop within each range */
2931             for(ip = iter2, k=0; k
2932             *(ip++) = 0;
2933              
2934             do {
2935             PDL_Indx poff = 0;
2936             PDL_Indx coff;
2937             PDL_Indx k2;
2938             char trunc = 0; /* Flag used to skip truncation case */
2939              
2940             /* Collect and boundary-check the current N-D coords */
2941             for(k=0; k < prdim; k++){
2942              
2943             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2944              
2945             /* normal case */
2946             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
2947             switch(__params->boundary[k]) {
2948             case 0: /* no boundary breakage allowed */
2949             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
2950             break;
2951             case 1: /* truncation */
2952             trunc = 1;
2953             break;
2954             case 2: /* extension -- crop */
2955             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
2956             break;
2957             case 3: /* periodic -- mod it */
2958             ck %= __privtrans->pdls[0]->dims[k];
2959             if(ck < 0) /* Fix mod breakage in C */
2960             ck += __privtrans->pdls[0]->dims[k];
2961             break;
2962             case 4: /* mirror -- reflect off the edges */
2963             ck += __privtrans->pdls[0]->dims[k];
2964             ck %= (__privtrans->pdls[0]->dims[k] * 2);
2965             if(ck < 0) /* Fix mod breakage in C */
2966             ck += __privtrans->pdls[0]->dims[k]*2;
2967             ck -= __privtrans->pdls[0]->dims[k];
2968             if(ck < 0) {
2969             ck *= -1;
2970             ck -= 1;
2971             }
2972             break;
2973             default:
2974             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
2975             break;
2976             }
2977             }
2978              
2979             coords[k] = ck;
2980              
2981             }
2982              
2983             /* Check extra dimensions -- pick up where k left off... */
2984             for( ; k < rdim ; k++) {
2985             /* Check for indexing off the end of the dimension list */
2986              
2987             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
2988              
2989             switch(__params->boundary[k]) {
2990             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
2991             if(ck != 0)
2992             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
2993             break;
2994             case 1: /* truncation - just truncate if the corner is nonzero */
2995             trunc |= (ck != 0);
2996             break;
2997             case 2: /* extension -- ignore the corner (same as 3) */
2998             case 3: /* periodic -- ignore the corner */
2999             case 4: /* mirror -- ignore the corner */
3000             ck = 0;
3001             break;
3002             default:
3003             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3004             break;
3005             }
3006             }
3007              
3008             /* Find offsets into the child and parent arrays, from the N-D coords */
3009             /* Note we only loop over real source dims (prdim) to accumulate -- */
3010             /* because the offset is trivial and/or we're truncating for virtual */
3011             /* dims caused by permissive ranging. */
3012             coff = __privtrans->pdls[1]->dimincs[0] * item;
3013             for(k2 = __params->itdim, poff = k = 0;
3014             k < prdim;
3015             k++) {
3016             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3017             if(__params->sizes[k])
3018             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3019             }
3020              
3021             /* Loop the copy over all the source broadcast dims (above rdim). */
3022             do {
3023             PDL_Indx poff1 = poff;
3024             PDL_Indx coff1 = coff;
3025              
3026             /* Accumulate the offset due to source broadcasting */
3027             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3028             k < pdim;
3029             k++) {
3030             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3031             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3032             }
3033              
3034             /* Finally -- make the copy
3035             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3036             * out-of-bounds conditions.
3037             */
3038             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,U,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3039              
3040             /* Increment the source broadcast iterator */
3041             for( k=__params->rdim;
3042             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3043             k++)
3044             iter2[k] = 0;
3045             } while(k < pdim); /* end of source-broadcast iteration */
3046              
3047             /* Increment the in-range iterator */
3048             for(k = 0;
3049             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3050             k++)
3051             iter2[k] = 0;
3052             } while(k < __params->rdim); /* end of main iteration */
3053             } /* end of item do loop */
3054             #line 3055 "lib/PDL/Slices-pp-rangeb.c"
3055             }
3056 0           } break;
3057 25           case PDL_L: {
3058 25 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Long,L)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
3059 25           {
3060             #line 877 "lib/PDL/Slices.pd"
3061             PDL_Indx *ip; /* vector iterator */
3062             PDL_Indx *sp; /* size vector including stdims */
3063             PDL_Indx *coords; /* current coordinates */
3064              
3065             PDL_Indx k; /* index */
3066             PDL_Indx item; /* index broadcast iterator */
3067             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3068             PDL_Indx rdim = __params->rdim;
3069             PDL_Indx prdim = PDLMIN(rdim,pdim);
3070             PDL_Indx iter2[pdim * 2 + rdim];
3071             PDL_Indx *sizes = iter2 + pdim;
3072             coords = sizes + pdim;
3073              
3074             /* Figure out size vector */
3075             for(ip = __params->sizes, sp = sizes, k=0; k
3076             *(sp++) = *(ip++);
3077             for(; k < pdim; k++)
3078             *(sp++) = __privtrans->pdls[0]->dims[k];
3079              
3080              
3081             /* Loop over all the ranges in the index list */
3082             for(item=0; item<__params->nitems; item++) {
3083              
3084             /* initialize in-range iterator to loop within each range */
3085             for(ip = iter2, k=0; k
3086             *(ip++) = 0;
3087              
3088             do {
3089             PDL_Indx poff = 0;
3090             PDL_Indx coff;
3091             PDL_Indx k2;
3092             char trunc = 0; /* Flag used to skip truncation case */
3093              
3094             /* Collect and boundary-check the current N-D coords */
3095             for(k=0; k < prdim; k++){
3096              
3097             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3098              
3099             /* normal case */
3100             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3101             switch(__params->boundary[k]) {
3102             case 0: /* no boundary breakage allowed */
3103             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3104             break;
3105             case 1: /* truncation */
3106             trunc = 1;
3107             break;
3108             case 2: /* extension -- crop */
3109             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3110             break;
3111             case 3: /* periodic -- mod it */
3112             ck %= __privtrans->pdls[0]->dims[k];
3113             if(ck < 0) /* Fix mod breakage in C */
3114             ck += __privtrans->pdls[0]->dims[k];
3115             break;
3116             case 4: /* mirror -- reflect off the edges */
3117             ck += __privtrans->pdls[0]->dims[k];
3118             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3119             if(ck < 0) /* Fix mod breakage in C */
3120             ck += __privtrans->pdls[0]->dims[k]*2;
3121             ck -= __privtrans->pdls[0]->dims[k];
3122             if(ck < 0) {
3123             ck *= -1;
3124             ck -= 1;
3125             }
3126             break;
3127             default:
3128             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3129             break;
3130             }
3131             }
3132              
3133             coords[k] = ck;
3134              
3135             }
3136              
3137             /* Check extra dimensions -- pick up where k left off... */
3138             for( ; k < rdim ; k++) {
3139             /* Check for indexing off the end of the dimension list */
3140              
3141             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3142              
3143             switch(__params->boundary[k]) {
3144             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3145             if(ck != 0)
3146             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3147             break;
3148             case 1: /* truncation - just truncate if the corner is nonzero */
3149             trunc |= (ck != 0);
3150             break;
3151             case 2: /* extension -- ignore the corner (same as 3) */
3152             case 3: /* periodic -- ignore the corner */
3153             case 4: /* mirror -- ignore the corner */
3154             ck = 0;
3155             break;
3156             default:
3157             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3158             break;
3159             }
3160             }
3161              
3162             /* Find offsets into the child and parent arrays, from the N-D coords */
3163             /* Note we only loop over real source dims (prdim) to accumulate -- */
3164             /* because the offset is trivial and/or we're truncating for virtual */
3165             /* dims caused by permissive ranging. */
3166             coff = __privtrans->pdls[1]->dimincs[0] * item;
3167             for(k2 = __params->itdim, poff = k = 0;
3168             k < prdim;
3169             k++) {
3170             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3171             if(__params->sizes[k])
3172             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3173             }
3174              
3175             /* Loop the copy over all the source broadcast dims (above rdim). */
3176             do {
3177             PDL_Indx poff1 = poff;
3178             PDL_Indx coff1 = coff;
3179              
3180             /* Accumulate the offset due to source broadcasting */
3181             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3182             k < pdim;
3183             k++) {
3184             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3185             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3186             }
3187              
3188             /* Finally -- make the copy
3189             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3190             * out-of-bounds conditions.
3191             */
3192             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,L,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3193              
3194             /* Increment the source broadcast iterator */
3195             for( k=__params->rdim;
3196             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3197             k++)
3198             iter2[k] = 0;
3199             } while(k < pdim); /* end of source-broadcast iteration */
3200              
3201             /* Increment the in-range iterator */
3202             for(k = 0;
3203             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3204             k++)
3205             iter2[k] = 0;
3206             } while(k < __params->rdim); /* end of main iteration */
3207             } /* end of item do loop */
3208             #line 3209 "lib/PDL/Slices-pp-rangeb.c"
3209             }
3210 25           } break;
3211 0           case PDL_UL: {
3212 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
3213 0           {
3214             #line 877 "lib/PDL/Slices.pd"
3215             PDL_Indx *ip; /* vector iterator */
3216             PDL_Indx *sp; /* size vector including stdims */
3217             PDL_Indx *coords; /* current coordinates */
3218              
3219             PDL_Indx k; /* index */
3220             PDL_Indx item; /* index broadcast iterator */
3221             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3222             PDL_Indx rdim = __params->rdim;
3223             PDL_Indx prdim = PDLMIN(rdim,pdim);
3224             PDL_Indx iter2[pdim * 2 + rdim];
3225             PDL_Indx *sizes = iter2 + pdim;
3226             coords = sizes + pdim;
3227              
3228             /* Figure out size vector */
3229             for(ip = __params->sizes, sp = sizes, k=0; k
3230             *(sp++) = *(ip++);
3231             for(; k < pdim; k++)
3232             *(sp++) = __privtrans->pdls[0]->dims[k];
3233              
3234              
3235             /* Loop over all the ranges in the index list */
3236             for(item=0; item<__params->nitems; item++) {
3237              
3238             /* initialize in-range iterator to loop within each range */
3239             for(ip = iter2, k=0; k
3240             *(ip++) = 0;
3241              
3242             do {
3243             PDL_Indx poff = 0;
3244             PDL_Indx coff;
3245             PDL_Indx k2;
3246             char trunc = 0; /* Flag used to skip truncation case */
3247              
3248             /* Collect and boundary-check the current N-D coords */
3249             for(k=0; k < prdim; k++){
3250              
3251             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3252              
3253             /* normal case */
3254             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3255             switch(__params->boundary[k]) {
3256             case 0: /* no boundary breakage allowed */
3257             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3258             break;
3259             case 1: /* truncation */
3260             trunc = 1;
3261             break;
3262             case 2: /* extension -- crop */
3263             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3264             break;
3265             case 3: /* periodic -- mod it */
3266             ck %= __privtrans->pdls[0]->dims[k];
3267             if(ck < 0) /* Fix mod breakage in C */
3268             ck += __privtrans->pdls[0]->dims[k];
3269             break;
3270             case 4: /* mirror -- reflect off the edges */
3271             ck += __privtrans->pdls[0]->dims[k];
3272             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3273             if(ck < 0) /* Fix mod breakage in C */
3274             ck += __privtrans->pdls[0]->dims[k]*2;
3275             ck -= __privtrans->pdls[0]->dims[k];
3276             if(ck < 0) {
3277             ck *= -1;
3278             ck -= 1;
3279             }
3280             break;
3281             default:
3282             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3283             break;
3284             }
3285             }
3286              
3287             coords[k] = ck;
3288              
3289             }
3290              
3291             /* Check extra dimensions -- pick up where k left off... */
3292             for( ; k < rdim ; k++) {
3293             /* Check for indexing off the end of the dimension list */
3294              
3295             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3296              
3297             switch(__params->boundary[k]) {
3298             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3299             if(ck != 0)
3300             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3301             break;
3302             case 1: /* truncation - just truncate if the corner is nonzero */
3303             trunc |= (ck != 0);
3304             break;
3305             case 2: /* extension -- ignore the corner (same as 3) */
3306             case 3: /* periodic -- ignore the corner */
3307             case 4: /* mirror -- ignore the corner */
3308             ck = 0;
3309             break;
3310             default:
3311             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3312             break;
3313             }
3314             }
3315              
3316             /* Find offsets into the child and parent arrays, from the N-D coords */
3317             /* Note we only loop over real source dims (prdim) to accumulate -- */
3318             /* because the offset is trivial and/or we're truncating for virtual */
3319             /* dims caused by permissive ranging. */
3320             coff = __privtrans->pdls[1]->dimincs[0] * item;
3321             for(k2 = __params->itdim, poff = k = 0;
3322             k < prdim;
3323             k++) {
3324             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3325             if(__params->sizes[k])
3326             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3327             }
3328              
3329             /* Loop the copy over all the source broadcast dims (above rdim). */
3330             do {
3331             PDL_Indx poff1 = poff;
3332             PDL_Indx coff1 = coff;
3333              
3334             /* Accumulate the offset due to source broadcasting */
3335             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3336             k < pdim;
3337             k++) {
3338             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3339             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3340             }
3341              
3342             /* Finally -- make the copy
3343             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3344             * out-of-bounds conditions.
3345             */
3346             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,K,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3347              
3348             /* Increment the source broadcast iterator */
3349             for( k=__params->rdim;
3350             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3351             k++)
3352             iter2[k] = 0;
3353             } while(k < pdim); /* end of source-broadcast iteration */
3354              
3355             /* Increment the in-range iterator */
3356             for(k = 0;
3357             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3358             k++)
3359             iter2[k] = 0;
3360             } while(k < __params->rdim); /* end of main iteration */
3361             } /* end of item do loop */
3362             #line 3363 "lib/PDL/Slices-pp-rangeb.c"
3363             }
3364 0           } break;
3365 1           case PDL_IND: {
3366 1 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Indx,N)
    50          
    0          
    50          
    50          
    50          
    50          
    50          
3367 1           {
3368             #line 877 "lib/PDL/Slices.pd"
3369             PDL_Indx *ip; /* vector iterator */
3370             PDL_Indx *sp; /* size vector including stdims */
3371             PDL_Indx *coords; /* current coordinates */
3372              
3373             PDL_Indx k; /* index */
3374             PDL_Indx item; /* index broadcast iterator */
3375             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3376             PDL_Indx rdim = __params->rdim;
3377             PDL_Indx prdim = PDLMIN(rdim,pdim);
3378             PDL_Indx iter2[pdim * 2 + rdim];
3379             PDL_Indx *sizes = iter2 + pdim;
3380             coords = sizes + pdim;
3381              
3382             /* Figure out size vector */
3383             for(ip = __params->sizes, sp = sizes, k=0; k
3384             *(sp++) = *(ip++);
3385             for(; k < pdim; k++)
3386             *(sp++) = __privtrans->pdls[0]->dims[k];
3387              
3388              
3389             /* Loop over all the ranges in the index list */
3390             for(item=0; item<__params->nitems; item++) {
3391              
3392             /* initialize in-range iterator to loop within each range */
3393             for(ip = iter2, k=0; k
3394             *(ip++) = 0;
3395              
3396             do {
3397             PDL_Indx poff = 0;
3398             PDL_Indx coff;
3399             PDL_Indx k2;
3400             char trunc = 0; /* Flag used to skip truncation case */
3401              
3402             /* Collect and boundary-check the current N-D coords */
3403             for(k=0; k < prdim; k++){
3404              
3405             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3406              
3407             /* normal case */
3408             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3409             switch(__params->boundary[k]) {
3410             case 0: /* no boundary breakage allowed */
3411             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3412             break;
3413             case 1: /* truncation */
3414             trunc = 1;
3415             break;
3416             case 2: /* extension -- crop */
3417             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3418             break;
3419             case 3: /* periodic -- mod it */
3420             ck %= __privtrans->pdls[0]->dims[k];
3421             if(ck < 0) /* Fix mod breakage in C */
3422             ck += __privtrans->pdls[0]->dims[k];
3423             break;
3424             case 4: /* mirror -- reflect off the edges */
3425             ck += __privtrans->pdls[0]->dims[k];
3426             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3427             if(ck < 0) /* Fix mod breakage in C */
3428             ck += __privtrans->pdls[0]->dims[k]*2;
3429             ck -= __privtrans->pdls[0]->dims[k];
3430             if(ck < 0) {
3431             ck *= -1;
3432             ck -= 1;
3433             }
3434             break;
3435             default:
3436             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3437             break;
3438             }
3439             }
3440              
3441             coords[k] = ck;
3442              
3443             }
3444              
3445             /* Check extra dimensions -- pick up where k left off... */
3446             for( ; k < rdim ; k++) {
3447             /* Check for indexing off the end of the dimension list */
3448              
3449             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3450              
3451             switch(__params->boundary[k]) {
3452             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3453             if(ck != 0)
3454             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3455             break;
3456             case 1: /* truncation - just truncate if the corner is nonzero */
3457             trunc |= (ck != 0);
3458             break;
3459             case 2: /* extension -- ignore the corner (same as 3) */
3460             case 3: /* periodic -- ignore the corner */
3461             case 4: /* mirror -- ignore the corner */
3462             ck = 0;
3463             break;
3464             default:
3465             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3466             break;
3467             }
3468             }
3469              
3470             /* Find offsets into the child and parent arrays, from the N-D coords */
3471             /* Note we only loop over real source dims (prdim) to accumulate -- */
3472             /* because the offset is trivial and/or we're truncating for virtual */
3473             /* dims caused by permissive ranging. */
3474             coff = __privtrans->pdls[1]->dimincs[0] * item;
3475             for(k2 = __params->itdim, poff = k = 0;
3476             k < prdim;
3477             k++) {
3478             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3479             if(__params->sizes[k])
3480             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3481             }
3482              
3483             /* Loop the copy over all the source broadcast dims (above rdim). */
3484             do {
3485             PDL_Indx poff1 = poff;
3486             PDL_Indx coff1 = coff;
3487              
3488             /* Accumulate the offset due to source broadcasting */
3489             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3490             k < pdim;
3491             k++) {
3492             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3493             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3494             }
3495              
3496             /* Finally -- make the copy
3497             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3498             * out-of-bounds conditions.
3499             */
3500             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,N,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3501              
3502             /* Increment the source broadcast iterator */
3503             for( k=__params->rdim;
3504             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3505             k++)
3506             iter2[k] = 0;
3507             } while(k < pdim); /* end of source-broadcast iteration */
3508              
3509             /* Increment the in-range iterator */
3510             for(k = 0;
3511             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3512             k++)
3513             iter2[k] = 0;
3514             } while(k < __params->rdim); /* end of main iteration */
3515             } /* end of item do loop */
3516             #line 3517 "lib/PDL/Slices-pp-rangeb.c"
3517             }
3518 1           } break;
3519 0           case PDL_ULL: {
3520 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
3521 0           {
3522             #line 877 "lib/PDL/Slices.pd"
3523             PDL_Indx *ip; /* vector iterator */
3524             PDL_Indx *sp; /* size vector including stdims */
3525             PDL_Indx *coords; /* current coordinates */
3526              
3527             PDL_Indx k; /* index */
3528             PDL_Indx item; /* index broadcast iterator */
3529             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3530             PDL_Indx rdim = __params->rdim;
3531             PDL_Indx prdim = PDLMIN(rdim,pdim);
3532             PDL_Indx iter2[pdim * 2 + rdim];
3533             PDL_Indx *sizes = iter2 + pdim;
3534             coords = sizes + pdim;
3535              
3536             /* Figure out size vector */
3537             for(ip = __params->sizes, sp = sizes, k=0; k
3538             *(sp++) = *(ip++);
3539             for(; k < pdim; k++)
3540             *(sp++) = __privtrans->pdls[0]->dims[k];
3541              
3542              
3543             /* Loop over all the ranges in the index list */
3544             for(item=0; item<__params->nitems; item++) {
3545              
3546             /* initialize in-range iterator to loop within each range */
3547             for(ip = iter2, k=0; k
3548             *(ip++) = 0;
3549              
3550             do {
3551             PDL_Indx poff = 0;
3552             PDL_Indx coff;
3553             PDL_Indx k2;
3554             char trunc = 0; /* Flag used to skip truncation case */
3555              
3556             /* Collect and boundary-check the current N-D coords */
3557             for(k=0; k < prdim; k++){
3558              
3559             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3560              
3561             /* normal case */
3562             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3563             switch(__params->boundary[k]) {
3564             case 0: /* no boundary breakage allowed */
3565             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3566             break;
3567             case 1: /* truncation */
3568             trunc = 1;
3569             break;
3570             case 2: /* extension -- crop */
3571             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3572             break;
3573             case 3: /* periodic -- mod it */
3574             ck %= __privtrans->pdls[0]->dims[k];
3575             if(ck < 0) /* Fix mod breakage in C */
3576             ck += __privtrans->pdls[0]->dims[k];
3577             break;
3578             case 4: /* mirror -- reflect off the edges */
3579             ck += __privtrans->pdls[0]->dims[k];
3580             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3581             if(ck < 0) /* Fix mod breakage in C */
3582             ck += __privtrans->pdls[0]->dims[k]*2;
3583             ck -= __privtrans->pdls[0]->dims[k];
3584             if(ck < 0) {
3585             ck *= -1;
3586             ck -= 1;
3587             }
3588             break;
3589             default:
3590             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3591             break;
3592             }
3593             }
3594              
3595             coords[k] = ck;
3596              
3597             }
3598              
3599             /* Check extra dimensions -- pick up where k left off... */
3600             for( ; k < rdim ; k++) {
3601             /* Check for indexing off the end of the dimension list */
3602              
3603             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3604              
3605             switch(__params->boundary[k]) {
3606             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3607             if(ck != 0)
3608             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3609             break;
3610             case 1: /* truncation - just truncate if the corner is nonzero */
3611             trunc |= (ck != 0);
3612             break;
3613             case 2: /* extension -- ignore the corner (same as 3) */
3614             case 3: /* periodic -- ignore the corner */
3615             case 4: /* mirror -- ignore the corner */
3616             ck = 0;
3617             break;
3618             default:
3619             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3620             break;
3621             }
3622             }
3623              
3624             /* Find offsets into the child and parent arrays, from the N-D coords */
3625             /* Note we only loop over real source dims (prdim) to accumulate -- */
3626             /* because the offset is trivial and/or we're truncating for virtual */
3627             /* dims caused by permissive ranging. */
3628             coff = __privtrans->pdls[1]->dimincs[0] * item;
3629             for(k2 = __params->itdim, poff = k = 0;
3630             k < prdim;
3631             k++) {
3632             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3633             if(__params->sizes[k])
3634             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3635             }
3636              
3637             /* Loop the copy over all the source broadcast dims (above rdim). */
3638             do {
3639             PDL_Indx poff1 = poff;
3640             PDL_Indx coff1 = coff;
3641              
3642             /* Accumulate the offset due to source broadcasting */
3643             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3644             k < pdim;
3645             k++) {
3646             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3647             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3648             }
3649              
3650             /* Finally -- make the copy
3651             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3652             * out-of-bounds conditions.
3653             */
3654             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,P,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3655              
3656             /* Increment the source broadcast iterator */
3657             for( k=__params->rdim;
3658             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3659             k++)
3660             iter2[k] = 0;
3661             } while(k < pdim); /* end of source-broadcast iteration */
3662              
3663             /* Increment the in-range iterator */
3664             for(k = 0;
3665             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3666             k++)
3667             iter2[k] = 0;
3668             } while(k < __params->rdim); /* end of main iteration */
3669             } /* end of item do loop */
3670             #line 3671 "lib/PDL/Slices-pp-rangeb.c"
3671             }
3672 0           } break;
3673 0           case PDL_LL: {
3674 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
3675 0           {
3676             #line 877 "lib/PDL/Slices.pd"
3677             PDL_Indx *ip; /* vector iterator */
3678             PDL_Indx *sp; /* size vector including stdims */
3679             PDL_Indx *coords; /* current coordinates */
3680              
3681             PDL_Indx k; /* index */
3682             PDL_Indx item; /* index broadcast iterator */
3683             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3684             PDL_Indx rdim = __params->rdim;
3685             PDL_Indx prdim = PDLMIN(rdim,pdim);
3686             PDL_Indx iter2[pdim * 2 + rdim];
3687             PDL_Indx *sizes = iter2 + pdim;
3688             coords = sizes + pdim;
3689              
3690             /* Figure out size vector */
3691             for(ip = __params->sizes, sp = sizes, k=0; k
3692             *(sp++) = *(ip++);
3693             for(; k < pdim; k++)
3694             *(sp++) = __privtrans->pdls[0]->dims[k];
3695              
3696              
3697             /* Loop over all the ranges in the index list */
3698             for(item=0; item<__params->nitems; item++) {
3699              
3700             /* initialize in-range iterator to loop within each range */
3701             for(ip = iter2, k=0; k
3702             *(ip++) = 0;
3703              
3704             do {
3705             PDL_Indx poff = 0;
3706             PDL_Indx coff;
3707             PDL_Indx k2;
3708             char trunc = 0; /* Flag used to skip truncation case */
3709              
3710             /* Collect and boundary-check the current N-D coords */
3711             for(k=0; k < prdim; k++){
3712              
3713             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3714              
3715             /* normal case */
3716             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3717             switch(__params->boundary[k]) {
3718             case 0: /* no boundary breakage allowed */
3719             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3720             break;
3721             case 1: /* truncation */
3722             trunc = 1;
3723             break;
3724             case 2: /* extension -- crop */
3725             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3726             break;
3727             case 3: /* periodic -- mod it */
3728             ck %= __privtrans->pdls[0]->dims[k];
3729             if(ck < 0) /* Fix mod breakage in C */
3730             ck += __privtrans->pdls[0]->dims[k];
3731             break;
3732             case 4: /* mirror -- reflect off the edges */
3733             ck += __privtrans->pdls[0]->dims[k];
3734             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3735             if(ck < 0) /* Fix mod breakage in C */
3736             ck += __privtrans->pdls[0]->dims[k]*2;
3737             ck -= __privtrans->pdls[0]->dims[k];
3738             if(ck < 0) {
3739             ck *= -1;
3740             ck -= 1;
3741             }
3742             break;
3743             default:
3744             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3745             break;
3746             }
3747             }
3748              
3749             coords[k] = ck;
3750              
3751             }
3752              
3753             /* Check extra dimensions -- pick up where k left off... */
3754             for( ; k < rdim ; k++) {
3755             /* Check for indexing off the end of the dimension list */
3756              
3757             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3758              
3759             switch(__params->boundary[k]) {
3760             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3761             if(ck != 0)
3762             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3763             break;
3764             case 1: /* truncation - just truncate if the corner is nonzero */
3765             trunc |= (ck != 0);
3766             break;
3767             case 2: /* extension -- ignore the corner (same as 3) */
3768             case 3: /* periodic -- ignore the corner */
3769             case 4: /* mirror -- ignore the corner */
3770             ck = 0;
3771             break;
3772             default:
3773             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3774             break;
3775             }
3776             }
3777              
3778             /* Find offsets into the child and parent arrays, from the N-D coords */
3779             /* Note we only loop over real source dims (prdim) to accumulate -- */
3780             /* because the offset is trivial and/or we're truncating for virtual */
3781             /* dims caused by permissive ranging. */
3782             coff = __privtrans->pdls[1]->dimincs[0] * item;
3783             for(k2 = __params->itdim, poff = k = 0;
3784             k < prdim;
3785             k++) {
3786             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3787             if(__params->sizes[k])
3788             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3789             }
3790              
3791             /* Loop the copy over all the source broadcast dims (above rdim). */
3792             do {
3793             PDL_Indx poff1 = poff;
3794             PDL_Indx coff1 = coff;
3795              
3796             /* Accumulate the offset due to source broadcasting */
3797             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3798             k < pdim;
3799             k++) {
3800             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3801             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3802             }
3803              
3804             /* Finally -- make the copy
3805             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3806             * out-of-bounds conditions.
3807             */
3808             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,Q,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3809              
3810             /* Increment the source broadcast iterator */
3811             for( k=__params->rdim;
3812             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3813             k++)
3814             iter2[k] = 0;
3815             } while(k < pdim); /* end of source-broadcast iteration */
3816              
3817             /* Increment the in-range iterator */
3818             for(k = 0;
3819             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3820             k++)
3821             iter2[k] = 0;
3822             } while(k < __params->rdim); /* end of main iteration */
3823             } /* end of item do loop */
3824             #line 3825 "lib/PDL/Slices-pp-rangeb.c"
3825             }
3826 0           } break;
3827 2           case PDL_F: {
3828 2 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Float,F)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
3829 2           {
3830             #line 877 "lib/PDL/Slices.pd"
3831             PDL_Indx *ip; /* vector iterator */
3832             PDL_Indx *sp; /* size vector including stdims */
3833             PDL_Indx *coords; /* current coordinates */
3834              
3835             PDL_Indx k; /* index */
3836             PDL_Indx item; /* index broadcast iterator */
3837             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3838             PDL_Indx rdim = __params->rdim;
3839             PDL_Indx prdim = PDLMIN(rdim,pdim);
3840             PDL_Indx iter2[pdim * 2 + rdim];
3841             PDL_Indx *sizes = iter2 + pdim;
3842             coords = sizes + pdim;
3843              
3844             /* Figure out size vector */
3845             for(ip = __params->sizes, sp = sizes, k=0; k
3846             *(sp++) = *(ip++);
3847             for(; k < pdim; k++)
3848             *(sp++) = __privtrans->pdls[0]->dims[k];
3849              
3850              
3851             /* Loop over all the ranges in the index list */
3852             for(item=0; item<__params->nitems; item++) {
3853              
3854             /* initialize in-range iterator to loop within each range */
3855             for(ip = iter2, k=0; k
3856             *(ip++) = 0;
3857              
3858             do {
3859             PDL_Indx poff = 0;
3860             PDL_Indx coff;
3861             PDL_Indx k2;
3862             char trunc = 0; /* Flag used to skip truncation case */
3863              
3864             /* Collect and boundary-check the current N-D coords */
3865             for(k=0; k < prdim; k++){
3866              
3867             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3868              
3869             /* normal case */
3870             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
3871             switch(__params->boundary[k]) {
3872             case 0: /* no boundary breakage allowed */
3873             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
3874             break;
3875             case 1: /* truncation */
3876             trunc = 1;
3877             break;
3878             case 2: /* extension -- crop */
3879             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
3880             break;
3881             case 3: /* periodic -- mod it */
3882             ck %= __privtrans->pdls[0]->dims[k];
3883             if(ck < 0) /* Fix mod breakage in C */
3884             ck += __privtrans->pdls[0]->dims[k];
3885             break;
3886             case 4: /* mirror -- reflect off the edges */
3887             ck += __privtrans->pdls[0]->dims[k];
3888             ck %= (__privtrans->pdls[0]->dims[k] * 2);
3889             if(ck < 0) /* Fix mod breakage in C */
3890             ck += __privtrans->pdls[0]->dims[k]*2;
3891             ck -= __privtrans->pdls[0]->dims[k];
3892             if(ck < 0) {
3893             ck *= -1;
3894             ck -= 1;
3895             }
3896             break;
3897             default:
3898             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3899             break;
3900             }
3901             }
3902              
3903             coords[k] = ck;
3904              
3905             }
3906              
3907             /* Check extra dimensions -- pick up where k left off... */
3908             for( ; k < rdim ; k++) {
3909             /* Check for indexing off the end of the dimension list */
3910              
3911             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
3912              
3913             switch(__params->boundary[k]) {
3914             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
3915             if(ck != 0)
3916             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
3917             break;
3918             case 1: /* truncation - just truncate if the corner is nonzero */
3919             trunc |= (ck != 0);
3920             break;
3921             case 2: /* extension -- ignore the corner (same as 3) */
3922             case 3: /* periodic -- ignore the corner */
3923             case 4: /* mirror -- ignore the corner */
3924             ck = 0;
3925             break;
3926             default:
3927             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
3928             break;
3929             }
3930             }
3931              
3932             /* Find offsets into the child and parent arrays, from the N-D coords */
3933             /* Note we only loop over real source dims (prdim) to accumulate -- */
3934             /* because the offset is trivial and/or we're truncating for virtual */
3935             /* dims caused by permissive ranging. */
3936             coff = __privtrans->pdls[1]->dimincs[0] * item;
3937             for(k2 = __params->itdim, poff = k = 0;
3938             k < prdim;
3939             k++) {
3940             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
3941             if(__params->sizes[k])
3942             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3943             }
3944              
3945             /* Loop the copy over all the source broadcast dims (above rdim). */
3946             do {
3947             PDL_Indx poff1 = poff;
3948             PDL_Indx coff1 = coff;
3949              
3950             /* Accumulate the offset due to source broadcasting */
3951             for(k2 = __params->itdim + __params->ntsize, k = rdim;
3952             k < pdim;
3953             k++) {
3954             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
3955             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
3956             }
3957              
3958             /* Finally -- make the copy
3959             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
3960             * out-of-bounds conditions.
3961             */
3962             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,F,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
3963              
3964             /* Increment the source broadcast iterator */
3965             for( k=__params->rdim;
3966             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
3967             k++)
3968             iter2[k] = 0;
3969             } while(k < pdim); /* end of source-broadcast iteration */
3970              
3971             /* Increment the in-range iterator */
3972             for(k = 0;
3973             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
3974             k++)
3975             iter2[k] = 0;
3976             } while(k < __params->rdim); /* end of main iteration */
3977             } /* end of item do loop */
3978             #line 3979 "lib/PDL/Slices-pp-rangeb.c"
3979             }
3980 2           } break;
3981 54           case PDL_D: {
3982 54 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
3983 54           {
3984             #line 877 "lib/PDL/Slices.pd"
3985             PDL_Indx *ip; /* vector iterator */
3986             PDL_Indx *sp; /* size vector including stdims */
3987             PDL_Indx *coords; /* current coordinates */
3988              
3989             PDL_Indx k; /* index */
3990             PDL_Indx item; /* index broadcast iterator */
3991             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
3992             PDL_Indx rdim = __params->rdim;
3993             PDL_Indx prdim = PDLMIN(rdim,pdim);
3994             PDL_Indx iter2[pdim * 2 + rdim];
3995             PDL_Indx *sizes = iter2 + pdim;
3996             coords = sizes + pdim;
3997              
3998             /* Figure out size vector */
3999             for(ip = __params->sizes, sp = sizes, k=0; k
4000             *(sp++) = *(ip++);
4001             for(; k < pdim; k++)
4002             *(sp++) = __privtrans->pdls[0]->dims[k];
4003              
4004              
4005             /* Loop over all the ranges in the index list */
4006             for(item=0; item<__params->nitems; item++) {
4007              
4008             /* initialize in-range iterator to loop within each range */
4009             for(ip = iter2, k=0; k
4010             *(ip++) = 0;
4011              
4012             do {
4013             PDL_Indx poff = 0;
4014             PDL_Indx coff;
4015             PDL_Indx k2;
4016             char trunc = 0; /* Flag used to skip truncation case */
4017              
4018             /* Collect and boundary-check the current N-D coords */
4019             for(k=0; k < prdim; k++){
4020              
4021             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4022              
4023             /* normal case */
4024             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4025             switch(__params->boundary[k]) {
4026             case 0: /* no boundary breakage allowed */
4027             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4028             break;
4029             case 1: /* truncation */
4030             trunc = 1;
4031             break;
4032             case 2: /* extension -- crop */
4033             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4034             break;
4035             case 3: /* periodic -- mod it */
4036             ck %= __privtrans->pdls[0]->dims[k];
4037             if(ck < 0) /* Fix mod breakage in C */
4038             ck += __privtrans->pdls[0]->dims[k];
4039             break;
4040             case 4: /* mirror -- reflect off the edges */
4041             ck += __privtrans->pdls[0]->dims[k];
4042             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4043             if(ck < 0) /* Fix mod breakage in C */
4044             ck += __privtrans->pdls[0]->dims[k]*2;
4045             ck -= __privtrans->pdls[0]->dims[k];
4046             if(ck < 0) {
4047             ck *= -1;
4048             ck -= 1;
4049             }
4050             break;
4051             default:
4052             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4053             break;
4054             }
4055             }
4056              
4057             coords[k] = ck;
4058              
4059             }
4060              
4061             /* Check extra dimensions -- pick up where k left off... */
4062             for( ; k < rdim ; k++) {
4063             /* Check for indexing off the end of the dimension list */
4064              
4065             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4066              
4067             switch(__params->boundary[k]) {
4068             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4069             if(ck != 0)
4070             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4071             break;
4072             case 1: /* truncation - just truncate if the corner is nonzero */
4073             trunc |= (ck != 0);
4074             break;
4075             case 2: /* extension -- ignore the corner (same as 3) */
4076             case 3: /* periodic -- ignore the corner */
4077             case 4: /* mirror -- ignore the corner */
4078             ck = 0;
4079             break;
4080             default:
4081             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4082             break;
4083             }
4084             }
4085              
4086             /* Find offsets into the child and parent arrays, from the N-D coords */
4087             /* Note we only loop over real source dims (prdim) to accumulate -- */
4088             /* because the offset is trivial and/or we're truncating for virtual */
4089             /* dims caused by permissive ranging. */
4090             coff = __privtrans->pdls[1]->dimincs[0] * item;
4091             for(k2 = __params->itdim, poff = k = 0;
4092             k < prdim;
4093             k++) {
4094             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4095             if(__params->sizes[k])
4096             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4097             }
4098              
4099             /* Loop the copy over all the source broadcast dims (above rdim). */
4100             do {
4101             PDL_Indx poff1 = poff;
4102             PDL_Indx coff1 = coff;
4103              
4104             /* Accumulate the offset due to source broadcasting */
4105             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4106             k < pdim;
4107             k++) {
4108             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4109             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4110             }
4111              
4112             /* Finally -- make the copy
4113             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4114             * out-of-bounds conditions.
4115             */
4116             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,D,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
4117              
4118             /* Increment the source broadcast iterator */
4119             for( k=__params->rdim;
4120             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4121             k++)
4122             iter2[k] = 0;
4123             } while(k < pdim); /* end of source-broadcast iteration */
4124              
4125             /* Increment the in-range iterator */
4126             for(k = 0;
4127             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4128             k++)
4129             iter2[k] = 0;
4130             } while(k < __params->rdim); /* end of main iteration */
4131             } /* end of item do loop */
4132             #line 4133 "lib/PDL/Slices-pp-rangeb.c"
4133             }
4134 53           } break;
4135 0           case PDL_LD: {
4136 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4137 0           {
4138             #line 877 "lib/PDL/Slices.pd"
4139             PDL_Indx *ip; /* vector iterator */
4140             PDL_Indx *sp; /* size vector including stdims */
4141             PDL_Indx *coords; /* current coordinates */
4142              
4143             PDL_Indx k; /* index */
4144             PDL_Indx item; /* index broadcast iterator */
4145             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4146             PDL_Indx rdim = __params->rdim;
4147             PDL_Indx prdim = PDLMIN(rdim,pdim);
4148             PDL_Indx iter2[pdim * 2 + rdim];
4149             PDL_Indx *sizes = iter2 + pdim;
4150             coords = sizes + pdim;
4151              
4152             /* Figure out size vector */
4153             for(ip = __params->sizes, sp = sizes, k=0; k
4154             *(sp++) = *(ip++);
4155             for(; k < pdim; k++)
4156             *(sp++) = __privtrans->pdls[0]->dims[k];
4157              
4158              
4159             /* Loop over all the ranges in the index list */
4160             for(item=0; item<__params->nitems; item++) {
4161              
4162             /* initialize in-range iterator to loop within each range */
4163             for(ip = iter2, k=0; k
4164             *(ip++) = 0;
4165              
4166             do {
4167             PDL_Indx poff = 0;
4168             PDL_Indx coff;
4169             PDL_Indx k2;
4170             char trunc = 0; /* Flag used to skip truncation case */
4171              
4172             /* Collect and boundary-check the current N-D coords */
4173             for(k=0; k < prdim; k++){
4174              
4175             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4176              
4177             /* normal case */
4178             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4179             switch(__params->boundary[k]) {
4180             case 0: /* no boundary breakage allowed */
4181             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4182             break;
4183             case 1: /* truncation */
4184             trunc = 1;
4185             break;
4186             case 2: /* extension -- crop */
4187             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4188             break;
4189             case 3: /* periodic -- mod it */
4190             ck %= __privtrans->pdls[0]->dims[k];
4191             if(ck < 0) /* Fix mod breakage in C */
4192             ck += __privtrans->pdls[0]->dims[k];
4193             break;
4194             case 4: /* mirror -- reflect off the edges */
4195             ck += __privtrans->pdls[0]->dims[k];
4196             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4197             if(ck < 0) /* Fix mod breakage in C */
4198             ck += __privtrans->pdls[0]->dims[k]*2;
4199             ck -= __privtrans->pdls[0]->dims[k];
4200             if(ck < 0) {
4201             ck *= -1;
4202             ck -= 1;
4203             }
4204             break;
4205             default:
4206             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4207             break;
4208             }
4209             }
4210              
4211             coords[k] = ck;
4212              
4213             }
4214              
4215             /* Check extra dimensions -- pick up where k left off... */
4216             for( ; k < rdim ; k++) {
4217             /* Check for indexing off the end of the dimension list */
4218              
4219             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4220              
4221             switch(__params->boundary[k]) {
4222             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4223             if(ck != 0)
4224             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4225             break;
4226             case 1: /* truncation - just truncate if the corner is nonzero */
4227             trunc |= (ck != 0);
4228             break;
4229             case 2: /* extension -- ignore the corner (same as 3) */
4230             case 3: /* periodic -- ignore the corner */
4231             case 4: /* mirror -- ignore the corner */
4232             ck = 0;
4233             break;
4234             default:
4235             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4236             break;
4237             }
4238             }
4239              
4240             /* Find offsets into the child and parent arrays, from the N-D coords */
4241             /* Note we only loop over real source dims (prdim) to accumulate -- */
4242             /* because the offset is trivial and/or we're truncating for virtual */
4243             /* dims caused by permissive ranging. */
4244             coff = __privtrans->pdls[1]->dimincs[0] * item;
4245             for(k2 = __params->itdim, poff = k = 0;
4246             k < prdim;
4247             k++) {
4248             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4249             if(__params->sizes[k])
4250             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4251             }
4252              
4253             /* Loop the copy over all the source broadcast dims (above rdim). */
4254             do {
4255             PDL_Indx poff1 = poff;
4256             PDL_Indx coff1 = coff;
4257              
4258             /* Accumulate the offset due to source broadcasting */
4259             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4260             k < pdim;
4261             k++) {
4262             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4263             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4264             }
4265              
4266             /* Finally -- make the copy
4267             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4268             * out-of-bounds conditions.
4269             */
4270             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,E,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
4271              
4272             /* Increment the source broadcast iterator */
4273             for( k=__params->rdim;
4274             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4275             k++)
4276             iter2[k] = 0;
4277             } while(k < pdim); /* end of source-broadcast iteration */
4278              
4279             /* Increment the in-range iterator */
4280             for(k = 0;
4281             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4282             k++)
4283             iter2[k] = 0;
4284             } while(k < __params->rdim); /* end of main iteration */
4285             } /* end of item do loop */
4286             #line 4287 "lib/PDL/Slices-pp-rangeb.c"
4287             }
4288 0           } break;
4289 0           case PDL_CF: {
4290 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CFloat,G)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4291 0           {
4292             #line 877 "lib/PDL/Slices.pd"
4293             PDL_Indx *ip; /* vector iterator */
4294             PDL_Indx *sp; /* size vector including stdims */
4295             PDL_Indx *coords; /* current coordinates */
4296              
4297             PDL_Indx k; /* index */
4298             PDL_Indx item; /* index broadcast iterator */
4299             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4300             PDL_Indx rdim = __params->rdim;
4301             PDL_Indx prdim = PDLMIN(rdim,pdim);
4302             PDL_Indx iter2[pdim * 2 + rdim];
4303             PDL_Indx *sizes = iter2 + pdim;
4304             coords = sizes + pdim;
4305              
4306             /* Figure out size vector */
4307             for(ip = __params->sizes, sp = sizes, k=0; k
4308             *(sp++) = *(ip++);
4309             for(; k < pdim; k++)
4310             *(sp++) = __privtrans->pdls[0]->dims[k];
4311              
4312              
4313             /* Loop over all the ranges in the index list */
4314             for(item=0; item<__params->nitems; item++) {
4315              
4316             /* initialize in-range iterator to loop within each range */
4317             for(ip = iter2, k=0; k
4318             *(ip++) = 0;
4319              
4320             do {
4321             PDL_Indx poff = 0;
4322             PDL_Indx coff;
4323             PDL_Indx k2;
4324             char trunc = 0; /* Flag used to skip truncation case */
4325              
4326             /* Collect and boundary-check the current N-D coords */
4327             for(k=0; k < prdim; k++){
4328              
4329             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4330              
4331             /* normal case */
4332             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4333             switch(__params->boundary[k]) {
4334             case 0: /* no boundary breakage allowed */
4335             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4336             break;
4337             case 1: /* truncation */
4338             trunc = 1;
4339             break;
4340             case 2: /* extension -- crop */
4341             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4342             break;
4343             case 3: /* periodic -- mod it */
4344             ck %= __privtrans->pdls[0]->dims[k];
4345             if(ck < 0) /* Fix mod breakage in C */
4346             ck += __privtrans->pdls[0]->dims[k];
4347             break;
4348             case 4: /* mirror -- reflect off the edges */
4349             ck += __privtrans->pdls[0]->dims[k];
4350             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4351             if(ck < 0) /* Fix mod breakage in C */
4352             ck += __privtrans->pdls[0]->dims[k]*2;
4353             ck -= __privtrans->pdls[0]->dims[k];
4354             if(ck < 0) {
4355             ck *= -1;
4356             ck -= 1;
4357             }
4358             break;
4359             default:
4360             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4361             break;
4362             }
4363             }
4364              
4365             coords[k] = ck;
4366              
4367             }
4368              
4369             /* Check extra dimensions -- pick up where k left off... */
4370             for( ; k < rdim ; k++) {
4371             /* Check for indexing off the end of the dimension list */
4372              
4373             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4374              
4375             switch(__params->boundary[k]) {
4376             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4377             if(ck != 0)
4378             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4379             break;
4380             case 1: /* truncation - just truncate if the corner is nonzero */
4381             trunc |= (ck != 0);
4382             break;
4383             case 2: /* extension -- ignore the corner (same as 3) */
4384             case 3: /* periodic -- ignore the corner */
4385             case 4: /* mirror -- ignore the corner */
4386             ck = 0;
4387             break;
4388             default:
4389             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4390             break;
4391             }
4392             }
4393              
4394             /* Find offsets into the child and parent arrays, from the N-D coords */
4395             /* Note we only loop over real source dims (prdim) to accumulate -- */
4396             /* because the offset is trivial and/or we're truncating for virtual */
4397             /* dims caused by permissive ranging. */
4398             coff = __privtrans->pdls[1]->dimincs[0] * item;
4399             for(k2 = __params->itdim, poff = k = 0;
4400             k < prdim;
4401             k++) {
4402             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4403             if(__params->sizes[k])
4404             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4405             }
4406              
4407             /* Loop the copy over all the source broadcast dims (above rdim). */
4408             do {
4409             PDL_Indx poff1 = poff;
4410             PDL_Indx coff1 = coff;
4411              
4412             /* Accumulate the offset due to source broadcasting */
4413             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4414             k < pdim;
4415             k++) {
4416             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4417             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4418             }
4419              
4420             /* Finally -- make the copy
4421             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4422             * out-of-bounds conditions.
4423             */
4424             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,G,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
4425              
4426             /* Increment the source broadcast iterator */
4427             for( k=__params->rdim;
4428             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4429             k++)
4430             iter2[k] = 0;
4431             } while(k < pdim); /* end of source-broadcast iteration */
4432              
4433             /* Increment the in-range iterator */
4434             for(k = 0;
4435             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4436             k++)
4437             iter2[k] = 0;
4438             } while(k < __params->rdim); /* end of main iteration */
4439             } /* end of item do loop */
4440             #line 4441 "lib/PDL/Slices-pp-rangeb.c"
4441             }
4442 0           } break;
4443 0           case PDL_CD: {
4444 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CDouble,C)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4445 0           {
4446             #line 877 "lib/PDL/Slices.pd"
4447             PDL_Indx *ip; /* vector iterator */
4448             PDL_Indx *sp; /* size vector including stdims */
4449             PDL_Indx *coords; /* current coordinates */
4450              
4451             PDL_Indx k; /* index */
4452             PDL_Indx item; /* index broadcast iterator */
4453             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4454             PDL_Indx rdim = __params->rdim;
4455             PDL_Indx prdim = PDLMIN(rdim,pdim);
4456             PDL_Indx iter2[pdim * 2 + rdim];
4457             PDL_Indx *sizes = iter2 + pdim;
4458             coords = sizes + pdim;
4459              
4460             /* Figure out size vector */
4461             for(ip = __params->sizes, sp = sizes, k=0; k
4462             *(sp++) = *(ip++);
4463             for(; k < pdim; k++)
4464             *(sp++) = __privtrans->pdls[0]->dims[k];
4465              
4466              
4467             /* Loop over all the ranges in the index list */
4468             for(item=0; item<__params->nitems; item++) {
4469              
4470             /* initialize in-range iterator to loop within each range */
4471             for(ip = iter2, k=0; k
4472             *(ip++) = 0;
4473              
4474             do {
4475             PDL_Indx poff = 0;
4476             PDL_Indx coff;
4477             PDL_Indx k2;
4478             char trunc = 0; /* Flag used to skip truncation case */
4479              
4480             /* Collect and boundary-check the current N-D coords */
4481             for(k=0; k < prdim; k++){
4482              
4483             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4484              
4485             /* normal case */
4486             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4487             switch(__params->boundary[k]) {
4488             case 0: /* no boundary breakage allowed */
4489             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4490             break;
4491             case 1: /* truncation */
4492             trunc = 1;
4493             break;
4494             case 2: /* extension -- crop */
4495             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4496             break;
4497             case 3: /* periodic -- mod it */
4498             ck %= __privtrans->pdls[0]->dims[k];
4499             if(ck < 0) /* Fix mod breakage in C */
4500             ck += __privtrans->pdls[0]->dims[k];
4501             break;
4502             case 4: /* mirror -- reflect off the edges */
4503             ck += __privtrans->pdls[0]->dims[k];
4504             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4505             if(ck < 0) /* Fix mod breakage in C */
4506             ck += __privtrans->pdls[0]->dims[k]*2;
4507             ck -= __privtrans->pdls[0]->dims[k];
4508             if(ck < 0) {
4509             ck *= -1;
4510             ck -= 1;
4511             }
4512             break;
4513             default:
4514             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4515             break;
4516             }
4517             }
4518              
4519             coords[k] = ck;
4520              
4521             }
4522              
4523             /* Check extra dimensions -- pick up where k left off... */
4524             for( ; k < rdim ; k++) {
4525             /* Check for indexing off the end of the dimension list */
4526              
4527             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4528              
4529             switch(__params->boundary[k]) {
4530             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4531             if(ck != 0)
4532             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4533             break;
4534             case 1: /* truncation - just truncate if the corner is nonzero */
4535             trunc |= (ck != 0);
4536             break;
4537             case 2: /* extension -- ignore the corner (same as 3) */
4538             case 3: /* periodic -- ignore the corner */
4539             case 4: /* mirror -- ignore the corner */
4540             ck = 0;
4541             break;
4542             default:
4543             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4544             break;
4545             }
4546             }
4547              
4548             /* Find offsets into the child and parent arrays, from the N-D coords */
4549             /* Note we only loop over real source dims (prdim) to accumulate -- */
4550             /* because the offset is trivial and/or we're truncating for virtual */
4551             /* dims caused by permissive ranging. */
4552             coff = __privtrans->pdls[1]->dimincs[0] * item;
4553             for(k2 = __params->itdim, poff = k = 0;
4554             k < prdim;
4555             k++) {
4556             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4557             if(__params->sizes[k])
4558             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4559             }
4560              
4561             /* Loop the copy over all the source broadcast dims (above rdim). */
4562             do {
4563             PDL_Indx poff1 = poff;
4564             PDL_Indx coff1 = coff;
4565              
4566             /* Accumulate the offset due to source broadcasting */
4567             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4568             k < pdim;
4569             k++) {
4570             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4571             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4572             }
4573              
4574             /* Finally -- make the copy
4575             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4576             * out-of-bounds conditions.
4577             */
4578             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,C,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
4579              
4580             /* Increment the source broadcast iterator */
4581             for( k=__params->rdim;
4582             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4583             k++)
4584             iter2[k] = 0;
4585             } while(k < pdim); /* end of source-broadcast iteration */
4586              
4587             /* Increment the in-range iterator */
4588             for(k = 0;
4589             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4590             k++)
4591             iter2[k] = 0;
4592             } while(k < __params->rdim); /* end of main iteration */
4593             } /* end of item do loop */
4594             #line 4595 "lib/PDL/Slices-pp-rangeb.c"
4595             }
4596 0           } break;
4597 0           case PDL_CLD: {
4598 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CLDouble,H)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4599 0           {
4600             #line 877 "lib/PDL/Slices.pd"
4601             PDL_Indx *ip; /* vector iterator */
4602             PDL_Indx *sp; /* size vector including stdims */
4603             PDL_Indx *coords; /* current coordinates */
4604              
4605             PDL_Indx k; /* index */
4606             PDL_Indx item; /* index broadcast iterator */
4607             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4608             PDL_Indx rdim = __params->rdim;
4609             PDL_Indx prdim = PDLMIN(rdim,pdim);
4610             PDL_Indx iter2[pdim * 2 + rdim];
4611             PDL_Indx *sizes = iter2 + pdim;
4612             coords = sizes + pdim;
4613              
4614             /* Figure out size vector */
4615             for(ip = __params->sizes, sp = sizes, k=0; k
4616             *(sp++) = *(ip++);
4617             for(; k < pdim; k++)
4618             *(sp++) = __privtrans->pdls[0]->dims[k];
4619              
4620              
4621             /* Loop over all the ranges in the index list */
4622             for(item=0; item<__params->nitems; item++) {
4623              
4624             /* initialize in-range iterator to loop within each range */
4625             for(ip = iter2, k=0; k
4626             *(ip++) = 0;
4627              
4628             do {
4629             PDL_Indx poff = 0;
4630             PDL_Indx coff;
4631             PDL_Indx k2;
4632             char trunc = 0; /* Flag used to skip truncation case */
4633              
4634             /* Collect and boundary-check the current N-D coords */
4635             for(k=0; k < prdim; k++){
4636              
4637             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4638              
4639             /* normal case */
4640             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4641             switch(__params->boundary[k]) {
4642             case 0: /* no boundary breakage allowed */
4643             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4644             break;
4645             case 1: /* truncation */
4646             trunc = 1;
4647             break;
4648             case 2: /* extension -- crop */
4649             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4650             break;
4651             case 3: /* periodic -- mod it */
4652             ck %= __privtrans->pdls[0]->dims[k];
4653             if(ck < 0) /* Fix mod breakage in C */
4654             ck += __privtrans->pdls[0]->dims[k];
4655             break;
4656             case 4: /* mirror -- reflect off the edges */
4657             ck += __privtrans->pdls[0]->dims[k];
4658             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4659             if(ck < 0) /* Fix mod breakage in C */
4660             ck += __privtrans->pdls[0]->dims[k]*2;
4661             ck -= __privtrans->pdls[0]->dims[k];
4662             if(ck < 0) {
4663             ck *= -1;
4664             ck -= 1;
4665             }
4666             break;
4667             default:
4668             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4669             break;
4670             }
4671             }
4672              
4673             coords[k] = ck;
4674              
4675             }
4676              
4677             /* Check extra dimensions -- pick up where k left off... */
4678             for( ; k < rdim ; k++) {
4679             /* Check for indexing off the end of the dimension list */
4680              
4681             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4682              
4683             switch(__params->boundary[k]) {
4684             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4685             if(ck != 0)
4686             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4687             break;
4688             case 1: /* truncation - just truncate if the corner is nonzero */
4689             trunc |= (ck != 0);
4690             break;
4691             case 2: /* extension -- ignore the corner (same as 3) */
4692             case 3: /* periodic -- ignore the corner */
4693             case 4: /* mirror -- ignore the corner */
4694             ck = 0;
4695             break;
4696             default:
4697             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4698             break;
4699             }
4700             }
4701              
4702             /* Find offsets into the child and parent arrays, from the N-D coords */
4703             /* Note we only loop over real source dims (prdim) to accumulate -- */
4704             /* because the offset is trivial and/or we're truncating for virtual */
4705             /* dims caused by permissive ranging. */
4706             coff = __privtrans->pdls[1]->dimincs[0] * item;
4707             for(k2 = __params->itdim, poff = k = 0;
4708             k < prdim;
4709             k++) {
4710             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4711             if(__params->sizes[k])
4712             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4713             }
4714              
4715             /* Loop the copy over all the source broadcast dims (above rdim). */
4716             do {
4717             PDL_Indx poff1 = poff;
4718             PDL_Indx coff1 = coff;
4719              
4720             /* Accumulate the offset due to source broadcasting */
4721             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4722             k < pdim;
4723             k++) {
4724             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4725             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4726             }
4727              
4728             /* Finally -- make the copy
4729             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4730             * out-of-bounds conditions.
4731             */
4732             do { if ((trunc) PDL_IF_BAD(|| PDL_ISBAD2(PARENT_datap[poff1],PARENT_badval,H,PARENT_badval_isnan),) ) { PDL_IF_BAD(CHILD_datap[coff1]=CHILD_badval,CHILD_datap[coff1] = 0); } else {CHILD_datap[coff1] = PARENT_datap[poff1]; } } while (0);
4733              
4734             /* Increment the source broadcast iterator */
4735             for( k=__params->rdim;
4736             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4737             k++)
4738             iter2[k] = 0;
4739             } while(k < pdim); /* end of source-broadcast iteration */
4740              
4741             /* Increment the in-range iterator */
4742             for(k = 0;
4743             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4744             k++)
4745             iter2[k] = 0;
4746             } while(k < __params->rdim); /* end of main iteration */
4747             } /* end of item do loop */
4748             #line 4749 "lib/PDL/Slices-pp-rangeb.c"
4749             }
4750 0           } break;
4751 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rangeb: unhandled datatype(%d), only handles (ABSULKNPQFDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
4752             }
4753             #undef PDL_IF_BAD
4754             }
4755 86           return PDL_err;
4756             }
4757              
4758              
4759             #line 1857 "lib/PDL/PP.pm"
4760             pdl_error pdl_rangeb_writebackdata(pdl_trans *__privtrans) {
4761             pdl_error PDL_err = {0, NULL, 0};
4762             #line 4763 "lib/PDL/Slices-pp-rangeb.c"
4763 16           pdl_params_rangeb *__params = __privtrans->params; (void)__params;
4764 16           pdl *__it = __privtrans->pdls[1]; (void) __it;
4765             #ifndef PDL_DECLARE_PARAMS_rangeb_1
4766             #define PDL_DECLARE_PARAMS_rangeb_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
4767             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, PARENT, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
4768             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, CHILD, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
4769             #endif
4770 16 50         if ( __privtrans->bvalflag ) { /* ** do 'bad' Code ** */
4771             #define PDL_BAD_CODE
4772             #define PDL_IF_BAD(t,f) t
4773 0           switch (__privtrans->__datatype) { /* Start generic switch */
4774 0           case PDL_SB: {
4775 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4776 0           {
4777             #line 877 "lib/PDL/Slices.pd"
4778             PDL_Indx *ip; /* vector iterator */
4779             PDL_Indx *sp; /* size vector including stdims */
4780             PDL_Indx *coords; /* current coordinates */
4781              
4782             PDL_Indx k; /* index */
4783             PDL_Indx item; /* index broadcast iterator */
4784             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4785             PDL_Indx rdim = __params->rdim;
4786             PDL_Indx prdim = PDLMIN(rdim,pdim);
4787             PDL_Indx iter2[pdim * 2 + rdim];
4788             PDL_Indx *sizes = iter2 + pdim;
4789             coords = sizes + pdim;
4790              
4791             /* Figure out size vector */
4792             for(ip = __params->sizes, sp = sizes, k=0; k
4793             *(sp++) = *(ip++);
4794             for(; k < pdim; k++)
4795             *(sp++) = __privtrans->pdls[0]->dims[k];
4796              
4797              
4798             /* Loop over all the ranges in the index list */
4799             for(item=0; item<__params->nitems; item++) {
4800              
4801             /* initialize in-range iterator to loop within each range */
4802             for(ip = iter2, k=0; k
4803             *(ip++) = 0;
4804              
4805             do {
4806             PDL_Indx poff = 0;
4807             PDL_Indx coff;
4808             PDL_Indx k2;
4809             char trunc = 0; /* Flag used to skip truncation case */
4810              
4811             /* Collect and boundary-check the current N-D coords */
4812             for(k=0; k < prdim; k++){
4813              
4814             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4815              
4816             /* normal case */
4817             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4818             switch(__params->boundary[k]) {
4819             case 0: /* no boundary breakage allowed */
4820             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4821             break;
4822             case 1: /* truncation */
4823             trunc = 1;
4824             break;
4825             case 2: /* extension -- crop */
4826             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4827             break;
4828             case 3: /* periodic -- mod it */
4829             ck %= __privtrans->pdls[0]->dims[k];
4830             if(ck < 0) /* Fix mod breakage in C */
4831             ck += __privtrans->pdls[0]->dims[k];
4832             break;
4833             case 4: /* mirror -- reflect off the edges */
4834             ck += __privtrans->pdls[0]->dims[k];
4835             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4836             if(ck < 0) /* Fix mod breakage in C */
4837             ck += __privtrans->pdls[0]->dims[k]*2;
4838             ck -= __privtrans->pdls[0]->dims[k];
4839             if(ck < 0) {
4840             ck *= -1;
4841             ck -= 1;
4842             }
4843             break;
4844             default:
4845             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4846             break;
4847             }
4848             }
4849              
4850             coords[k] = ck;
4851              
4852             }
4853              
4854             /* Check extra dimensions -- pick up where k left off... */
4855             for( ; k < rdim ; k++) {
4856             /* Check for indexing off the end of the dimension list */
4857              
4858             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4859              
4860             switch(__params->boundary[k]) {
4861             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
4862             if(ck != 0)
4863             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
4864             break;
4865             case 1: /* truncation - just truncate if the corner is nonzero */
4866             trunc |= (ck != 0);
4867             break;
4868             case 2: /* extension -- ignore the corner (same as 3) */
4869             case 3: /* periodic -- ignore the corner */
4870             case 4: /* mirror -- ignore the corner */
4871             ck = 0;
4872             break;
4873             default:
4874             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
4875             break;
4876             }
4877             }
4878              
4879             /* Find offsets into the child and parent arrays, from the N-D coords */
4880             /* Note we only loop over real source dims (prdim) to accumulate -- */
4881             /* because the offset is trivial and/or we're truncating for virtual */
4882             /* dims caused by permissive ranging. */
4883             coff = __privtrans->pdls[1]->dimincs[0] * item;
4884             for(k2 = __params->itdim, poff = k = 0;
4885             k < prdim;
4886             k++) {
4887             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
4888             if(__params->sizes[k])
4889             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4890             }
4891              
4892             /* Loop the copy over all the source broadcast dims (above rdim). */
4893             do {
4894             PDL_Indx poff1 = poff;
4895             PDL_Indx coff1 = coff;
4896              
4897             /* Accumulate the offset due to source broadcasting */
4898             for(k2 = __params->itdim + __params->ntsize, k = rdim;
4899             k < pdim;
4900             k++) {
4901             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
4902             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
4903             }
4904              
4905             /* Finally -- make the copy
4906             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
4907             * out-of-bounds conditions.
4908             */
4909             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,A,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
4910              
4911             /* Increment the source broadcast iterator */
4912             for( k=__params->rdim;
4913             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
4914             k++)
4915             iter2[k] = 0;
4916             } while(k < pdim); /* end of source-broadcast iteration */
4917              
4918             /* Increment the in-range iterator */
4919             for(k = 0;
4920             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
4921             k++)
4922             iter2[k] = 0;
4923             } while(k < __params->rdim); /* end of main iteration */
4924             } /* end of item do loop */
4925             #line 4926 "lib/PDL/Slices-pp-rangeb.c"
4926             }
4927 0           } break;
4928 0           case PDL_B: {
4929 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
4930 0           {
4931             #line 877 "lib/PDL/Slices.pd"
4932             PDL_Indx *ip; /* vector iterator */
4933             PDL_Indx *sp; /* size vector including stdims */
4934             PDL_Indx *coords; /* current coordinates */
4935              
4936             PDL_Indx k; /* index */
4937             PDL_Indx item; /* index broadcast iterator */
4938             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
4939             PDL_Indx rdim = __params->rdim;
4940             PDL_Indx prdim = PDLMIN(rdim,pdim);
4941             PDL_Indx iter2[pdim * 2 + rdim];
4942             PDL_Indx *sizes = iter2 + pdim;
4943             coords = sizes + pdim;
4944              
4945             /* Figure out size vector */
4946             for(ip = __params->sizes, sp = sizes, k=0; k
4947             *(sp++) = *(ip++);
4948             for(; k < pdim; k++)
4949             *(sp++) = __privtrans->pdls[0]->dims[k];
4950              
4951              
4952             /* Loop over all the ranges in the index list */
4953             for(item=0; item<__params->nitems; item++) {
4954              
4955             /* initialize in-range iterator to loop within each range */
4956             for(ip = iter2, k=0; k
4957             *(ip++) = 0;
4958              
4959             do {
4960             PDL_Indx poff = 0;
4961             PDL_Indx coff;
4962             PDL_Indx k2;
4963             char trunc = 0; /* Flag used to skip truncation case */
4964              
4965             /* Collect and boundary-check the current N-D coords */
4966             for(k=0; k < prdim; k++){
4967              
4968             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
4969              
4970             /* normal case */
4971             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
4972             switch(__params->boundary[k]) {
4973             case 0: /* no boundary breakage allowed */
4974             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
4975             break;
4976             case 1: /* truncation */
4977             trunc = 1;
4978             break;
4979             case 2: /* extension -- crop */
4980             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
4981             break;
4982             case 3: /* periodic -- mod it */
4983             ck %= __privtrans->pdls[0]->dims[k];
4984             if(ck < 0) /* Fix mod breakage in C */
4985             ck += __privtrans->pdls[0]->dims[k];
4986             break;
4987             case 4: /* mirror -- reflect off the edges */
4988             ck += __privtrans->pdls[0]->dims[k];
4989             ck %= (__privtrans->pdls[0]->dims[k] * 2);
4990             if(ck < 0) /* Fix mod breakage in C */
4991             ck += __privtrans->pdls[0]->dims[k]*2;
4992             ck -= __privtrans->pdls[0]->dims[k];
4993             if(ck < 0) {
4994             ck *= -1;
4995             ck -= 1;
4996             }
4997             break;
4998             default:
4999             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5000             break;
5001             }
5002             }
5003              
5004             coords[k] = ck;
5005              
5006             }
5007              
5008             /* Check extra dimensions -- pick up where k left off... */
5009             for( ; k < rdim ; k++) {
5010             /* Check for indexing off the end of the dimension list */
5011              
5012             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5013              
5014             switch(__params->boundary[k]) {
5015             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5016             if(ck != 0)
5017             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5018             break;
5019             case 1: /* truncation - just truncate if the corner is nonzero */
5020             trunc |= (ck != 0);
5021             break;
5022             case 2: /* extension -- ignore the corner (same as 3) */
5023             case 3: /* periodic -- ignore the corner */
5024             case 4: /* mirror -- ignore the corner */
5025             ck = 0;
5026             break;
5027             default:
5028             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5029             break;
5030             }
5031             }
5032              
5033             /* Find offsets into the child and parent arrays, from the N-D coords */
5034             /* Note we only loop over real source dims (prdim) to accumulate -- */
5035             /* because the offset is trivial and/or we're truncating for virtual */
5036             /* dims caused by permissive ranging. */
5037             coff = __privtrans->pdls[1]->dimincs[0] * item;
5038             for(k2 = __params->itdim, poff = k = 0;
5039             k < prdim;
5040             k++) {
5041             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5042             if(__params->sizes[k])
5043             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5044             }
5045              
5046             /* Loop the copy over all the source broadcast dims (above rdim). */
5047             do {
5048             PDL_Indx poff1 = poff;
5049             PDL_Indx coff1 = coff;
5050              
5051             /* Accumulate the offset due to source broadcasting */
5052             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5053             k < pdim;
5054             k++) {
5055             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5056             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5057             }
5058              
5059             /* Finally -- make the copy
5060             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5061             * out-of-bounds conditions.
5062             */
5063             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,B,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5064              
5065             /* Increment the source broadcast iterator */
5066             for( k=__params->rdim;
5067             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5068             k++)
5069             iter2[k] = 0;
5070             } while(k < pdim); /* end of source-broadcast iteration */
5071              
5072             /* Increment the in-range iterator */
5073             for(k = 0;
5074             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5075             k++)
5076             iter2[k] = 0;
5077             } while(k < __params->rdim); /* end of main iteration */
5078             } /* end of item do loop */
5079             #line 5080 "lib/PDL/Slices-pp-rangeb.c"
5080             }
5081 0           } break;
5082 0           case PDL_S: {
5083 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5084 0           {
5085             #line 877 "lib/PDL/Slices.pd"
5086             PDL_Indx *ip; /* vector iterator */
5087             PDL_Indx *sp; /* size vector including stdims */
5088             PDL_Indx *coords; /* current coordinates */
5089              
5090             PDL_Indx k; /* index */
5091             PDL_Indx item; /* index broadcast iterator */
5092             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5093             PDL_Indx rdim = __params->rdim;
5094             PDL_Indx prdim = PDLMIN(rdim,pdim);
5095             PDL_Indx iter2[pdim * 2 + rdim];
5096             PDL_Indx *sizes = iter2 + pdim;
5097             coords = sizes + pdim;
5098              
5099             /* Figure out size vector */
5100             for(ip = __params->sizes, sp = sizes, k=0; k
5101             *(sp++) = *(ip++);
5102             for(; k < pdim; k++)
5103             *(sp++) = __privtrans->pdls[0]->dims[k];
5104              
5105              
5106             /* Loop over all the ranges in the index list */
5107             for(item=0; item<__params->nitems; item++) {
5108              
5109             /* initialize in-range iterator to loop within each range */
5110             for(ip = iter2, k=0; k
5111             *(ip++) = 0;
5112              
5113             do {
5114             PDL_Indx poff = 0;
5115             PDL_Indx coff;
5116             PDL_Indx k2;
5117             char trunc = 0; /* Flag used to skip truncation case */
5118              
5119             /* Collect and boundary-check the current N-D coords */
5120             for(k=0; k < prdim; k++){
5121              
5122             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5123              
5124             /* normal case */
5125             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5126             switch(__params->boundary[k]) {
5127             case 0: /* no boundary breakage allowed */
5128             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5129             break;
5130             case 1: /* truncation */
5131             trunc = 1;
5132             break;
5133             case 2: /* extension -- crop */
5134             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5135             break;
5136             case 3: /* periodic -- mod it */
5137             ck %= __privtrans->pdls[0]->dims[k];
5138             if(ck < 0) /* Fix mod breakage in C */
5139             ck += __privtrans->pdls[0]->dims[k];
5140             break;
5141             case 4: /* mirror -- reflect off the edges */
5142             ck += __privtrans->pdls[0]->dims[k];
5143             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5144             if(ck < 0) /* Fix mod breakage in C */
5145             ck += __privtrans->pdls[0]->dims[k]*2;
5146             ck -= __privtrans->pdls[0]->dims[k];
5147             if(ck < 0) {
5148             ck *= -1;
5149             ck -= 1;
5150             }
5151             break;
5152             default:
5153             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5154             break;
5155             }
5156             }
5157              
5158             coords[k] = ck;
5159              
5160             }
5161              
5162             /* Check extra dimensions -- pick up where k left off... */
5163             for( ; k < rdim ; k++) {
5164             /* Check for indexing off the end of the dimension list */
5165              
5166             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5167              
5168             switch(__params->boundary[k]) {
5169             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5170             if(ck != 0)
5171             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5172             break;
5173             case 1: /* truncation - just truncate if the corner is nonzero */
5174             trunc |= (ck != 0);
5175             break;
5176             case 2: /* extension -- ignore the corner (same as 3) */
5177             case 3: /* periodic -- ignore the corner */
5178             case 4: /* mirror -- ignore the corner */
5179             ck = 0;
5180             break;
5181             default:
5182             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5183             break;
5184             }
5185             }
5186              
5187             /* Find offsets into the child and parent arrays, from the N-D coords */
5188             /* Note we only loop over real source dims (prdim) to accumulate -- */
5189             /* because the offset is trivial and/or we're truncating for virtual */
5190             /* dims caused by permissive ranging. */
5191             coff = __privtrans->pdls[1]->dimincs[0] * item;
5192             for(k2 = __params->itdim, poff = k = 0;
5193             k < prdim;
5194             k++) {
5195             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5196             if(__params->sizes[k])
5197             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5198             }
5199              
5200             /* Loop the copy over all the source broadcast dims (above rdim). */
5201             do {
5202             PDL_Indx poff1 = poff;
5203             PDL_Indx coff1 = coff;
5204              
5205             /* Accumulate the offset due to source broadcasting */
5206             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5207             k < pdim;
5208             k++) {
5209             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5210             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5211             }
5212              
5213             /* Finally -- make the copy
5214             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5215             * out-of-bounds conditions.
5216             */
5217             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,S,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5218              
5219             /* Increment the source broadcast iterator */
5220             for( k=__params->rdim;
5221             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5222             k++)
5223             iter2[k] = 0;
5224             } while(k < pdim); /* end of source-broadcast iteration */
5225              
5226             /* Increment the in-range iterator */
5227             for(k = 0;
5228             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5229             k++)
5230             iter2[k] = 0;
5231             } while(k < __params->rdim); /* end of main iteration */
5232             } /* end of item do loop */
5233             #line 5234 "lib/PDL/Slices-pp-rangeb.c"
5234             }
5235 0           } break;
5236 0           case PDL_US: {
5237 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5238 0           {
5239             #line 877 "lib/PDL/Slices.pd"
5240             PDL_Indx *ip; /* vector iterator */
5241             PDL_Indx *sp; /* size vector including stdims */
5242             PDL_Indx *coords; /* current coordinates */
5243              
5244             PDL_Indx k; /* index */
5245             PDL_Indx item; /* index broadcast iterator */
5246             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5247             PDL_Indx rdim = __params->rdim;
5248             PDL_Indx prdim = PDLMIN(rdim,pdim);
5249             PDL_Indx iter2[pdim * 2 + rdim];
5250             PDL_Indx *sizes = iter2 + pdim;
5251             coords = sizes + pdim;
5252              
5253             /* Figure out size vector */
5254             for(ip = __params->sizes, sp = sizes, k=0; k
5255             *(sp++) = *(ip++);
5256             for(; k < pdim; k++)
5257             *(sp++) = __privtrans->pdls[0]->dims[k];
5258              
5259              
5260             /* Loop over all the ranges in the index list */
5261             for(item=0; item<__params->nitems; item++) {
5262              
5263             /* initialize in-range iterator to loop within each range */
5264             for(ip = iter2, k=0; k
5265             *(ip++) = 0;
5266              
5267             do {
5268             PDL_Indx poff = 0;
5269             PDL_Indx coff;
5270             PDL_Indx k2;
5271             char trunc = 0; /* Flag used to skip truncation case */
5272              
5273             /* Collect and boundary-check the current N-D coords */
5274             for(k=0; k < prdim; k++){
5275              
5276             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5277              
5278             /* normal case */
5279             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5280             switch(__params->boundary[k]) {
5281             case 0: /* no boundary breakage allowed */
5282             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5283             break;
5284             case 1: /* truncation */
5285             trunc = 1;
5286             break;
5287             case 2: /* extension -- crop */
5288             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5289             break;
5290             case 3: /* periodic -- mod it */
5291             ck %= __privtrans->pdls[0]->dims[k];
5292             if(ck < 0) /* Fix mod breakage in C */
5293             ck += __privtrans->pdls[0]->dims[k];
5294             break;
5295             case 4: /* mirror -- reflect off the edges */
5296             ck += __privtrans->pdls[0]->dims[k];
5297             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5298             if(ck < 0) /* Fix mod breakage in C */
5299             ck += __privtrans->pdls[0]->dims[k]*2;
5300             ck -= __privtrans->pdls[0]->dims[k];
5301             if(ck < 0) {
5302             ck *= -1;
5303             ck -= 1;
5304             }
5305             break;
5306             default:
5307             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5308             break;
5309             }
5310             }
5311              
5312             coords[k] = ck;
5313              
5314             }
5315              
5316             /* Check extra dimensions -- pick up where k left off... */
5317             for( ; k < rdim ; k++) {
5318             /* Check for indexing off the end of the dimension list */
5319              
5320             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5321              
5322             switch(__params->boundary[k]) {
5323             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5324             if(ck != 0)
5325             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5326             break;
5327             case 1: /* truncation - just truncate if the corner is nonzero */
5328             trunc |= (ck != 0);
5329             break;
5330             case 2: /* extension -- ignore the corner (same as 3) */
5331             case 3: /* periodic -- ignore the corner */
5332             case 4: /* mirror -- ignore the corner */
5333             ck = 0;
5334             break;
5335             default:
5336             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5337             break;
5338             }
5339             }
5340              
5341             /* Find offsets into the child and parent arrays, from the N-D coords */
5342             /* Note we only loop over real source dims (prdim) to accumulate -- */
5343             /* because the offset is trivial and/or we're truncating for virtual */
5344             /* dims caused by permissive ranging. */
5345             coff = __privtrans->pdls[1]->dimincs[0] * item;
5346             for(k2 = __params->itdim, poff = k = 0;
5347             k < prdim;
5348             k++) {
5349             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5350             if(__params->sizes[k])
5351             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5352             }
5353              
5354             /* Loop the copy over all the source broadcast dims (above rdim). */
5355             do {
5356             PDL_Indx poff1 = poff;
5357             PDL_Indx coff1 = coff;
5358              
5359             /* Accumulate the offset due to source broadcasting */
5360             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5361             k < pdim;
5362             k++) {
5363             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5364             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5365             }
5366              
5367             /* Finally -- make the copy
5368             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5369             * out-of-bounds conditions.
5370             */
5371             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,U,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5372              
5373             /* Increment the source broadcast iterator */
5374             for( k=__params->rdim;
5375             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5376             k++)
5377             iter2[k] = 0;
5378             } while(k < pdim); /* end of source-broadcast iteration */
5379              
5380             /* Increment the in-range iterator */
5381             for(k = 0;
5382             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5383             k++)
5384             iter2[k] = 0;
5385             } while(k < __params->rdim); /* end of main iteration */
5386             } /* end of item do loop */
5387             #line 5388 "lib/PDL/Slices-pp-rangeb.c"
5388             }
5389 0           } break;
5390 0           case PDL_L: {
5391 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Long,L)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5392 0           {
5393             #line 877 "lib/PDL/Slices.pd"
5394             PDL_Indx *ip; /* vector iterator */
5395             PDL_Indx *sp; /* size vector including stdims */
5396             PDL_Indx *coords; /* current coordinates */
5397              
5398             PDL_Indx k; /* index */
5399             PDL_Indx item; /* index broadcast iterator */
5400             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5401             PDL_Indx rdim = __params->rdim;
5402             PDL_Indx prdim = PDLMIN(rdim,pdim);
5403             PDL_Indx iter2[pdim * 2 + rdim];
5404             PDL_Indx *sizes = iter2 + pdim;
5405             coords = sizes + pdim;
5406              
5407             /* Figure out size vector */
5408             for(ip = __params->sizes, sp = sizes, k=0; k
5409             *(sp++) = *(ip++);
5410             for(; k < pdim; k++)
5411             *(sp++) = __privtrans->pdls[0]->dims[k];
5412              
5413              
5414             /* Loop over all the ranges in the index list */
5415             for(item=0; item<__params->nitems; item++) {
5416              
5417             /* initialize in-range iterator to loop within each range */
5418             for(ip = iter2, k=0; k
5419             *(ip++) = 0;
5420              
5421             do {
5422             PDL_Indx poff = 0;
5423             PDL_Indx coff;
5424             PDL_Indx k2;
5425             char trunc = 0; /* Flag used to skip truncation case */
5426              
5427             /* Collect and boundary-check the current N-D coords */
5428             for(k=0; k < prdim; k++){
5429              
5430             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5431              
5432             /* normal case */
5433             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5434             switch(__params->boundary[k]) {
5435             case 0: /* no boundary breakage allowed */
5436             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5437             break;
5438             case 1: /* truncation */
5439             trunc = 1;
5440             break;
5441             case 2: /* extension -- crop */
5442             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5443             break;
5444             case 3: /* periodic -- mod it */
5445             ck %= __privtrans->pdls[0]->dims[k];
5446             if(ck < 0) /* Fix mod breakage in C */
5447             ck += __privtrans->pdls[0]->dims[k];
5448             break;
5449             case 4: /* mirror -- reflect off the edges */
5450             ck += __privtrans->pdls[0]->dims[k];
5451             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5452             if(ck < 0) /* Fix mod breakage in C */
5453             ck += __privtrans->pdls[0]->dims[k]*2;
5454             ck -= __privtrans->pdls[0]->dims[k];
5455             if(ck < 0) {
5456             ck *= -1;
5457             ck -= 1;
5458             }
5459             break;
5460             default:
5461             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5462             break;
5463             }
5464             }
5465              
5466             coords[k] = ck;
5467              
5468             }
5469              
5470             /* Check extra dimensions -- pick up where k left off... */
5471             for( ; k < rdim ; k++) {
5472             /* Check for indexing off the end of the dimension list */
5473              
5474             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5475              
5476             switch(__params->boundary[k]) {
5477             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5478             if(ck != 0)
5479             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5480             break;
5481             case 1: /* truncation - just truncate if the corner is nonzero */
5482             trunc |= (ck != 0);
5483             break;
5484             case 2: /* extension -- ignore the corner (same as 3) */
5485             case 3: /* periodic -- ignore the corner */
5486             case 4: /* mirror -- ignore the corner */
5487             ck = 0;
5488             break;
5489             default:
5490             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5491             break;
5492             }
5493             }
5494              
5495             /* Find offsets into the child and parent arrays, from the N-D coords */
5496             /* Note we only loop over real source dims (prdim) to accumulate -- */
5497             /* because the offset is trivial and/or we're truncating for virtual */
5498             /* dims caused by permissive ranging. */
5499             coff = __privtrans->pdls[1]->dimincs[0] * item;
5500             for(k2 = __params->itdim, poff = k = 0;
5501             k < prdim;
5502             k++) {
5503             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5504             if(__params->sizes[k])
5505             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5506             }
5507              
5508             /* Loop the copy over all the source broadcast dims (above rdim). */
5509             do {
5510             PDL_Indx poff1 = poff;
5511             PDL_Indx coff1 = coff;
5512              
5513             /* Accumulate the offset due to source broadcasting */
5514             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5515             k < pdim;
5516             k++) {
5517             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5518             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5519             }
5520              
5521             /* Finally -- make the copy
5522             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5523             * out-of-bounds conditions.
5524             */
5525             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,L,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5526              
5527             /* Increment the source broadcast iterator */
5528             for( k=__params->rdim;
5529             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5530             k++)
5531             iter2[k] = 0;
5532             } while(k < pdim); /* end of source-broadcast iteration */
5533              
5534             /* Increment the in-range iterator */
5535             for(k = 0;
5536             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5537             k++)
5538             iter2[k] = 0;
5539             } while(k < __params->rdim); /* end of main iteration */
5540             } /* end of item do loop */
5541             #line 5542 "lib/PDL/Slices-pp-rangeb.c"
5542             }
5543 0           } break;
5544 0           case PDL_UL: {
5545 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5546 0           {
5547             #line 877 "lib/PDL/Slices.pd"
5548             PDL_Indx *ip; /* vector iterator */
5549             PDL_Indx *sp; /* size vector including stdims */
5550             PDL_Indx *coords; /* current coordinates */
5551              
5552             PDL_Indx k; /* index */
5553             PDL_Indx item; /* index broadcast iterator */
5554             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5555             PDL_Indx rdim = __params->rdim;
5556             PDL_Indx prdim = PDLMIN(rdim,pdim);
5557             PDL_Indx iter2[pdim * 2 + rdim];
5558             PDL_Indx *sizes = iter2 + pdim;
5559             coords = sizes + pdim;
5560              
5561             /* Figure out size vector */
5562             for(ip = __params->sizes, sp = sizes, k=0; k
5563             *(sp++) = *(ip++);
5564             for(; k < pdim; k++)
5565             *(sp++) = __privtrans->pdls[0]->dims[k];
5566              
5567              
5568             /* Loop over all the ranges in the index list */
5569             for(item=0; item<__params->nitems; item++) {
5570              
5571             /* initialize in-range iterator to loop within each range */
5572             for(ip = iter2, k=0; k
5573             *(ip++) = 0;
5574              
5575             do {
5576             PDL_Indx poff = 0;
5577             PDL_Indx coff;
5578             PDL_Indx k2;
5579             char trunc = 0; /* Flag used to skip truncation case */
5580              
5581             /* Collect and boundary-check the current N-D coords */
5582             for(k=0; k < prdim; k++){
5583              
5584             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5585              
5586             /* normal case */
5587             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5588             switch(__params->boundary[k]) {
5589             case 0: /* no boundary breakage allowed */
5590             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5591             break;
5592             case 1: /* truncation */
5593             trunc = 1;
5594             break;
5595             case 2: /* extension -- crop */
5596             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5597             break;
5598             case 3: /* periodic -- mod it */
5599             ck %= __privtrans->pdls[0]->dims[k];
5600             if(ck < 0) /* Fix mod breakage in C */
5601             ck += __privtrans->pdls[0]->dims[k];
5602             break;
5603             case 4: /* mirror -- reflect off the edges */
5604             ck += __privtrans->pdls[0]->dims[k];
5605             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5606             if(ck < 0) /* Fix mod breakage in C */
5607             ck += __privtrans->pdls[0]->dims[k]*2;
5608             ck -= __privtrans->pdls[0]->dims[k];
5609             if(ck < 0) {
5610             ck *= -1;
5611             ck -= 1;
5612             }
5613             break;
5614             default:
5615             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5616             break;
5617             }
5618             }
5619              
5620             coords[k] = ck;
5621              
5622             }
5623              
5624             /* Check extra dimensions -- pick up where k left off... */
5625             for( ; k < rdim ; k++) {
5626             /* Check for indexing off the end of the dimension list */
5627              
5628             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5629              
5630             switch(__params->boundary[k]) {
5631             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5632             if(ck != 0)
5633             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5634             break;
5635             case 1: /* truncation - just truncate if the corner is nonzero */
5636             trunc |= (ck != 0);
5637             break;
5638             case 2: /* extension -- ignore the corner (same as 3) */
5639             case 3: /* periodic -- ignore the corner */
5640             case 4: /* mirror -- ignore the corner */
5641             ck = 0;
5642             break;
5643             default:
5644             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5645             break;
5646             }
5647             }
5648              
5649             /* Find offsets into the child and parent arrays, from the N-D coords */
5650             /* Note we only loop over real source dims (prdim) to accumulate -- */
5651             /* because the offset is trivial and/or we're truncating for virtual */
5652             /* dims caused by permissive ranging. */
5653             coff = __privtrans->pdls[1]->dimincs[0] * item;
5654             for(k2 = __params->itdim, poff = k = 0;
5655             k < prdim;
5656             k++) {
5657             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5658             if(__params->sizes[k])
5659             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5660             }
5661              
5662             /* Loop the copy over all the source broadcast dims (above rdim). */
5663             do {
5664             PDL_Indx poff1 = poff;
5665             PDL_Indx coff1 = coff;
5666              
5667             /* Accumulate the offset due to source broadcasting */
5668             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5669             k < pdim;
5670             k++) {
5671             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5672             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5673             }
5674              
5675             /* Finally -- make the copy
5676             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5677             * out-of-bounds conditions.
5678             */
5679             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,K,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5680              
5681             /* Increment the source broadcast iterator */
5682             for( k=__params->rdim;
5683             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5684             k++)
5685             iter2[k] = 0;
5686             } while(k < pdim); /* end of source-broadcast iteration */
5687              
5688             /* Increment the in-range iterator */
5689             for(k = 0;
5690             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5691             k++)
5692             iter2[k] = 0;
5693             } while(k < __params->rdim); /* end of main iteration */
5694             } /* end of item do loop */
5695             #line 5696 "lib/PDL/Slices-pp-rangeb.c"
5696             }
5697 0           } break;
5698 0           case PDL_IND: {
5699 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5700 0           {
5701             #line 877 "lib/PDL/Slices.pd"
5702             PDL_Indx *ip; /* vector iterator */
5703             PDL_Indx *sp; /* size vector including stdims */
5704             PDL_Indx *coords; /* current coordinates */
5705              
5706             PDL_Indx k; /* index */
5707             PDL_Indx item; /* index broadcast iterator */
5708             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5709             PDL_Indx rdim = __params->rdim;
5710             PDL_Indx prdim = PDLMIN(rdim,pdim);
5711             PDL_Indx iter2[pdim * 2 + rdim];
5712             PDL_Indx *sizes = iter2 + pdim;
5713             coords = sizes + pdim;
5714              
5715             /* Figure out size vector */
5716             for(ip = __params->sizes, sp = sizes, k=0; k
5717             *(sp++) = *(ip++);
5718             for(; k < pdim; k++)
5719             *(sp++) = __privtrans->pdls[0]->dims[k];
5720              
5721              
5722             /* Loop over all the ranges in the index list */
5723             for(item=0; item<__params->nitems; item++) {
5724              
5725             /* initialize in-range iterator to loop within each range */
5726             for(ip = iter2, k=0; k
5727             *(ip++) = 0;
5728              
5729             do {
5730             PDL_Indx poff = 0;
5731             PDL_Indx coff;
5732             PDL_Indx k2;
5733             char trunc = 0; /* Flag used to skip truncation case */
5734              
5735             /* Collect and boundary-check the current N-D coords */
5736             for(k=0; k < prdim; k++){
5737              
5738             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5739              
5740             /* normal case */
5741             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5742             switch(__params->boundary[k]) {
5743             case 0: /* no boundary breakage allowed */
5744             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5745             break;
5746             case 1: /* truncation */
5747             trunc = 1;
5748             break;
5749             case 2: /* extension -- crop */
5750             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5751             break;
5752             case 3: /* periodic -- mod it */
5753             ck %= __privtrans->pdls[0]->dims[k];
5754             if(ck < 0) /* Fix mod breakage in C */
5755             ck += __privtrans->pdls[0]->dims[k];
5756             break;
5757             case 4: /* mirror -- reflect off the edges */
5758             ck += __privtrans->pdls[0]->dims[k];
5759             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5760             if(ck < 0) /* Fix mod breakage in C */
5761             ck += __privtrans->pdls[0]->dims[k]*2;
5762             ck -= __privtrans->pdls[0]->dims[k];
5763             if(ck < 0) {
5764             ck *= -1;
5765             ck -= 1;
5766             }
5767             break;
5768             default:
5769             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5770             break;
5771             }
5772             }
5773              
5774             coords[k] = ck;
5775              
5776             }
5777              
5778             /* Check extra dimensions -- pick up where k left off... */
5779             for( ; k < rdim ; k++) {
5780             /* Check for indexing off the end of the dimension list */
5781              
5782             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5783              
5784             switch(__params->boundary[k]) {
5785             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5786             if(ck != 0)
5787             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5788             break;
5789             case 1: /* truncation - just truncate if the corner is nonzero */
5790             trunc |= (ck != 0);
5791             break;
5792             case 2: /* extension -- ignore the corner (same as 3) */
5793             case 3: /* periodic -- ignore the corner */
5794             case 4: /* mirror -- ignore the corner */
5795             ck = 0;
5796             break;
5797             default:
5798             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5799             break;
5800             }
5801             }
5802              
5803             /* Find offsets into the child and parent arrays, from the N-D coords */
5804             /* Note we only loop over real source dims (prdim) to accumulate -- */
5805             /* because the offset is trivial and/or we're truncating for virtual */
5806             /* dims caused by permissive ranging. */
5807             coff = __privtrans->pdls[1]->dimincs[0] * item;
5808             for(k2 = __params->itdim, poff = k = 0;
5809             k < prdim;
5810             k++) {
5811             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5812             if(__params->sizes[k])
5813             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5814             }
5815              
5816             /* Loop the copy over all the source broadcast dims (above rdim). */
5817             do {
5818             PDL_Indx poff1 = poff;
5819             PDL_Indx coff1 = coff;
5820              
5821             /* Accumulate the offset due to source broadcasting */
5822             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5823             k < pdim;
5824             k++) {
5825             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5826             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5827             }
5828              
5829             /* Finally -- make the copy
5830             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5831             * out-of-bounds conditions.
5832             */
5833             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,N,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5834              
5835             /* Increment the source broadcast iterator */
5836             for( k=__params->rdim;
5837             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5838             k++)
5839             iter2[k] = 0;
5840             } while(k < pdim); /* end of source-broadcast iteration */
5841              
5842             /* Increment the in-range iterator */
5843             for(k = 0;
5844             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5845             k++)
5846             iter2[k] = 0;
5847             } while(k < __params->rdim); /* end of main iteration */
5848             } /* end of item do loop */
5849             #line 5850 "lib/PDL/Slices-pp-rangeb.c"
5850             }
5851 0           } break;
5852 0           case PDL_ULL: {
5853 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5854 0           {
5855             #line 877 "lib/PDL/Slices.pd"
5856             PDL_Indx *ip; /* vector iterator */
5857             PDL_Indx *sp; /* size vector including stdims */
5858             PDL_Indx *coords; /* current coordinates */
5859              
5860             PDL_Indx k; /* index */
5861             PDL_Indx item; /* index broadcast iterator */
5862             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
5863             PDL_Indx rdim = __params->rdim;
5864             PDL_Indx prdim = PDLMIN(rdim,pdim);
5865             PDL_Indx iter2[pdim * 2 + rdim];
5866             PDL_Indx *sizes = iter2 + pdim;
5867             coords = sizes + pdim;
5868              
5869             /* Figure out size vector */
5870             for(ip = __params->sizes, sp = sizes, k=0; k
5871             *(sp++) = *(ip++);
5872             for(; k < pdim; k++)
5873             *(sp++) = __privtrans->pdls[0]->dims[k];
5874              
5875              
5876             /* Loop over all the ranges in the index list */
5877             for(item=0; item<__params->nitems; item++) {
5878              
5879             /* initialize in-range iterator to loop within each range */
5880             for(ip = iter2, k=0; k
5881             *(ip++) = 0;
5882              
5883             do {
5884             PDL_Indx poff = 0;
5885             PDL_Indx coff;
5886             PDL_Indx k2;
5887             char trunc = 0; /* Flag used to skip truncation case */
5888              
5889             /* Collect and boundary-check the current N-D coords */
5890             for(k=0; k < prdim; k++){
5891              
5892             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5893              
5894             /* normal case */
5895             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
5896             switch(__params->boundary[k]) {
5897             case 0: /* no boundary breakage allowed */
5898             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
5899             break;
5900             case 1: /* truncation */
5901             trunc = 1;
5902             break;
5903             case 2: /* extension -- crop */
5904             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
5905             break;
5906             case 3: /* periodic -- mod it */
5907             ck %= __privtrans->pdls[0]->dims[k];
5908             if(ck < 0) /* Fix mod breakage in C */
5909             ck += __privtrans->pdls[0]->dims[k];
5910             break;
5911             case 4: /* mirror -- reflect off the edges */
5912             ck += __privtrans->pdls[0]->dims[k];
5913             ck %= (__privtrans->pdls[0]->dims[k] * 2);
5914             if(ck < 0) /* Fix mod breakage in C */
5915             ck += __privtrans->pdls[0]->dims[k]*2;
5916             ck -= __privtrans->pdls[0]->dims[k];
5917             if(ck < 0) {
5918             ck *= -1;
5919             ck -= 1;
5920             }
5921             break;
5922             default:
5923             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5924             break;
5925             }
5926             }
5927              
5928             coords[k] = ck;
5929              
5930             }
5931              
5932             /* Check extra dimensions -- pick up where k left off... */
5933             for( ; k < rdim ; k++) {
5934             /* Check for indexing off the end of the dimension list */
5935              
5936             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
5937              
5938             switch(__params->boundary[k]) {
5939             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
5940             if(ck != 0)
5941             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
5942             break;
5943             case 1: /* truncation - just truncate if the corner is nonzero */
5944             trunc |= (ck != 0);
5945             break;
5946             case 2: /* extension -- ignore the corner (same as 3) */
5947             case 3: /* periodic -- ignore the corner */
5948             case 4: /* mirror -- ignore the corner */
5949             ck = 0;
5950             break;
5951             default:
5952             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
5953             break;
5954             }
5955             }
5956              
5957             /* Find offsets into the child and parent arrays, from the N-D coords */
5958             /* Note we only loop over real source dims (prdim) to accumulate -- */
5959             /* because the offset is trivial and/or we're truncating for virtual */
5960             /* dims caused by permissive ranging. */
5961             coff = __privtrans->pdls[1]->dimincs[0] * item;
5962             for(k2 = __params->itdim, poff = k = 0;
5963             k < prdim;
5964             k++) {
5965             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
5966             if(__params->sizes[k])
5967             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5968             }
5969              
5970             /* Loop the copy over all the source broadcast dims (above rdim). */
5971             do {
5972             PDL_Indx poff1 = poff;
5973             PDL_Indx coff1 = coff;
5974              
5975             /* Accumulate the offset due to source broadcasting */
5976             for(k2 = __params->itdim + __params->ntsize, k = rdim;
5977             k < pdim;
5978             k++) {
5979             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
5980             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
5981             }
5982              
5983             /* Finally -- make the copy
5984             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
5985             * out-of-bounds conditions.
5986             */
5987             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,P,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
5988              
5989             /* Increment the source broadcast iterator */
5990             for( k=__params->rdim;
5991             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
5992             k++)
5993             iter2[k] = 0;
5994             } while(k < pdim); /* end of source-broadcast iteration */
5995              
5996             /* Increment the in-range iterator */
5997             for(k = 0;
5998             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
5999             k++)
6000             iter2[k] = 0;
6001             } while(k < __params->rdim); /* end of main iteration */
6002             } /* end of item do loop */
6003             #line 6004 "lib/PDL/Slices-pp-rangeb.c"
6004             }
6005 0           } break;
6006 0           case PDL_LL: {
6007 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6008 0           {
6009             #line 877 "lib/PDL/Slices.pd"
6010             PDL_Indx *ip; /* vector iterator */
6011             PDL_Indx *sp; /* size vector including stdims */
6012             PDL_Indx *coords; /* current coordinates */
6013              
6014             PDL_Indx k; /* index */
6015             PDL_Indx item; /* index broadcast iterator */
6016             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6017             PDL_Indx rdim = __params->rdim;
6018             PDL_Indx prdim = PDLMIN(rdim,pdim);
6019             PDL_Indx iter2[pdim * 2 + rdim];
6020             PDL_Indx *sizes = iter2 + pdim;
6021             coords = sizes + pdim;
6022              
6023             /* Figure out size vector */
6024             for(ip = __params->sizes, sp = sizes, k=0; k
6025             *(sp++) = *(ip++);
6026             for(; k < pdim; k++)
6027             *(sp++) = __privtrans->pdls[0]->dims[k];
6028              
6029              
6030             /* Loop over all the ranges in the index list */
6031             for(item=0; item<__params->nitems; item++) {
6032              
6033             /* initialize in-range iterator to loop within each range */
6034             for(ip = iter2, k=0; k
6035             *(ip++) = 0;
6036              
6037             do {
6038             PDL_Indx poff = 0;
6039             PDL_Indx coff;
6040             PDL_Indx k2;
6041             char trunc = 0; /* Flag used to skip truncation case */
6042              
6043             /* Collect and boundary-check the current N-D coords */
6044             for(k=0; k < prdim; k++){
6045              
6046             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6047              
6048             /* normal case */
6049             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6050             switch(__params->boundary[k]) {
6051             case 0: /* no boundary breakage allowed */
6052             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6053             break;
6054             case 1: /* truncation */
6055             trunc = 1;
6056             break;
6057             case 2: /* extension -- crop */
6058             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6059             break;
6060             case 3: /* periodic -- mod it */
6061             ck %= __privtrans->pdls[0]->dims[k];
6062             if(ck < 0) /* Fix mod breakage in C */
6063             ck += __privtrans->pdls[0]->dims[k];
6064             break;
6065             case 4: /* mirror -- reflect off the edges */
6066             ck += __privtrans->pdls[0]->dims[k];
6067             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6068             if(ck < 0) /* Fix mod breakage in C */
6069             ck += __privtrans->pdls[0]->dims[k]*2;
6070             ck -= __privtrans->pdls[0]->dims[k];
6071             if(ck < 0) {
6072             ck *= -1;
6073             ck -= 1;
6074             }
6075             break;
6076             default:
6077             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6078             break;
6079             }
6080             }
6081              
6082             coords[k] = ck;
6083              
6084             }
6085              
6086             /* Check extra dimensions -- pick up where k left off... */
6087             for( ; k < rdim ; k++) {
6088             /* Check for indexing off the end of the dimension list */
6089              
6090             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6091              
6092             switch(__params->boundary[k]) {
6093             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6094             if(ck != 0)
6095             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6096             break;
6097             case 1: /* truncation - just truncate if the corner is nonzero */
6098             trunc |= (ck != 0);
6099             break;
6100             case 2: /* extension -- ignore the corner (same as 3) */
6101             case 3: /* periodic -- ignore the corner */
6102             case 4: /* mirror -- ignore the corner */
6103             ck = 0;
6104             break;
6105             default:
6106             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6107             break;
6108             }
6109             }
6110              
6111             /* Find offsets into the child and parent arrays, from the N-D coords */
6112             /* Note we only loop over real source dims (prdim) to accumulate -- */
6113             /* because the offset is trivial and/or we're truncating for virtual */
6114             /* dims caused by permissive ranging. */
6115             coff = __privtrans->pdls[1]->dimincs[0] * item;
6116             for(k2 = __params->itdim, poff = k = 0;
6117             k < prdim;
6118             k++) {
6119             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6120             if(__params->sizes[k])
6121             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6122             }
6123              
6124             /* Loop the copy over all the source broadcast dims (above rdim). */
6125             do {
6126             PDL_Indx poff1 = poff;
6127             PDL_Indx coff1 = coff;
6128              
6129             /* Accumulate the offset due to source broadcasting */
6130             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6131             k < pdim;
6132             k++) {
6133             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6134             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6135             }
6136              
6137             /* Finally -- make the copy
6138             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6139             * out-of-bounds conditions.
6140             */
6141             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,Q,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6142              
6143             /* Increment the source broadcast iterator */
6144             for( k=__params->rdim;
6145             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6146             k++)
6147             iter2[k] = 0;
6148             } while(k < pdim); /* end of source-broadcast iteration */
6149              
6150             /* Increment the in-range iterator */
6151             for(k = 0;
6152             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6153             k++)
6154             iter2[k] = 0;
6155             } while(k < __params->rdim); /* end of main iteration */
6156             } /* end of item do loop */
6157             #line 6158 "lib/PDL/Slices-pp-rangeb.c"
6158             }
6159 0           } break;
6160 0           case PDL_F: {
6161 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6162 0           {
6163             #line 877 "lib/PDL/Slices.pd"
6164             PDL_Indx *ip; /* vector iterator */
6165             PDL_Indx *sp; /* size vector including stdims */
6166             PDL_Indx *coords; /* current coordinates */
6167              
6168             PDL_Indx k; /* index */
6169             PDL_Indx item; /* index broadcast iterator */
6170             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6171             PDL_Indx rdim = __params->rdim;
6172             PDL_Indx prdim = PDLMIN(rdim,pdim);
6173             PDL_Indx iter2[pdim * 2 + rdim];
6174             PDL_Indx *sizes = iter2 + pdim;
6175             coords = sizes + pdim;
6176              
6177             /* Figure out size vector */
6178             for(ip = __params->sizes, sp = sizes, k=0; k
6179             *(sp++) = *(ip++);
6180             for(; k < pdim; k++)
6181             *(sp++) = __privtrans->pdls[0]->dims[k];
6182              
6183              
6184             /* Loop over all the ranges in the index list */
6185             for(item=0; item<__params->nitems; item++) {
6186              
6187             /* initialize in-range iterator to loop within each range */
6188             for(ip = iter2, k=0; k
6189             *(ip++) = 0;
6190              
6191             do {
6192             PDL_Indx poff = 0;
6193             PDL_Indx coff;
6194             PDL_Indx k2;
6195             char trunc = 0; /* Flag used to skip truncation case */
6196              
6197             /* Collect and boundary-check the current N-D coords */
6198             for(k=0; k < prdim; k++){
6199              
6200             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6201              
6202             /* normal case */
6203             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6204             switch(__params->boundary[k]) {
6205             case 0: /* no boundary breakage allowed */
6206             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6207             break;
6208             case 1: /* truncation */
6209             trunc = 1;
6210             break;
6211             case 2: /* extension -- crop */
6212             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6213             break;
6214             case 3: /* periodic -- mod it */
6215             ck %= __privtrans->pdls[0]->dims[k];
6216             if(ck < 0) /* Fix mod breakage in C */
6217             ck += __privtrans->pdls[0]->dims[k];
6218             break;
6219             case 4: /* mirror -- reflect off the edges */
6220             ck += __privtrans->pdls[0]->dims[k];
6221             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6222             if(ck < 0) /* Fix mod breakage in C */
6223             ck += __privtrans->pdls[0]->dims[k]*2;
6224             ck -= __privtrans->pdls[0]->dims[k];
6225             if(ck < 0) {
6226             ck *= -1;
6227             ck -= 1;
6228             }
6229             break;
6230             default:
6231             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6232             break;
6233             }
6234             }
6235              
6236             coords[k] = ck;
6237              
6238             }
6239              
6240             /* Check extra dimensions -- pick up where k left off... */
6241             for( ; k < rdim ; k++) {
6242             /* Check for indexing off the end of the dimension list */
6243              
6244             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6245              
6246             switch(__params->boundary[k]) {
6247             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6248             if(ck != 0)
6249             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6250             break;
6251             case 1: /* truncation - just truncate if the corner is nonzero */
6252             trunc |= (ck != 0);
6253             break;
6254             case 2: /* extension -- ignore the corner (same as 3) */
6255             case 3: /* periodic -- ignore the corner */
6256             case 4: /* mirror -- ignore the corner */
6257             ck = 0;
6258             break;
6259             default:
6260             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6261             break;
6262             }
6263             }
6264              
6265             /* Find offsets into the child and parent arrays, from the N-D coords */
6266             /* Note we only loop over real source dims (prdim) to accumulate -- */
6267             /* because the offset is trivial and/or we're truncating for virtual */
6268             /* dims caused by permissive ranging. */
6269             coff = __privtrans->pdls[1]->dimincs[0] * item;
6270             for(k2 = __params->itdim, poff = k = 0;
6271             k < prdim;
6272             k++) {
6273             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6274             if(__params->sizes[k])
6275             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6276             }
6277              
6278             /* Loop the copy over all the source broadcast dims (above rdim). */
6279             do {
6280             PDL_Indx poff1 = poff;
6281             PDL_Indx coff1 = coff;
6282              
6283             /* Accumulate the offset due to source broadcasting */
6284             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6285             k < pdim;
6286             k++) {
6287             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6288             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6289             }
6290              
6291             /* Finally -- make the copy
6292             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6293             * out-of-bounds conditions.
6294             */
6295             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,F,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6296              
6297             /* Increment the source broadcast iterator */
6298             for( k=__params->rdim;
6299             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6300             k++)
6301             iter2[k] = 0;
6302             } while(k < pdim); /* end of source-broadcast iteration */
6303              
6304             /* Increment the in-range iterator */
6305             for(k = 0;
6306             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6307             k++)
6308             iter2[k] = 0;
6309             } while(k < __params->rdim); /* end of main iteration */
6310             } /* end of item do loop */
6311             #line 6312 "lib/PDL/Slices-pp-rangeb.c"
6312             }
6313 0           } break;
6314 0           case PDL_D: {
6315 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Double,D)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6316 0           {
6317             #line 877 "lib/PDL/Slices.pd"
6318             PDL_Indx *ip; /* vector iterator */
6319             PDL_Indx *sp; /* size vector including stdims */
6320             PDL_Indx *coords; /* current coordinates */
6321              
6322             PDL_Indx k; /* index */
6323             PDL_Indx item; /* index broadcast iterator */
6324             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6325             PDL_Indx rdim = __params->rdim;
6326             PDL_Indx prdim = PDLMIN(rdim,pdim);
6327             PDL_Indx iter2[pdim * 2 + rdim];
6328             PDL_Indx *sizes = iter2 + pdim;
6329             coords = sizes + pdim;
6330              
6331             /* Figure out size vector */
6332             for(ip = __params->sizes, sp = sizes, k=0; k
6333             *(sp++) = *(ip++);
6334             for(; k < pdim; k++)
6335             *(sp++) = __privtrans->pdls[0]->dims[k];
6336              
6337              
6338             /* Loop over all the ranges in the index list */
6339             for(item=0; item<__params->nitems; item++) {
6340              
6341             /* initialize in-range iterator to loop within each range */
6342             for(ip = iter2, k=0; k
6343             *(ip++) = 0;
6344              
6345             do {
6346             PDL_Indx poff = 0;
6347             PDL_Indx coff;
6348             PDL_Indx k2;
6349             char trunc = 0; /* Flag used to skip truncation case */
6350              
6351             /* Collect and boundary-check the current N-D coords */
6352             for(k=0; k < prdim; k++){
6353              
6354             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6355              
6356             /* normal case */
6357             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6358             switch(__params->boundary[k]) {
6359             case 0: /* no boundary breakage allowed */
6360             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6361             break;
6362             case 1: /* truncation */
6363             trunc = 1;
6364             break;
6365             case 2: /* extension -- crop */
6366             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6367             break;
6368             case 3: /* periodic -- mod it */
6369             ck %= __privtrans->pdls[0]->dims[k];
6370             if(ck < 0) /* Fix mod breakage in C */
6371             ck += __privtrans->pdls[0]->dims[k];
6372             break;
6373             case 4: /* mirror -- reflect off the edges */
6374             ck += __privtrans->pdls[0]->dims[k];
6375             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6376             if(ck < 0) /* Fix mod breakage in C */
6377             ck += __privtrans->pdls[0]->dims[k]*2;
6378             ck -= __privtrans->pdls[0]->dims[k];
6379             if(ck < 0) {
6380             ck *= -1;
6381             ck -= 1;
6382             }
6383             break;
6384             default:
6385             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6386             break;
6387             }
6388             }
6389              
6390             coords[k] = ck;
6391              
6392             }
6393              
6394             /* Check extra dimensions -- pick up where k left off... */
6395             for( ; k < rdim ; k++) {
6396             /* Check for indexing off the end of the dimension list */
6397              
6398             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6399              
6400             switch(__params->boundary[k]) {
6401             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6402             if(ck != 0)
6403             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6404             break;
6405             case 1: /* truncation - just truncate if the corner is nonzero */
6406             trunc |= (ck != 0);
6407             break;
6408             case 2: /* extension -- ignore the corner (same as 3) */
6409             case 3: /* periodic -- ignore the corner */
6410             case 4: /* mirror -- ignore the corner */
6411             ck = 0;
6412             break;
6413             default:
6414             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6415             break;
6416             }
6417             }
6418              
6419             /* Find offsets into the child and parent arrays, from the N-D coords */
6420             /* Note we only loop over real source dims (prdim) to accumulate -- */
6421             /* because the offset is trivial and/or we're truncating for virtual */
6422             /* dims caused by permissive ranging. */
6423             coff = __privtrans->pdls[1]->dimincs[0] * item;
6424             for(k2 = __params->itdim, poff = k = 0;
6425             k < prdim;
6426             k++) {
6427             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6428             if(__params->sizes[k])
6429             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6430             }
6431              
6432             /* Loop the copy over all the source broadcast dims (above rdim). */
6433             do {
6434             PDL_Indx poff1 = poff;
6435             PDL_Indx coff1 = coff;
6436              
6437             /* Accumulate the offset due to source broadcasting */
6438             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6439             k < pdim;
6440             k++) {
6441             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6442             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6443             }
6444              
6445             /* Finally -- make the copy
6446             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6447             * out-of-bounds conditions.
6448             */
6449             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,D,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6450              
6451             /* Increment the source broadcast iterator */
6452             for( k=__params->rdim;
6453             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6454             k++)
6455             iter2[k] = 0;
6456             } while(k < pdim); /* end of source-broadcast iteration */
6457              
6458             /* Increment the in-range iterator */
6459             for(k = 0;
6460             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6461             k++)
6462             iter2[k] = 0;
6463             } while(k < __params->rdim); /* end of main iteration */
6464             } /* end of item do loop */
6465             #line 6466 "lib/PDL/Slices-pp-rangeb.c"
6466             }
6467 0           } break;
6468 0           case PDL_LD: {
6469 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6470 0           {
6471             #line 877 "lib/PDL/Slices.pd"
6472             PDL_Indx *ip; /* vector iterator */
6473             PDL_Indx *sp; /* size vector including stdims */
6474             PDL_Indx *coords; /* current coordinates */
6475              
6476             PDL_Indx k; /* index */
6477             PDL_Indx item; /* index broadcast iterator */
6478             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6479             PDL_Indx rdim = __params->rdim;
6480             PDL_Indx prdim = PDLMIN(rdim,pdim);
6481             PDL_Indx iter2[pdim * 2 + rdim];
6482             PDL_Indx *sizes = iter2 + pdim;
6483             coords = sizes + pdim;
6484              
6485             /* Figure out size vector */
6486             for(ip = __params->sizes, sp = sizes, k=0; k
6487             *(sp++) = *(ip++);
6488             for(; k < pdim; k++)
6489             *(sp++) = __privtrans->pdls[0]->dims[k];
6490              
6491              
6492             /* Loop over all the ranges in the index list */
6493             for(item=0; item<__params->nitems; item++) {
6494              
6495             /* initialize in-range iterator to loop within each range */
6496             for(ip = iter2, k=0; k
6497             *(ip++) = 0;
6498              
6499             do {
6500             PDL_Indx poff = 0;
6501             PDL_Indx coff;
6502             PDL_Indx k2;
6503             char trunc = 0; /* Flag used to skip truncation case */
6504              
6505             /* Collect and boundary-check the current N-D coords */
6506             for(k=0; k < prdim; k++){
6507              
6508             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6509              
6510             /* normal case */
6511             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6512             switch(__params->boundary[k]) {
6513             case 0: /* no boundary breakage allowed */
6514             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6515             break;
6516             case 1: /* truncation */
6517             trunc = 1;
6518             break;
6519             case 2: /* extension -- crop */
6520             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6521             break;
6522             case 3: /* periodic -- mod it */
6523             ck %= __privtrans->pdls[0]->dims[k];
6524             if(ck < 0) /* Fix mod breakage in C */
6525             ck += __privtrans->pdls[0]->dims[k];
6526             break;
6527             case 4: /* mirror -- reflect off the edges */
6528             ck += __privtrans->pdls[0]->dims[k];
6529             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6530             if(ck < 0) /* Fix mod breakage in C */
6531             ck += __privtrans->pdls[0]->dims[k]*2;
6532             ck -= __privtrans->pdls[0]->dims[k];
6533             if(ck < 0) {
6534             ck *= -1;
6535             ck -= 1;
6536             }
6537             break;
6538             default:
6539             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6540             break;
6541             }
6542             }
6543              
6544             coords[k] = ck;
6545              
6546             }
6547              
6548             /* Check extra dimensions -- pick up where k left off... */
6549             for( ; k < rdim ; k++) {
6550             /* Check for indexing off the end of the dimension list */
6551              
6552             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6553              
6554             switch(__params->boundary[k]) {
6555             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6556             if(ck != 0)
6557             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6558             break;
6559             case 1: /* truncation - just truncate if the corner is nonzero */
6560             trunc |= (ck != 0);
6561             break;
6562             case 2: /* extension -- ignore the corner (same as 3) */
6563             case 3: /* periodic -- ignore the corner */
6564             case 4: /* mirror -- ignore the corner */
6565             ck = 0;
6566             break;
6567             default:
6568             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6569             break;
6570             }
6571             }
6572              
6573             /* Find offsets into the child and parent arrays, from the N-D coords */
6574             /* Note we only loop over real source dims (prdim) to accumulate -- */
6575             /* because the offset is trivial and/or we're truncating for virtual */
6576             /* dims caused by permissive ranging. */
6577             coff = __privtrans->pdls[1]->dimincs[0] * item;
6578             for(k2 = __params->itdim, poff = k = 0;
6579             k < prdim;
6580             k++) {
6581             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6582             if(__params->sizes[k])
6583             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6584             }
6585              
6586             /* Loop the copy over all the source broadcast dims (above rdim). */
6587             do {
6588             PDL_Indx poff1 = poff;
6589             PDL_Indx coff1 = coff;
6590              
6591             /* Accumulate the offset due to source broadcasting */
6592             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6593             k < pdim;
6594             k++) {
6595             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6596             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6597             }
6598              
6599             /* Finally -- make the copy
6600             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6601             * out-of-bounds conditions.
6602             */
6603             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,E,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6604              
6605             /* Increment the source broadcast iterator */
6606             for( k=__params->rdim;
6607             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6608             k++)
6609             iter2[k] = 0;
6610             } while(k < pdim); /* end of source-broadcast iteration */
6611              
6612             /* Increment the in-range iterator */
6613             for(k = 0;
6614             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6615             k++)
6616             iter2[k] = 0;
6617             } while(k < __params->rdim); /* end of main iteration */
6618             } /* end of item do loop */
6619             #line 6620 "lib/PDL/Slices-pp-rangeb.c"
6620             }
6621 0           } break;
6622 0           case PDL_CF: {
6623 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CFloat,G)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6624 0           {
6625             #line 877 "lib/PDL/Slices.pd"
6626             PDL_Indx *ip; /* vector iterator */
6627             PDL_Indx *sp; /* size vector including stdims */
6628             PDL_Indx *coords; /* current coordinates */
6629              
6630             PDL_Indx k; /* index */
6631             PDL_Indx item; /* index broadcast iterator */
6632             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6633             PDL_Indx rdim = __params->rdim;
6634             PDL_Indx prdim = PDLMIN(rdim,pdim);
6635             PDL_Indx iter2[pdim * 2 + rdim];
6636             PDL_Indx *sizes = iter2 + pdim;
6637             coords = sizes + pdim;
6638              
6639             /* Figure out size vector */
6640             for(ip = __params->sizes, sp = sizes, k=0; k
6641             *(sp++) = *(ip++);
6642             for(; k < pdim; k++)
6643             *(sp++) = __privtrans->pdls[0]->dims[k];
6644              
6645              
6646             /* Loop over all the ranges in the index list */
6647             for(item=0; item<__params->nitems; item++) {
6648              
6649             /* initialize in-range iterator to loop within each range */
6650             for(ip = iter2, k=0; k
6651             *(ip++) = 0;
6652              
6653             do {
6654             PDL_Indx poff = 0;
6655             PDL_Indx coff;
6656             PDL_Indx k2;
6657             char trunc = 0; /* Flag used to skip truncation case */
6658              
6659             /* Collect and boundary-check the current N-D coords */
6660             for(k=0; k < prdim; k++){
6661              
6662             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6663              
6664             /* normal case */
6665             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6666             switch(__params->boundary[k]) {
6667             case 0: /* no boundary breakage allowed */
6668             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6669             break;
6670             case 1: /* truncation */
6671             trunc = 1;
6672             break;
6673             case 2: /* extension -- crop */
6674             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6675             break;
6676             case 3: /* periodic -- mod it */
6677             ck %= __privtrans->pdls[0]->dims[k];
6678             if(ck < 0) /* Fix mod breakage in C */
6679             ck += __privtrans->pdls[0]->dims[k];
6680             break;
6681             case 4: /* mirror -- reflect off the edges */
6682             ck += __privtrans->pdls[0]->dims[k];
6683             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6684             if(ck < 0) /* Fix mod breakage in C */
6685             ck += __privtrans->pdls[0]->dims[k]*2;
6686             ck -= __privtrans->pdls[0]->dims[k];
6687             if(ck < 0) {
6688             ck *= -1;
6689             ck -= 1;
6690             }
6691             break;
6692             default:
6693             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6694             break;
6695             }
6696             }
6697              
6698             coords[k] = ck;
6699              
6700             }
6701              
6702             /* Check extra dimensions -- pick up where k left off... */
6703             for( ; k < rdim ; k++) {
6704             /* Check for indexing off the end of the dimension list */
6705              
6706             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6707              
6708             switch(__params->boundary[k]) {
6709             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6710             if(ck != 0)
6711             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6712             break;
6713             case 1: /* truncation - just truncate if the corner is nonzero */
6714             trunc |= (ck != 0);
6715             break;
6716             case 2: /* extension -- ignore the corner (same as 3) */
6717             case 3: /* periodic -- ignore the corner */
6718             case 4: /* mirror -- ignore the corner */
6719             ck = 0;
6720             break;
6721             default:
6722             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6723             break;
6724             }
6725             }
6726              
6727             /* Find offsets into the child and parent arrays, from the N-D coords */
6728             /* Note we only loop over real source dims (prdim) to accumulate -- */
6729             /* because the offset is trivial and/or we're truncating for virtual */
6730             /* dims caused by permissive ranging. */
6731             coff = __privtrans->pdls[1]->dimincs[0] * item;
6732             for(k2 = __params->itdim, poff = k = 0;
6733             k < prdim;
6734             k++) {
6735             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6736             if(__params->sizes[k])
6737             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6738             }
6739              
6740             /* Loop the copy over all the source broadcast dims (above rdim). */
6741             do {
6742             PDL_Indx poff1 = poff;
6743             PDL_Indx coff1 = coff;
6744              
6745             /* Accumulate the offset due to source broadcasting */
6746             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6747             k < pdim;
6748             k++) {
6749             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6750             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6751             }
6752              
6753             /* Finally -- make the copy
6754             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6755             * out-of-bounds conditions.
6756             */
6757             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,G,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6758              
6759             /* Increment the source broadcast iterator */
6760             for( k=__params->rdim;
6761             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6762             k++)
6763             iter2[k] = 0;
6764             } while(k < pdim); /* end of source-broadcast iteration */
6765              
6766             /* Increment the in-range iterator */
6767             for(k = 0;
6768             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6769             k++)
6770             iter2[k] = 0;
6771             } while(k < __params->rdim); /* end of main iteration */
6772             } /* end of item do loop */
6773             #line 6774 "lib/PDL/Slices-pp-rangeb.c"
6774             }
6775 0           } break;
6776 0           case PDL_CD: {
6777 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CDouble,C)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6778 0           {
6779             #line 877 "lib/PDL/Slices.pd"
6780             PDL_Indx *ip; /* vector iterator */
6781             PDL_Indx *sp; /* size vector including stdims */
6782             PDL_Indx *coords; /* current coordinates */
6783              
6784             PDL_Indx k; /* index */
6785             PDL_Indx item; /* index broadcast iterator */
6786             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6787             PDL_Indx rdim = __params->rdim;
6788             PDL_Indx prdim = PDLMIN(rdim,pdim);
6789             PDL_Indx iter2[pdim * 2 + rdim];
6790             PDL_Indx *sizes = iter2 + pdim;
6791             coords = sizes + pdim;
6792              
6793             /* Figure out size vector */
6794             for(ip = __params->sizes, sp = sizes, k=0; k
6795             *(sp++) = *(ip++);
6796             for(; k < pdim; k++)
6797             *(sp++) = __privtrans->pdls[0]->dims[k];
6798              
6799              
6800             /* Loop over all the ranges in the index list */
6801             for(item=0; item<__params->nitems; item++) {
6802              
6803             /* initialize in-range iterator to loop within each range */
6804             for(ip = iter2, k=0; k
6805             *(ip++) = 0;
6806              
6807             do {
6808             PDL_Indx poff = 0;
6809             PDL_Indx coff;
6810             PDL_Indx k2;
6811             char trunc = 0; /* Flag used to skip truncation case */
6812              
6813             /* Collect and boundary-check the current N-D coords */
6814             for(k=0; k < prdim; k++){
6815              
6816             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6817              
6818             /* normal case */
6819             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6820             switch(__params->boundary[k]) {
6821             case 0: /* no boundary breakage allowed */
6822             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6823             break;
6824             case 1: /* truncation */
6825             trunc = 1;
6826             break;
6827             case 2: /* extension -- crop */
6828             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6829             break;
6830             case 3: /* periodic -- mod it */
6831             ck %= __privtrans->pdls[0]->dims[k];
6832             if(ck < 0) /* Fix mod breakage in C */
6833             ck += __privtrans->pdls[0]->dims[k];
6834             break;
6835             case 4: /* mirror -- reflect off the edges */
6836             ck += __privtrans->pdls[0]->dims[k];
6837             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6838             if(ck < 0) /* Fix mod breakage in C */
6839             ck += __privtrans->pdls[0]->dims[k]*2;
6840             ck -= __privtrans->pdls[0]->dims[k];
6841             if(ck < 0) {
6842             ck *= -1;
6843             ck -= 1;
6844             }
6845             break;
6846             default:
6847             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6848             break;
6849             }
6850             }
6851              
6852             coords[k] = ck;
6853              
6854             }
6855              
6856             /* Check extra dimensions -- pick up where k left off... */
6857             for( ; k < rdim ; k++) {
6858             /* Check for indexing off the end of the dimension list */
6859              
6860             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6861              
6862             switch(__params->boundary[k]) {
6863             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
6864             if(ck != 0)
6865             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
6866             break;
6867             case 1: /* truncation - just truncate if the corner is nonzero */
6868             trunc |= (ck != 0);
6869             break;
6870             case 2: /* extension -- ignore the corner (same as 3) */
6871             case 3: /* periodic -- ignore the corner */
6872             case 4: /* mirror -- ignore the corner */
6873             ck = 0;
6874             break;
6875             default:
6876             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
6877             break;
6878             }
6879             }
6880              
6881             /* Find offsets into the child and parent arrays, from the N-D coords */
6882             /* Note we only loop over real source dims (prdim) to accumulate -- */
6883             /* because the offset is trivial and/or we're truncating for virtual */
6884             /* dims caused by permissive ranging. */
6885             coff = __privtrans->pdls[1]->dimincs[0] * item;
6886             for(k2 = __params->itdim, poff = k = 0;
6887             k < prdim;
6888             k++) {
6889             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
6890             if(__params->sizes[k])
6891             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6892             }
6893              
6894             /* Loop the copy over all the source broadcast dims (above rdim). */
6895             do {
6896             PDL_Indx poff1 = poff;
6897             PDL_Indx coff1 = coff;
6898              
6899             /* Accumulate the offset due to source broadcasting */
6900             for(k2 = __params->itdim + __params->ntsize, k = rdim;
6901             k < pdim;
6902             k++) {
6903             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
6904             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
6905             }
6906              
6907             /* Finally -- make the copy
6908             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
6909             * out-of-bounds conditions.
6910             */
6911             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,C,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
6912              
6913             /* Increment the source broadcast iterator */
6914             for( k=__params->rdim;
6915             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
6916             k++)
6917             iter2[k] = 0;
6918             } while(k < pdim); /* end of source-broadcast iteration */
6919              
6920             /* Increment the in-range iterator */
6921             for(k = 0;
6922             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
6923             k++)
6924             iter2[k] = 0;
6925             } while(k < __params->rdim); /* end of main iteration */
6926             } /* end of item do loop */
6927             #line 6928 "lib/PDL/Slices-pp-rangeb.c"
6928             }
6929 0           } break;
6930 0           case PDL_CLD: {
6931 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CLDouble,H)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
6932 0           {
6933             #line 877 "lib/PDL/Slices.pd"
6934             PDL_Indx *ip; /* vector iterator */
6935             PDL_Indx *sp; /* size vector including stdims */
6936             PDL_Indx *coords; /* current coordinates */
6937              
6938             PDL_Indx k; /* index */
6939             PDL_Indx item; /* index broadcast iterator */
6940             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
6941             PDL_Indx rdim = __params->rdim;
6942             PDL_Indx prdim = PDLMIN(rdim,pdim);
6943             PDL_Indx iter2[pdim * 2 + rdim];
6944             PDL_Indx *sizes = iter2 + pdim;
6945             coords = sizes + pdim;
6946              
6947             /* Figure out size vector */
6948             for(ip = __params->sizes, sp = sizes, k=0; k
6949             *(sp++) = *(ip++);
6950             for(; k < pdim; k++)
6951             *(sp++) = __privtrans->pdls[0]->dims[k];
6952              
6953              
6954             /* Loop over all the ranges in the index list */
6955             for(item=0; item<__params->nitems; item++) {
6956              
6957             /* initialize in-range iterator to loop within each range */
6958             for(ip = iter2, k=0; k
6959             *(ip++) = 0;
6960              
6961             do {
6962             PDL_Indx poff = 0;
6963             PDL_Indx coff;
6964             PDL_Indx k2;
6965             char trunc = 0; /* Flag used to skip truncation case */
6966              
6967             /* Collect and boundary-check the current N-D coords */
6968             for(k=0; k < prdim; k++){
6969              
6970             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
6971              
6972             /* normal case */
6973             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
6974             switch(__params->boundary[k]) {
6975             case 0: /* no boundary breakage allowed */
6976             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
6977             break;
6978             case 1: /* truncation */
6979             trunc = 1;
6980             break;
6981             case 2: /* extension -- crop */
6982             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
6983             break;
6984             case 3: /* periodic -- mod it */
6985             ck %= __privtrans->pdls[0]->dims[k];
6986             if(ck < 0) /* Fix mod breakage in C */
6987             ck += __privtrans->pdls[0]->dims[k];
6988             break;
6989             case 4: /* mirror -- reflect off the edges */
6990             ck += __privtrans->pdls[0]->dims[k];
6991             ck %= (__privtrans->pdls[0]->dims[k] * 2);
6992             if(ck < 0) /* Fix mod breakage in C */
6993             ck += __privtrans->pdls[0]->dims[k]*2;
6994             ck -= __privtrans->pdls[0]->dims[k];
6995             if(ck < 0) {
6996             ck *= -1;
6997             ck -= 1;
6998             }
6999             break;
7000             default:
7001             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7002             break;
7003             }
7004             }
7005              
7006             coords[k] = ck;
7007              
7008             }
7009              
7010             /* Check extra dimensions -- pick up where k left off... */
7011             for( ; k < rdim ; k++) {
7012             /* Check for indexing off the end of the dimension list */
7013              
7014             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7015              
7016             switch(__params->boundary[k]) {
7017             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7018             if(ck != 0)
7019             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7020             break;
7021             case 1: /* truncation - just truncate if the corner is nonzero */
7022             trunc |= (ck != 0);
7023             break;
7024             case 2: /* extension -- ignore the corner (same as 3) */
7025             case 3: /* periodic -- ignore the corner */
7026             case 4: /* mirror -- ignore the corner */
7027             ck = 0;
7028             break;
7029             default:
7030             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7031             break;
7032             }
7033             }
7034              
7035             /* Find offsets into the child and parent arrays, from the N-D coords */
7036             /* Note we only loop over real source dims (prdim) to accumulate -- */
7037             /* because the offset is trivial and/or we're truncating for virtual */
7038             /* dims caused by permissive ranging. */
7039             coff = __privtrans->pdls[1]->dimincs[0] * item;
7040             for(k2 = __params->itdim, poff = k = 0;
7041             k < prdim;
7042             k++) {
7043             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7044             if(__params->sizes[k])
7045             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7046             }
7047              
7048             /* Loop the copy over all the source broadcast dims (above rdim). */
7049             do {
7050             PDL_Indx poff1 = poff;
7051             PDL_Indx coff1 = coff;
7052              
7053             /* Accumulate the offset due to source broadcasting */
7054             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7055             k < pdim;
7056             k++) {
7057             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7058             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7059             }
7060              
7061             /* Finally -- make the copy
7062             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7063             * out-of-bounds conditions.
7064             */
7065             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,H,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7066              
7067             /* Increment the source broadcast iterator */
7068             for( k=__params->rdim;
7069             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7070             k++)
7071             iter2[k] = 0;
7072             } while(k < pdim); /* end of source-broadcast iteration */
7073              
7074             /* Increment the in-range iterator */
7075             for(k = 0;
7076             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7077             k++)
7078             iter2[k] = 0;
7079             } while(k < __params->rdim); /* end of main iteration */
7080             } /* end of item do loop */
7081             #line 7082 "lib/PDL/Slices-pp-rangeb.c"
7082             }
7083 0           } break;
7084 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rangeb: unhandled datatype(%d), only handles (ABSULKNPQFDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
7085             }
7086             #undef PDL_BAD_CODE
7087             #undef PDL_IF_BAD
7088             } else { /* ** else do 'good' Code ** */
7089             #define PDL_IF_BAD(t,f) f
7090 16           switch (__privtrans->__datatype) { /* Start generic switch */
7091 0           case PDL_SB: {
7092 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
7093 0           {
7094             #line 877 "lib/PDL/Slices.pd"
7095             PDL_Indx *ip; /* vector iterator */
7096             PDL_Indx *sp; /* size vector including stdims */
7097             PDL_Indx *coords; /* current coordinates */
7098              
7099             PDL_Indx k; /* index */
7100             PDL_Indx item; /* index broadcast iterator */
7101             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7102             PDL_Indx rdim = __params->rdim;
7103             PDL_Indx prdim = PDLMIN(rdim,pdim);
7104             PDL_Indx iter2[pdim * 2 + rdim];
7105             PDL_Indx *sizes = iter2 + pdim;
7106             coords = sizes + pdim;
7107              
7108             /* Figure out size vector */
7109             for(ip = __params->sizes, sp = sizes, k=0; k
7110             *(sp++) = *(ip++);
7111             for(; k < pdim; k++)
7112             *(sp++) = __privtrans->pdls[0]->dims[k];
7113              
7114              
7115             /* Loop over all the ranges in the index list */
7116             for(item=0; item<__params->nitems; item++) {
7117              
7118             /* initialize in-range iterator to loop within each range */
7119             for(ip = iter2, k=0; k
7120             *(ip++) = 0;
7121              
7122             do {
7123             PDL_Indx poff = 0;
7124             PDL_Indx coff;
7125             PDL_Indx k2;
7126             char trunc = 0; /* Flag used to skip truncation case */
7127              
7128             /* Collect and boundary-check the current N-D coords */
7129             for(k=0; k < prdim; k++){
7130              
7131             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7132              
7133             /* normal case */
7134             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7135             switch(__params->boundary[k]) {
7136             case 0: /* no boundary breakage allowed */
7137             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7138             break;
7139             case 1: /* truncation */
7140             trunc = 1;
7141             break;
7142             case 2: /* extension -- crop */
7143             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7144             break;
7145             case 3: /* periodic -- mod it */
7146             ck %= __privtrans->pdls[0]->dims[k];
7147             if(ck < 0) /* Fix mod breakage in C */
7148             ck += __privtrans->pdls[0]->dims[k];
7149             break;
7150             case 4: /* mirror -- reflect off the edges */
7151             ck += __privtrans->pdls[0]->dims[k];
7152             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7153             if(ck < 0) /* Fix mod breakage in C */
7154             ck += __privtrans->pdls[0]->dims[k]*2;
7155             ck -= __privtrans->pdls[0]->dims[k];
7156             if(ck < 0) {
7157             ck *= -1;
7158             ck -= 1;
7159             }
7160             break;
7161             default:
7162             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7163             break;
7164             }
7165             }
7166              
7167             coords[k] = ck;
7168              
7169             }
7170              
7171             /* Check extra dimensions -- pick up where k left off... */
7172             for( ; k < rdim ; k++) {
7173             /* Check for indexing off the end of the dimension list */
7174              
7175             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7176              
7177             switch(__params->boundary[k]) {
7178             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7179             if(ck != 0)
7180             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7181             break;
7182             case 1: /* truncation - just truncate if the corner is nonzero */
7183             trunc |= (ck != 0);
7184             break;
7185             case 2: /* extension -- ignore the corner (same as 3) */
7186             case 3: /* periodic -- ignore the corner */
7187             case 4: /* mirror -- ignore the corner */
7188             ck = 0;
7189             break;
7190             default:
7191             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7192             break;
7193             }
7194             }
7195              
7196             /* Find offsets into the child and parent arrays, from the N-D coords */
7197             /* Note we only loop over real source dims (prdim) to accumulate -- */
7198             /* because the offset is trivial and/or we're truncating for virtual */
7199             /* dims caused by permissive ranging. */
7200             coff = __privtrans->pdls[1]->dimincs[0] * item;
7201             for(k2 = __params->itdim, poff = k = 0;
7202             k < prdim;
7203             k++) {
7204             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7205             if(__params->sizes[k])
7206             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7207             }
7208              
7209             /* Loop the copy over all the source broadcast dims (above rdim). */
7210             do {
7211             PDL_Indx poff1 = poff;
7212             PDL_Indx coff1 = coff;
7213              
7214             /* Accumulate the offset due to source broadcasting */
7215             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7216             k < pdim;
7217             k++) {
7218             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7219             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7220             }
7221              
7222             /* Finally -- make the copy
7223             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7224             * out-of-bounds conditions.
7225             */
7226             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,A,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7227              
7228             /* Increment the source broadcast iterator */
7229             for( k=__params->rdim;
7230             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7231             k++)
7232             iter2[k] = 0;
7233             } while(k < pdim); /* end of source-broadcast iteration */
7234              
7235             /* Increment the in-range iterator */
7236             for(k = 0;
7237             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7238             k++)
7239             iter2[k] = 0;
7240             } while(k < __params->rdim); /* end of main iteration */
7241             } /* end of item do loop */
7242             #line 7243 "lib/PDL/Slices-pp-rangeb.c"
7243             }
7244 0           } break;
7245 0           case PDL_B: {
7246 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
7247 0           {
7248             #line 877 "lib/PDL/Slices.pd"
7249             PDL_Indx *ip; /* vector iterator */
7250             PDL_Indx *sp; /* size vector including stdims */
7251             PDL_Indx *coords; /* current coordinates */
7252              
7253             PDL_Indx k; /* index */
7254             PDL_Indx item; /* index broadcast iterator */
7255             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7256             PDL_Indx rdim = __params->rdim;
7257             PDL_Indx prdim = PDLMIN(rdim,pdim);
7258             PDL_Indx iter2[pdim * 2 + rdim];
7259             PDL_Indx *sizes = iter2 + pdim;
7260             coords = sizes + pdim;
7261              
7262             /* Figure out size vector */
7263             for(ip = __params->sizes, sp = sizes, k=0; k
7264             *(sp++) = *(ip++);
7265             for(; k < pdim; k++)
7266             *(sp++) = __privtrans->pdls[0]->dims[k];
7267              
7268              
7269             /* Loop over all the ranges in the index list */
7270             for(item=0; item<__params->nitems; item++) {
7271              
7272             /* initialize in-range iterator to loop within each range */
7273             for(ip = iter2, k=0; k
7274             *(ip++) = 0;
7275              
7276             do {
7277             PDL_Indx poff = 0;
7278             PDL_Indx coff;
7279             PDL_Indx k2;
7280             char trunc = 0; /* Flag used to skip truncation case */
7281              
7282             /* Collect and boundary-check the current N-D coords */
7283             for(k=0; k < prdim; k++){
7284              
7285             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7286              
7287             /* normal case */
7288             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7289             switch(__params->boundary[k]) {
7290             case 0: /* no boundary breakage allowed */
7291             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7292             break;
7293             case 1: /* truncation */
7294             trunc = 1;
7295             break;
7296             case 2: /* extension -- crop */
7297             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7298             break;
7299             case 3: /* periodic -- mod it */
7300             ck %= __privtrans->pdls[0]->dims[k];
7301             if(ck < 0) /* Fix mod breakage in C */
7302             ck += __privtrans->pdls[0]->dims[k];
7303             break;
7304             case 4: /* mirror -- reflect off the edges */
7305             ck += __privtrans->pdls[0]->dims[k];
7306             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7307             if(ck < 0) /* Fix mod breakage in C */
7308             ck += __privtrans->pdls[0]->dims[k]*2;
7309             ck -= __privtrans->pdls[0]->dims[k];
7310             if(ck < 0) {
7311             ck *= -1;
7312             ck -= 1;
7313             }
7314             break;
7315             default:
7316             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7317             break;
7318             }
7319             }
7320              
7321             coords[k] = ck;
7322              
7323             }
7324              
7325             /* Check extra dimensions -- pick up where k left off... */
7326             for( ; k < rdim ; k++) {
7327             /* Check for indexing off the end of the dimension list */
7328              
7329             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7330              
7331             switch(__params->boundary[k]) {
7332             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7333             if(ck != 0)
7334             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7335             break;
7336             case 1: /* truncation - just truncate if the corner is nonzero */
7337             trunc |= (ck != 0);
7338             break;
7339             case 2: /* extension -- ignore the corner (same as 3) */
7340             case 3: /* periodic -- ignore the corner */
7341             case 4: /* mirror -- ignore the corner */
7342             ck = 0;
7343             break;
7344             default:
7345             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7346             break;
7347             }
7348             }
7349              
7350             /* Find offsets into the child and parent arrays, from the N-D coords */
7351             /* Note we only loop over real source dims (prdim) to accumulate -- */
7352             /* because the offset is trivial and/or we're truncating for virtual */
7353             /* dims caused by permissive ranging. */
7354             coff = __privtrans->pdls[1]->dimincs[0] * item;
7355             for(k2 = __params->itdim, poff = k = 0;
7356             k < prdim;
7357             k++) {
7358             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7359             if(__params->sizes[k])
7360             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7361             }
7362              
7363             /* Loop the copy over all the source broadcast dims (above rdim). */
7364             do {
7365             PDL_Indx poff1 = poff;
7366             PDL_Indx coff1 = coff;
7367              
7368             /* Accumulate the offset due to source broadcasting */
7369             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7370             k < pdim;
7371             k++) {
7372             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7373             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7374             }
7375              
7376             /* Finally -- make the copy
7377             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7378             * out-of-bounds conditions.
7379             */
7380             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,B,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7381              
7382             /* Increment the source broadcast iterator */
7383             for( k=__params->rdim;
7384             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7385             k++)
7386             iter2[k] = 0;
7387             } while(k < pdim); /* end of source-broadcast iteration */
7388              
7389             /* Increment the in-range iterator */
7390             for(k = 0;
7391             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7392             k++)
7393             iter2[k] = 0;
7394             } while(k < __params->rdim); /* end of main iteration */
7395             } /* end of item do loop */
7396             #line 7397 "lib/PDL/Slices-pp-rangeb.c"
7397             }
7398 0           } break;
7399 0           case PDL_S: {
7400 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
7401 0           {
7402             #line 877 "lib/PDL/Slices.pd"
7403             PDL_Indx *ip; /* vector iterator */
7404             PDL_Indx *sp; /* size vector including stdims */
7405             PDL_Indx *coords; /* current coordinates */
7406              
7407             PDL_Indx k; /* index */
7408             PDL_Indx item; /* index broadcast iterator */
7409             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7410             PDL_Indx rdim = __params->rdim;
7411             PDL_Indx prdim = PDLMIN(rdim,pdim);
7412             PDL_Indx iter2[pdim * 2 + rdim];
7413             PDL_Indx *sizes = iter2 + pdim;
7414             coords = sizes + pdim;
7415              
7416             /* Figure out size vector */
7417             for(ip = __params->sizes, sp = sizes, k=0; k
7418             *(sp++) = *(ip++);
7419             for(; k < pdim; k++)
7420             *(sp++) = __privtrans->pdls[0]->dims[k];
7421              
7422              
7423             /* Loop over all the ranges in the index list */
7424             for(item=0; item<__params->nitems; item++) {
7425              
7426             /* initialize in-range iterator to loop within each range */
7427             for(ip = iter2, k=0; k
7428             *(ip++) = 0;
7429              
7430             do {
7431             PDL_Indx poff = 0;
7432             PDL_Indx coff;
7433             PDL_Indx k2;
7434             char trunc = 0; /* Flag used to skip truncation case */
7435              
7436             /* Collect and boundary-check the current N-D coords */
7437             for(k=0; k < prdim; k++){
7438              
7439             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7440              
7441             /* normal case */
7442             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7443             switch(__params->boundary[k]) {
7444             case 0: /* no boundary breakage allowed */
7445             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7446             break;
7447             case 1: /* truncation */
7448             trunc = 1;
7449             break;
7450             case 2: /* extension -- crop */
7451             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7452             break;
7453             case 3: /* periodic -- mod it */
7454             ck %= __privtrans->pdls[0]->dims[k];
7455             if(ck < 0) /* Fix mod breakage in C */
7456             ck += __privtrans->pdls[0]->dims[k];
7457             break;
7458             case 4: /* mirror -- reflect off the edges */
7459             ck += __privtrans->pdls[0]->dims[k];
7460             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7461             if(ck < 0) /* Fix mod breakage in C */
7462             ck += __privtrans->pdls[0]->dims[k]*2;
7463             ck -= __privtrans->pdls[0]->dims[k];
7464             if(ck < 0) {
7465             ck *= -1;
7466             ck -= 1;
7467             }
7468             break;
7469             default:
7470             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7471             break;
7472             }
7473             }
7474              
7475             coords[k] = ck;
7476              
7477             }
7478              
7479             /* Check extra dimensions -- pick up where k left off... */
7480             for( ; k < rdim ; k++) {
7481             /* Check for indexing off the end of the dimension list */
7482              
7483             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7484              
7485             switch(__params->boundary[k]) {
7486             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7487             if(ck != 0)
7488             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7489             break;
7490             case 1: /* truncation - just truncate if the corner is nonzero */
7491             trunc |= (ck != 0);
7492             break;
7493             case 2: /* extension -- ignore the corner (same as 3) */
7494             case 3: /* periodic -- ignore the corner */
7495             case 4: /* mirror -- ignore the corner */
7496             ck = 0;
7497             break;
7498             default:
7499             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7500             break;
7501             }
7502             }
7503              
7504             /* Find offsets into the child and parent arrays, from the N-D coords */
7505             /* Note we only loop over real source dims (prdim) to accumulate -- */
7506             /* because the offset is trivial and/or we're truncating for virtual */
7507             /* dims caused by permissive ranging. */
7508             coff = __privtrans->pdls[1]->dimincs[0] * item;
7509             for(k2 = __params->itdim, poff = k = 0;
7510             k < prdim;
7511             k++) {
7512             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7513             if(__params->sizes[k])
7514             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7515             }
7516              
7517             /* Loop the copy over all the source broadcast dims (above rdim). */
7518             do {
7519             PDL_Indx poff1 = poff;
7520             PDL_Indx coff1 = coff;
7521              
7522             /* Accumulate the offset due to source broadcasting */
7523             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7524             k < pdim;
7525             k++) {
7526             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7527             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7528             }
7529              
7530             /* Finally -- make the copy
7531             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7532             * out-of-bounds conditions.
7533             */
7534             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,S,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7535              
7536             /* Increment the source broadcast iterator */
7537             for( k=__params->rdim;
7538             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7539             k++)
7540             iter2[k] = 0;
7541             } while(k < pdim); /* end of source-broadcast iteration */
7542              
7543             /* Increment the in-range iterator */
7544             for(k = 0;
7545             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7546             k++)
7547             iter2[k] = 0;
7548             } while(k < __params->rdim); /* end of main iteration */
7549             } /* end of item do loop */
7550             #line 7551 "lib/PDL/Slices-pp-rangeb.c"
7551             }
7552 0           } break;
7553 0           case PDL_US: {
7554 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
7555 0           {
7556             #line 877 "lib/PDL/Slices.pd"
7557             PDL_Indx *ip; /* vector iterator */
7558             PDL_Indx *sp; /* size vector including stdims */
7559             PDL_Indx *coords; /* current coordinates */
7560              
7561             PDL_Indx k; /* index */
7562             PDL_Indx item; /* index broadcast iterator */
7563             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7564             PDL_Indx rdim = __params->rdim;
7565             PDL_Indx prdim = PDLMIN(rdim,pdim);
7566             PDL_Indx iter2[pdim * 2 + rdim];
7567             PDL_Indx *sizes = iter2 + pdim;
7568             coords = sizes + pdim;
7569              
7570             /* Figure out size vector */
7571             for(ip = __params->sizes, sp = sizes, k=0; k
7572             *(sp++) = *(ip++);
7573             for(; k < pdim; k++)
7574             *(sp++) = __privtrans->pdls[0]->dims[k];
7575              
7576              
7577             /* Loop over all the ranges in the index list */
7578             for(item=0; item<__params->nitems; item++) {
7579              
7580             /* initialize in-range iterator to loop within each range */
7581             for(ip = iter2, k=0; k
7582             *(ip++) = 0;
7583              
7584             do {
7585             PDL_Indx poff = 0;
7586             PDL_Indx coff;
7587             PDL_Indx k2;
7588             char trunc = 0; /* Flag used to skip truncation case */
7589              
7590             /* Collect and boundary-check the current N-D coords */
7591             for(k=0; k < prdim; k++){
7592              
7593             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7594              
7595             /* normal case */
7596             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7597             switch(__params->boundary[k]) {
7598             case 0: /* no boundary breakage allowed */
7599             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7600             break;
7601             case 1: /* truncation */
7602             trunc = 1;
7603             break;
7604             case 2: /* extension -- crop */
7605             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7606             break;
7607             case 3: /* periodic -- mod it */
7608             ck %= __privtrans->pdls[0]->dims[k];
7609             if(ck < 0) /* Fix mod breakage in C */
7610             ck += __privtrans->pdls[0]->dims[k];
7611             break;
7612             case 4: /* mirror -- reflect off the edges */
7613             ck += __privtrans->pdls[0]->dims[k];
7614             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7615             if(ck < 0) /* Fix mod breakage in C */
7616             ck += __privtrans->pdls[0]->dims[k]*2;
7617             ck -= __privtrans->pdls[0]->dims[k];
7618             if(ck < 0) {
7619             ck *= -1;
7620             ck -= 1;
7621             }
7622             break;
7623             default:
7624             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7625             break;
7626             }
7627             }
7628              
7629             coords[k] = ck;
7630              
7631             }
7632              
7633             /* Check extra dimensions -- pick up where k left off... */
7634             for( ; k < rdim ; k++) {
7635             /* Check for indexing off the end of the dimension list */
7636              
7637             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7638              
7639             switch(__params->boundary[k]) {
7640             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7641             if(ck != 0)
7642             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7643             break;
7644             case 1: /* truncation - just truncate if the corner is nonzero */
7645             trunc |= (ck != 0);
7646             break;
7647             case 2: /* extension -- ignore the corner (same as 3) */
7648             case 3: /* periodic -- ignore the corner */
7649             case 4: /* mirror -- ignore the corner */
7650             ck = 0;
7651             break;
7652             default:
7653             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7654             break;
7655             }
7656             }
7657              
7658             /* Find offsets into the child and parent arrays, from the N-D coords */
7659             /* Note we only loop over real source dims (prdim) to accumulate -- */
7660             /* because the offset is trivial and/or we're truncating for virtual */
7661             /* dims caused by permissive ranging. */
7662             coff = __privtrans->pdls[1]->dimincs[0] * item;
7663             for(k2 = __params->itdim, poff = k = 0;
7664             k < prdim;
7665             k++) {
7666             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7667             if(__params->sizes[k])
7668             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7669             }
7670              
7671             /* Loop the copy over all the source broadcast dims (above rdim). */
7672             do {
7673             PDL_Indx poff1 = poff;
7674             PDL_Indx coff1 = coff;
7675              
7676             /* Accumulate the offset due to source broadcasting */
7677             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7678             k < pdim;
7679             k++) {
7680             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7681             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7682             }
7683              
7684             /* Finally -- make the copy
7685             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7686             * out-of-bounds conditions.
7687             */
7688             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,U,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7689              
7690             /* Increment the source broadcast iterator */
7691             for( k=__params->rdim;
7692             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7693             k++)
7694             iter2[k] = 0;
7695             } while(k < pdim); /* end of source-broadcast iteration */
7696              
7697             /* Increment the in-range iterator */
7698             for(k = 0;
7699             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7700             k++)
7701             iter2[k] = 0;
7702             } while(k < __params->rdim); /* end of main iteration */
7703             } /* end of item do loop */
7704             #line 7705 "lib/PDL/Slices-pp-rangeb.c"
7705             }
7706 0           } break;
7707 7           case PDL_L: {
7708 7 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Long,L)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
7709 7           {
7710             #line 877 "lib/PDL/Slices.pd"
7711             PDL_Indx *ip; /* vector iterator */
7712             PDL_Indx *sp; /* size vector including stdims */
7713             PDL_Indx *coords; /* current coordinates */
7714              
7715             PDL_Indx k; /* index */
7716             PDL_Indx item; /* index broadcast iterator */
7717             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7718             PDL_Indx rdim = __params->rdim;
7719             PDL_Indx prdim = PDLMIN(rdim,pdim);
7720             PDL_Indx iter2[pdim * 2 + rdim];
7721             PDL_Indx *sizes = iter2 + pdim;
7722             coords = sizes + pdim;
7723              
7724             /* Figure out size vector */
7725             for(ip = __params->sizes, sp = sizes, k=0; k
7726             *(sp++) = *(ip++);
7727             for(; k < pdim; k++)
7728             *(sp++) = __privtrans->pdls[0]->dims[k];
7729              
7730              
7731             /* Loop over all the ranges in the index list */
7732             for(item=0; item<__params->nitems; item++) {
7733              
7734             /* initialize in-range iterator to loop within each range */
7735             for(ip = iter2, k=0; k
7736             *(ip++) = 0;
7737              
7738             do {
7739             PDL_Indx poff = 0;
7740             PDL_Indx coff;
7741             PDL_Indx k2;
7742             char trunc = 0; /* Flag used to skip truncation case */
7743              
7744             /* Collect and boundary-check the current N-D coords */
7745             for(k=0; k < prdim; k++){
7746              
7747             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7748              
7749             /* normal case */
7750             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7751             switch(__params->boundary[k]) {
7752             case 0: /* no boundary breakage allowed */
7753             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7754             break;
7755             case 1: /* truncation */
7756             trunc = 1;
7757             break;
7758             case 2: /* extension -- crop */
7759             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7760             break;
7761             case 3: /* periodic -- mod it */
7762             ck %= __privtrans->pdls[0]->dims[k];
7763             if(ck < 0) /* Fix mod breakage in C */
7764             ck += __privtrans->pdls[0]->dims[k];
7765             break;
7766             case 4: /* mirror -- reflect off the edges */
7767             ck += __privtrans->pdls[0]->dims[k];
7768             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7769             if(ck < 0) /* Fix mod breakage in C */
7770             ck += __privtrans->pdls[0]->dims[k]*2;
7771             ck -= __privtrans->pdls[0]->dims[k];
7772             if(ck < 0) {
7773             ck *= -1;
7774             ck -= 1;
7775             }
7776             break;
7777             default:
7778             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7779             break;
7780             }
7781             }
7782              
7783             coords[k] = ck;
7784              
7785             }
7786              
7787             /* Check extra dimensions -- pick up where k left off... */
7788             for( ; k < rdim ; k++) {
7789             /* Check for indexing off the end of the dimension list */
7790              
7791             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7792              
7793             switch(__params->boundary[k]) {
7794             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7795             if(ck != 0)
7796             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7797             break;
7798             case 1: /* truncation - just truncate if the corner is nonzero */
7799             trunc |= (ck != 0);
7800             break;
7801             case 2: /* extension -- ignore the corner (same as 3) */
7802             case 3: /* periodic -- ignore the corner */
7803             case 4: /* mirror -- ignore the corner */
7804             ck = 0;
7805             break;
7806             default:
7807             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7808             break;
7809             }
7810             }
7811              
7812             /* Find offsets into the child and parent arrays, from the N-D coords */
7813             /* Note we only loop over real source dims (prdim) to accumulate -- */
7814             /* because the offset is trivial and/or we're truncating for virtual */
7815             /* dims caused by permissive ranging. */
7816             coff = __privtrans->pdls[1]->dimincs[0] * item;
7817             for(k2 = __params->itdim, poff = k = 0;
7818             k < prdim;
7819             k++) {
7820             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7821             if(__params->sizes[k])
7822             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7823             }
7824              
7825             /* Loop the copy over all the source broadcast dims (above rdim). */
7826             do {
7827             PDL_Indx poff1 = poff;
7828             PDL_Indx coff1 = coff;
7829              
7830             /* Accumulate the offset due to source broadcasting */
7831             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7832             k < pdim;
7833             k++) {
7834             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7835             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7836             }
7837              
7838             /* Finally -- make the copy
7839             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7840             * out-of-bounds conditions.
7841             */
7842             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,L,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7843              
7844             /* Increment the source broadcast iterator */
7845             for( k=__params->rdim;
7846             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
7847             k++)
7848             iter2[k] = 0;
7849             } while(k < pdim); /* end of source-broadcast iteration */
7850              
7851             /* Increment the in-range iterator */
7852             for(k = 0;
7853             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
7854             k++)
7855             iter2[k] = 0;
7856             } while(k < __params->rdim); /* end of main iteration */
7857             } /* end of item do loop */
7858             #line 7859 "lib/PDL/Slices-pp-rangeb.c"
7859             }
7860 7           } break;
7861 0           case PDL_UL: {
7862 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
7863 0           {
7864             #line 877 "lib/PDL/Slices.pd"
7865             PDL_Indx *ip; /* vector iterator */
7866             PDL_Indx *sp; /* size vector including stdims */
7867             PDL_Indx *coords; /* current coordinates */
7868              
7869             PDL_Indx k; /* index */
7870             PDL_Indx item; /* index broadcast iterator */
7871             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
7872             PDL_Indx rdim = __params->rdim;
7873             PDL_Indx prdim = PDLMIN(rdim,pdim);
7874             PDL_Indx iter2[pdim * 2 + rdim];
7875             PDL_Indx *sizes = iter2 + pdim;
7876             coords = sizes + pdim;
7877              
7878             /* Figure out size vector */
7879             for(ip = __params->sizes, sp = sizes, k=0; k
7880             *(sp++) = *(ip++);
7881             for(; k < pdim; k++)
7882             *(sp++) = __privtrans->pdls[0]->dims[k];
7883              
7884              
7885             /* Loop over all the ranges in the index list */
7886             for(item=0; item<__params->nitems; item++) {
7887              
7888             /* initialize in-range iterator to loop within each range */
7889             for(ip = iter2, k=0; k
7890             *(ip++) = 0;
7891              
7892             do {
7893             PDL_Indx poff = 0;
7894             PDL_Indx coff;
7895             PDL_Indx k2;
7896             char trunc = 0; /* Flag used to skip truncation case */
7897              
7898             /* Collect and boundary-check the current N-D coords */
7899             for(k=0; k < prdim; k++){
7900              
7901             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7902              
7903             /* normal case */
7904             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
7905             switch(__params->boundary[k]) {
7906             case 0: /* no boundary breakage allowed */
7907             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
7908             break;
7909             case 1: /* truncation */
7910             trunc = 1;
7911             break;
7912             case 2: /* extension -- crop */
7913             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
7914             break;
7915             case 3: /* periodic -- mod it */
7916             ck %= __privtrans->pdls[0]->dims[k];
7917             if(ck < 0) /* Fix mod breakage in C */
7918             ck += __privtrans->pdls[0]->dims[k];
7919             break;
7920             case 4: /* mirror -- reflect off the edges */
7921             ck += __privtrans->pdls[0]->dims[k];
7922             ck %= (__privtrans->pdls[0]->dims[k] * 2);
7923             if(ck < 0) /* Fix mod breakage in C */
7924             ck += __privtrans->pdls[0]->dims[k]*2;
7925             ck -= __privtrans->pdls[0]->dims[k];
7926             if(ck < 0) {
7927             ck *= -1;
7928             ck -= 1;
7929             }
7930             break;
7931             default:
7932             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7933             break;
7934             }
7935             }
7936              
7937             coords[k] = ck;
7938              
7939             }
7940              
7941             /* Check extra dimensions -- pick up where k left off... */
7942             for( ; k < rdim ; k++) {
7943             /* Check for indexing off the end of the dimension list */
7944              
7945             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
7946              
7947             switch(__params->boundary[k]) {
7948             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
7949             if(ck != 0)
7950             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
7951             break;
7952             case 1: /* truncation - just truncate if the corner is nonzero */
7953             trunc |= (ck != 0);
7954             break;
7955             case 2: /* extension -- ignore the corner (same as 3) */
7956             case 3: /* periodic -- ignore the corner */
7957             case 4: /* mirror -- ignore the corner */
7958             ck = 0;
7959             break;
7960             default:
7961             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
7962             break;
7963             }
7964             }
7965              
7966             /* Find offsets into the child and parent arrays, from the N-D coords */
7967             /* Note we only loop over real source dims (prdim) to accumulate -- */
7968             /* because the offset is trivial and/or we're truncating for virtual */
7969             /* dims caused by permissive ranging. */
7970             coff = __privtrans->pdls[1]->dimincs[0] * item;
7971             for(k2 = __params->itdim, poff = k = 0;
7972             k < prdim;
7973             k++) {
7974             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
7975             if(__params->sizes[k])
7976             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7977             }
7978              
7979             /* Loop the copy over all the source broadcast dims (above rdim). */
7980             do {
7981             PDL_Indx poff1 = poff;
7982             PDL_Indx coff1 = coff;
7983              
7984             /* Accumulate the offset due to source broadcasting */
7985             for(k2 = __params->itdim + __params->ntsize, k = rdim;
7986             k < pdim;
7987             k++) {
7988             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
7989             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
7990             }
7991              
7992             /* Finally -- make the copy
7993             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
7994             * out-of-bounds conditions.
7995             */
7996             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,K,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
7997              
7998             /* Increment the source broadcast iterator */
7999             for( k=__params->rdim;
8000             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8001             k++)
8002             iter2[k] = 0;
8003             } while(k < pdim); /* end of source-broadcast iteration */
8004              
8005             /* Increment the in-range iterator */
8006             for(k = 0;
8007             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8008             k++)
8009             iter2[k] = 0;
8010             } while(k < __params->rdim); /* end of main iteration */
8011             } /* end of item do loop */
8012             #line 8013 "lib/PDL/Slices-pp-rangeb.c"
8013             }
8014 0           } break;
8015 0           case PDL_IND: {
8016 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8017 0           {
8018             #line 877 "lib/PDL/Slices.pd"
8019             PDL_Indx *ip; /* vector iterator */
8020             PDL_Indx *sp; /* size vector including stdims */
8021             PDL_Indx *coords; /* current coordinates */
8022              
8023             PDL_Indx k; /* index */
8024             PDL_Indx item; /* index broadcast iterator */
8025             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8026             PDL_Indx rdim = __params->rdim;
8027             PDL_Indx prdim = PDLMIN(rdim,pdim);
8028             PDL_Indx iter2[pdim * 2 + rdim];
8029             PDL_Indx *sizes = iter2 + pdim;
8030             coords = sizes + pdim;
8031              
8032             /* Figure out size vector */
8033             for(ip = __params->sizes, sp = sizes, k=0; k
8034             *(sp++) = *(ip++);
8035             for(; k < pdim; k++)
8036             *(sp++) = __privtrans->pdls[0]->dims[k];
8037              
8038              
8039             /* Loop over all the ranges in the index list */
8040             for(item=0; item<__params->nitems; item++) {
8041              
8042             /* initialize in-range iterator to loop within each range */
8043             for(ip = iter2, k=0; k
8044             *(ip++) = 0;
8045              
8046             do {
8047             PDL_Indx poff = 0;
8048             PDL_Indx coff;
8049             PDL_Indx k2;
8050             char trunc = 0; /* Flag used to skip truncation case */
8051              
8052             /* Collect and boundary-check the current N-D coords */
8053             for(k=0; k < prdim; k++){
8054              
8055             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8056              
8057             /* normal case */
8058             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8059             switch(__params->boundary[k]) {
8060             case 0: /* no boundary breakage allowed */
8061             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8062             break;
8063             case 1: /* truncation */
8064             trunc = 1;
8065             break;
8066             case 2: /* extension -- crop */
8067             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8068             break;
8069             case 3: /* periodic -- mod it */
8070             ck %= __privtrans->pdls[0]->dims[k];
8071             if(ck < 0) /* Fix mod breakage in C */
8072             ck += __privtrans->pdls[0]->dims[k];
8073             break;
8074             case 4: /* mirror -- reflect off the edges */
8075             ck += __privtrans->pdls[0]->dims[k];
8076             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8077             if(ck < 0) /* Fix mod breakage in C */
8078             ck += __privtrans->pdls[0]->dims[k]*2;
8079             ck -= __privtrans->pdls[0]->dims[k];
8080             if(ck < 0) {
8081             ck *= -1;
8082             ck -= 1;
8083             }
8084             break;
8085             default:
8086             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8087             break;
8088             }
8089             }
8090              
8091             coords[k] = ck;
8092              
8093             }
8094              
8095             /* Check extra dimensions -- pick up where k left off... */
8096             for( ; k < rdim ; k++) {
8097             /* Check for indexing off the end of the dimension list */
8098              
8099             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8100              
8101             switch(__params->boundary[k]) {
8102             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8103             if(ck != 0)
8104             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8105             break;
8106             case 1: /* truncation - just truncate if the corner is nonzero */
8107             trunc |= (ck != 0);
8108             break;
8109             case 2: /* extension -- ignore the corner (same as 3) */
8110             case 3: /* periodic -- ignore the corner */
8111             case 4: /* mirror -- ignore the corner */
8112             ck = 0;
8113             break;
8114             default:
8115             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8116             break;
8117             }
8118             }
8119              
8120             /* Find offsets into the child and parent arrays, from the N-D coords */
8121             /* Note we only loop over real source dims (prdim) to accumulate -- */
8122             /* because the offset is trivial and/or we're truncating for virtual */
8123             /* dims caused by permissive ranging. */
8124             coff = __privtrans->pdls[1]->dimincs[0] * item;
8125             for(k2 = __params->itdim, poff = k = 0;
8126             k < prdim;
8127             k++) {
8128             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8129             if(__params->sizes[k])
8130             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8131             }
8132              
8133             /* Loop the copy over all the source broadcast dims (above rdim). */
8134             do {
8135             PDL_Indx poff1 = poff;
8136             PDL_Indx coff1 = coff;
8137              
8138             /* Accumulate the offset due to source broadcasting */
8139             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8140             k < pdim;
8141             k++) {
8142             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8143             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8144             }
8145              
8146             /* Finally -- make the copy
8147             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8148             * out-of-bounds conditions.
8149             */
8150             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,N,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8151              
8152             /* Increment the source broadcast iterator */
8153             for( k=__params->rdim;
8154             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8155             k++)
8156             iter2[k] = 0;
8157             } while(k < pdim); /* end of source-broadcast iteration */
8158              
8159             /* Increment the in-range iterator */
8160             for(k = 0;
8161             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8162             k++)
8163             iter2[k] = 0;
8164             } while(k < __params->rdim); /* end of main iteration */
8165             } /* end of item do loop */
8166             #line 8167 "lib/PDL/Slices-pp-rangeb.c"
8167             }
8168 0           } break;
8169 0           case PDL_ULL: {
8170 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8171 0           {
8172             #line 877 "lib/PDL/Slices.pd"
8173             PDL_Indx *ip; /* vector iterator */
8174             PDL_Indx *sp; /* size vector including stdims */
8175             PDL_Indx *coords; /* current coordinates */
8176              
8177             PDL_Indx k; /* index */
8178             PDL_Indx item; /* index broadcast iterator */
8179             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8180             PDL_Indx rdim = __params->rdim;
8181             PDL_Indx prdim = PDLMIN(rdim,pdim);
8182             PDL_Indx iter2[pdim * 2 + rdim];
8183             PDL_Indx *sizes = iter2 + pdim;
8184             coords = sizes + pdim;
8185              
8186             /* Figure out size vector */
8187             for(ip = __params->sizes, sp = sizes, k=0; k
8188             *(sp++) = *(ip++);
8189             for(; k < pdim; k++)
8190             *(sp++) = __privtrans->pdls[0]->dims[k];
8191              
8192              
8193             /* Loop over all the ranges in the index list */
8194             for(item=0; item<__params->nitems; item++) {
8195              
8196             /* initialize in-range iterator to loop within each range */
8197             for(ip = iter2, k=0; k
8198             *(ip++) = 0;
8199              
8200             do {
8201             PDL_Indx poff = 0;
8202             PDL_Indx coff;
8203             PDL_Indx k2;
8204             char trunc = 0; /* Flag used to skip truncation case */
8205              
8206             /* Collect and boundary-check the current N-D coords */
8207             for(k=0; k < prdim; k++){
8208              
8209             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8210              
8211             /* normal case */
8212             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8213             switch(__params->boundary[k]) {
8214             case 0: /* no boundary breakage allowed */
8215             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8216             break;
8217             case 1: /* truncation */
8218             trunc = 1;
8219             break;
8220             case 2: /* extension -- crop */
8221             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8222             break;
8223             case 3: /* periodic -- mod it */
8224             ck %= __privtrans->pdls[0]->dims[k];
8225             if(ck < 0) /* Fix mod breakage in C */
8226             ck += __privtrans->pdls[0]->dims[k];
8227             break;
8228             case 4: /* mirror -- reflect off the edges */
8229             ck += __privtrans->pdls[0]->dims[k];
8230             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8231             if(ck < 0) /* Fix mod breakage in C */
8232             ck += __privtrans->pdls[0]->dims[k]*2;
8233             ck -= __privtrans->pdls[0]->dims[k];
8234             if(ck < 0) {
8235             ck *= -1;
8236             ck -= 1;
8237             }
8238             break;
8239             default:
8240             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8241             break;
8242             }
8243             }
8244              
8245             coords[k] = ck;
8246              
8247             }
8248              
8249             /* Check extra dimensions -- pick up where k left off... */
8250             for( ; k < rdim ; k++) {
8251             /* Check for indexing off the end of the dimension list */
8252              
8253             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8254              
8255             switch(__params->boundary[k]) {
8256             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8257             if(ck != 0)
8258             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8259             break;
8260             case 1: /* truncation - just truncate if the corner is nonzero */
8261             trunc |= (ck != 0);
8262             break;
8263             case 2: /* extension -- ignore the corner (same as 3) */
8264             case 3: /* periodic -- ignore the corner */
8265             case 4: /* mirror -- ignore the corner */
8266             ck = 0;
8267             break;
8268             default:
8269             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8270             break;
8271             }
8272             }
8273              
8274             /* Find offsets into the child and parent arrays, from the N-D coords */
8275             /* Note we only loop over real source dims (prdim) to accumulate -- */
8276             /* because the offset is trivial and/or we're truncating for virtual */
8277             /* dims caused by permissive ranging. */
8278             coff = __privtrans->pdls[1]->dimincs[0] * item;
8279             for(k2 = __params->itdim, poff = k = 0;
8280             k < prdim;
8281             k++) {
8282             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8283             if(__params->sizes[k])
8284             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8285             }
8286              
8287             /* Loop the copy over all the source broadcast dims (above rdim). */
8288             do {
8289             PDL_Indx poff1 = poff;
8290             PDL_Indx coff1 = coff;
8291              
8292             /* Accumulate the offset due to source broadcasting */
8293             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8294             k < pdim;
8295             k++) {
8296             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8297             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8298             }
8299              
8300             /* Finally -- make the copy
8301             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8302             * out-of-bounds conditions.
8303             */
8304             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,P,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8305              
8306             /* Increment the source broadcast iterator */
8307             for( k=__params->rdim;
8308             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8309             k++)
8310             iter2[k] = 0;
8311             } while(k < pdim); /* end of source-broadcast iteration */
8312              
8313             /* Increment the in-range iterator */
8314             for(k = 0;
8315             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8316             k++)
8317             iter2[k] = 0;
8318             } while(k < __params->rdim); /* end of main iteration */
8319             } /* end of item do loop */
8320             #line 8321 "lib/PDL/Slices-pp-rangeb.c"
8321             }
8322 0           } break;
8323 0           case PDL_LL: {
8324 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8325 0           {
8326             #line 877 "lib/PDL/Slices.pd"
8327             PDL_Indx *ip; /* vector iterator */
8328             PDL_Indx *sp; /* size vector including stdims */
8329             PDL_Indx *coords; /* current coordinates */
8330              
8331             PDL_Indx k; /* index */
8332             PDL_Indx item; /* index broadcast iterator */
8333             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8334             PDL_Indx rdim = __params->rdim;
8335             PDL_Indx prdim = PDLMIN(rdim,pdim);
8336             PDL_Indx iter2[pdim * 2 + rdim];
8337             PDL_Indx *sizes = iter2 + pdim;
8338             coords = sizes + pdim;
8339              
8340             /* Figure out size vector */
8341             for(ip = __params->sizes, sp = sizes, k=0; k
8342             *(sp++) = *(ip++);
8343             for(; k < pdim; k++)
8344             *(sp++) = __privtrans->pdls[0]->dims[k];
8345              
8346              
8347             /* Loop over all the ranges in the index list */
8348             for(item=0; item<__params->nitems; item++) {
8349              
8350             /* initialize in-range iterator to loop within each range */
8351             for(ip = iter2, k=0; k
8352             *(ip++) = 0;
8353              
8354             do {
8355             PDL_Indx poff = 0;
8356             PDL_Indx coff;
8357             PDL_Indx k2;
8358             char trunc = 0; /* Flag used to skip truncation case */
8359              
8360             /* Collect and boundary-check the current N-D coords */
8361             for(k=0; k < prdim; k++){
8362              
8363             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8364              
8365             /* normal case */
8366             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8367             switch(__params->boundary[k]) {
8368             case 0: /* no boundary breakage allowed */
8369             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8370             break;
8371             case 1: /* truncation */
8372             trunc = 1;
8373             break;
8374             case 2: /* extension -- crop */
8375             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8376             break;
8377             case 3: /* periodic -- mod it */
8378             ck %= __privtrans->pdls[0]->dims[k];
8379             if(ck < 0) /* Fix mod breakage in C */
8380             ck += __privtrans->pdls[0]->dims[k];
8381             break;
8382             case 4: /* mirror -- reflect off the edges */
8383             ck += __privtrans->pdls[0]->dims[k];
8384             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8385             if(ck < 0) /* Fix mod breakage in C */
8386             ck += __privtrans->pdls[0]->dims[k]*2;
8387             ck -= __privtrans->pdls[0]->dims[k];
8388             if(ck < 0) {
8389             ck *= -1;
8390             ck -= 1;
8391             }
8392             break;
8393             default:
8394             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8395             break;
8396             }
8397             }
8398              
8399             coords[k] = ck;
8400              
8401             }
8402              
8403             /* Check extra dimensions -- pick up where k left off... */
8404             for( ; k < rdim ; k++) {
8405             /* Check for indexing off the end of the dimension list */
8406              
8407             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8408              
8409             switch(__params->boundary[k]) {
8410             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8411             if(ck != 0)
8412             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8413             break;
8414             case 1: /* truncation - just truncate if the corner is nonzero */
8415             trunc |= (ck != 0);
8416             break;
8417             case 2: /* extension -- ignore the corner (same as 3) */
8418             case 3: /* periodic -- ignore the corner */
8419             case 4: /* mirror -- ignore the corner */
8420             ck = 0;
8421             break;
8422             default:
8423             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8424             break;
8425             }
8426             }
8427              
8428             /* Find offsets into the child and parent arrays, from the N-D coords */
8429             /* Note we only loop over real source dims (prdim) to accumulate -- */
8430             /* because the offset is trivial and/or we're truncating for virtual */
8431             /* dims caused by permissive ranging. */
8432             coff = __privtrans->pdls[1]->dimincs[0] * item;
8433             for(k2 = __params->itdim, poff = k = 0;
8434             k < prdim;
8435             k++) {
8436             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8437             if(__params->sizes[k])
8438             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8439             }
8440              
8441             /* Loop the copy over all the source broadcast dims (above rdim). */
8442             do {
8443             PDL_Indx poff1 = poff;
8444             PDL_Indx coff1 = coff;
8445              
8446             /* Accumulate the offset due to source broadcasting */
8447             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8448             k < pdim;
8449             k++) {
8450             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8451             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8452             }
8453              
8454             /* Finally -- make the copy
8455             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8456             * out-of-bounds conditions.
8457             */
8458             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,Q,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8459              
8460             /* Increment the source broadcast iterator */
8461             for( k=__params->rdim;
8462             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8463             k++)
8464             iter2[k] = 0;
8465             } while(k < pdim); /* end of source-broadcast iteration */
8466              
8467             /* Increment the in-range iterator */
8468             for(k = 0;
8469             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8470             k++)
8471             iter2[k] = 0;
8472             } while(k < __params->rdim); /* end of main iteration */
8473             } /* end of item do loop */
8474             #line 8475 "lib/PDL/Slices-pp-rangeb.c"
8475             }
8476 0           } break;
8477 0           case PDL_F: {
8478 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8479 0           {
8480             #line 877 "lib/PDL/Slices.pd"
8481             PDL_Indx *ip; /* vector iterator */
8482             PDL_Indx *sp; /* size vector including stdims */
8483             PDL_Indx *coords; /* current coordinates */
8484              
8485             PDL_Indx k; /* index */
8486             PDL_Indx item; /* index broadcast iterator */
8487             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8488             PDL_Indx rdim = __params->rdim;
8489             PDL_Indx prdim = PDLMIN(rdim,pdim);
8490             PDL_Indx iter2[pdim * 2 + rdim];
8491             PDL_Indx *sizes = iter2 + pdim;
8492             coords = sizes + pdim;
8493              
8494             /* Figure out size vector */
8495             for(ip = __params->sizes, sp = sizes, k=0; k
8496             *(sp++) = *(ip++);
8497             for(; k < pdim; k++)
8498             *(sp++) = __privtrans->pdls[0]->dims[k];
8499              
8500              
8501             /* Loop over all the ranges in the index list */
8502             for(item=0; item<__params->nitems; item++) {
8503              
8504             /* initialize in-range iterator to loop within each range */
8505             for(ip = iter2, k=0; k
8506             *(ip++) = 0;
8507              
8508             do {
8509             PDL_Indx poff = 0;
8510             PDL_Indx coff;
8511             PDL_Indx k2;
8512             char trunc = 0; /* Flag used to skip truncation case */
8513              
8514             /* Collect and boundary-check the current N-D coords */
8515             for(k=0; k < prdim; k++){
8516              
8517             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8518              
8519             /* normal case */
8520             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8521             switch(__params->boundary[k]) {
8522             case 0: /* no boundary breakage allowed */
8523             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8524             break;
8525             case 1: /* truncation */
8526             trunc = 1;
8527             break;
8528             case 2: /* extension -- crop */
8529             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8530             break;
8531             case 3: /* periodic -- mod it */
8532             ck %= __privtrans->pdls[0]->dims[k];
8533             if(ck < 0) /* Fix mod breakage in C */
8534             ck += __privtrans->pdls[0]->dims[k];
8535             break;
8536             case 4: /* mirror -- reflect off the edges */
8537             ck += __privtrans->pdls[0]->dims[k];
8538             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8539             if(ck < 0) /* Fix mod breakage in C */
8540             ck += __privtrans->pdls[0]->dims[k]*2;
8541             ck -= __privtrans->pdls[0]->dims[k];
8542             if(ck < 0) {
8543             ck *= -1;
8544             ck -= 1;
8545             }
8546             break;
8547             default:
8548             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8549             break;
8550             }
8551             }
8552              
8553             coords[k] = ck;
8554              
8555             }
8556              
8557             /* Check extra dimensions -- pick up where k left off... */
8558             for( ; k < rdim ; k++) {
8559             /* Check for indexing off the end of the dimension list */
8560              
8561             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8562              
8563             switch(__params->boundary[k]) {
8564             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8565             if(ck != 0)
8566             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8567             break;
8568             case 1: /* truncation - just truncate if the corner is nonzero */
8569             trunc |= (ck != 0);
8570             break;
8571             case 2: /* extension -- ignore the corner (same as 3) */
8572             case 3: /* periodic -- ignore the corner */
8573             case 4: /* mirror -- ignore the corner */
8574             ck = 0;
8575             break;
8576             default:
8577             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8578             break;
8579             }
8580             }
8581              
8582             /* Find offsets into the child and parent arrays, from the N-D coords */
8583             /* Note we only loop over real source dims (prdim) to accumulate -- */
8584             /* because the offset is trivial and/or we're truncating for virtual */
8585             /* dims caused by permissive ranging. */
8586             coff = __privtrans->pdls[1]->dimincs[0] * item;
8587             for(k2 = __params->itdim, poff = k = 0;
8588             k < prdim;
8589             k++) {
8590             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8591             if(__params->sizes[k])
8592             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8593             }
8594              
8595             /* Loop the copy over all the source broadcast dims (above rdim). */
8596             do {
8597             PDL_Indx poff1 = poff;
8598             PDL_Indx coff1 = coff;
8599              
8600             /* Accumulate the offset due to source broadcasting */
8601             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8602             k < pdim;
8603             k++) {
8604             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8605             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8606             }
8607              
8608             /* Finally -- make the copy
8609             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8610             * out-of-bounds conditions.
8611             */
8612             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,F,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8613              
8614             /* Increment the source broadcast iterator */
8615             for( k=__params->rdim;
8616             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8617             k++)
8618             iter2[k] = 0;
8619             } while(k < pdim); /* end of source-broadcast iteration */
8620              
8621             /* Increment the in-range iterator */
8622             for(k = 0;
8623             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8624             k++)
8625             iter2[k] = 0;
8626             } while(k < __params->rdim); /* end of main iteration */
8627             } /* end of item do loop */
8628             #line 8629 "lib/PDL/Slices-pp-rangeb.c"
8629             }
8630 0           } break;
8631 9           case PDL_D: {
8632 9 50         PDL_DECLARE_PARAMS_rangeb_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
8633 9           {
8634             #line 877 "lib/PDL/Slices.pd"
8635             PDL_Indx *ip; /* vector iterator */
8636             PDL_Indx *sp; /* size vector including stdims */
8637             PDL_Indx *coords; /* current coordinates */
8638              
8639             PDL_Indx k; /* index */
8640             PDL_Indx item; /* index broadcast iterator */
8641             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8642             PDL_Indx rdim = __params->rdim;
8643             PDL_Indx prdim = PDLMIN(rdim,pdim);
8644             PDL_Indx iter2[pdim * 2 + rdim];
8645             PDL_Indx *sizes = iter2 + pdim;
8646             coords = sizes + pdim;
8647              
8648             /* Figure out size vector */
8649             for(ip = __params->sizes, sp = sizes, k=0; k
8650             *(sp++) = *(ip++);
8651             for(; k < pdim; k++)
8652             *(sp++) = __privtrans->pdls[0]->dims[k];
8653              
8654              
8655             /* Loop over all the ranges in the index list */
8656             for(item=0; item<__params->nitems; item++) {
8657              
8658             /* initialize in-range iterator to loop within each range */
8659             for(ip = iter2, k=0; k
8660             *(ip++) = 0;
8661              
8662             do {
8663             PDL_Indx poff = 0;
8664             PDL_Indx coff;
8665             PDL_Indx k2;
8666             char trunc = 0; /* Flag used to skip truncation case */
8667              
8668             /* Collect and boundary-check the current N-D coords */
8669             for(k=0; k < prdim; k++){
8670              
8671             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8672              
8673             /* normal case */
8674             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8675             switch(__params->boundary[k]) {
8676             case 0: /* no boundary breakage allowed */
8677             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8678             break;
8679             case 1: /* truncation */
8680             trunc = 1;
8681             break;
8682             case 2: /* extension -- crop */
8683             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8684             break;
8685             case 3: /* periodic -- mod it */
8686             ck %= __privtrans->pdls[0]->dims[k];
8687             if(ck < 0) /* Fix mod breakage in C */
8688             ck += __privtrans->pdls[0]->dims[k];
8689             break;
8690             case 4: /* mirror -- reflect off the edges */
8691             ck += __privtrans->pdls[0]->dims[k];
8692             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8693             if(ck < 0) /* Fix mod breakage in C */
8694             ck += __privtrans->pdls[0]->dims[k]*2;
8695             ck -= __privtrans->pdls[0]->dims[k];
8696             if(ck < 0) {
8697             ck *= -1;
8698             ck -= 1;
8699             }
8700             break;
8701             default:
8702             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8703             break;
8704             }
8705             }
8706              
8707             coords[k] = ck;
8708              
8709             }
8710              
8711             /* Check extra dimensions -- pick up where k left off... */
8712             for( ; k < rdim ; k++) {
8713             /* Check for indexing off the end of the dimension list */
8714              
8715             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8716              
8717             switch(__params->boundary[k]) {
8718             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8719             if(ck != 0)
8720             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8721             break;
8722             case 1: /* truncation - just truncate if the corner is nonzero */
8723             trunc |= (ck != 0);
8724             break;
8725             case 2: /* extension -- ignore the corner (same as 3) */
8726             case 3: /* periodic -- ignore the corner */
8727             case 4: /* mirror -- ignore the corner */
8728             ck = 0;
8729             break;
8730             default:
8731             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8732             break;
8733             }
8734             }
8735              
8736             /* Find offsets into the child and parent arrays, from the N-D coords */
8737             /* Note we only loop over real source dims (prdim) to accumulate -- */
8738             /* because the offset is trivial and/or we're truncating for virtual */
8739             /* dims caused by permissive ranging. */
8740             coff = __privtrans->pdls[1]->dimincs[0] * item;
8741             for(k2 = __params->itdim, poff = k = 0;
8742             k < prdim;
8743             k++) {
8744             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8745             if(__params->sizes[k])
8746             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8747             }
8748              
8749             /* Loop the copy over all the source broadcast dims (above rdim). */
8750             do {
8751             PDL_Indx poff1 = poff;
8752             PDL_Indx coff1 = coff;
8753              
8754             /* Accumulate the offset due to source broadcasting */
8755             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8756             k < pdim;
8757             k++) {
8758             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8759             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8760             }
8761              
8762             /* Finally -- make the copy
8763             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8764             * out-of-bounds conditions.
8765             */
8766             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,D,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8767              
8768             /* Increment the source broadcast iterator */
8769             for( k=__params->rdim;
8770             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8771             k++)
8772             iter2[k] = 0;
8773             } while(k < pdim); /* end of source-broadcast iteration */
8774              
8775             /* Increment the in-range iterator */
8776             for(k = 0;
8777             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8778             k++)
8779             iter2[k] = 0;
8780             } while(k < __params->rdim); /* end of main iteration */
8781             } /* end of item do loop */
8782             #line 8783 "lib/PDL/Slices-pp-rangeb.c"
8783             }
8784 9           } break;
8785 0           case PDL_LD: {
8786 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8787 0           {
8788             #line 877 "lib/PDL/Slices.pd"
8789             PDL_Indx *ip; /* vector iterator */
8790             PDL_Indx *sp; /* size vector including stdims */
8791             PDL_Indx *coords; /* current coordinates */
8792              
8793             PDL_Indx k; /* index */
8794             PDL_Indx item; /* index broadcast iterator */
8795             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8796             PDL_Indx rdim = __params->rdim;
8797             PDL_Indx prdim = PDLMIN(rdim,pdim);
8798             PDL_Indx iter2[pdim * 2 + rdim];
8799             PDL_Indx *sizes = iter2 + pdim;
8800             coords = sizes + pdim;
8801              
8802             /* Figure out size vector */
8803             for(ip = __params->sizes, sp = sizes, k=0; k
8804             *(sp++) = *(ip++);
8805             for(; k < pdim; k++)
8806             *(sp++) = __privtrans->pdls[0]->dims[k];
8807              
8808              
8809             /* Loop over all the ranges in the index list */
8810             for(item=0; item<__params->nitems; item++) {
8811              
8812             /* initialize in-range iterator to loop within each range */
8813             for(ip = iter2, k=0; k
8814             *(ip++) = 0;
8815              
8816             do {
8817             PDL_Indx poff = 0;
8818             PDL_Indx coff;
8819             PDL_Indx k2;
8820             char trunc = 0; /* Flag used to skip truncation case */
8821              
8822             /* Collect and boundary-check the current N-D coords */
8823             for(k=0; k < prdim; k++){
8824              
8825             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8826              
8827             /* normal case */
8828             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8829             switch(__params->boundary[k]) {
8830             case 0: /* no boundary breakage allowed */
8831             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8832             break;
8833             case 1: /* truncation */
8834             trunc = 1;
8835             break;
8836             case 2: /* extension -- crop */
8837             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8838             break;
8839             case 3: /* periodic -- mod it */
8840             ck %= __privtrans->pdls[0]->dims[k];
8841             if(ck < 0) /* Fix mod breakage in C */
8842             ck += __privtrans->pdls[0]->dims[k];
8843             break;
8844             case 4: /* mirror -- reflect off the edges */
8845             ck += __privtrans->pdls[0]->dims[k];
8846             ck %= (__privtrans->pdls[0]->dims[k] * 2);
8847             if(ck < 0) /* Fix mod breakage in C */
8848             ck += __privtrans->pdls[0]->dims[k]*2;
8849             ck -= __privtrans->pdls[0]->dims[k];
8850             if(ck < 0) {
8851             ck *= -1;
8852             ck -= 1;
8853             }
8854             break;
8855             default:
8856             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8857             break;
8858             }
8859             }
8860              
8861             coords[k] = ck;
8862              
8863             }
8864              
8865             /* Check extra dimensions -- pick up where k left off... */
8866             for( ; k < rdim ; k++) {
8867             /* Check for indexing off the end of the dimension list */
8868              
8869             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8870              
8871             switch(__params->boundary[k]) {
8872             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
8873             if(ck != 0)
8874             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
8875             break;
8876             case 1: /* truncation - just truncate if the corner is nonzero */
8877             trunc |= (ck != 0);
8878             break;
8879             case 2: /* extension -- ignore the corner (same as 3) */
8880             case 3: /* periodic -- ignore the corner */
8881             case 4: /* mirror -- ignore the corner */
8882             ck = 0;
8883             break;
8884             default:
8885             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
8886             break;
8887             }
8888             }
8889              
8890             /* Find offsets into the child and parent arrays, from the N-D coords */
8891             /* Note we only loop over real source dims (prdim) to accumulate -- */
8892             /* because the offset is trivial and/or we're truncating for virtual */
8893             /* dims caused by permissive ranging. */
8894             coff = __privtrans->pdls[1]->dimincs[0] * item;
8895             for(k2 = __params->itdim, poff = k = 0;
8896             k < prdim;
8897             k++) {
8898             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
8899             if(__params->sizes[k])
8900             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8901             }
8902              
8903             /* Loop the copy over all the source broadcast dims (above rdim). */
8904             do {
8905             PDL_Indx poff1 = poff;
8906             PDL_Indx coff1 = coff;
8907              
8908             /* Accumulate the offset due to source broadcasting */
8909             for(k2 = __params->itdim + __params->ntsize, k = rdim;
8910             k < pdim;
8911             k++) {
8912             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
8913             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
8914             }
8915              
8916             /* Finally -- make the copy
8917             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
8918             * out-of-bounds conditions.
8919             */
8920             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,E,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
8921              
8922             /* Increment the source broadcast iterator */
8923             for( k=__params->rdim;
8924             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
8925             k++)
8926             iter2[k] = 0;
8927             } while(k < pdim); /* end of source-broadcast iteration */
8928              
8929             /* Increment the in-range iterator */
8930             for(k = 0;
8931             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
8932             k++)
8933             iter2[k] = 0;
8934             } while(k < __params->rdim); /* end of main iteration */
8935             } /* end of item do loop */
8936             #line 8937 "lib/PDL/Slices-pp-rangeb.c"
8937             }
8938 0           } break;
8939 0           case PDL_CF: {
8940 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CFloat,G)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
8941 0           {
8942             #line 877 "lib/PDL/Slices.pd"
8943             PDL_Indx *ip; /* vector iterator */
8944             PDL_Indx *sp; /* size vector including stdims */
8945             PDL_Indx *coords; /* current coordinates */
8946              
8947             PDL_Indx k; /* index */
8948             PDL_Indx item; /* index broadcast iterator */
8949             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
8950             PDL_Indx rdim = __params->rdim;
8951             PDL_Indx prdim = PDLMIN(rdim,pdim);
8952             PDL_Indx iter2[pdim * 2 + rdim];
8953             PDL_Indx *sizes = iter2 + pdim;
8954             coords = sizes + pdim;
8955              
8956             /* Figure out size vector */
8957             for(ip = __params->sizes, sp = sizes, k=0; k
8958             *(sp++) = *(ip++);
8959             for(; k < pdim; k++)
8960             *(sp++) = __privtrans->pdls[0]->dims[k];
8961              
8962              
8963             /* Loop over all the ranges in the index list */
8964             for(item=0; item<__params->nitems; item++) {
8965              
8966             /* initialize in-range iterator to loop within each range */
8967             for(ip = iter2, k=0; k
8968             *(ip++) = 0;
8969              
8970             do {
8971             PDL_Indx poff = 0;
8972             PDL_Indx coff;
8973             PDL_Indx k2;
8974             char trunc = 0; /* Flag used to skip truncation case */
8975              
8976             /* Collect and boundary-check the current N-D coords */
8977             for(k=0; k < prdim; k++){
8978              
8979             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
8980              
8981             /* normal case */
8982             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
8983             switch(__params->boundary[k]) {
8984             case 0: /* no boundary breakage allowed */
8985             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
8986             break;
8987             case 1: /* truncation */
8988             trunc = 1;
8989             break;
8990             case 2: /* extension -- crop */
8991             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
8992             break;
8993             case 3: /* periodic -- mod it */
8994             ck %= __privtrans->pdls[0]->dims[k];
8995             if(ck < 0) /* Fix mod breakage in C */
8996             ck += __privtrans->pdls[0]->dims[k];
8997             break;
8998             case 4: /* mirror -- reflect off the edges */
8999             ck += __privtrans->pdls[0]->dims[k];
9000             ck %= (__privtrans->pdls[0]->dims[k] * 2);
9001             if(ck < 0) /* Fix mod breakage in C */
9002             ck += __privtrans->pdls[0]->dims[k]*2;
9003             ck -= __privtrans->pdls[0]->dims[k];
9004             if(ck < 0) {
9005             ck *= -1;
9006             ck -= 1;
9007             }
9008             break;
9009             default:
9010             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9011             break;
9012             }
9013             }
9014              
9015             coords[k] = ck;
9016              
9017             }
9018              
9019             /* Check extra dimensions -- pick up where k left off... */
9020             for( ; k < rdim ; k++) {
9021             /* Check for indexing off the end of the dimension list */
9022              
9023             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
9024              
9025             switch(__params->boundary[k]) {
9026             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
9027             if(ck != 0)
9028             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
9029             break;
9030             case 1: /* truncation - just truncate if the corner is nonzero */
9031             trunc |= (ck != 0);
9032             break;
9033             case 2: /* extension -- ignore the corner (same as 3) */
9034             case 3: /* periodic -- ignore the corner */
9035             case 4: /* mirror -- ignore the corner */
9036             ck = 0;
9037             break;
9038             default:
9039             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9040             break;
9041             }
9042             }
9043              
9044             /* Find offsets into the child and parent arrays, from the N-D coords */
9045             /* Note we only loop over real source dims (prdim) to accumulate -- */
9046             /* because the offset is trivial and/or we're truncating for virtual */
9047             /* dims caused by permissive ranging. */
9048             coff = __privtrans->pdls[1]->dimincs[0] * item;
9049             for(k2 = __params->itdim, poff = k = 0;
9050             k < prdim;
9051             k++) {
9052             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
9053             if(__params->sizes[k])
9054             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9055             }
9056              
9057             /* Loop the copy over all the source broadcast dims (above rdim). */
9058             do {
9059             PDL_Indx poff1 = poff;
9060             PDL_Indx coff1 = coff;
9061              
9062             /* Accumulate the offset due to source broadcasting */
9063             for(k2 = __params->itdim + __params->ntsize, k = rdim;
9064             k < pdim;
9065             k++) {
9066             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
9067             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9068             }
9069              
9070             /* Finally -- make the copy
9071             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
9072             * out-of-bounds conditions.
9073             */
9074             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,G,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
9075              
9076             /* Increment the source broadcast iterator */
9077             for( k=__params->rdim;
9078             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
9079             k++)
9080             iter2[k] = 0;
9081             } while(k < pdim); /* end of source-broadcast iteration */
9082              
9083             /* Increment the in-range iterator */
9084             for(k = 0;
9085             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
9086             k++)
9087             iter2[k] = 0;
9088             } while(k < __params->rdim); /* end of main iteration */
9089             } /* end of item do loop */
9090             #line 9091 "lib/PDL/Slices-pp-rangeb.c"
9091             }
9092 0           } break;
9093 0           case PDL_CD: {
9094 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CDouble,C)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
9095 0           {
9096             #line 877 "lib/PDL/Slices.pd"
9097             PDL_Indx *ip; /* vector iterator */
9098             PDL_Indx *sp; /* size vector including stdims */
9099             PDL_Indx *coords; /* current coordinates */
9100              
9101             PDL_Indx k; /* index */
9102             PDL_Indx item; /* index broadcast iterator */
9103             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
9104             PDL_Indx rdim = __params->rdim;
9105             PDL_Indx prdim = PDLMIN(rdim,pdim);
9106             PDL_Indx iter2[pdim * 2 + rdim];
9107             PDL_Indx *sizes = iter2 + pdim;
9108             coords = sizes + pdim;
9109              
9110             /* Figure out size vector */
9111             for(ip = __params->sizes, sp = sizes, k=0; k
9112             *(sp++) = *(ip++);
9113             for(; k < pdim; k++)
9114             *(sp++) = __privtrans->pdls[0]->dims[k];
9115              
9116              
9117             /* Loop over all the ranges in the index list */
9118             for(item=0; item<__params->nitems; item++) {
9119              
9120             /* initialize in-range iterator to loop within each range */
9121             for(ip = iter2, k=0; k
9122             *(ip++) = 0;
9123              
9124             do {
9125             PDL_Indx poff = 0;
9126             PDL_Indx coff;
9127             PDL_Indx k2;
9128             char trunc = 0; /* Flag used to skip truncation case */
9129              
9130             /* Collect and boundary-check the current N-D coords */
9131             for(k=0; k < prdim; k++){
9132              
9133             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
9134              
9135             /* normal case */
9136             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
9137             switch(__params->boundary[k]) {
9138             case 0: /* no boundary breakage allowed */
9139             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
9140             break;
9141             case 1: /* truncation */
9142             trunc = 1;
9143             break;
9144             case 2: /* extension -- crop */
9145             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
9146             break;
9147             case 3: /* periodic -- mod it */
9148             ck %= __privtrans->pdls[0]->dims[k];
9149             if(ck < 0) /* Fix mod breakage in C */
9150             ck += __privtrans->pdls[0]->dims[k];
9151             break;
9152             case 4: /* mirror -- reflect off the edges */
9153             ck += __privtrans->pdls[0]->dims[k];
9154             ck %= (__privtrans->pdls[0]->dims[k] * 2);
9155             if(ck < 0) /* Fix mod breakage in C */
9156             ck += __privtrans->pdls[0]->dims[k]*2;
9157             ck -= __privtrans->pdls[0]->dims[k];
9158             if(ck < 0) {
9159             ck *= -1;
9160             ck -= 1;
9161             }
9162             break;
9163             default:
9164             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9165             break;
9166             }
9167             }
9168              
9169             coords[k] = ck;
9170              
9171             }
9172              
9173             /* Check extra dimensions -- pick up where k left off... */
9174             for( ; k < rdim ; k++) {
9175             /* Check for indexing off the end of the dimension list */
9176              
9177             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
9178              
9179             switch(__params->boundary[k]) {
9180             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
9181             if(ck != 0)
9182             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
9183             break;
9184             case 1: /* truncation - just truncate if the corner is nonzero */
9185             trunc |= (ck != 0);
9186             break;
9187             case 2: /* extension -- ignore the corner (same as 3) */
9188             case 3: /* periodic -- ignore the corner */
9189             case 4: /* mirror -- ignore the corner */
9190             ck = 0;
9191             break;
9192             default:
9193             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9194             break;
9195             }
9196             }
9197              
9198             /* Find offsets into the child and parent arrays, from the N-D coords */
9199             /* Note we only loop over real source dims (prdim) to accumulate -- */
9200             /* because the offset is trivial and/or we're truncating for virtual */
9201             /* dims caused by permissive ranging. */
9202             coff = __privtrans->pdls[1]->dimincs[0] * item;
9203             for(k2 = __params->itdim, poff = k = 0;
9204             k < prdim;
9205             k++) {
9206             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
9207             if(__params->sizes[k])
9208             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9209             }
9210              
9211             /* Loop the copy over all the source broadcast dims (above rdim). */
9212             do {
9213             PDL_Indx poff1 = poff;
9214             PDL_Indx coff1 = coff;
9215              
9216             /* Accumulate the offset due to source broadcasting */
9217             for(k2 = __params->itdim + __params->ntsize, k = rdim;
9218             k < pdim;
9219             k++) {
9220             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
9221             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9222             }
9223              
9224             /* Finally -- make the copy
9225             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
9226             * out-of-bounds conditions.
9227             */
9228             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,C,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
9229              
9230             /* Increment the source broadcast iterator */
9231             for( k=__params->rdim;
9232             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
9233             k++)
9234             iter2[k] = 0;
9235             } while(k < pdim); /* end of source-broadcast iteration */
9236              
9237             /* Increment the in-range iterator */
9238             for(k = 0;
9239             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
9240             k++)
9241             iter2[k] = 0;
9242             } while(k < __params->rdim); /* end of main iteration */
9243             } /* end of item do loop */
9244             #line 9245 "lib/PDL/Slices-pp-rangeb.c"
9245             }
9246 0           } break;
9247 0           case PDL_CLD: {
9248 0 0         PDL_DECLARE_PARAMS_rangeb_1(PDL_CLDouble,H)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
9249 0           {
9250             #line 877 "lib/PDL/Slices.pd"
9251             PDL_Indx *ip; /* vector iterator */
9252             PDL_Indx *sp; /* size vector including stdims */
9253             PDL_Indx *coords; /* current coordinates */
9254              
9255             PDL_Indx k; /* index */
9256             PDL_Indx item; /* index broadcast iterator */
9257             PDL_Indx pdim = __privtrans->pdls[0]->ndims;
9258             PDL_Indx rdim = __params->rdim;
9259             PDL_Indx prdim = PDLMIN(rdim,pdim);
9260             PDL_Indx iter2[pdim * 2 + rdim];
9261             PDL_Indx *sizes = iter2 + pdim;
9262             coords = sizes + pdim;
9263              
9264             /* Figure out size vector */
9265             for(ip = __params->sizes, sp = sizes, k=0; k
9266             *(sp++) = *(ip++);
9267             for(; k < pdim; k++)
9268             *(sp++) = __privtrans->pdls[0]->dims[k];
9269              
9270              
9271             /* Loop over all the ranges in the index list */
9272             for(item=0; item<__params->nitems; item++) {
9273              
9274             /* initialize in-range iterator to loop within each range */
9275             for(ip = iter2, k=0; k
9276             *(ip++) = 0;
9277              
9278             do {
9279             PDL_Indx poff = 0;
9280             PDL_Indx coff;
9281             PDL_Indx k2;
9282             char trunc = 0; /* Flag used to skip truncation case */
9283              
9284             /* Collect and boundary-check the current N-D coords */
9285             for(k=0; k < prdim; k++){
9286              
9287             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
9288              
9289             /* normal case */
9290             if(ck < 0 || ck >= __privtrans->pdls[0]->dims[k]) {
9291             switch(__params->boundary[k]) {
9292             case 0: /* no boundary breakage allowed */
9293             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "index out-of-bounds in range (index vector #%ld)",item);
9294             break;
9295             case 1: /* truncation */
9296             trunc = 1;
9297             break;
9298             case 2: /* extension -- crop */
9299             ck = (ck >= __privtrans->pdls[0]->dims[k]) ? __privtrans->pdls[0]->dims[k]-1 : 0;
9300             break;
9301             case 3: /* periodic -- mod it */
9302             ck %= __privtrans->pdls[0]->dims[k];
9303             if(ck < 0) /* Fix mod breakage in C */
9304             ck += __privtrans->pdls[0]->dims[k];
9305             break;
9306             case 4: /* mirror -- reflect off the edges */
9307             ck += __privtrans->pdls[0]->dims[k];
9308             ck %= (__privtrans->pdls[0]->dims[k] * 2);
9309             if(ck < 0) /* Fix mod breakage in C */
9310             ck += __privtrans->pdls[0]->dims[k]*2;
9311             ck -= __privtrans->pdls[0]->dims[k];
9312             if(ck < 0) {
9313             ck *= -1;
9314             ck -= 1;
9315             }
9316             break;
9317             default:
9318             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9319             break;
9320             }
9321             }
9322              
9323             coords[k] = ck;
9324              
9325             }
9326              
9327             /* Check extra dimensions -- pick up where k left off... */
9328             for( ; k < rdim ; k++) {
9329             /* Check for indexing off the end of the dimension list */
9330              
9331             PDL_Indx ck = iter2[k] + __params->corners[ item * rdim + k ] ;
9332              
9333             switch(__params->boundary[k]) {
9334             case 0: /* No boundary breakage allowed -- nonzero corners cause barfage */
9335             if(ck != 0)
9336             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Too many dims in range index (and you've forbidden boundary violations)");
9337             break;
9338             case 1: /* truncation - just truncate if the corner is nonzero */
9339             trunc |= (ck != 0);
9340             break;
9341             case 2: /* extension -- ignore the corner (same as 3) */
9342             case 3: /* periodic -- ignore the corner */
9343             case 4: /* mirror -- ignore the corner */
9344             ck = 0;
9345             break;
9346             default:
9347             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition in range -- bug alert!");
9348             break;
9349             }
9350             }
9351              
9352             /* Find offsets into the child and parent arrays, from the N-D coords */
9353             /* Note we only loop over real source dims (prdim) to accumulate -- */
9354             /* because the offset is trivial and/or we're truncating for virtual */
9355             /* dims caused by permissive ranging. */
9356             coff = __privtrans->pdls[1]->dimincs[0] * item;
9357             for(k2 = __params->itdim, poff = k = 0;
9358             k < prdim;
9359             k++) {
9360             poff += coords[k]*__privtrans->pdls[0]->dimincs[k];
9361             if(__params->sizes[k])
9362             coff += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9363             }
9364              
9365             /* Loop the copy over all the source broadcast dims (above rdim). */
9366             do {
9367             PDL_Indx poff1 = poff;
9368             PDL_Indx coff1 = coff;
9369              
9370             /* Accumulate the offset due to source broadcasting */
9371             for(k2 = __params->itdim + __params->ntsize, k = rdim;
9372             k < pdim;
9373             k++) {
9374             poff1 += iter2[k] * __privtrans->pdls[0]->dimincs[k];
9375             coff1 += iter2[k] * __privtrans->pdls[1]->dimincs[k2++];
9376             }
9377              
9378             /* Finally -- make the copy
9379             * EQUIVCPTRUNC works like EQUIVCPOFFS but with checking for
9380             * out-of-bounds conditions.
9381             */
9382             do { if (!(trunc)) { PDL_IF_BAD(if (PDL_ISBAD2(CHILD_datap[coff1],CHILD_badval,H,CHILD_badval_isnan) ) { PARENT_datap[poff1]=PARENT_badval; } else,) { PARENT_datap[poff1] = CHILD_datap[coff1]; } } } while (0);
9383              
9384             /* Increment the source broadcast iterator */
9385             for( k=__params->rdim;
9386             k < pdim && (++(iter2[k]) >= __privtrans->pdls[0]->dims[k]);
9387             k++)
9388             iter2[k] = 0;
9389             } while(k < pdim); /* end of source-broadcast iteration */
9390              
9391             /* Increment the in-range iterator */
9392             for(k = 0;
9393             k < __params->rdim && (++(iter2[k]) >= __params->sizes[k]);
9394             k++)
9395             iter2[k] = 0;
9396             } while(k < __params->rdim); /* end of main iteration */
9397             } /* end of item do loop */
9398             #line 9399 "lib/PDL/Slices-pp-rangeb.c"
9399             }
9400 0           } break;
9401 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rangeb: unhandled datatype(%d), only handles (ABSULKNPQFDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
9402             }
9403             #undef PDL_IF_BAD
9404             }
9405 16           return PDL_err;
9406             }
9407              
9408              
9409             #line 1857 "lib/PDL/PP.pm"
9410             pdl_error pdl_rangeb_free(pdl_trans *__privtrans, char destroy) {
9411             pdl_error PDL_err = {0, NULL, 0};
9412             #line 9413 "lib/PDL/Slices-pp-rangeb.c"
9413 83           pdl_params_rangeb *__params = __privtrans->params; (void)__params;
9414 83           pdl *__it = __privtrans->pdls[1]; (void) __it;
9415 83 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->size_sv); /* CType.get_free */
9416             SvREFCNT_dec(__params->boundary_sv); /* CType.get_free */
9417             free(__params->sizes); /* CType.get_free */
9418             free(__params->itdims); /* CType.get_free */
9419             free(__params->corners); /* CType.get_free */
9420             free(__params->boundary); /* CType.get_free */
9421 83           , ) return PDL_err;
9422             }
9423              
9424             static pdl_datatypes pdl_rangeb_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 };
9425             static PDL_Indx pdl_rangeb_vtable_realdims[] = { 0, 0 };
9426             static char *pdl_rangeb_vtable_parnames[] = { "PARENT","CHILD" };
9427             static short pdl_rangeb_vtable_parflags[] = {
9428             PDL_PARAM_ISPHYS,
9429             PDL_PARAM_ISCREAT|PDL_PARAM_ISCREATEALWAYS|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE
9430             };
9431             static pdl_datatypes pdl_rangeb_vtable_partypes[] = { -1, -1 };
9432             static PDL_Indx pdl_rangeb_vtable_realdims_starts[] = { 0, 0 };
9433             static PDL_Indx pdl_rangeb_vtable_realdims_ind_ids[] = { 0 };
9434             static char *pdl_rangeb_vtable_indnames[] = { "" };
9435             pdl_transvtable pdl_rangeb_vtable = {
9436             PDL_TRANS_BADPROCESS, PDL_ITRANS_TWOWAY|PDL_ITRANS_DO_DATAFLOW_ANY, pdl_rangeb_vtable_gentypes, 1, 2, NULL /*CORE21*/,
9437             pdl_rangeb_vtable_realdims, pdl_rangeb_vtable_parnames,
9438             pdl_rangeb_vtable_parflags, pdl_rangeb_vtable_partypes,
9439             pdl_rangeb_vtable_realdims_starts, pdl_rangeb_vtable_realdims_ind_ids, 0,
9440             0, pdl_rangeb_vtable_indnames,
9441             pdl_rangeb_redodims, pdl_rangeb_readdata, pdl_rangeb_writebackdata,
9442             pdl_rangeb_free,
9443             sizeof(pdl_params_rangeb),"PDL::Slices::rangeb"
9444             };
9445              
9446              
9447 83           pdl_error pdl_run_rangeb(pdl *PARENT,pdl *CHILD,pdl *ind_pdl,SV *size_sv,SV *boundary_sv) {
9448 83           pdl_error PDL_err = {0, NULL, 0};
9449 83 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
9450 83           pdl_trans *__privtrans = PDL->create_trans(&pdl_rangeb_vtable);
9451 83 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
9452 83           pdl_params_rangeb *__params = __privtrans->params;
9453 83           __privtrans->pdls[0] = PARENT;
9454 83           __privtrans->pdls[1] = CHILD;
9455 83 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
9456 83           PARENT = __privtrans->pdls[0];
9457 83           CHILD = __privtrans->pdls[1];
9458 83           (__params->ind_pdl) = (ind_pdl); /* CType.get_copy */
9459 83           (__params->size_sv) = newSVsv(size_sv); /* CType.get_copy */
9460 83           (__params->boundary_sv) = newSVsv(boundary_sv); /* CType.get_copy */
9461              
9462              
9463             #line 615 "lib/PDL/Slices.pd"
9464             pdl *size_pdl = NULL;
9465             PDL_RETERROR(PDL_err, PDL->make_physdims(ind_pdl));
9466             __params->size_pdl_destroy = __params->ind_pdl_destroy = 0;
9467              
9468             /* Generalized empties are ok, but not in the special 0 dim (the index vector) */
9469             if(ind_pdl->dims[0] == 0)
9470             { return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "can't handle Empty indices -- call range instead"); }
9471              
9472             /***
9473             * Ensure that the index is a PDL_Indx. If there's no loss of information,
9474             * just upgrade it -- otherwise, make a temporary copy.
9475             */
9476             switch(ind_pdl->datatype) {
9477             default: /* Most types: */
9478             ind_pdl = PDL->hard_copy(ind_pdl); /* copy and fall through */
9479             if (!ind_pdl) return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Error in hard_copy");
9480             __params->ind_pdl_destroy = 1;
9481             case PDL_SB: case PDL_B: case PDL_S: case PDL_US: case PDL_L: case PDL_UL: case PDL_LL: case PDL_ULL:
9482             PDL_RETERROR(PDL_err, PDL->converttype(ind_pdl,PDL_IND)); /* convert in place. */
9483             break;
9484             case PDL_IND:
9485             PDL_RETERROR(PDL_err, PDL->make_physical(ind_pdl));
9486             break;
9487             }
9488              
9489             /***
9490             * Figure sizes of the COMP arrays and allocate them.
9491             */
9492             {
9493             PDL_Indx i,nitems;
9494              
9495             __params->rdim = ind_pdl->ndims ? ind_pdl->dims[0] : 1;
9496             for(i=nitems=1; i < ind_pdl->ndims; i++) /* Accumulate item list size */
9497             nitems *= ind_pdl->dims[i];
9498             __params->nitems = nitems;
9499             __params->itdim = ind_pdl->ndims ? ind_pdl->ndims - 1 : 0;
9500             __params->sizes = malloc(sizeof(*__params->sizes) * __params->rdim); /* CType.get_malloc */
9501             __params->itdims = malloc(sizeof(*__params->itdims) * __params->itdim); /* CType.get_malloc */
9502             __params->corners = malloc(sizeof(*__params->corners) * __params->rdim * __params->nitems); /* CType.get_malloc */
9503             __params->boundary = malloc(sizeof(*__params->boundary) * __params->rdim); /* CType.get_malloc */
9504             ;
9505             }
9506              
9507             /***
9508             * Fill in the boundary condition array
9509             */
9510             {
9511             char *bstr;
9512             STRLEN blen;
9513             bstr = SvPV(boundary_sv,blen);
9514              
9515             if(blen == 0) {
9516             /* If no boundary is specified then every dim gets forbidden */
9517             PDL_Indx i;
9518             for (i=0;i<__params->rdim;i++)
9519             __params->boundary[i] = 0;
9520             } else {
9521             PDL_Indx i;
9522             for(i=0;i<__params->rdim;i++) {
9523             switch(bstr[PDLMIN(i, blen-1)]) {
9524             case '0': case 'f': case 'F': /* forbid */
9525             __params->boundary[i] = 0;
9526             break;
9527             case '1': case 't': case 'T': /* truncate */
9528             __params->boundary[i] = 1;
9529             break;
9530             case '2': case 'e': case 'E': /* extend */
9531             __params->boundary[i] = 2;
9532             break;
9533             case '3': case 'p': case 'P': /* periodic */
9534             __params->boundary[i] = 3;
9535             break;
9536             case '4': case 'm': case 'M': /* mirror */
9537             __params->boundary[i] = 4;
9538             break;
9539             default:
9540             {
9541             /* No need to check if i < blen -- this will barf out the
9542             * first time it gets hit.
9543             */
9544             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unknown boundary condition '%c' in range",bstr[i]);
9545             }
9546             break;
9547             } // end of switch
9548             }
9549             }
9550             }
9551             /***
9552             * Store the sizes of the index-broadcast dims
9553             */
9554             {
9555             PDL_Indx i;
9556             PDL_Indx nd = ind_pdl->ndims - 1;
9557             for(i=0; i < nd ; i++)
9558             __params->itdims[i] = ind_pdl->dims[i+1];
9559             }
9560              
9561             /***
9562             * Check and condition the size ndarray, and store sizes of the ranges
9563             */
9564             {
9565             PDL_Indx i,ntsize;
9566              
9567             if( (size_sv == NULL) || !SvOK(size_sv) ) {
9568             // NO size was passed in, not normally executed even if you passed in no size to range(),
9569             // as range() generates a size array...
9570             for(i=0;i<__params->rdim;i++)
9571             __params->sizes[i] = 0;
9572              
9573             } else {
9574             /* Normal case with sizes present in a PDL */
9575              
9576             if(!(size_pdl = PDL->SvPDLV(size_sv))) /* assignment */
9577             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Unable to convert size to a PDL");
9578              
9579             if(size_pdl->nvals == 0) {
9580             // no values in the size_pdl - Empty or Null. Just copy 0s to all the range dims
9581             for(i=0;i<__params->rdim;i++)
9582             __params->sizes[i] = 0;
9583              
9584             } else {
9585              
9586             // Convert size PDL to PDL_IND to support indices
9587             switch(size_pdl->datatype) {
9588             default: /* Most types: */
9589             size_pdl = PDL->hard_copy(size_pdl); /* copy and fall through */
9590             if (!size_pdl) return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Error in hard_copy");
9591             __params->size_pdl_destroy = 1;
9592             case PDL_SB: case PDL_B: case PDL_S: case PDL_US: case PDL_L: case PDL_UL: case PDL_LL: case PDL_ULL:
9593             PDL_RETERROR(PDL_err, PDL->converttype(size_pdl,PDL_IND)); /* convert in place. */
9594             break;
9595             case PDL_IND:
9596             PDL_RETERROR(PDL_err, PDL->make_physical(size_pdl));
9597             break;
9598             }
9599              
9600             __params->nsizes = size_pdl->nvals; /* Store for later permissiveness check */
9601              
9602             /* Copy the sizes, or die if they're the wrong shape */
9603             if(size_pdl->nvals == 1) {
9604             for(i=0;i<__params->rdim;i++) {
9605             __params->sizes[i] = *((PDL_Indx *)(size_pdl->data));
9606             }
9607              
9608             /* Check for nonnegativity of sizes. The rdim>0 mask ensures that */
9609             /* we don't barf on the Empty PDL (as an index). */
9610             if( __params->rdim > 0 && __params->sizes[0] < 0 ) {
9611             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Negative range size is not allowed\n");
9612             }
9613             }
9614             else if( size_pdl->nvals <= __params->rdim && size_pdl->ndims == 1) {
9615             for(i=0;i<__params->rdim;i++) {
9616             __params->sizes[i] = ( (i < size_pdl->nvals) ?
9617             ((PDL_Indx *)(size_pdl->data))[i] :
9618             0
9619             );
9620             if(__params->sizes[i] < 0)
9621             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Negative range sizes are not allowed\n");
9622             }
9623             }
9624             else {
9625             return PDL->make_error(PDL_EUSERERROR, "Error in rangeb:" "Size must match index's 0th dim\n");
9626             }
9627              
9628             } /* end of nonempty size-ndarray code */
9629             } /* end of defined-size-ndarray code */
9630              
9631             /* Insert the number of nontrivial sizes (these get output dimensions) */
9632             for(i=ntsize=0;i<__params->rdim;i++)
9633             if(__params->sizes[i])
9634             ntsize++;
9635             __params->ntsize = ntsize;
9636             }
9637              
9638             /***
9639             * Stash coordinates of the corners
9640             */
9641              
9642             PDL_Indx j,k,ioff, iter[__params->itdim];
9643             /* initialize iterator to loop over index broadcasts */
9644             PDL_Indx *cptr = iter;
9645             for(k=0;k<__params->itdim;k++)
9646             *(cptr++) = 0;
9647             cptr = __params->corners;
9648             do {
9649             /* accumulate offset into the index from the iterator */
9650             for(k=ioff=0;k<__params->itdim;k++)
9651             ioff += iter[k] * ind_pdl->dimincs[k+1];
9652             /* Loop over the 0th dim of index, copying coords. */
9653             /* This is the natural place to check for permissive ranging; too */
9654             /* bad we don't have access to the parent ndarray here... */
9655             for(j=0;j<__params->rdim;j++)
9656             *(cptr++) = ((PDL_Indx *)(ind_pdl->data))[ioff + ind_pdl->dimincs[0] * j];
9657             /* Increment the iterator -- the test increments, the body carries. */
9658             for(k=0; k<__params->itdim && (++(iter[k]))>=(__params->itdims[k]) ;k++)
9659             iter[k] = 0;
9660             } while(k<__params->itdim);
9661             if (__params->ind_pdl_destroy)
9662             PDL->destroy(ind_pdl); /* finished with our copy */
9663             if (__params->size_pdl_destroy)
9664             PDL->destroy(size_pdl); /* finished with our copy */
9665             #line 9666 "lib/PDL/Slices-pp-rangeb.c"
9666 83 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
9667 83           return PDL_err;
9668             }