From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- pkg/xtools/icfit/icgaddr.x | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkg/xtools/icfit/icgaddr.x (limited to 'pkg/xtools/icfit/icgaddr.x') diff --git a/pkg/xtools/icfit/icgaddr.x b/pkg/xtools/icfit/icgaddr.x new file mode 100644 index 00000000..4e09be1b --- /dev/null +++ b/pkg/xtools/icfit/icgaddr.x @@ -0,0 +1,50 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include + +define MSIZE 2. # Mark size + +# ICG_ADD -- Add a point. + +procedure icg_addr (gp, wx, wy, wt, x, y, w1, w2, npts) + +pointer gp # GIO pointer +real wx # X point to insert +real wy # Y point to insert +real wt # Weight of point to add +real x[npts] # Independent variable +real y[npts] # Dependent variable +real w1[npts] # Current weights +real w2[npts] # Initial weights +int npts # Number of points + +int i, j + +begin + # Find the place to insert the new point. + if (x[1] < x[npts]) + for (i = npts; (i > 0) && (wx < x[i]); i = i - 1) + ; + else + for (i = npts; (i > 0) && (wx > x[i]); i = i - 1) + ; + + # Shift the data to insert the new point. + for (j = npts; j > i; j = j - 1) { + x[j+1] = x[j] + y[j+1] = y[j] + w1[j+1] = w1[j] + w2[j+1] = w2[j] + } + + # Add the new point and increment the number of points. + i = i + 1 + x[i] = wx + y[i] = wy + w1[i] = wt + w2[i] = wt + npts = npts + 1 + + # Mark the point + call gmark (gp, real (x[i]), real (y[i]), GM_PLUS, MSIZE, MSIZE) +end -- cgit