| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "pdl.h" |
|
2
|
|
|
|
|
|
|
#define PDL_IN_CORE |
|
3
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
/* also in pdlconv.c */ |
|
6
|
|
|
|
|
|
|
#define PDL_ALL_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 } |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
/* delete these in CORE21 */ |
|
9
|
0
|
|
|
|
|
|
pdl_error pdl_readdata_affine(pdl_trans *trans) { |
|
10
|
0
|
|
|
|
|
|
return (pdl_error){PDL_EUSERERROR, "readdata called with no vtable entry", 0}; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
0
|
|
|
|
|
|
pdl_error pdl_writebackdata_affine(pdl_trans *trans) { |
|
13
|
0
|
|
|
|
|
|
return (pdl_error){PDL_EUSERERROR, "writebackdata called with no vtable entry", 0}; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
/* generated from: |
|
17
|
|
|
|
|
|
|
pp_def( 'affine', |
|
18
|
|
|
|
|
|
|
P2Child => 1, |
|
19
|
|
|
|
|
|
|
TwoWay => 1, |
|
20
|
|
|
|
|
|
|
AffinePriv => 1, |
|
21
|
|
|
|
|
|
|
GlobalNew => 'affine_new', |
|
22
|
|
|
|
|
|
|
OtherPars => 'PDL_Indx offset; PDL_Indx dims[]; PDL_Indx incs[]', |
|
23
|
|
|
|
|
|
|
Comp => 'PDL_Indx nd; PDL_Indx sdims[$COMP(nd)]; |
|
24
|
|
|
|
|
|
|
PDL_Indx sincs[$COMP(nd)];', |
|
25
|
|
|
|
|
|
|
MakeComp => ' |
|
26
|
|
|
|
|
|
|
PDL_Indx i = 0; |
|
27
|
|
|
|
|
|
|
$COMP(nd) = dims_count; |
|
28
|
|
|
|
|
|
|
if ($COMP(nd) < 0) |
|
29
|
|
|
|
|
|
|
$CROAK("Affine: can not have negative no of dims"); |
|
30
|
|
|
|
|
|
|
if ($COMP(nd) != incs_count) |
|
31
|
|
|
|
|
|
|
$CROAK("Affine: number of incs does not match dims"); |
|
32
|
|
|
|
|
|
|
$DOCOMPALLOC(); |
|
33
|
|
|
|
|
|
|
for (i=0; i<$COMP(nd); i++) { |
|
34
|
|
|
|
|
|
|
$COMP(sdims)[i] = dims[i]; |
|
35
|
|
|
|
|
|
|
$COMP(sincs)[i] = incs[i]; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
', |
|
38
|
|
|
|
|
|
|
RedoDims => ' |
|
39
|
|
|
|
|
|
|
PDL_Indx i; |
|
40
|
|
|
|
|
|
|
$SETNDIMS($COMP(nd)); |
|
41
|
|
|
|
|
|
|
$DOPRIVALLOC(); |
|
42
|
|
|
|
|
|
|
$PRIV(offs) = $COMP(offset); |
|
43
|
|
|
|
|
|
|
for (i=0;i<$PDL(CHILD)->ndims;i++) { |
|
44
|
|
|
|
|
|
|
$PRIV(incs)[i] = $COMP(sincs)[i]; |
|
45
|
|
|
|
|
|
|
$PDL(CHILD)->dims[i] = $COMP(sdims)[i]; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
$SETDIMS(); |
|
48
|
|
|
|
|
|
|
', |
|
49
|
|
|
|
|
|
|
Doc => undef, |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
*/ |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
typedef struct pdl_params_affine { |
|
54
|
|
|
|
|
|
|
PDL_Indx nd; |
|
55
|
|
|
|
|
|
|
PDL_Indx offset; |
|
56
|
|
|
|
|
|
|
PDL_Indx *sdims; |
|
57
|
|
|
|
|
|
|
PDL_Indx *sincs; |
|
58
|
|
|
|
|
|
|
} pdl_params_affine; |
|
59
|
|
|
|
|
|
|
|
|
60
|
170
|
|
|
|
|
|
pdl_error pdl_affine_redodims(pdl_trans *trans) { |
|
61
|
170
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
62
|
170
|
|
|
|
|
|
pdl_params_affine *params = trans->params; |
|
63
|
170
|
|
|
|
|
|
pdl *__it = trans->pdls[1]; |
|
64
|
170
|
|
|
|
|
|
pdl_hdr_childcopy(trans); |
|
65
|
|
|
|
|
|
|
PDL_Indx i; |
|
66
|
170
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, pdl_reallocdims(__it, params->nd)); |
|
67
|
170
|
|
|
|
|
|
trans->incs = malloc(sizeof(*trans->incs) * trans->pdls[1]->ndims); |
|
68
|
170
|
50
|
|
|
|
|
if (!trans->incs) return pdl_make_error_simple(PDL_EFATAL, "Out of Memory\n"); |
|
69
|
170
|
|
|
|
|
|
trans->offs = params->offset; |
|
70
|
315
|
100
|
|
|
|
|
for (i=0;ipdls[1]->ndims;i++) { |
|
71
|
145
|
|
|
|
|
|
trans->incs[i] = params->sincs[i]; |
|
72
|
145
|
|
|
|
|
|
trans->pdls[1]->dims[i] = params->sdims[i]; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
170
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, pdl_setdims_careful(__it)); |
|
75
|
170
|
|
|
|
|
|
trans->dims_redone = 1; |
|
76
|
170
|
|
|
|
|
|
return PDL_err; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
1188
|
|
|
|
|
|
pdl_error pdl_affine_free(pdl_trans *trans, char destroy) { |
|
80
|
1188
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
81
|
1188
|
|
|
|
|
|
pdl_params_affine *params = trans->params; |
|
82
|
1188
|
50
|
|
|
|
|
if (destroy) { |
|
83
|
1188
|
|
|
|
|
|
free(params->sdims); |
|
84
|
1188
|
|
|
|
|
|
free(params->sincs); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
1188
|
100
|
|
|
|
|
if ((trans)->dims_redone) free(trans->incs); |
|
87
|
1188
|
|
|
|
|
|
return PDL_err; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
static pdl_datatypes pdl_affine_vtable_gentypes[] = PDL_ALL_GENTYPES; |
|
91
|
|
|
|
|
|
|
static char pdl_affine_vtable_flags[] = { 0, 0 }; /*CORE21*/ |
|
92
|
|
|
|
|
|
|
static PDL_Indx pdl_affine_vtable_realdims[] = { 0, 0 }; |
|
93
|
|
|
|
|
|
|
static char *pdl_affine_vtable_parnames[] = { "PARENT","CHILD" }; |
|
94
|
|
|
|
|
|
|
static short pdl_affine_vtable_parflags[] = { |
|
95
|
|
|
|
|
|
|
0, |
|
96
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISCREATEALWAYS|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE |
|
97
|
|
|
|
|
|
|
}; |
|
98
|
|
|
|
|
|
|
static pdl_datatypes pdl_affine_vtable_partypes[] = { -1, -1 }; |
|
99
|
|
|
|
|
|
|
static PDL_Indx pdl_affine_vtable_realdims_starts[] = { 0, 0 }; |
|
100
|
|
|
|
|
|
|
static PDL_Indx pdl_affine_vtable_realdims_ind_ids[] = { 0 }; |
|
101
|
|
|
|
|
|
|
static char *pdl_affine_vtable_indnames[] = { "" }; |
|
102
|
|
|
|
|
|
|
pdl_transvtable pdl_affine_vtable = { |
|
103
|
|
|
|
|
|
|
0, PDL_ITRANS_ISAFFINE|PDL_ITRANS_TWOWAY|PDL_ITRANS_DO_DATAFLOW_ANY, pdl_affine_vtable_gentypes, 1, 2, pdl_affine_vtable_flags /*CORE21*/, |
|
104
|
|
|
|
|
|
|
pdl_affine_vtable_realdims, pdl_affine_vtable_parnames, |
|
105
|
|
|
|
|
|
|
pdl_affine_vtable_parflags, pdl_affine_vtable_partypes, |
|
106
|
|
|
|
|
|
|
pdl_affine_vtable_realdims_starts, pdl_affine_vtable_realdims_ind_ids, 0, |
|
107
|
|
|
|
|
|
|
0, pdl_affine_vtable_indnames, |
|
108
|
|
|
|
|
|
|
pdl_affine_redodims, NULL, NULL, |
|
109
|
|
|
|
|
|
|
pdl_affine_free, |
|
110
|
|
|
|
|
|
|
sizeof(pdl_params_affine),"affine_new" |
|
111
|
|
|
|
|
|
|
}; |
|
112
|
|
|
|
|
|
|
|
|
113
|
1188
|
|
|
|
|
|
pdl_error pdl_affine_new(pdl *PARENT,pdl *CHILD,PDL_Indx offset,PDL_Indx *dims,PDL_Indx dims_count, PDL_Indx *incs, PDL_Indx incs_count) { |
|
114
|
1188
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
115
|
1188
|
|
|
|
|
|
pdl_trans *trans = pdl_create_trans(&pdl_affine_vtable); |
|
116
|
1188
|
|
|
|
|
|
pdl_params_affine *params = trans->params; |
|
117
|
1188
|
|
|
|
|
|
trans->pdls[0] = PARENT; |
|
118
|
1188
|
|
|
|
|
|
trans->pdls[1] = CHILD; |
|
119
|
1188
|
|
|
|
|
|
pdl_type_coerce((pdl_trans *)trans); |
|
120
|
1188
|
|
|
|
|
|
PARENT = trans->pdls[0]; |
|
121
|
1188
|
|
|
|
|
|
CHILD = trans->pdls[1]; |
|
122
|
1188
|
|
|
|
|
|
PDL_Indx i = 0; |
|
123
|
1188
|
|
|
|
|
|
params->nd = dims_count; |
|
124
|
1188
|
50
|
|
|
|
|
if (params->nd < 0) |
|
125
|
0
|
|
|
|
|
|
return pdl_make_error_simple(PDL_EUSERERROR, "Error in affine: can not have negative no of dims"); |
|
126
|
1188
|
50
|
|
|
|
|
if (params->nd != incs_count) |
|
127
|
0
|
|
|
|
|
|
return pdl_make_error_simple(PDL_EUSERERROR, "Error in affine: number of incs does not match dims"); |
|
128
|
1188
|
|
|
|
|
|
params->sdims = malloc(sizeof(* params->sdims) * params->nd); |
|
129
|
1188
|
50
|
|
|
|
|
if (!params->sdims) return pdl_make_error_simple(PDL_EFATAL, "Out of Memory\n"); |
|
130
|
1188
|
|
|
|
|
|
params->sincs = malloc(sizeof(* params->sincs) * params->nd); |
|
131
|
1188
|
50
|
|
|
|
|
if (!params->sincs) return pdl_make_error_simple(PDL_EFATAL, "Out of Memory\n"); |
|
132
|
1188
|
|
|
|
|
|
params->offset = offset; |
|
133
|
2346
|
100
|
|
|
|
|
for (i=0; ind; i++) { |
|
134
|
1158
|
|
|
|
|
|
params->sdims[i] = dims[i]; |
|
135
|
1158
|
|
|
|
|
|
params->sincs[i] = incs[i]; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
1188
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, pdl_make_trans_mutual((pdl_trans *)trans)); |
|
138
|
1188
|
|
|
|
|
|
return PDL_err; |
|
139
|
|
|
|
|
|
|
} |