debian/0000775000000000000000000000000012317432406007172 5ustar debian/rules0000775000000000000000000000110212317432330010240 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 include /usr/share/dpkg/buildflags.mk ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) MAKEFLAGS += -j$(NUMJOBS) endif %: dh $@ --with=autoreconf override_dh_auto_configure: chmod +x configure # was added by Debian patch, so had wrong permissions dh_auto_configure override_dh_installdocs: dh_installdocs install -D -m 644 ex/file06 debian/minpack-dev/usr/share/doc/minpack-dev/minpack-documentation.txt debian/minpack-dev.manpages0000664000000000000000000000001312317310365013076 0ustar debian/*.3 debian/changelog0000664000000000000000000001412312317432375011052 0ustar minpack (19961126+dfsg1-2ubuntu1) trusty; urgency=medium * Use dh-autoreconf instead of autotools-dev to also fix FTBFS on ppc64el by getting new libtool macros (still updates config.{sub,guess}). -- Logan Rosen Fri, 04 Apr 2014 00:28:20 -0400 minpack (19961126+dfsg1-2) unstable; urgency=medium * Rewrite debian/rules using dh. * Inject compilation and linking flags from dpkg-buildflags. * Use autotools-dev to regenerate config.{sub,guess}. (Closes: #734575) * Multi-archify the package. * Remove incorrect dependency of minpack-dev on libc6-dev (the latter does not exist on !linux). * Add myself to Uploaders. * Bump to debhelper compat level 9. * Bump to Standards-Version 3.9.5. * Fix prototype of C function in tlmdif1.c example. (Closes: #698338) * Manpages: fix prototypes of C functions, and replace g77 by gfortran. -- Sébastien Villemot Thu, 03 Apr 2014 19:10:45 +0200 minpack (19961126+dfsg1-1) unstable; urgency=low * Team upload. * Correct repack of the archive * Adopt package in the Debian Science team (Closes: #636413) * Standards-Version updated to version 3.9.2 * Switch to dpkg-source 3.0 (quilt) format -- Sylvestre Ledru Wed, 03 Aug 2011 22:10:31 +0200 minpack (19961126-16) unstable; urgency=low * minpack.h: add guards for C++ compilers (thanks to Rene Wagner , Closes:Bug#527627) * debian/control: bump version to 3.8.1 (no changes needed) -- James R. Van Zandt Sat, 23 May 2009 16:06:41 -0400 minpack (19961126-15) unstable; urgency=low * revise man page (thanks to Jörgen Tegner, jorgen.tegner@telia.com, Closes:#510510) * debian/Makefile: update selftest script to extract numerical results from documentation. -- James R. Van Zandt Sat, 03 Jan 2009 09:58:26 -0500 minpack (19961126-14) unstable; urgency=low * recompile with gfortran 4.3.2 (Closes:#509278). Update "missing" script. * debian/doc-base: move documentation to section Science/Mathematics, to comply with new policy. * debian/rules: parse DEB_BUILD_OPTIONS * debian/control: bump policy version to 3.8.0 -- James R. Van Zandt Sat, 20 Dec 2008 12:49:38 -0500 minpack (19961126-13) unstable; urgency=low * Replace copyright notice (thanks to Bernd Zeimetz , closes:Bug#488299) * bumped policy version to 3.7.3 (no changes needed). -- James R. Van Zandt Mon, 07 Jul 2008 09:23:08 -0400 minpack (19961126-12) unstable; urgency=low * switch to gfortran (thanks to Aurelien Jarno , closes:Bug#430181) * debian/rules: set DH_COMPAT in debian/compat, not in debian/rules * debian/rules: catch errors in "make distclean" * debian/control: Source-Version -> binary:Version -- James R. Van Zandt Mon, 16 Jul 2007 21:12:58 -0400 minpack (19961126-11) unstable; urgency=low * configure.in: don't require automake or autoconf (thanks to Emanuele Rocca , closes:bug#394475,#395984) -- James R. Van Zandt Mon, 30 Oct 2006 20:10:10 -0500 minpack (19961126-10) unstable; urgency=low * debian/control: don't depend on automake or autoconf (not needed for building, closes:bug#394475) * debian/Makefile: Note that the minpack documentation includes sample numerical results. * config.guess, config.sub: update to version of 2006-07-02 -- James R. Van Zandt Sat, 28 Oct 2006 10:05:31 -0400 minpack (19961126-9) unstable; urgency=low * minpack.h: fix spelling fjac->fjec to match the code. * lmstr_.3: fix parameter list to match the code (thanks to Dennis Furey , closes:Bug#385632) * debian/rules: bumped debhelper compat level to 5 * debian/control: bumped debhelper depends version 5, added ${misc:Depends}, bumped policy version to 3.7.2 (no changes needed). -- James R. Van Zandt Mon, 4 Sep 2006 10:35:53 -0400 minpack (19961126-8) unstable; urgency=low * rebuild with updated libtool (thanks to Aurelien Jarno , closes:Bug#331450) -- James R. Van Zandt Sun, 16 Oct 2005 16:31:45 -0400 minpack (19961126-7) unstable; urgency=low * Fix package renaming (thanks to Aurelien Jarno , closes:Bug#331449) -- James R. Van Zandt Sun, 16 Oct 2005 16:20:26 -0400 minpack (19961126-6) unstable; urgency=low * Move doc-base registration from math to Apps/Math (closes:Bug#329962) * Makefile.am: Add to link flags: -D_REENTRANT,Wl,-z,defs per policy 10.2. * debian/control: Policy version 3.6.2. Changed runtime library package name from "minpack1" to "libminpack1". -- James R. Van Zandt Sat, 24 Sep 2005 22:44:08 -0400 minpack (19961126-5) unstable; urgency=low * debian/copyright: add upstream author email (with his permission). * /usr/share/doc/minpack-dev/examples/Makefile: C test programs generate binaries with names starting "tc". -- James R. Van Zandt Wed, 17 Apr 2002 19:52:42 -0400 minpack (19961126-4) unstable; urgency=low * debian/control: build-depend on autoconf and automake time. (closes:Bug#140689) -- James R. Van Zandt Fri, 12 Apr 2002 20:41:46 -0400 minpack (19961126-3) unstable; urgency=low * debian/rules: upload the fixed version this time (closes:Bug#139552) -- James R. Van Zandt Fri, 29 Mar 2002 22:05:44 -0500 minpack (19961126-2) unstable; urgency=low * debian/rules: since configure is added by the patch, we have to specifically give it execute permissions (closes:Bug#139552) -- James R. Van Zandt Sat, 23 Mar 2002 12:19:52 -0500 minpack (19961126-1) unstable; urgency=low * Initial Release. * autoconfiscated, automakified, and libtoolized the sources. * Added man pages for primary routines. * Added C header files for primary routines. * Reconstructed column 72 of ex/file06 from context. -- James R. Van Zandt Fri, 22 Feb 2002 20:29:59 -0500 debian/minpack-dev.docs0000664000000000000000000000000712317310365012236 0ustar readme debian/libminpack1.install0000664000000000000000000000002412317310365012747 0ustar usr/lib/*/lib*.so.* debian/minpack-dev.doc-base0000664000000000000000000000062512317310365012771 0ustar Document: minpack Title: Documentation for MINPACK Author: Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More Abstract: This file documents MINPACK. For each routine, it supplies the calling sequence, a simple example and its expected output, and an explanation of the numerical methods used. Section: Science/Mathematics Format: text Files: /usr/share/doc/minpack-dev/minpack-documentation.txt.gz debian/minpack-dev.examples0000664000000000000000000000003412317310365013124 0ustar debian/Makefile debian/t*.c debian/tlmdif.c0000664000000000000000000000375511766421452010635 0ustar /* driver for lmdif example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, int *iflag); int main() { int j, m, n, maxfev, mode, nprint, info, nfev, ldfjac; int ipvt[3]; double ftol, xtol, gtol, epsfcn, factor, fnorm; double x[3], fvec[15], diag[3], fjac[15*3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int one=1; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[1-1] = 1.; x[2-1] = 1.; x[3-1] = 1.; ldfjac = 15; /* set ftol and xtol to the square root of the machine */ /* and gtol to zero. unless high solutions are */ /* required, these are the recommended settings. */ ftol = sqrt(dpmpar_(&one)); xtol = sqrt(dpmpar_(&one)); gtol = 0.; maxfev = 800; epsfcn = 0.; mode = 1; factor = 1.e2; nprint = 0; lmdif_(&fcn, &m, &n, x, fvec, &ftol, &xtol, >ol, &maxfev, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = enorm_(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", fnorm); printf(" number of function evaluations%10i\n\n", nfev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *m, int *n, double *x, double *fvec, int *iflag) { /* subroutine fcn for lmdif example. */ int i; double tmp1, tmp2, tmp3; double y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag == 0) { /* insert print statements here when nprint is positive. */ return; } for (i = 1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } return; } debian/compat0000664000000000000000000000000212317310365010367 0ustar 9 debian/hybrd1_.30000664000000000000000000000002211766421452010606 0ustar .so man3/hybrd_.3 debian/thybrj.c0000664000000000000000000000444711766421452010657 0ustar /* driver for hybrj example. */ #include #include #include void fcn(int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag); int main() { int j, n, ldfjac, maxfev, mode, nprint, info, nfev, njev, lr; double xtol, factor, fnorm; double x[9], fvec[9], fjac[9*9], diag[9], r[45], qtf[9], wa1[9], wa2[9], wa3[9], wa4[9]; int one=1; n = 9; /* the following starting values provide a rough solution. */ for (j=1; j<=9; j++) { x[j-1] = -1.; } ldfjac = 9; lr = 45; /* set xtol to the square root of the machine precision. */ /* unless high solutions are required, */ /* this is the recommended setting. */ xtol = sqrt(dpmpar_(&one)); maxfev = 1000; mode = 2; for (j=1; j<=9; j++) { diag[j-1] = 1.; } factor = 1.e2; nprint = 0; hybrj_(&fcn, &n, x, fvec, fjac, &ldfjac, &xtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, r, &lr, qtf, wa1, wa2, wa3, wa4); fnorm = enorm_(&n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", fnorm); printf(" number of function evaluations%10i\n\n", nfev); printf(" number of jacobian evaluations%10i\n\n", njev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* subroutine fcn for hybrj example. */ int j, k; double one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; if (iflag == 0) { /* insert print statements here when nprint is positive. */ return; } if (*iflag != 2) { for (k=1; k <= *n; k++) { temp = (three - two*x[k-1])*x[k-1]; temp1 = zero; if (k != 1) temp1 = x[k-1-1]; temp2 = zero; if (k != *n) temp2 = x[k+1-1]; fvec[k-1] = temp - temp1 - two*temp2 + one; } } else { for (k = 1; k <= *n; k++) { for (j=1; j <= *n; j++) { fjac[k-1 + *ldfjac*(j-1)] = zero; } fjac[k-1 + *ldfjac*(k-1)] = three - four*x[k-1]; if (k != 1) fjac[k-1 + *ldfjac*(k-1-1)] = -one; if (k != *n) fjac[k-1 + *ldfjac*(k+1-1)] = -two; } } return; } debian/hybrj_.30000664000000000000000000002143712317307714010545 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH HYBRJ_ 3 "March 8, 2002" Minpack .\" Please adjust this date whenever revising the manpage. .SH NAME hybrj_, hybrj1_ \- find a zero of a system of nonlinear function .SH SYNOPSIS .B #include .nh .ad l .HP 14 .BI "void hybrj1_ (void (*" fcn ")(int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .BI "int *" iflag ), .RS 4 .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .br .BI "int *" ldfjac , .br .BI "double *" tol , .BI "int *" info , .BI "double *" wa , .BI "int *" lwa ); .RE .HP 13 .BI "void hybrj_ (void (*" fcn ")(int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .BI "int *" iflag ), .RS 4 .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .br .BI "int *" ldfjac , .br .BI "double *" xtol , .BI "int *" maxfev , .BI "double *" diag , .BI "int *" mode , .BI "double *" factor , .BI "int *" nprint , .BI "int *" info , .BI "int *" nfev , .br .BI "int *" njev , .BI "double *" r , .BI "int *" lr , .BI "double *" qtf , .br .BI "double *" wa1 , .BI "double *" wa2 , .BI "double *" wa3 , .BI "double *" wa4 ); .RE .hy .ad b .br .SH DESCRIPTION The purpose of \fBhybrj_\fP is to find a zero of a system of \fIn\fP nonlinear functions in \fIn\fP variables by a modification of the Powell hybrid method. The user must provide a subroutine which calculates the functions and a subroutine which calculates the Jacobian. .PP \fBhybrj1_\fP serves the same function but has a simplified calling sequence. .br .SS Language notes \fBhybrj_\fP and \fBhybrj1_\fP are written in FORTRAN. If calling from C, keep these points in mind: .TP Name mangling. With \fBgfortran\fP, all the function names end in an underscore. .TP Compile with \fBgfortran\fP. Even if your program is all C code, you should link with \fBgfortran\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBgfortran\fP to do all the compiling. (It handles C just fine.) .TP Call by reference. All function parameters must be pointers. .TP Column-major arrays. Suppose a function returns an array with 5 rows and 3 columns in an array \fIz\fP and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are: .sp .nf z(1,1) z[0] z(2,1) z[1] z(5,1) z[4] z(1,2) z[7] z(1,3) z[14] z(i,j) z[(i-1) + (j-1)*7] .fi .SS Parameters for both functions \fIfcn\fP is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, \fIfcn\fP must be declared in an external statement in the user calling program, and should be written as follows: .sp .nf subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) integer n,ldfjac,iflag double precision x(n),fvec(n),fjac(ldfjac,n) ---------- if iflag = 1 calculate the functions at x and return this vector in fvec. do not alter fjac. if iflag = 2 calculate the jacobian at x and return this matrix in fjac. do not alter fvec. --------- return end .fi .sp .sp In C, \fIfcn\fP should be written as follows: .sp .nf void fcn(int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* if iflag = 1 calculate the functions at x and return this vector in fvec. do not alter fjac. if iflag = 2 calculate the jacobian at x and return this matrix in fjac. do not alter fvec. */ } .fi .sp The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the user wants to terminate execution of hybrj_. In this case set \fIiflag\fP to a negative integer. \fIn\fP is a positive integer input variable set to the number of functions and variables. \fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain an initial estimate of the solution vector. On output \fIx\fP contains the final estimate of the solution vector. \fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the orthogonal matrix q produced by the qr factorization of the final approximate jacobian. \fIldfjac\fP is a positive integer input variable not less than \fIn\fP which specifies the leading dimension of the array \fIfjac\fP. \fIfvec\fP is an output array of length \fIn\fP which contains the functions evaluated at the output \fIx\fP. .br .SS Parameters for \fBhybrj1_\fP \fItol\fP is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP is an integer output variable. If the user has terminated execution, \fIinfo\fP is set to the (negative) value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 algorithm estimates that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP = 2 number of calls to fcn has reached or exceeded 200*(\fIn\fP+1). \fIinfo\fP = 3 \fItol\fP is too small. No further improvement in the approximate solution \fIx\fP is possible. \fIinfo\fP = 4 iteration is not making good progress. \fIwa\fP is a work array of length \fIlwa\fP. \fIlwa\fP is a positive integer input variable not less than (\fIn\fP*(3*\fIn\fP+13))/2. .br .SS Parameters for \fBhybrj_\fP \fIxtol\fP is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most \fIxtol\fP. \fImaxfev\fP is a positive integer input variable. Termination occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP by the end of an iteration. \fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP must contain positive entries that serve as multiplicative scale factors for the variables. \fImode\fP is an integer input variable. If \fImode\fP = 1, the variables will be scaled internally. If \fImode\fP = 2, the scaling is specified by the input \fIdiag\fP. Other values of mode are equivalent to \fImode\fP = 1. \fIfactor\fP is a positive input variable used in determining the initial step bound. This bound is set to the product of \fIfactor\fP and the euclidean norm of diag*x if nonzero, or else to \fIfactor\fP itself. In most cases factor should lie in the interval (.1,100.). 100. Is a generally recommended value. \fInprint\fP is an integer input variable that enables controlled printing of iterates if it is positive. In this case, \fIfcn\fP is called with \fIiflag\fP = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with \fIx\fP and \fIfvec\fP available for printing. If \fInprint\fP is not positive, no special calls of \fIfcn\fP with \fIiflag\fP = 0 are made. \fIinfo\fP is an integer output variable. If the user has terminated execution, \fIinfo\fP is set to the (negative) value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 relative error between two consecutive iterates is at most \fIxtol\fP. \fIinfo\fP = 2 number of calls to \fIfcn\fP has reached or exceeded \fImaxfev\fP. \fIinfo\fP = 3 \fIxtol\fP is too small. No further improvement in the approximate solution \fIx\fP is possible. \fIinfo\fP = 4 iteration is not making good progress, as measured by the improvement from the last five jacobian evaluations. \fIinfo\fP = 5 iteration is not making good progress, as measured by the improvement from the last ten iterations. \fInfev\fP is an integer output variable set to the number of calls to \fIfcn\fP. \fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the orthogonal matrix \fIq\fP produced by the \fIqr\fP factorization of the final approximate jacobian. \fIldfjac\fP is a positive integer input variable not less than \fIn\fP which specifies the leading dimension of the array \fIfjac\fP. \fIr\fP is an output array of length \fIlr\fP which contains the upper triangular matrix produced by the \fIqr\fP factorization of the final approximate Jacobian, stored rowwise. \fIlr\fP is a positive integer input variable not less than (\fIn\fP*(\fIn\fP+1))/2. \fIqtf\fP is an output array of length \fIn\fP which contains the vector (q transpose)*\fIfvec\fP. \fIwa1\fP, \fIwa2\fP, \fIwa3\fP, and \fIwa4\fP are work arrays of length \fIn\fP. .SH SEE ALSO .BR hybrd (3), .BR hybrd1 (3). .br .SH AUTHORS Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More. .br This manual page was written by Jim Van Zandt , for the Debian GNU/Linux system (but may be used by others). debian/extract0000664000000000000000000000064611766421452010603 0ustar #!/usr/bin/awk -f # extract - extract example drivers from minpack documentation file /DRIVER FOR [A-Z1]+ EXAMPLE/{ pgm=tolower($4); oname="t" pgm ".f"; $0 = substr($0,3); print >oname; do { getline; $0 = substr($0,3); if (!/^ +Page$/) print >>oname; } while (!/LAST CARD OF SUBROUTINE FCN/); getline; $0 = substr($0,3); print >>oname; getline; $0 = substr($0,3); print >>oname; } debian/lmstr_.30000664000000000000000000002644612317307656010602 0ustar .\" Hey, EMACS: -*- nroff -*- .TH LMSTR_ 3 "March 8, 2002" Minpack .\" Please adjust this date whenever revising the manpage. .SH NAME lmstr_, lmstr1_ \- minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage .SH SYNOPSIS .B include .nh .ad l .HP 28 .BI "void lmstr1_ ( " .BI "void (*" fcn ) .BI "(int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjrow , .BI "int *" iflag ), .RS 15 .BI "int *" m , .BI "int * " n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .br .BI "double *" tol , .BI "int *" info , .BI "int *" iwa , .br .BI "double *" wa , .BI "int *" kwa ); .RE .HP 27 .BI "void lmstr_" .BI "( void (*" fcn )( .BI "int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjrow , .BI "int *" iflag ), .RS 14 .BI "int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .br .BI "double *" ftol , .BI "double *" xtol , .BI "double *" gtol , .br .BI "int *" maxfev , .BI "double *" diag , .BI "int *" mode , .BI "double *" factor , .br .BI "int *" nprint , .BI "int *" info , .BI "int *" nfev , .BI "int *" njev , .br .BI "int *" ipvt , .BI "double *" qtf , .br .BI "double *" wa1 , .BI "double *" wa2 , .BI "double *" wa3 , .BI "double *" wa4 " );" .RE .hy .ad b .br .SH DESCRIPTION The purpose of \fBlmstr_\fP is to minimize the sum of the squares of \fIm\fP nonlinear functions in \fIn\fP variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a function which calculates the functions and the rows of the Jacobian. .PP \fBlmstr1_\fP performs the same function but has a simplified calling sequence. .PP \fBlmder\fP(3) and \fBlmder1\fP(3) perform the same function but do not attempt to minimize storage. .br .SS Language notes These functions are written in FORTRAN. If calling from C, keep these points in mind: .TP Name mangling. With \fBgfortran\fP, all the function names end in an underscore. .TP Compile with \fBgfortran\fP. Even if your program is all C code, you should link with \fBgfortran\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBgfortran\fP to do all the compiling. (It handles C just fine.) .TP Call by reference. All function parameters must be pointers. .TP Column-major arrays. Suppose a function returns an array with 5 rows and 3 columns in an array \fIz\fP and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are: .sp .nf z(1,1) z[0] z(2,1) z[1] z(5,1) z[4] z(1,2) z[7] z(1,3) z[14] z(i,j) z[(i-1) + (j-1)*7] .fi .br .SS User-supplied Function \fIfcn\fP is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, \fIfcn\fP must be declared in an external statement in the user calling program, and should be written as follows: .sp .nf subroutine fcn(m,n,x,fvec,fjrow,iflag) integer m,n,iflag double precision x(n),fvec(m),fjrow(n) ---------- if iflag = 1 calculate the functions at x and return this vector in fvec. Do not alter fjac. if iflag = i calculate row (i-1) of the Jacobian at x and return this vector in fjrow. ---------- return end .fi .sp In C, \fIfcn\fP should be written as follows: .sp .nf void fcn(int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag) { /* If iflag = 1 calculate the functions at x and return the values in fvec[0] through fvec[m-1]. Do not alter fjac. If iflag = i calculate row (i-1) of the Jacobian at x and return the vector in fjrow. */ } .fi .sp \fIiflag\fP is an input integer which specifies whether a function value or Jacobian row is to be calculated. The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the user wants to terminate execution of \fBlmstr_\fP (or \fBlmstr1_\fP). In this case set \fIiflag\fP to a negative integer. .br .SS Parameters for both \fBlmstr_\fP and \fBlmstr1_\fP \fIm\fP is a positive integer input variable set to the number of functions. \fIn\fP is a positive integer input variable set to the number of variables. \fIn\fP must not exceed \fIm\fP. \fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain an initial estimate of the solution vector. On output \fIx\fP contains the final estimate of the solution vector. \fIfvec\fP is an output array of length \fIm\fP which contains the functions evaluated at the output \fIx\fP. \fIfjrow\fP is an output array of length \fIn\fP which is set to one row of the Jacobian evaluated at \fIx\fP. \fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by \fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix \fBr\fP with diagonal elements of nonincreasing magnitude such that t t t p *(jac *jac)*p = r *r, where \fIp\fP is a permutation matrix and \fBjac\fP is the final calculated Jacobian. Column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower trapezoidal part of \fIfjac\fP contains information generated during the computation of \fBr\fP. \fIldfjac\fP is a positive integer input variable not less than \fIm\fP which specifies the leading dimension of the array \fIfjac\fP. .br .SS Parameters for \fBlmstr1_\fP \fItol\fP is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most \fItol\fP or that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP is an integer output variable. if the user has terminated execution, \fIinfo\fP is set to the (negative) value of iflag. see description of \fIfcn\fP. otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 algorithm estimates that the relative error in the sum of squares is at most \fItol\fP. \fIinfo\fP = 2 algorithm estimates that the relative error between x and the solution is at most \fItol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded 100*(\fIn\fP+1). \fIinfo\fP = 6 \fItol\fP is too small. no further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fItol\fP is too small. no further improvement in the approximate solution x is possible. \fIwa\fP is a work array of length \fIlwa\fP. \fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP + 5*\fIn\fP + \fIm\fP for \fBlmder1\fP, or 5*\fIn\fP+\fIm\fP for \fBlmstr1_\fP. .br .SS Parameters for \fBlmstr_\fP \fIftol\fP is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. Therefore, \fIftol\fP measures the relative error desired in the sum of squares. \fIxtol\fP is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the relative error desired in the approximate solution. \fIgtol\fP is a nonnegative input variable. Termination occurs when the cosine of the angle between \fIfvec\fP and any column of the Jacobian is at most \fIgtol\fP in absolute value. Therefore, \fIgtol\fP measures the orthogonality desired between the function vector and the columns of the Jacobian. \fImaxfev\fP is a positive integer input variable. Termination occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP by the end of an iteration. \fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP must contain positive entries that serve as multiplicative scale factors for the variables. \fImode\fP is an integer input variable. If \fImode\fP = 1, the variables will be scaled internally. If \fImode\fP = 2, the scaling is specified by the input \fIdiag\fP. Other values of mode are equivalent to \fImode\fP = 1. \fIfactor\fP is a positive input variable used in determining the initial step bound. This bound is set to the product of \fIfactor\fP and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is nonzero, or else to \fIfactor\fP itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value. \fInprint\fP is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with \fIiflag\fP = 0 at the beginning of the first iteration and every \fInprint\fP iterations thereafter and immediately prior to return, with \fIx\fP and \fIfvec\fP available for printing. If \fInprint\fP is not positive, no special calls of fcn with \fIiflag\fP = 0 are made. \fIinfo\fP is an integer output variable. If the user has terminated execution, info is set to the (negative) value of iflag. See description of fcn. Otherwise, info is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 both actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. \fIinfo\fP = 2 relative error between two consecutive iterates is at most \fIxtol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded maxfev. \fIinfo\fP = 6 \fIftol\fP is too small. No further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fIxtol\fP is too small. No further improvement in the approximate solution x is possible. \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fInfev\fP is an integer output variable set to the number of calls to \fIfcn\fP with \fIiflag\fP = 1. \fInjev\fP is an integer output variable set to the number of calls to fcn with \fIiflag\fP = 2. \fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP = \fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian, \fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular with diagonal elements of nonincreasing magnitude. Column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix. \fIqtf\fP is an output array of length \fIn\fP which contains the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP. \fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP. \fIwa4\fP is a work array of length \fIm\fP. .br .SH SEE ALSO .BR lmdif (3), .BR lmdif1 (3), .BR lmder (3), .BR lmder1 (3). .br .SH AUTHORS Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt , for the Debian GNU/Linux system (but may be used by others). debian/hybrj1_.30000664000000000000000000000002211766421452010614 0ustar .so man3/hybrj_.3 debian/copyright0000664000000000000000000000477611766421452011151 0ustar This package was debianized by Jim Van Zandt on Fri, 22 Feb 2002. The source code was downloaded from http://ftp.netlib.org/minpack The copyright notice was downloaded from http://ftp.netlib.org/minpack/disclaimer Upstream Authors: Jorge More' , Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. Copyright: Minpack Copyright Notice (1999) University of Chicago. All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the University of Chicago, as Operator of Argonne National Laboratory. Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED. 5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGES. debian/tlmstr1.c0000664000000000000000000000335311766421452010756 0ustar /* driver for lmstr1 example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag); int main() { int m, n, ldfjac, info, lwa, ipvt[3], one=1; double tol, fnorm; double x[3], fvec[15], fjac[9], wa[30]; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[1] = 1.; x[2] = 1.; x[3] = 1.; ldfjac = 3; lwa = 30; /* set tol to the square root of the machine precision. unless high precision solutions are required, this is the recommended setting. */ tol = sqrt(dpmpar_(&one)); lmstr1_(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &tol, &info, ipvt, wa, &lwa); fnorm = enorm_(&m, fvec); printf(" FINAL L2 NORM OF THE RESIDUALS%15.7g\n\n", fnorm); printf(" EXIT PARAMETER %10i\n\n", info); printf(" FINAL APPROXIMATE SOLUTION\n\n%15.7g%15.7g%15.7g\n", x[0], x[1], x[2]); return 0; } void fcn(int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag) { /* subroutine fcn for lmstr1 example. */ int i; double tmp1, tmp2, tmp3, tmp4; double y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag < 2) { for (i=1; i<=15; i++) { tmp1=i; tmp2 = 16-i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } } else { i = *iflag - 1; tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4; fjrow[1-1] = -1; fjrow[2-1] = tmp1*tmp2/tmp4; fjrow[3-1] = tmp1*tmp3/tmp4; } } debian/lmder_.30000664000000000000000000002622612317307731010532 0ustar .\" Hey, EMACS: -*- nroff -*- .TH LMDER_ 3 "March 8, 2002" Minpack .\" Please adjust this date whenever revising the manpage. .SH NAME lmder_, lmder1_ \- minimize the sum of squares of m nonlinear functions, with user supplied Jacobian .SH SYNOPSIS .B include .nh .ad l .HP 28 .BI "void lmder1_ ( " .BI "void (*" fcn ) .BI "(int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .br .BI "int *" ldfjac , .BI "int *" iflag ), .RS 15 .BI "int *" m , .BI "int * " n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .br .BI "double *" tol , .BI "int *" info , .BI "int *" iwa , .BI "double *" wa , .BI "int *" lwa ); .RE .HP 27 .BI "void lmder_" .BI "( void (*" fcn )( .BI "int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .br .BI "int *" ldfjac , .BI "int *" iflag ), .RS 14 .BI "int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .BI "double *" fjac , .BI "int *" ldfjac , .br .BI "double *" ftol , .BI "double *" xtol , .BI "double *" gtol , .BI "int *" maxfev , .BI "double *" diag , .BI "int *" mode , .br .BI "double *" factor , .BI "int *" nprint , .BI "int *" info , .br .BI "int *" nfev , .BI "int *" njev , .BI "int *" ipvt , .br .BI "double *" qtf , .BI "double *" wa1 , .BI "double *" wa2 , .BI "double *" wa3 , .BI "double *" wa4 " );" .RE .hy .ad b .br .SH DESCRIPTION The purpose of \fBlmder_\fP is to minimize the sum of the squares of \fIm\fP nonlinear functions in \fIn\fP variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a function which calculates the functions and the Jacobian. .PP \fBlmder1_\fP performs the same function as \fBlmder_\fP but has a simplified calling sequence. .PP \fBlmstr\fP and \fBlmstr1\fP also perform the same function but use minimal storage. .br .SS Language notes These functions are written in FORTRAN. If calling from C, keep these points in mind: .TP Name mangling. With \fBgfortran\fP, all the function names end in an underscore. .TP Compile with \fBgfortran\fP. Even if your program is all C code, you should link with \fBgfortran\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBgfortran\fP to do all the compiling. (It handles C just fine.) .TP Call by reference. All function parameters must be pointers. .TP Column-major arrays. Suppose a function returns an array with 5 rows and 3 columns in an array \fIz\fP and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are: .sp .nf z(1,1) z[0] z(2,1) z[1] z(5,1) z[4] z(1,2) z[7] z(1,3) z[14] z(i,j) z[(i-1) + (j-1)*7] .fi .br .SS User-supplied Function \fIfcn\fP is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, \fIfcn\fP must be declared in an external statement in the user calling program, and should be written as follows: .sp .nf subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) integer m,n,iflag double precision x(n),fvec(m),fjac(ldfjac,n) ---------- if iflag = 1 calculate the functions at x and return this vector in fvec. do not alter fjac. if iflag = 2 calculate the jacobian at x and return this matrix in fjac. do not alter fvec. ---------- return end .fi .sp In C, \fIfcn\fP should be written as follows: .sp .nf void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* if iflag = 1 calculate the functions at x and return this vector in fvec[0] through fvec[m-1]. do not alter fjac. if iflag = 2 calculate the jacobian at x and return this matrix in fjac. do not alter fvec. */ } .fi .sp The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the user wants to terminate execution of \fBlmder_\fP (or \fBlmder1_\fP). In this case set \fIiflag\fP to a negative integer. .br .SS Parameters for both \fBlmder_\fP and \fBlmder1_\fP \fIm\fP is a positive integer input variable set to the number of functions. \fIn\fP is a positive integer input variable set to the number of variables. \fIn\fP must not exceed \fIm\fP. \fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain an initial estimate of the solution vector. On output \fIx\fP contains the final estimate of the solution vector. \fIfvec\fP is an output array of length \fIm\fP which contains the functions evaluated at the output \fIx\fP. \fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by \fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix \fIr\fP with diagonal elements of nonincreasing magnitude such that t t t p *(jac *jac)*p = r *r, where \fIp\fP is a permutation matrix and \fIjac\fP is the final calculated Jacobian. column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower trapezoidal part of \fIfjac\fP contains information generated during the computation of \fIr\fP. \fIldfjac\fP is a positive integer input variable not less than \fIm\fP which specifies the leading dimension of the array \fIfjac\fP. .br .SS Parameters for \fBlmder1_\fP \fItol\fP is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most \fItol\fP or that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP is an integer output variable. if the user has terminated execution, \fIinfo\fP is set to the (negative) value of iflag. see description of \fIfcn\fP. otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 algorithm estimates that the relative error in the sum of squares is at most \fItol\fP. \fIinfo\fP = 2 algorithm estimates that the relative error between x and the solution is at most \fItol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded 200*(\fIn\fP+1). \fIinfo\fP = 6 \fItol\fP is too small. no further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fItol\fP is too small. no further improvement in the approximate solution x is possible. \fIiwa\fP is an integer work array of length \fIn\fP. \fIwa\fP is a work array of length \fIlwa\fP. \fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP + 5*\fIn\fP + \fIm\fP for \fBlmder1_\fP. .br .SS Parameters for \fBlmder_\fP \fIftol\fP is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. Therefore, \fIftol\fP measures the relative error desired in the sum of squares. \fIxtol\fP is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the relative error desired in the approximate solution. \fIgtol\fP is a nonnegative input variable. Termination occurs when the cosine of the angle between \fIfvec\fP and any column of the Jacobian is at most \fIgtol\fP in absolute value. Therefore, \fIgtol\fP measures the orthogonality desired between the function vector and the columns of the Jacobian. \fImaxfev\fP is a positive integer input variable. Termination occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP by the end of an iteration. \fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP must contain positive entries that serve as multiplicative scale factors for the variables. \fImode\fP is an integer input variable. If \fImode\fP = 1, the variables will be scaled internally. If \fImode\fP = 2, the scaling is specified by the input \fIdiag\fP. Other values of mode are equivalent to \fImode\fP = 1. \fIfactor\fP is a positive input variable used in determining the initial step bound. This bound is set to the product of \fIfactor\fP and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is nonzero, or else to \fIfactor\fP itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value. \fInprint\fP is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with \fIiflag\fP = 0 at the beginning of the first iteration and every \fInprint\fP iterations thereafter and immediately prior to return, with \fIx\fP and \fIfvec\fP available for printing. If \fInprint\fP is not positive, no special calls of fcn with \fIiflag\fP = 0 are made. \fIinfo\fP is an integer output variable. If the user has terminated execution, info is set to the (negative) value of iflag. See description of fcn. Otherwise, info is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 both actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. \fIinfo\fP = 2 relative error between two consecutive iterates is at most \fIxtol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded maxfev. \fIinfo\fP = 6 \fIftol\fP is too small. No further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fIxtol\fP is too small. No further improvement in the approximate solution x is possible. \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fInfev\fP is an integer output variable set to the number of calls to \fIfcn\fP with \fIiflag\fP = 1. \fInjev\fP is an integer output variable set to the number of calls to fcn with \fIiflag\fP = 2. \fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP = \fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian, \fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular with diagonal elements of nonincreasing magnitude. Column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix. \fIqtf\fP is an output array of length \fIn\fP which contains the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP. \fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP. \fIwa4\fP is a work array of length \fIm\fP. .br .SH SEE ALSO .BR lmdif (3), .BR lmdif1 (3), .BR lmstr (3), .BR lmstr1 (3). .br .SH AUTHORS Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt , for the Debian GNU/Linux system (but may be used by others). debian/source/0000775000000000000000000000000012317313421010465 5ustar debian/source/format0000664000000000000000000000001412317313351011675 0ustar 3.0 (quilt) debian/Makefile0000664000000000000000000000530111766421452010637 0ustar #!/usr/bin/make # Execute this script to extract the examples from the MINPACK # documentation # (/usr/share/doc/minpack-dev/minpack-documentation.txt.gz) and # compile and run them. It also extracts the numerical results from # the documentation and writes them to the file "documented". You may # compare those results with those printed by this script. PGM= thybrd1 thybrd thybrj1 thybrj tlmder1 tlmder tlmstr1 tlmstr \ tlmdif1 tlmdif tchkder CPGM=$(patsubst t%,tc%,$(PGM)) # tchybrd1 ... SRC=$(addsuffix .f,$(PGM)) # thybrd1.f ... CSRC=$(addsuffix .c,$(PGM)) # thybrd1.c ... all: ctest ftest documented ctest: ${CPGM} echo "--- C driver programs ---" for x in ${CPGM}; do echo $$x; ./$$x; done ftest: ${PGM} echo "--- FORTRAN driver programs ---" for x in ${PGM}; do echo $$x; ./$$x; done ${SRC} documented: /usr/share/doc/minpack-dev/minpack-documentation.txt.gz rm -f documented zcat $< | awk ' \ /DRIVER FOR [A-Z1]+ EXAMPLE/{ \ pgm=tolower($$4); \ oname="t" pgm ".f"; \ $$0 = substr($$0,3); \ print >oname; \ do { \ getline; $$0 = substr($$0,3); \ if (!/^ +Page$$/) print >>oname; \ } \ while (!/LAST CARD OF SUBROUTINE FCN/); \ getline; $$0 = substr($$0,3); print >>oname; \ getline; $$0 = substr($$0,3); print >>oname; \ } \ /may be slightly different/||/machine dependent/{ \ print pgm >>"documented"; \ while (getline) { \ $$0 = substr($$0,3); \ if (/Documentation/) break; \ if (!/^ +Page$$/ && !/^ *$$/) print >>"documented"; \ } \ }' tchkder: tchkder.f gfortran -o $@ $< -lminpack thybrd: thybrd.f gfortran -o $@ $< -lminpack thybrd1: thybrd1.f gfortran -o $@ $< -lminpack thybrj: thybrj.f gfortran -o $@ $< -lminpack thybrj1: thybrj1.f gfortran -o $@ $< -lminpack tlmder: tlmder.f gfortran -o $@ $< -lminpack tlmder1: tlmder1.f gfortran -o $@ $< -lminpack tlmdif: tlmdif.f gfortran -o $@ $< -lminpack tlmdif1: tlmdif1.f gfortran -o $@ $< -lminpack tlmstr: tlmstr.f gfortran -o $@ $< -lminpack tlmstr1: tlmstr1.f gfortran -o $@ $< -lminpack tcchkder: tchkder.c gfortran -o $@ $< -lminpack -lm tchybrd: thybrd.c gfortran -o $@ $< -lminpack -lm tchybrd1: thybrd1.c gfortran -o $@ $< -lminpack -lm tchybrj: thybrj.c gfortran -o $@ $< -lminpack -lm tchybrj1: thybrj1.c gfortran -o $@ $< -lminpack -lm tclmder: tlmder.c gfortran -o $@ $< -lminpack -lm tclmder1: tlmder1.c gfortran -o $@ $< -lminpack -lm tclmdif: tlmdif.c gfortran -o $@ $< -lminpack -lm tclmdif1: tlmdif1.c gfortran -o $@ $< -lminpack -lm tclmstr: tlmstr.c gfortran -o $@ $< -lminpack -lm tclmstr1: tlmstr1.c gfortran -o $@ $< -lminpack -lm debian/README.Debian0000664000000000000000000000123112317301074011224 0ustar minpack for Debian ------------------ These libraries are compiled from unchanged FORTRAN files downloaded from netlib. Since these are from FORTRAN files: - Use gfortran to compile programs to be linked against the library, even if only C files are being compiled. (Otherwise the linker will not be able to find the needed functions from the FORTRAN library). - When calling from C, all parameters must be pointers. - Two dimensional arrays are stored by column rather than by row. For an explanation of how the programs work, see /usr/share/doc/minpack-dev/minpack-documentation.txt -- Jim Van Zandt , Fri, 22 Feb 2002 20:29:59 -0500 debian/tlmder.c0000664000000000000000000000465711766421452010647 0ustar /* driver for lmder example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag); int main() { int j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; double ftol, xtol, gtol, factor, fnorm; double x[3], fvec[15], fjac[15*3], diag[3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int one=1; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[1-1] = 1.; x[2-1] = 1.; x[3-1] = 1.; ldfjac = 15; /* set ftol and xtol to the square root of the machine */ /* and gtol to zero. unless high solutions are */ /* required, these are the recommended settings. */ ftol = sqrt(dpmpar_(&one)); xtol = sqrt(dpmpar_(&one)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; lmder_(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &ftol, &xtol, >ol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = enorm_(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", fnorm); printf(" number of function evaluations%10i\n\n", nfev); printf(" number of Jacobian evaluations%10i\n\n", njev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* subroutine fcn for lmder example. */ int i; double tmp1, tmp2, tmp3, tmp4; double y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag == 0) { /* insert print statements here when nprint is positive. */ return; } if (*iflag != 2) { for (i=1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } } else { for (i=1; i<=15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4; fjac[i-1 + *ldfjac*(1-1)] = -1.; fjac[i-1 + *ldfjac*(2-1)] = tmp1*tmp2/tmp4; fjac[i-1 + *ldfjac*(3-1)] = tmp1*tmp3/tmp4; }; } return; } debian/tlmdif1.c0000664000000000000000000000245612317307220010700 0ustar /* driver for lmdif1 example. */ #include #include #include int main() { int m, n, info, lwa, iwa[3], one=1; double tol, fnorm, x[3], fvec[15], wa[75]; extern void fcn(); m = 15; n = 3; /* the following starting values provide a rough fit. */ x[0] = 1.e0; x[1] = 1.e0; x[2] = 1.e0; lwa = 75; /* set tol to the square root of the machine precision. unless high precision solutions are required, this is the recommended setting. */ tol = sqrt(dpmpar_(&one)); lmdif1_(&fcn, &m, &n, x, fvec, &tol, &info, iwa, wa, &lwa); fnorm = enorm_(&m, fvec); printf(" FINAL L2 NORM OF THE RESIDUALS%15.7f\n\n",fnorm); printf(" EXIT PARAMETER %10i\n\n", info); printf(" FINAL APPROXIMATE SOLUTION\n\n %15.7f%15.7f%15.7f\n", x[0], x[1], x[2]); return 0; } void fcn(int *m, int *n, double *x, double *fvec, int *iflag) { /* function fcn for lmdif1 example */ int i; double tmp1,tmp2,tmp3; double y[15]={1.4e-1,1.8e-1,2.2e-1,2.5e-1,2.9e-1,3.2e-1,3.5e-1,3.9e-1, 3.7e-1,5.8e-1,7.3e-1,9.6e-1,1.34e0,2.1e0,4.39e0}; for (i=0; i<15; i++) { tmp1 = i+1; tmp2 = 15 - i; tmp3 = tmp1; if (i >= 8) tmp3 = tmp2; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } debian/minpack-dev.install0000664000000000000000000000006112317310365012754 0ustar usr/include/* usr/lib/*/lib*.a usr/lib/*/lib*.so debian/lmder1_.30000664000000000000000000000002211766421452010601 0ustar .so man3/lmder_.3 debian/patch0000664000000000000000000000177611766421452010235 0ustar --- hybrj_.3.orig 2009-01-02 18:19:15.000000000 +0100 +++ hybrj_.3 2009-01-02 18:23:47.000000000 +0100 @@ -14,7 +14,7 @@ .BI "void hybrj1_ (void (*" fcn ")(int *" n , .BI "double *" x , .BI "double *" fvec , -.BI "double *" fjec , +.BI "double *" fjac , .BI "int *" ldfjac , .BI "int *" iflag ), .RS 4 @@ -35,7 +35,7 @@ .BI "void hybrj_ (void (*" fcn ")(int *" n , .BI "double *" x , .BI "double *" fvec , -.BI "double *" fjec , +.BI "double *" fjac , .BI "int *" ldfjac , .BI "int *" iflag ), .RS 4 @@ -72,8 +72,8 @@ The purpose of \fBhybrj_\fP is to find a zero of a system of \fIn\fP nonlinear functions in \fIn\fP variables by a modification of the Powell hybrid method. The user must provide a -subroutine which calculates the functions. The Jacobian is -then calculated by a forward-difference approximation. +subroutine which calculates the functions and a subroutine which calculates +the Jacobian. .PP \fBhybrj1_\fP serves the same function but has a simplified calling sequence. debian/tchkder.c0000664000000000000000000000424311766421452010773 0ustar /* driver for chkder example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag); int main() { int i, m, n, ldfjac, mode; double x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], err[15]; int one=1, two=2; m = 15; n = 3; /* the following values should be suitable for */ /* checking the jacobian matrix. */ x[1-1] = 9.2e-1; x[2-1] = 1.3e-1; x[3-1] = 5.4e-1; ldfjac = 15; mode = 1; chkder_(&m, &n, x, fvec, fjac, &ldfjac, xp, fvecp, &mode, err); mode = 2; fcn(&m, &n, x, fvec, fjac, &ldfjac, &one); fcn(&m, &n, x, fvec, fjac, &ldfjac, &two); fcn(&m, &n, xp, fvecp, fjac, &ldfjac, &one); chkder_(&m, &n, x, fvec, fjac, &ldfjac, xp, fvecp, &mode, err); for (i=1; i<=m; i++) { fvecp[i-1] = fvecp[i-1] - fvec[i-1]; } printf("\n fvec\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", fvec[i-1]); printf("\n fvecp - fvec\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", fvecp[i-1]); printf("\n err\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", err[i-1]); printf("\n"); return 0; } void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* subroutine fcn for chkder example. */ int i; double tmp1, tmp2, tmp3, tmp4; double y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag != 2) for (i=1; i<=15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } else { for (i = 1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; /* error introduced into next statement for illustration. */ /* corrected statement should read tmp3 = tmp1 . */ tmp3 = tmp2; if (i > 8) tmp3 = tmp2; tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4; fjac[i-1+ *ldfjac*(1-1)] = -1.; fjac[i-1+ *ldfjac*(2-1)] = tmp1*tmp2/tmp4; fjac[i-1+ *ldfjac*(3-1)] = tmp1*tmp3/tmp4; } } return; } debian/lmstr1_.30000664000000000000000000000002211766421452010637 0ustar .so man3/lmstr_.3 debian/thybrd.c0000664000000000000000000000366011766421452010645 0ustar /* driver for hybrd example. */ #include #include #include void fcn(int *n, double *x, double *fvec, int *iflag); int main() { int j, n, maxfev, ml, mu, mode, nprint, info, nfev, ldfjac, lr; double xtol, epsfcn, factor, fnorm; double x[9], fvec[9], diag[9], fjac[9*9], r[45], qtf[9], wa1[9], wa2[9], wa3[9], wa4[9]; int one=1; n = 9; /* the following starting values provide a rough solution. */ for (j=1; j<=9; j++) { x[j-1] = -1.; } ldfjac = 9; lr = 45; /* set xtol to the square root of the machine precision. */ /* unless high solutions are required, */ /* this is the recommended setting. */ xtol = sqrt(dpmpar_(&one)); maxfev = 2000; ml = 1; mu = 1; epsfcn = 0.; mode = 2; for (j=1; j<=9; j++) { diag[j-1] = 1.; } factor = 1.e2; nprint = 0; hybrd_(&fcn, &n, x, fvec, &xtol, &maxfev, &ml, &mu, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, r, &lr, qtf, wa1, wa2, wa3, wa4); fnorm = enorm_(&n, fvec); printf(" final l2 norm of the residuals %15.7g\n\n", fnorm); printf(" number of function evaluations %10i\n\n", nfev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *n, double *x, double *fvec, int *iflag) { /* subroutine fcn for hybrd example. */ int k; double one=1, temp, temp1, temp2, three=3, two=2, zero=0; if (iflag == 0) { /* insert print statements here when nprint is positive. */ return; } for (k=1; k<=*n; k++) { temp = (three - two*x[k-1])*x[k-1]; temp1 = zero; if (k != 1) temp1 = x[k-1-1]; temp2 = zero; if (k != *n) temp2 = x[k+1-1]; fvec[k-1] = temp - temp1 - two*temp2 + one; } return; } debian/lmdif_.30000664000000000000000000002520712317307745010525 0ustar .\" Hey, EMACS: -*- nroff -*- .TH LMDIF_ 3 "March 8, 2002" Minpack .\" Please adjust this date whenever revising the manpage. .SH NAME lmdif_, lmdif1_ \- minimize the sum of squares of m nonlinear functions .SH SYNOPSIS .B include .nh .ad l .HP 15 .BI "void lmdif1_ ( " .BI "void (*" fcn ")(int *" m ", int *" n ", double *" x , .BI "double *" fvec ", int *" iflag ), .RS 2 .BI "int *" m , .BI "int * " n , .BI "double *" x , .BI "double *" fvec , .br .BI "double *" tol , .BI "int *" info , .BI "int *" iwa , .BI "double *" wa , .BI "int *" lwa ); .RE .HP 14 .BI "void lmdif_" .BI "( void (*" fcn ")(int *" m ", int *" n ", double *" x , .BI "double *" fvec ", int *" iflag ), .RS 2 .BI "int *" m , .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .br .BI "double *" ftol , .BI "double *" xtol , .BI "double *" gtol , .BI "int *" maxfev , .BI "double *" epsfcn , .BI "double *" diag , .BI "int *" mode , .BI "double *" factor , .BI "int *" nprint , .BI "int *" info , .BI "int *" nfev , .BI "double *" fjac , .br .BI "int *" ldfjac , .BI "int *" ipvt , .BI "double *" qtf , .br .BI "double *" wa1 , .BI "double *" wa2 , .BI "double *" wa3 , .BI "double *" wa4 " );" .RE .hy .ad b .br .SH DESCRIPTION The purpose of \fBlmdif_\fP is to minimize the sum of the squares of \fIm\fP nonlinear functions in \fIn\fP variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a subroutine which calculates the functions. The Jacobian is then calculated by a forward-difference approximation. \fBlmdif1_\fP serves the same purpose but has a simplified calling sequence. .br .SS Language notes These functions are written in FORTRAN. If calling from C, keep these points in mind: .TP Name mangling. With \fBgfortran\fP, all the function names end in an underscore. .TP Compile with \fBgfortran\fP. Even if your program is all C code, you should link with \fBgfortran\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBgfortran\fP to do all the compiling. (It handles C just fine.) .TP Call by reference. All function parameters must be pointers. .TP Column-major arrays. Suppose a function returns an array with 5 rows and 3 columns in an array \fIz\fP and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are: .sp .nf z(1,1) z[0] z(2,1) z[1] z(5,1) z[4] z(1,2) z[7] z(1,3) z[14] z(i,j) z[(i-1) + (j-1)*7] .fi .br \fIfcn\fP is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, \fIfcn\fP must be declared in an external statement in the user calling program, and should be written as follows: .sp .nf subroutine fcn(m,n,x,fvec,iflag) integer m,n,iflag double precision x(n),fvec(m) ---------- calculate the functions at x and return this vector in fvec. ---------- return end .fi .sp In C, \fIfcn\fP should be written as follows: .sp .nf void fcn(int *m, int *n, double *x, double *fvec, int *iflag) { /* calculate the functions at x and return the values in fvec[0] through fvec[m-1] */ } .fi .sp The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the user wants to terminate execution of \fBlmdif_\fP (or \fBlmdif1_\fP). In this case set \fIiflag\fP to a negative integer. .br .SS Parameters for both \fBlmdif_\fP and \fBlmdif1_\fP \fIm\fP is a positive integer input variable set to the number of functions. \fIn\fP is a positive integer input variable set to the number of variables. \fIn\fP must not exceed \fIm\fP. \fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain an initial estimate of the solution vector. On output \fIx\fP contains the final estimate of the solution vector. \fIfvec\fP is an output array of length \fIm\fP which contains the functions evaluated at the output \fIx\fP. .br .SS Parameters for \fBlmdif1_\fP \fItol\fP is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most \fItol\fP or that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP is an integer output variable. if the user has terminated execution, \fIinfo\fP is set to the (negative) value of iflag. see description of \fIfcn\fP. otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 algorithm estimates that the relative error in the sum of squares is at most \fItol\fP. \fIinfo\fP = 2 algorithm estimates that the relative error between x and the solution is at most \fItol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded 200*(\fIn\fP+1). \fIinfo\fP = 6 \fItol\fP is too small. no further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fItol\fP is too small. no further improvement in the approximate solution x is possible. \fIiwa\fP is an integer work array of length \fIn\fP. \fIwa\fP is a work array of length \fIlwa\fP. \fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP + 5*\fIn\fP + \fIm\fP. .br .SS Parameters for \fBlmdif_\fP \fIftol\fP is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. Therefore, \fIftol\fP measures the relative error desired in the sum of squares. \fIxtol\fP is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the relative error desired in the approximate solution. \fIgtol\fP is a nonnegative input variable. Termination occurs when the cosine of the angle between \fIfvec\fP and any column of the Jacobian is at most \fIgtol\fP in absolute value. Therefore, \fIgtol\fP measures the orthogonality desired between the function vector and the columns of the Jacobian. \fImaxfev\fP is a positive integer input variable. Termination occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP by the end of an iteration. \fIepsfcn\fP is an input variable used in determining a suitable step length for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of \fIepsfcn\fP. If \fIepsfcn\fP is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision. \fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP must contain positive entries that serve as multiplicative scale factors for the variables. \fImode\fP is an integer input variable. If \fImode\fP = 1, the variables will be scaled internally. If \fImode\fP = 2, the scaling is specified by the input \fIdiag\fP. Other values of mode are equivalent to \fImode\fP = 1. \fIfactor\fP is a positive input variable used in determining the initial step bound. This bound is set to the product of \fIfactor\fP and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is nonzero, or else to \fIfactor\fP itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value. \fInprint\fP is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with \fIiflag\fP = 0 at the beginning of the first iteration and every \fInprint\fP iterations thereafter and immediately prior to return, with \fIx\fP and \fIfvec\fP available for printing. If \fInprint\fP is not positive, no special calls of fcn with \fIiflag\fP = 0 are made. \fIinfo\fP is an integer output variable. If the user has terminated execution, info is set to the (negative) value of iflag. See description of fcn. Otherwise, info is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 both actual and predicted relative reductions in the sum of squares are at most \fIftol\fP. \fIinfo\fP = 2 relative error between two consecutive iterates is at most \fIxtol\fP. \fIinfo\fP = 3 conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold. \fIinfo\fP = 4 the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. \fIinfo\fP = 5 number of calls to \fIfcn\fP has reached or exceeded maxfev. \fIinfo\fP = 6 \fIftol\fP is too small. No further reduction in the sum of squares is possible. \fIinfo\fP = 7 \fIxtol\fP is too small. No further improvement in the approximate solution x is possible. \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to the columns of the Jacobian to machine precision. \fInfev\fP is an integer output variable set to the number of calls to \fIfcn\fP. \fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by \fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix \fIr\fP with diagonal elements of nonincreasing magnitude such that t t t p *(jac *jac)*p = r *r, where \fIp\fP is a permutation matrix and \fIjac\fP is the final calculated Jacobian. column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower trapezoidal part of \fIfjac\fP contains information generated during the computation of \fIr\fP. \fIldfjac\fP is a positive integer input variable not less than \fIm\fP which specifies the leading dimension of the array \fIfjac\fP. \fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP = \fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian, \fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular with diagonal elements of nonincreasing magnitude. Column \fBj\fP of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix. \fIqtf\fP is an output array of length \fIn\fP which contains the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP. \fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP. \fIwa4\fP is a work array of length \fIm\fP. .br .SH SEE ALSO .BR lmder (3), .BR lmder1 (3), .BR lmstr (3), .BR lmstr1 (3). .br .SH AUTHORS Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt , for the Debian GNU/Linux system (but may be used by others). debian/tlmder1.c0000664000000000000000000000360511766421452010720 0ustar /* driver for lmder1 example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag); int main() { int j, m, n, ldfjac, info, lwa; int ipvt[3]; double tol, fnorm; double x[3], fvec[15], fjac[15*3], wa[30]; int one=1; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[1-1] = 1.; x[2-1] = 1.; x[3-1] = 1.; ldfjac = 15; lwa = 30; /* set tol to the square root of the machine precision. */ /* unless high solutions are required, */ /* this is the recommended setting. */ tol = sqrt(dpmpar_(&one)); lmder1_(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &tol, &info, ipvt, wa, &lwa); fnorm = enorm_(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* subroutine fcn for lmder1 example. */ int i; double tmp1, tmp2, tmp3, tmp4; double y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag != 2) { for (i = 1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } } else { for ( i = 1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4; fjac[i-1 + *ldfjac*(1-1)] = -1.; fjac[i-1 + *ldfjac*(2-1)] = tmp1*tmp2/tmp4; fjac[i-1 + *ldfjac*(3-1)] = tmp1*tmp3/tmp4; } } } debian/tlmstr.c0000664000000000000000000000451311766421452010674 0ustar /* driver for lmstr example. */ #include #include #include void fcn(int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag); int main() { int j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; double ftol, xtol, gtol, factor, fnorm; double x[3], fvec[15], fjac[3*3], diag[3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int one=1; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[1-1] = 1.; x[2-1] = 1.; x[3-1] = 1.; ldfjac = 3; /* set ftol and xtol to the square root of the machine */ /* and gtol to zero. unless high solutions are */ /* required, these are the recommended settings. */ ftol = sqrt(dpmpar_(&one)); xtol = sqrt(dpmpar_(&one)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; lmstr_(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &ftol, &xtol, >ol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = enorm_(&m, fvec); printf(" final L2 norm of the residuals%15.7g\n\n", fnorm); printf(" number of function evaluations%10i\n\n", nfev); printf(" number of Jacobian evaluations%10i\n\n", njev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag) { /* subroutine fcn for lmstr example. */ int i; double tmp1, tmp2, tmp3, tmp4; double y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; if (*iflag == 0) { /* insert print statements here when nprint is positive. */ return; } if (*iflag < 2) { for (i = 1; i <= 15; i++) { tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } } else { i = *iflag - 1; tmp1 = i; tmp2 = 16 - i; tmp3 = tmp1; if (i > 8) tmp3 = tmp2; tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4; fjrow[1-1] = -1.; fjrow[2-1] = tmp1*tmp2/tmp4; fjrow[3-1] = tmp1*tmp3/tmp4; } return; } debian/thybrj1.c0000664000000000000000000000345711766421452010740 0ustar /* driver for hybrj1 example. */ #include #include #include void fcn(int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag); int main() { int j, n, ldfjac, info, lwa; double tol, fnorm; double x[9], fvec[9], fjac[9*9], wa[99]; int one=1; n = 9; /* the following starting values provide a rough solution. */ for (j=1; j<=9; j++) { x[j-1] = -1.; } ldfjac = 9; lwa = 99; /* set tol to the square root of the machine precision. */ /* unless high solutions are required, */ /* this is the recommended setting. */ tol = sqrt(dpmpar_(&one)); hybrj1_(&fcn, &n, x, fvec, fjac, &ldfjac, &tol, &info, wa, &lwa); fnorm = enorm_(&n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *n, double *x, double *fvec, double *fjac, int *ldfjac, int *iflag) { /* subroutine fcn for hybrj1 example. */ int j, k; double one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; if (*iflag != 2) { for (k = 1; k <= *n; k++) { temp = (three - two*x[k-1])*x[k-1]; temp1 = zero; if (k != 1) temp1 = x[k-1-1]; temp2 = zero; if (k != *n) temp2 = x[k+1-1]; fvec[k-1] = temp - temp1 - two*temp2 + one; } } else { for (k = 1; k <= *n; k++) { for (j = 1; j <= *n; j++) { fjac[k-1 + *ldfjac*(j-1)] = zero; } fjac[k-1 + *ldfjac*(k-1)] = three - four*x[k-1]; if (k != 1) fjac[k-1 + *ldfjac*(k-1-1)] = -one; if (k != *n) fjac[k-1 + *ldfjac*(k+1-1)] = -two; } } return; } debian/lmdif1_.30000664000000000000000000000002211766421452010571 0ustar .so man3/lmdif_.3 debian/control0000664000000000000000000000422712317432377010611 0ustar Source: minpack Section: devel Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Debian Science Team Uploaders: Sébastien Villemot Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), dh-autoreconf, gfortran, libtool Standards-Version: 3.9.5 Homepage: http://www.netlib.org/minpack/ Vcs-Svn: svn://svn.debian.org/svn/debian-science/packages/minpack/trunk/ Vcs-Browser: http://svn.debian.org/viewsvn/debian-science/packages/minpack/trunk/ Package: minpack-dev Architecture: any Multi-Arch: same Depends: libminpack1 (= ${binary:Version}), ${misc:Depends} Description: nonlinear equations and nonlinear least squares static library Minpack includes software for solving nonlinear equations and nonlinear least squares problems. Five algorithmic paths each include a core subroutine and an easy-to-use driver. The algorithms proceed either from an analytic specification of the Jacobian matrix or directly from the problem functions. The paths include facilities for systems of equations with a banded Jacobian matrix, for least squares problems with a large amount of data, and for checking the consistency of the Jacobian matrix with the functions. . This package provides the headers, man pages, examples, and static library. Package: libminpack1 Section: libs Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Description: nonlinear equations and nonlinear least squares shared library Minpack includes software for solving nonlinear equations and nonlinear least squares problems. Five algorithmic paths each include a core subroutine and an easy-to-use driver. The algorithms proceed either from an analytic specification of the Jacobian matrix or directly from the problem functions. The paths include facilities for systems of equations with a banded Jacobian matrix, for least squares problems with a large amount of data, and for checking the consistency of the Jacobian matrix with the functions. . This package provides the shared library. debian/hybrd_.30000664000000000000000000002163712317307677010551 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH HYBRD_ 3 "March 8, 2002" Minpack .\" Please adjust this date whenever revising the manpage. .SH NAME hybrd_, hybrd1_ \- find a zero of a system of nonlinear function .SH SYNOPSIS .B #include .sp .nh .ad l .HP 28 .BI "void hybrd1_ ( " .BI "void (*" fcn ")(" .BI "int *" n , .BI "double *" x , .br .BI "double *" fvec , .BI "int *" iflag ), .RS 15 .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .br .BI "double *" tol , .BI "int *" info , .BI "double *" wa , .br .BI "int *" lwa ); .RE .HP 27 .BI "void hybrd_" .BI "( void (*" fcn ")(" .BI "int * " n , .BI "double *" x , .br .BI "double *" fvec , .BI "int *" iflag ), .RS 14 .BI "int *" n , .BI "double *" x , .BI "double *" fvec , .br .BI "double *" xtol , .BI "int *" maxfev , .BI "int *" ml , .BI "int *" mu , .br .BI "double *" epsfcn , .BI "double *" diag , .BI "int *" mode , .BI "double *" factor , .BI "int *" nprint , .BI "int *" info , .br .BI "int *" nfev , .BI "double *" fjac , .BI "int *" ldfjac , .br .BI "double *" r , .BI "int *" lr , .BI "double *" qtf , .br .BI "double *" wa1 , .BI "double *" wa2 , .BI "double *" wa3 , .BI "double *" wa4 ); .RE .hy .ad b .br .SH DESCRIPTION The purpose of \fBhybrd_\fP is to find a zero of a system of \fIn\fP nonlinear functions in \fIn\fP variables by a modification of the Powell hybrid method. The user must provide a subroutine which calculates the functions. The Jacobian is then calculated by a forward-difference approximation. .PP \fBhybrd1_\fP serves the same function but has a simplified calling sequence. .br .SS Language notes \fBhybrd_\fP and \fBhybrd1_\fP are written in FORTRAN. If calling from C, keep these points in mind: .TP Name mangling. With \fBgfortran\fP, all the function names end in an underscore. .TP Compile with \fBgfortran\fP. Even if your program is all C code, you should link with \fBgfortran\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBgfortran\fP to do all the compiling. (It handles C just fine.) .TP Call by reference. All function parameters must be pointers. .TP Column-major arrays. Suppose a function returns an array with 5 rows and 3 columns in an array \fIz\fP and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are: .sp .nf z(1,1) z[0] z(2,1) z[1] z(5,1) z[4] z(1,2) z[7] z(1,3) z[14] z(i,j) z[(i-1) + (j-1)*7] .fi .SS Parameters for both functions \fIfcn\fP is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, \fIfcn\fP must be declared in an external statement in the user calling program, and should be written as follows: .sp .nf subroutine fcn(n,x,fvec,iflag) integer n,iflag double precision x(n),fvec(n) ---------- calculate the functions at x and return this vector in fvec. --------- return end .fi .sp .sp In C, \fIfcn\fP should be written as follows: .sp .nf void fcn(int *n, double *x, double *fvec, int *iflag) { /* calculate the functions at x and return this vector in fvec. */ } .fi .sp The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the user wants to terminate execution of \fBhybrd_\fP. In this case set \fIiflag\fP to a negative integer. \fIn\fP is a positive integer input variable set to the number of functions and variables. \fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain an initial estimate of the solution vector. On output \fIx\fP contains the final estimate of the solution vector. \fIfvec\fP is an output array of length \fIn\fP which contains the functions evaluated at the output \fIx\fP. .br .SS Parameters for \fBhybrd1_\fP \fItol\fP is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP is an integer output variable. If the user has terminated execution, \fIinfo\fP is set to the (negative) value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 algorithm estimates that the relative error between \fIx\fP and the solution is at most \fItol\fP. \fIinfo\fP = 2 number of calls to fcn has reached or exceeded 200*(\fIn\fP+1). \fIinfo\fP = 3 \fItol\fP is too small. No further improvement in the approximate solution \fIx\fP is possible. \fIinfo\fP = 4 iteration is not making good progress. \fIwa\fP is a work array of length \fIlwa\fP. \fIlwa\fP is a positive integer input variable not less than (\fIn\fP*(3*\fIn\fP+13))/2. .br .SS Parameters for \fBhybrd_\fP \fIxtol\fP is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most \fIxtol\fP. \fImaxfev\fP is a positive integer input variable. Termination occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP by the end of an iteration. \fIml\fP is a nonnegative integer input variable which specifies the number of subdiagonals within the band of the jacobian matrix. If the Jacobian is not banded, set \fIml\fP to at least \fIn\fP - 1. \fImu\fP is a nonnegative integer input variable which specifies the number of superdiagonals within the band of the jacobian matrix. If the jacobian is not banded, set mu to at least \fIn\fP - 1. \fIepsfcn\fP is an input variable used in determining a suitable step length for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of \fIepsfcn\fP. If \fIepsfcn\fP is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision. \fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP must contain positive entries that serve as multiplicative scale factors for the variables. \fImode\fP is an integer input variable. If \fImode\fP = 1, the variables will be scaled internally. If \fImode\fP = 2, the scaling is specified by the input \fIdiag\fP. Other values of mode are equivalent to \fImode\fP = 1. \fIfactor\fP is a positive input variable used in determining the initial step bound. This bound is set to the product of \fIfactor\fP and the euclidean norm of diag*x if nonzero, or else to \fIfactor\fP itself. In most cases factor should lie in the interval (.1,100.). 100. Is a generally recommended value. \fInprint\fP is an integer input variable that enables controlled printing of iterates if it is positive. In this case, \fIfcn\fP is called with \fIiflag\fP = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with \fIx\fP and \fIfvec\fP available for printing. If \fInprint\fP is not positive, no special calls of \fIfcn\fP with \fIiflag\fP = 0 are made. \fIinfo\fP is an integer output variable. If the user has terminated execution, \fIinfo\fP is set to the (negative) value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise, \fIinfo\fP is set as follows. \fIinfo\fP = 0 improper input parameters. \fIinfo\fP = 1 relative error between two consecutive iterates is at most \fIxtol\fP. \fIinfo\fP = 2 number of calls to \fIfcn\fP has reached or exceeded \fImaxfev\fP. \fIinfo\fP = 3 \fIxtol\fP is too small. No further improvement in the approximate solution \fIx\fP is possible. \fIinfo\fP = 4 iteration is not making good progress, as measured by the improvement from the last five jacobian evaluations. \fIinfo\fP = 5 iteration is not making good progress, as measured by the improvement from the last ten iterations. \fInfev\fP is an integer output variable set to the number of calls to \fIfcn\fP. \fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the orthogonal matrix \fIq\fP produced by the \fIqr\fP factorization of the final approximate jacobian. \fIldfjac\fP is a positive integer input variable not less than \fIn\fP which specifies the leading dimension of the array \fIfjac\fP. \fIr\fP is an output array of length \fIlr\fP which contains the upper triangular matrix produced by the \fIqr\fP factorization of the final approximate Jacobian, stored rowwise. \fIlr\fP is a positive integer input variable not less than (\fIn\fP*(\fIn\fP+1))/2. \fIqtf\fP is an output array of length \fIn\fP which contains the vector (q transpose)*\fIfvec\fP. \fIwa1\fP, \fIwa2\fP, \fIwa3\fP, and \fIwa4\fP are work arrays of length \fIn\fP. .SH SEE ALSO .BR hybrj (3), .BR hybrj1 (3). .br .SH AUTHORS Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More. .br This manual page was written by Jim Van Zandt , for the Debian GNU/Linux system (but may be used by others). debian/thybrd1.c0000664000000000000000000000254311766421452010725 0ustar /* driver for hybrd1 example. */ #include #include #include void fcn(int *n, double *x, double *fvec, int *iflag); int main() { int j, n, info, lwa; double tol, fnorm; double x[9], fvec[9], wa[180]; int one=1; n = 9; /* the following starting values provide a rough solution. */ for (j=1; j<=9; j++) { x[j-1] = -1.; } lwa = 180; /* set tol to the square root of the machine precision. */ /* unless high solutions are required, */ /* this is the recommended setting. */ tol = sqrt(dpmpar_(&one)); hybrd1_(&fcn, &n, x, fvec, &tol, &info, wa, &lwa); fnorm = enorm_(&n, fvec); printf(" final L2 norm of the residuals %15.7g\n", fnorm); printf(" exit parameter %10i\n", info); printf(" final approximate solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g",j%3==1?"\n ":"", x[j-1]); printf("\n"); return 0; } void fcn(int *n, double *x, double *fvec, int *iflag) { /* subroutine fcn for hybrd1 example. */ int k; double one=1, temp, temp1, temp2, three=3, two=2, zero=0; for (k=1; k <= *n; k++) { temp = (three - two*x[k-1])*x[k-1]; temp1 = zero; if (k != 1) temp1 = x[k-1-1]; temp2 = zero; if (k != *n) temp2 = x[k+1-1]; fvec[k-1] = temp - temp1 - two*temp2 + one; } return; }