| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#line 453 "lib/PDL/PP.pm" |
|
3
|
|
|
|
|
|
|
/* |
|
4
|
|
|
|
|
|
|
* THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Slices.pd! Do not modify! |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \ |
|
8
|
|
|
|
|
|
|
if (destroy) { \ |
|
9
|
|
|
|
|
|
|
comp_free_code \ |
|
10
|
|
|
|
|
|
|
} \ |
|
11
|
|
|
|
|
|
|
if ((trans)->dims_redone) { \ |
|
12
|
|
|
|
|
|
|
ntpriv_free_code \ |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
16
|
|
|
|
|
|
|
#include "perl.h" |
|
17
|
|
|
|
|
|
|
#include "XSUB.h" |
|
18
|
|
|
|
|
|
|
#include "pdl.h" |
|
19
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
20
|
|
|
|
|
|
|
#define PDL PDL_Slices |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
#line 23 "lib/PDL/Slices-pp-diagonal.c" |
|
23
|
278
|
|
|
|
|
|
static int cmp_pdll(const void *a_,const void *b_) { |
|
24
|
278
|
|
|
|
|
|
PDL_Indx *a = (PDL_Indx *)a_; PDL_Indx *b=(PDL_Indx *)b_; |
|
25
|
278
|
50
|
|
|
|
|
if(*a>*b) return 1; |
|
26
|
278
|
50
|
|
|
|
|
else if(*a==*b) return 0; |
|
27
|
278
|
|
|
|
|
|
else return -1; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#line 1846 "lib/PDL/PP.pm" |
|
33
|
|
|
|
|
|
|
typedef struct pdl_params_diagonal { |
|
34
|
|
|
|
|
|
|
#line 35 "lib/PDL/Slices-pp-diagonal.c" |
|
35
|
|
|
|
|
|
|
PDL_Indx *whichdims; |
|
36
|
|
|
|
|
|
|
PDL_Indx whichdims_count; |
|
37
|
|
|
|
|
|
|
} pdl_params_diagonal; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
41
|
|
|
|
|
|
|
pdl_error pdl_diagonal_redodims(pdl_trans *__privtrans) { |
|
42
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
43
|
|
|
|
|
|
|
#line 44 "lib/PDL/Slices-pp-diagonal.c" |
|
44
|
278
|
|
|
|
|
|
pdl_params_diagonal *__params = __privtrans->params; (void)__params; |
|
45
|
278
|
|
|
|
|
|
pdl *__it = __privtrans->pdls[1]; (void) __it; |
|
46
|
278
|
|
|
|
|
|
PDL->hdr_childcopy(__privtrans); __privtrans->dims_redone = 1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#line 2464 "lib/PDL/Slices.pd" |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
PDL_Indx nthp,nthc,nthd, cd = __params->whichdims[0]; |
|
51
|
|
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->reallocdims(__it,__privtrans->pdls[0]->ndims-__params->whichdims_count+1));; |
|
52
|
|
|
|
|
|
|
__privtrans->incs = malloc(sizeof(*__privtrans->incs) * __privtrans->pdls[1]->ndims); /* CType.get_malloc */ |
|
53
|
|
|
|
|
|
|
; |
|
54
|
|
|
|
|
|
|
__privtrans->offs = 0; |
|
55
|
|
|
|
|
|
|
if (__params->whichdims[__params->whichdims_count-1] >= __privtrans->pdls[0]->ndims || |
|
56
|
|
|
|
|
|
|
__params->whichdims[0] < 0) |
|
57
|
|
|
|
|
|
|
return PDL->make_error(PDL_EUSERERROR, "Error in diagonal:" "dim out of range"); |
|
58
|
|
|
|
|
|
|
nthd=0; nthc=0; |
|
59
|
|
|
|
|
|
|
for(nthp=0; nthp<__privtrans->pdls[0]->ndims; nthp++) |
|
60
|
|
|
|
|
|
|
if (nthd < __params->whichdims_count && |
|
61
|
|
|
|
|
|
|
nthp == __params->whichdims[nthd]) { |
|
62
|
|
|
|
|
|
|
if (!nthd) { |
|
63
|
|
|
|
|
|
|
__privtrans->pdls[1]->dims[cd] = __privtrans->pdls[0]->dims[cd]; |
|
64
|
|
|
|
|
|
|
nthc++; |
|
65
|
|
|
|
|
|
|
__privtrans->incs[cd] = 0; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
if (nthd && __params->whichdims[nthd] == |
|
68
|
|
|
|
|
|
|
__params->whichdims[nthd-1]) |
|
69
|
|
|
|
|
|
|
return PDL->make_error(PDL_EUSERERROR, "Error in diagonal:" "dims must be unique"); |
|
70
|
|
|
|
|
|
|
nthd++; /* advance pointer into whichdims */ |
|
71
|
|
|
|
|
|
|
if(__privtrans->pdls[1]->dims[cd] != |
|
72
|
|
|
|
|
|
|
__privtrans->pdls[0]->dims[nthp]) { |
|
73
|
|
|
|
|
|
|
return PDL->make_error(PDL_EUSERERROR, "Error in diagonal:" "Different dims %"IND_FLAG" and %"IND_FLAG"",__privtrans->pdls[1]->dims[cd],__privtrans->pdls[0]->dims[nthp]); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
__privtrans->incs[cd] += __privtrans->pdls[0]->dimincs[nthp]; |
|
76
|
|
|
|
|
|
|
} else { |
|
77
|
|
|
|
|
|
|
__privtrans->incs[nthc] = __privtrans->pdls[0]->dimincs[nthp]; |
|
78
|
|
|
|
|
|
|
__privtrans->pdls[1]->dims[nthc] = __privtrans->pdls[0]->dims[nthp]; |
|
79
|
|
|
|
|
|
|
nthc++; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->setdims_careful(__it));; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#line 84 "lib/PDL/Slices-pp-diagonal.c" |
|
84
|
278
|
|
|
|
|
|
return PDL_err; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
89
|
|
|
|
|
|
|
pdl_error pdl_diagonal_free(pdl_trans *__privtrans, char destroy) { |
|
90
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
91
|
|
|
|
|
|
|
#line 92 "lib/PDL/Slices-pp-diagonal.c" |
|
92
|
278
|
|
|
|
|
|
pdl_params_diagonal *__params = __privtrans->params; (void)__params; |
|
93
|
278
|
|
|
|
|
|
pdl *__it = __privtrans->pdls[1]; (void) __it; |
|
94
|
278
|
50
|
|
|
|
|
PDL_FREE_CODE(__privtrans, destroy, free(__params->whichdims); /* CType.get_free */ |
|
|
|
50
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
, free(__privtrans->incs); /* CType.get_free */ |
|
96
|
278
|
|
|
|
|
|
) return PDL_err; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
static pdl_datatypes pdl_diagonal_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 }; |
|
100
|
|
|
|
|
|
|
static PDL_Indx pdl_diagonal_vtable_realdims[] = { 0, 0 }; |
|
101
|
|
|
|
|
|
|
static char *pdl_diagonal_vtable_parnames[] = { "PARENT","CHILD" }; |
|
102
|
|
|
|
|
|
|
static short pdl_diagonal_vtable_parflags[] = { |
|
103
|
|
|
|
|
|
|
0, |
|
104
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISCREATEALWAYS|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE |
|
105
|
|
|
|
|
|
|
}; |
|
106
|
|
|
|
|
|
|
static pdl_datatypes pdl_diagonal_vtable_partypes[] = { -1, -1 }; |
|
107
|
|
|
|
|
|
|
static PDL_Indx pdl_diagonal_vtable_realdims_starts[] = { 0, 0 }; |
|
108
|
|
|
|
|
|
|
static PDL_Indx pdl_diagonal_vtable_realdims_ind_ids[] = { 0 }; |
|
109
|
|
|
|
|
|
|
static char *pdl_diagonal_vtable_indnames[] = { "" }; |
|
110
|
|
|
|
|
|
|
pdl_transvtable pdl_diagonal_vtable = { |
|
111
|
|
|
|
|
|
|
0, PDL_ITRANS_ISAFFINE|PDL_ITRANS_TWOWAY|PDL_ITRANS_DO_DATAFLOW_ANY, pdl_diagonal_vtable_gentypes, 1, 2, NULL /*CORE21*/, |
|
112
|
|
|
|
|
|
|
pdl_diagonal_vtable_realdims, pdl_diagonal_vtable_parnames, |
|
113
|
|
|
|
|
|
|
pdl_diagonal_vtable_parflags, pdl_diagonal_vtable_partypes, |
|
114
|
|
|
|
|
|
|
pdl_diagonal_vtable_realdims_starts, pdl_diagonal_vtable_realdims_ind_ids, 0, |
|
115
|
|
|
|
|
|
|
0, pdl_diagonal_vtable_indnames, |
|
116
|
|
|
|
|
|
|
pdl_diagonal_redodims, NULL, NULL, |
|
117
|
|
|
|
|
|
|
pdl_diagonal_free, |
|
118
|
|
|
|
|
|
|
sizeof(pdl_params_diagonal),"PDL::Slices::diagonal" |
|
119
|
|
|
|
|
|
|
}; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
278
|
|
|
|
|
|
pdl_error pdl_run_diagonal(pdl *PARENT,pdl *CHILD,PDL_Indx *whichdims,PDL_Indx whichdims_count) { |
|
123
|
278
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
124
|
278
|
50
|
|
|
|
|
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
|
125
|
278
|
|
|
|
|
|
pdl_trans *__privtrans = PDL->create_trans(&pdl_diagonal_vtable); |
|
126
|
278
|
50
|
|
|
|
|
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
|
127
|
278
|
|
|
|
|
|
pdl_params_diagonal *__params = __privtrans->params; |
|
128
|
278
|
|
|
|
|
|
__privtrans->pdls[0] = PARENT; |
|
129
|
278
|
|
|
|
|
|
__privtrans->pdls[1] = CHILD; |
|
130
|
278
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
|
131
|
278
|
|
|
|
|
|
PARENT = __privtrans->pdls[0]; |
|
132
|
278
|
|
|
|
|
|
CHILD = __privtrans->pdls[1]; |
|
133
|
278
|
|
|
|
|
|
__params->whichdims = malloc(sizeof(*__params->whichdims) * whichdims_count); /* CType.get_malloc */ |
|
134
|
|
|
|
|
|
|
|
|
135
|
278
|
50
|
|
|
|
|
if(!whichdims) {__params->whichdims=0;} /* CType.get_copy */ |
|
136
|
|
|
|
|
|
|
else {int __malloc_ind_1; |
|
137
|
278
|
|
|
|
|
|
for(__malloc_ind_1 = 0; |
|
138
|
834
|
100
|
|
|
|
|
__malloc_ind_1 < whichdims_count; |
|
139
|
556
|
|
|
|
|
|
__malloc_ind_1 ++) { __params->whichdims[__malloc_ind_1] = whichdims[__malloc_ind_1]; }} |
|
140
|
278
|
50
|
|
|
|
|
(__params->whichdims_count) = (whichdims_count); /* CType.get_copy */ |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#line 2450 "lib/PDL/Slices.pd" |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
if (__params->whichdims_count < 1) |
|
146
|
|
|
|
|
|
|
return PDL->make_error(PDL_EUSERERROR, "Error in diagonal:" "must have at least 1 dimension"); |
|
147
|
|
|
|
|
|
|
qsort(__params->whichdims, __params->whichdims_count, sizeof(PDL_Indx), |
|
148
|
|
|
|
|
|
|
cmp_pdll); |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#line 151 "lib/PDL/Slices-pp-diagonal.c" |
|
151
|
278
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
|
152
|
278
|
|
|
|
|
|
return PDL_err; |
|
153
|
|
|
|
|
|
|
} |