aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/inrefitd.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/xtools/inlfit/inrefitd.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/xtools/inlfit/inrefitd.x')
-rw-r--r--pkg/xtools/inlfit/inrefitd.x67
1 files changed, 67 insertions, 0 deletions
diff --git a/pkg/xtools/inlfit/inrefitd.x b/pkg/xtools/inlfit/inrefitd.x
new file mode 100644
index 00000000..956e125e
--- /dev/null
+++ b/pkg/xtools/inlfit/inrefitd.x
@@ -0,0 +1,67 @@
+include <math/nlfit.h>
+include <pkg/inlfit.h>
+
+
+# IN_REFIT -- Refit a function. This procedure is analogous to in_fit(),
+# except that this one does not initialize the weigths and the rejected
+# point list, and it does not reject points after the fit, because it is
+# intended to be called from the data rejection procedure.
+
+procedure in_refitd (in, nl, x, y, wts, npts, nvars, wtflag)
+
+pointer in # INLFIT pointer
+pointer nl # NLFIT pointer
+double x[ARB] # Ordinates
+double y[npts] # Data to be fit
+double wts[npts] # Weights
+int npts # Number of points
+int nvars # Number of variables
+int wtflag # Type of weighting
+
+int i, ndeleted, ier
+pointer rejpts
+pointer in_getp()
+int in_geti()
+
+begin
+# # Debug
+# call eprintf ("in_refit: in=%d, nl=%d, npts=%d, nvars=%d\n")
+# call pargi (in)
+# call pargi (nl)
+# call pargi (npts)
+# call pargi (nvars)
+
+
+ # Assign a zero weight to each rejected point.
+ rejpts = in_getp (in, INLREJPTS)
+ do i = 1, npts {
+ if (Memi[rejpts+i-1] == YES)
+ wts[i] = double (0.0)
+ }
+
+ # Reinitialize NLFIT.
+ call in_nlinitd (in, nl)
+
+ # Check number of data points.
+ if (npts == 0) {
+ call in_puti (in, INLFITERROR, NO_DEG_FREEDOM)
+ return
+ }
+
+ # Check number of deleted points.
+ ndeleted = 0
+ do i = 1, npts {
+ if (wts[i] <= double(0.0))
+ ndeleted = ndeleted + 1
+ }
+ if ((npts - ndeleted) < in_geti(in, INLNFPARAMS)) {
+ call in_puti (in, INLFITERROR, NO_DEG_FREEDOM)
+ return
+ }
+
+ # Refit.
+ call nlfitd (nl, x, y, wts, npts, nvars, wtflag, ier)
+
+ # Store fit status in the INLFIT structure.
+ call in_puti (in, INLFITERROR, ier)
+end