aboutsummaryrefslogtreecommitdiff
path: root/math/nlfit/nlsolved.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /math/nlfit/nlsolved.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'math/nlfit/nlsolved.x')
-rw-r--r--math/nlfit/nlsolved.x37
1 files changed, 37 insertions, 0 deletions
diff --git a/math/nlfit/nlsolved.x b/math/nlfit/nlsolved.x
new file mode 100644
index 00000000..77a43337
--- /dev/null
+++ b/math/nlfit/nlsolved.x
@@ -0,0 +1,37 @@
+include <math/nlfit.h>
+include "nlfitdefd.h"
+
+# NLSOLVE -- Procedure to solve nonlinear system
+
+procedure nlsolved (nl, ier)
+
+pointer nl # pointer to the nlfit structure
+int ier # error code
+
+int nfree
+
+begin
+ # Make temporary arrays.
+ call amovd (ALPHA(NL_ALPHA(nl)), COVAR(NL_COVAR(nl)),
+ NL_NFPARAMS(nl) ** 2)
+ call amovd (BETA(NL_BETA(nl)), DPARAM(NL_DPARAM(nl)), NL_NFPARAMS(nl))
+
+ # Add the lambda damping factor.
+ call nl_dampd (COVAR(NL_COVAR(nl)), COVAR(NL_COVAR(nl)),
+ (1.0 + NL_LAMBDA(nl)), NL_NFPARAMS(nl), NL_NFPARAMS(nl))
+
+ ier = OK
+ nfree = NL_NPTS(nl) - NL_NFPARAMS(nl)
+ if (nfree < 0) {
+ ier = NO_DEG_FREEDOM
+ return
+ }
+
+ # Compute the factorization of the matrix.
+ call nl_chfacd (COVAR(NL_COVAR(nl)), NL_NFPARAMS(nl), NL_NFPARAMS(nl),
+ CHOFAC(NL_CHOFAC(nl)), ier)
+
+ # Solve the equations for the parameter increments.
+ call nl_chslvd (CHOFAC(NL_CHOFAC(nl)), NL_NFPARAMS(nl), NL_NFPARAMS(nl),
+ DPARAM(NL_DPARAM(nl)), DPARAM(NL_DPARAM(nl)))
+end