# Function types. define CHEBYSHEV 1 # CURFIT Chebyshev polynomial define LEGENDRE 2 # CURFIT Legendre polynomial define SPLINE3 3 # CURFIT cubic spline define SPLINE1 4 # CURFIT linear spline define PIXEL 5 # pixel coordinate array define SAMPLE 6 # sampled coordinates # SSHIFT1 -- Shift coordinate zero point of nonlinear functions. procedure sshift1 (shift, coeff) double shift # Shift to add pointer coeff # Attribute function coefficients int i, j, ip, nalloc, ncoeff, type, order, fd double dval pointer coeffs int ctod(), stropen() errchk stropen begin if (coeff == NULL) return if (Memc[coeff] == EOS) return coeffs = NULL ncoeff = 0 ip = 1 while (ctod (Memc[coeff], ip, dval) > 0) { if (coeffs == NULL) { nalloc = 10 call malloc (coeffs, nalloc, TY_DOUBLE) } else if (ncoeff == nalloc) { nalloc = nalloc + 10 call realloc (coeffs, nalloc, TY_DOUBLE) } Memd[coeffs+ncoeff] = dval ncoeff = ncoeff + 1 } ip = ip + SZ_LINE call realloc (coeff, ip, TY_CHAR) call aclrc (Memc[coeff], ip) fd = stropen (Memc[coeff], ip, NEW_FILE) ip = 0 while (ip < ncoeff) { if (ip > 0) call fprintf (fd, " ") Memd[coeffs+ip+1] = Memd[coeffs+ip+1] + shift type = nint (Memd[coeffs+ip+2]) order = nint (Memd[coeffs+ip+3]) call fprintf (fd, "%.3g %g %d %d") call pargd (Memd[coeffs+ip]) call pargd (Memd[coeffs+ip+1]) call pargi (type) call pargi (order) switch (type) { case CHEBYSHEV, LEGENDRE: j = 6 + order case SPLINE3: j = 9 + order case SPLINE1: j = 7 + order case PIXEL: j = 4 + order case SAMPLE: j = 5 + order } do i = 4, j-1 { call fprintf (fd, " %g") call pargd (Memd[coeffs+ip+i]) } ip = ip + j } call strclose (fd) call mfree (coeffs, TY_DOUBLE) end