1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
include "hdicfit.h"
define FUNCTIONS "|chebyshev|legendre|spline3|spline1|power|"
define TRANSFORMS "|none|logopacitance|k50|k75|"
# IC_OPEN -- Open ICFIT parameter structure.
procedure ic_open (ic)
pointer ic # ICFIT pointer
errchk malloc
begin
# Allocate memory for the package parameter structure.
call malloc (ic, IC_LENSTRUCT, TY_STRUCT)
call malloc (IC_SAMPLE(ic), SZ_LINE, TY_CHAR)
call malloc (IC_LABELS(ic,1), SZ_LINE, TY_CHAR)
call malloc (IC_LABELS(ic,2), SZ_LINE, TY_CHAR)
call malloc (IC_UNITS(ic,1), SZ_LINE, TY_CHAR)
call malloc (IC_UNITS(ic,2), SZ_LINE, TY_CHAR)
# Set defaults.
call ic_pstr (ic, "function", "spline3")
call ic_puti (ic, "order", 1)
call ic_pstr (ic, "sample", "*")
call ic_puti (ic, "naverage", 1)
call ic_puti (ic, "niterate", 0)
call ic_putr (ic, "low", 0.)
call ic_putr (ic, "high", 0.)
call ic_putr (ic, "grow", 0.)
call ic_pstr (ic, "xlabel", "X")
call ic_pstr (ic, "ylabel", "Y")
call ic_pstr (ic, "xunits", "")
call ic_pstr (ic, "yunits", "")
call ic_puti (ic, "key", 1)
call ic_pkey (ic, 1, 'x', 'y')
call ic_pkey (ic, 2, 'y', 'x')
call ic_pkey (ic, 3, 'x', 'r')
call ic_pkey (ic, 4, 'x', 'd')
call ic_pkey (ic, 5, 'x', 'n')
# Initialize other parameters
IC_RG(ic) = NULL
IC_XFIT(ic) = NULL
IC_YFIT(ic) = NULL
IC_WTSFIT(ic) = NULL
IC_REJPTS(ic) = NULL
end
# IC_CLOSER -- Close ICFIT parameter structure.
procedure ic_closer (ic)
pointer ic # ICFIT pointer
begin
# Free memory for the package parameter structure.
call rg_free (IC_RG(ic))
call mfree (IC_XFIT(ic), TY_REAL)
call mfree (IC_YFIT(ic), TY_REAL)
call mfree (IC_WTSFIT(ic), TY_REAL)
call mfree (IC_REJPTS(ic), TY_INT)
call mfree (IC_SAMPLE(ic), TY_CHAR)
call mfree (IC_LABELS(ic,1), TY_CHAR)
call mfree (IC_LABELS(ic,2), TY_CHAR)
call mfree (IC_UNITS(ic,1), TY_CHAR)
call mfree (IC_UNITS(ic,2), TY_CHAR)
call mfree (ic, TY_STRUCT)
end
# IC_CLOSED -- Close ICFIT parameter structure.
procedure ic_closed (ic)
pointer ic # ICFIT pointer
begin
# Free memory for the package parameter structure.
call rg_free (IC_RG(ic))
call mfree (IC_XFIT(ic), TY_DOUBLE)
call mfree (IC_YFIT(ic), TY_DOUBLE)
call mfree (IC_WTSFIT(ic), TY_DOUBLE)
call mfree (IC_REJPTS(ic), TY_INT)
call mfree (IC_SAMPLE(ic), TY_CHAR)
call mfree (IC_LABELS(ic,1), TY_CHAR)
call mfree (IC_LABELS(ic,2), TY_CHAR)
call mfree (IC_UNITS(ic,1), TY_CHAR)
call mfree (IC_UNITS(ic,2), TY_CHAR)
call mfree (ic, TY_STRUCT)
end
# IC_PSTR -- Put string valued parameters.
procedure ic_pstr (ic, param, str)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be put
char str[ARB] # String value
int i
pointer ptr
int strdic()
bool streq()
begin
if (streq (param, "sample"))
call strcpy (str, Memc[IC_SAMPLE(ic)], SZ_LINE)
else if (streq (param, "function")) {
call malloc (ptr, SZ_LINE, TY_CHAR)
i = strdic (str, Memc[ptr], SZ_LINE, FUNCTIONS)
if (i > 0)
IC_FUNCTION(ic) = i
call mfree (ptr, TY_CHAR)
} else if (streq (param, "transform")) {
call malloc (ptr, SZ_LINE, TY_CHAR)
i = strdic (str, Memc[ptr], SZ_LINE, TRANSFORMS)
if (i > 0)
IC_TRANSFORM(ic) = i
call mfree (ptr, TY_CHAR)
} else if (streq (param, "xlabel"))
call strcpy (str, Memc[IC_LABELS(ic,1)], SZ_LINE)
else if (streq (param, "ylabel"))
call strcpy (str, Memc[IC_LABELS(ic,2)], SZ_LINE)
else if (streq (param, "xunits"))
call strcpy (str, Memc[IC_UNITS(ic,1)], SZ_LINE)
else if (streq (param, "yunits"))
call strcpy (str, Memc[IC_UNITS(ic,2)], SZ_LINE)
else
call error (0, "ICFIT: Unknown parameter")
end
# IC_PUTI -- Put integer valued parameters.
procedure ic_puti (ic, param, ival)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be put
int ival # Integer value
bool streq()
begin
if (streq (param, "naverage"))
IC_NAVERAGE(ic) = ival
else if (streq (param, "order"))
IC_ORDER(ic) = ival
else if (streq (param, "niterate"))
IC_NITERATE(ic) = ival
else if (streq (param, "key"))
IC_GKEY(ic) = ival
else if (streq (param, "transform"))
IC_TRANSFORM(ic) = ival
else
call error (0, "ICFIT: Unknown parameter")
end
# IC_PKEY -- Put key parameters.
# Note the key types must be integers not characters.
procedure ic_pkey (ic, key, xaxis, yaxis)
pointer ic # ICFIT pointer
int key # Key to be defined
int xaxis # X axis type
int yaxis # Y axis type
begin
IC_AXES(ic, key, 1) = xaxis
IC_AXES(ic, key, 2) = yaxis
end
# IC_GKEY -- Get key parameters.
procedure ic_gkey (ic, key, xaxis, yaxis)
pointer ic # ICFIT pointer
int key # Key to be gotten
int xaxis # X axis type
int yaxis # Y axis type
begin
xaxis = IC_AXES(ic, key, 1)
yaxis = IC_AXES(ic, key, 2)
end
# IC_PUTR -- Put real valued parameters.
procedure ic_putr (ic, param, rval)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be put
real rval # Real value
bool streq()
begin
if (streq (param, "xmin"))
IC_XMIN(ic) = rval
else if (streq (param, "xmax"))
IC_XMAX(ic) = rval
else if (streq (param, "low"))
IC_LOW(ic) = rval
else if (streq (param, "high"))
IC_HIGH(ic) = rval
else if (streq (param, "grow"))
IC_GROW(ic) = rval
else if (streq (param, "fog"))
IC_FOG(ic) = rval
else if (streq (param, "rfog"))
IC_RFOG(ic) = rval
else
call error (0, "ICFIT: Unknown parameter")
end
# IC_GSTR -- Get string valued parameters.
procedure ic_gstr (ic, param, str, maxchars)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be put
char str[maxchars] # String value
int maxchars # Maximum number of characters
bool streq()
begin
if (streq (param, "sample"))
call strcpy (Memc[IC_SAMPLE(ic)], str, maxchars)
else if (streq (param, "xlabel"))
call strcpy (Memc[IC_LABELS(ic,1)], str, maxchars)
else if (streq (param, "ylabel"))
call strcpy (Memc[IC_LABELS(ic,2)], str, maxchars)
else if (streq (param, "xunits"))
call strcpy (Memc[IC_UNITS(ic,1)], str, maxchars)
else if (streq (param, "yunits"))
call strcpy (Memc[IC_UNITS(ic,2)], str, maxchars)
else if (streq (param, "function")) {
switch (IC_FUNCTION(ic)) {
case 1:
call strcpy ("chebyshev", str, maxchars)
case 2:
call strcpy ("legendre", str, maxchars)
case 3:
call strcpy ("spline3", str, maxchars)
case 4:
call strcpy ("spline1", str, maxchars)
case 5:
call strcpy ("power", str, maxchars)
}
} else if (streq (param, "transform")) {
switch (IC_TRANSFORM(ic)) {
case 1:
call strcpy ("none", str, maxchars)
case 2:
call strcpy ("logopacitance", str, maxchars)
case 3:
call strcpy ("k50", str, maxchars)
case 4:
call strcpy ("k75", str, maxchars)
}
} else
call error (0, "ICFIT: Unknown parameter")
end
# IC_GETI -- Get integer valued parameters.
int procedure ic_geti (ic, param)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be gotten
bool streq()
begin
if (streq (param, "naverage"))
return (IC_NAVERAGE(ic))
else if (streq (param, "order"))
return (IC_ORDER(ic))
else if (streq (param, "niterate"))
return (IC_NITERATE(ic))
else if (streq (param, "key"))
return (IC_GKEY(ic))
else if (streq (param, "transform"))
return (IC_TRANSFORM(ic))
call error (0, "ICFIT: Unknown parameter")
end
# IC_GETR -- Get real valued parameters.
real procedure ic_getr (ic, param)
pointer ic # ICFIT pointer
char param[ARB] # Parameter to be put
bool streq()
begin
if (streq (param, "xmin"))
return (IC_XMIN(ic))
else if (streq (param, "xmax"))
return (IC_XMAX(ic))
else if (streq (param, "low"))
return (IC_LOW(ic))
else if (streq (param, "high"))
return (IC_HIGH(ic))
else if (streq (param, "grow"))
return (IC_GROW(ic))
else if (streq (param, "fog"))
return (IC_FOG(ic))
call error (0, "ICFIT: Unknown parameter")
end
|