aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/incopy.gx
blob: 8165cf6d7b30e58fe84ae235331ed8d409145434 (plain) (blame)
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
include	<pkg/inlfit.h>
include	"inlfitdef.h"

# IN_COPY -- Copy INLFIT parameter structure, into another. The destination
# structure is allocated if the pointer is NULL.

procedure in_copy$t (insrc, indst)

pointer	insrc			# source INLFIT pointer
pointer	indst			# destination INLFIT pointer

int	in_geti()
PIXEL	in_get$t()
pointer	in_getp()

begin
#	# Debug.
#	call eprintf (
#	    "in_copy: insrc=%d, indst=%d\n")
#	    call pargi (insrc)
#	    call pargi (indst)

	# Allocate destination.
	if (indst == NULL) {

	    # Allocate structure memory.
	    call malloc (indst, LEN_INLSTRUCT, TY_STRUCT)

	    # Allocate memory for parameter values, changes, and list.
	    call malloc (IN_PARAM  (indst), in_geti (insrc, INLNPARAMS),
			 TY_PIXEL)
	    call malloc (IN_DPARAM (indst), in_geti (insrc, INLNPARAMS),
			 TY_PIXEL)
	    call malloc (IN_PLIST  (indst), in_geti (insrc, INLNPARAMS),
			 TY_INT)

	    # Allocate space for strings. All strings are limited
	    # to SZ_LINE or SZ_FNAME.
	    call malloc (IN_LABELS     (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_UNITS      (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_FLABELS    (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_FUNITS     (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_PLABELS    (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_PUNITS     (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_VLABELS    (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_VUNITS     (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_USERLABELS (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_USERUNITS  (indst), SZ_LINE,  TY_CHAR)
	    call malloc (IN_HELP       (indst), SZ_FNAME, TY_CHAR)
	    call malloc (IN_PROMPT     (indst), SZ_FNAME, TY_CHAR)

	    # Allocate space for floating point and graph substructures.
	    call malloc (IN_SFLOAT (indst), LEN_INLFLOAT, TY_PIXEL)
	    call malloc (IN_SGAXES (indst), INLNGKEYS * LEN_INLGRAPH, TY_INT)
	}

	# Copy integer parameters.
	call in_puti (indst, INLFUNCTION,   in_geti (insrc, INLFUNCTION))
	call in_puti (indst, INLDERIVATIVE, in_geti (insrc, INLDERIVATIVE))
	call in_puti (indst, INLNPARAMS,    in_geti (insrc, INLNPARAMS))
	call in_puti (indst, INLNFPARAMS,   in_geti (insrc, INLNFPARAMS))

	# Copy parameter values, changes, and list.
	call amov$t  (Mem$t[in_getp (insrc, INLPARAM)],
		      Mem$t[in_getp (indst, INLPARAM)],
		      in_geti (insrc, INLNPARAMS))
	call amov$t  (Mem$t[in_getp (insrc, INLDPARAM)],
		      Mem$t[in_getp (indst, INLDPARAM)],
		      in_geti (insrc, INLNPARAMS))
	call amovi   (Memi[in_getp (insrc, INLPLIST)],
		      Memi[in_getp (indst, INLPLIST)],
		      in_geti (insrc, INLNPARAMS))

	# Copy defaults.
	call in_put$t (indst, INLTOLERANCE, in_get$t (insrc, INLTOLERANCE))
	call in_puti  (indst, INLMAXITER,   in_geti  (insrc, INLMAXITER))
	call in_puti  (indst, INLNREJECT,   in_geti  (insrc, INLNREJECT))
	call in_put$t (indst, INLLOW,       in_get$t (insrc, INLLOW))
	call in_put$t (indst, INLHIGH,      in_get$t (insrc, INLHIGH))
	call in_put$t (indst, INLGROW,      in_get$t (insrc, INLGROW))

	# Copy character strings.
	call in_pstr (indst, INLLABELS,     Memc[IN_LABELS     (insrc)])
	call in_pstr (indst, INLUNITS,      Memc[IN_UNITS      (insrc)])
	call in_pstr (indst, INLFLABELS,    Memc[IN_FLABELS    (insrc)])
	call in_pstr (indst, INLFUNITS,     Memc[IN_FUNITS     (insrc)])
	call in_pstr (indst, INLPLABELS,    Memc[IN_PLABELS    (insrc)])
	call in_pstr (indst, INLPUNITS,     Memc[IN_PUNITS     (insrc)])
	call in_pstr (indst, INLVLABELS,    Memc[IN_VLABELS    (insrc)])
	call in_pstr (indst, INLVUNITS,     Memc[IN_VUNITS     (insrc)])
	call in_pstr (indst, INLUSERLABELS, Memc[IN_USERLABELS (insrc)])
	call in_pstr (indst, INLUSERUNITS,  Memc[IN_USERUNITS  (insrc)])
	call in_pstr (indst, INLHELP,       Memc[IN_HELP       (insrc)])
	call in_pstr (indst, INLPROMPT,     Memc[IN_PROMPT     (insrc)])

	# Copy user defined functions.
	call in_puti (indst, INLUAXES,  in_geti (insrc, INLUAXES))
	call in_puti (indst, INLUCOLON, in_geti (insrc, INLUCOLON))
	call in_puti (indst, INLUFIT,   in_geti (insrc, INLUFIT))

	# Copy graph key, and axes.
	call in_puti (indst, INLGKEY, in_geti (insrc, INLGKEY))
	call amovi (IN_SGAXES (insrc), IN_SGAXES (indst),
	    INLNGKEYS * LEN_INLGRAPH)

	# Copy flags and counters.
	call in_puti (indst, INLOVERPLOT, in_geti (insrc, INLOVERPLOT))
	call in_puti (indst, INLPLOTFIT,  in_geti (insrc, INLPLOTFIT))
	call in_puti (indst, INLNREJPTS,  in_geti (insrc, INLNREJPTS))

	# Initialize number of points and variables.
	call in_puti (indst, INLNVARS, 0)
	call in_puti (indst, INLNPTS,  0)

	# Reallocate rejected point list and limit values.
	call in_bfinit (indst, in_geti (insrc, INLNPTS),
	    in_geti (insrc, INLNVARS))

	# Copy rejected point list and limit values.
	call amovi  (MEMP[in_getp (insrc, INLREJPTS)],
	    MEMP[in_getp (indst, INLREJPTS)], in_geti (indst, INLNPTS))
	call amov$t (Mem$t[in_getp (insrc, INLXMIN)],
	    Mem$t[in_getp (indst, INLXMIN)], in_geti (indst, INLNVARS))
	call amov$t (Mem$t[in_getp (insrc, INLXMAX)],
	    Mem$t[in_getp (indst, INLXMAX)], in_geti (indst, INLNVARS))
end