aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/inlimit.gx
blob: ed4c2b43881329e5ce8e270ce3d20e8aff221c97 (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
include	<pkg/inlfit.h>


# IN_LIMIT -- Compute the independent variable limits for all variables,
# and store them in the INLFIT structure.

procedure in_limit$t (in, x, npts, nvars)

pointer	in			# INLFIT descriptor
PIXEL	x[ARB]			# Independent values (npts * nvars)
int	npts			# number of points
int	nvars			# number of variables

int	i, j
PIXEL	aux, xmin, xmax
pointer	minptr, maxptr

pointer	in_getp()

begin
#	# Debug
#	call eprintf ("in_limit: in=%d, npts=%d, nvars=%d\n")
#	    call pargi (in)
#	    call pargi (npts)
#	    call pargi (nvars)

	# Get minimum and maximum buffer pointers
	minptr = in_getp (in, INLXMIN)
	maxptr = in_getp (in, INLXMAX)

	# Loop over variables
	do i = 1, nvars {

	    # Set initial values
	    xmin = x[i]
	    xmax = x[i]

	    # Search for maximum and minimum values
	    do j = 1, npts {
		aux = x[(j - 1) * nvars + i]
		if (xmin > aux)
		    xmin = aux
		else if (xmax < aux)
		    xmax = aux
	    }

	    # Enter values into the structure
	    Mem$t[minptr + i - 1] = xmin
	    Mem$t[maxptr + i - 1] = xmax
	}
end