cminpack-1.3.4/000755 000765 000765 00000000000 12341325605 013255 5ustar00devernay000000 000000 cminpack-1.3.4/.cproject000644 000765 000765 00000017607 12225167750 015110 0ustar00devernay000000 000000 cminpack-1.3.4/.project000644 000765 000765 00000004365 12225167750 014742 0ustar00devernay000000 000000 cminpack org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, ?name? org.eclipse.cdt.make.core.append_environment true org.eclipse.cdt.make.core.autoBuildTarget all org.eclipse.cdt.make.core.buildArguments org.eclipse.cdt.make.core.buildCommand make org.eclipse.cdt.make.core.cleanBuildTarget clean org.eclipse.cdt.make.core.contents org.eclipse.cdt.make.core.activeConfigSettings org.eclipse.cdt.make.core.enableAutoBuild false org.eclipse.cdt.make.core.enableCleanBuild true org.eclipse.cdt.make.core.enableFullBuild true org.eclipse.cdt.make.core.fullBuildTarget all org.eclipse.cdt.make.core.stopOnError true org.eclipse.cdt.make.core.useDefaultBuildCmd true org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder org.eclipse.cdt.core.cnature org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature cminpack-1.3.4/.travis.yml000644 000765 000765 00000001341 12305351621 015362 0ustar00devernay000000 000000 language: c compiler: - gcc - clang before_install: - sudo apt-get install gfortran libblas-dev liblapack-dev libilmbase-dev - sudo pip install cpp-coveralls script: - make double float lapack fortran half - make check - make -C examples checklapack LDADD_L='-llapack -lblas' - make veryclean - make -k -C examples test ctest testdrv ctestdrv CFLAGS='-g -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror' FFLAGS='-g -fprofile-arcs -ftest-coverage' - make fortran FFLAGS='-g -fprofile-arcs -ftest-coverage' - make -C examples ftest LIBSUFFIX= MINPACK=../fortran/libminpack.a FFLAGS='-g -fprofile-arcs -ftest-coverage' after_success: - coveralls --extension .c --extension .f --extension .h --exclude examples cminpack-1.3.4/chkder.c000644 000765 000765 00000011652 12225167750 014674 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" #define log10e 0.43429448190325182765 #define factor 100. /* Table of constant values */ __cminpack_attr__ void __cminpack_func__(chkder)(int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, real *xp, real *fvecp, int mode, real *err) { /* Local variables */ int i, j; real eps, epsf, temp, epsmch; real epslog; /* ********** */ /* subroutine chkder */ /* this subroutine checks the gradients of m nonlinear functions */ /* in n variables, evaluated at a point x, for consistency with */ /* the functions themselves. the user must call chkder twice, */ /* first with mode = 1 and then with mode = 2. */ /* mode = 1. on input, x must contain the point of evaluation. */ /* on output, xp is set to a neighboring point. */ /* mode = 2. on input, fvec must contain the functions and the */ /* rows of fjac must contain the gradients */ /* of the respective functions each evaluated */ /* at x, and fvecp must contain the functions */ /* evaluated at xp. */ /* on output, err contains measures of correctness of */ /* the respective gradients. */ /* the subroutine does not perform reliably if cancellation or */ /* rounding errors cause a severe loss of significance in the */ /* evaluation of a function. therefore, none of the components */ /* of x should be unusually small (in particular, zero) or any */ /* other value which may cause loss of significance. */ /* the subroutine statement is */ /* subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) */ /* where */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. */ /* x is an input array of length n. */ /* fvec is an array of length m. on input when mode = 2, */ /* fvec must contain the functions evaluated at x. */ /* fjac is an m by n array. on input when mode = 2, */ /* the rows of fjac must contain the gradients of */ /* the respective functions evaluated at x. */ /* ldfjac is a positive integer input parameter not less than m */ /* which specifies the leading dimension of the array fjac. */ /* xp is an array of length n. on output when mode = 1, */ /* xp is set to a neighboring point of x. */ /* fvecp is an array of length m. on input when mode = 2, */ /* fvecp must contain the functions evaluated at xp. */ /* mode is an integer input variable set to 1 on the first call */ /* and 2 on the second. other values of mode are equivalent */ /* to mode = 1. */ /* err is an array of length m. on output when mode = 2, */ /* err contains measures of correctness of the respective */ /* gradients. if there is no severe loss of significance, */ /* then if err(i) is 1.0 the i-th gradient is correct, */ /* while if err(i) is 0.0 the i-th gradient is incorrect. */ /* for values of err between 0.0 and 1.0, the categorization */ /* is less certain. in general, a value of err(i) greater */ /* than 0.5 indicates that the i-th gradient is probably */ /* correct, while a value of err(i) less than 0.5 indicates */ /* that the i-th gradient is probably incorrect. */ /* subprograms called */ /* minpack supplied ... dpmpar */ /* fortran supplied ... dabs,dlog10,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); eps = sqrt(epsmch); if (mode != 2) { /* mode = 1. */ for (j = 0; j < n; ++j) { temp = eps * fabs(x[j]); if (temp == 0.) { temp = eps; } xp[j] = x[j] + temp; } return; } /* mode = 2. */ epsf = factor * epsmch; epslog = log10e * log(eps); for (i = 0; i < m; ++i) { err[i] = 0.; } for (j = 0; j < n; ++j) { temp = fabs(x[j]); if (temp == 0.) { temp = 1.; } for (i = 0; i < m; ++i) { err[i] += temp * fjac[i + j * ldfjac]; } } for (i = 0; i < m; ++i) { temp = 1.; if (fvec[i] != 0. && fvecp[i] != 0. && fabs(fvecp[i] - fvec[i]) >= epsf * fabs(fvec[i])) { temp = eps * fabs((fvecp[i] - fvec[i]) / eps - err[i]) / (fabs(fvec[i]) + fabs(fvecp[i])); } err[i] = 1.; if (temp > epsmch && temp < eps) { err[i] = (log10e * log(temp) - epslog) / epslog; } if (temp >= eps) { err[i] = 0.; } } /* last card of subroutine chkder. */ } /* chkder_ */ cminpack-1.3.4/chkder_.c000644 000765 000765 00000013160 12225167750 015027 0ustar00devernay000000 000000 /* chkder.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define log10e 0.43429448190325182765 #define factor 100. /* Table of constant values */ __minpack_attr__ void __minpack_func__(chkder)(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, real *xp, real *fvecp, const int *mode, real *err) { /* Initialized data */ const int c__1 = 1; /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; /* Local variables */ int i__, j; real eps, epsf, temp, epsmch; real epslog; /* ********** */ /* subroutine chkder */ /* this subroutine checks the gradients of m nonlinear functions */ /* in n variables, evaluated at a point x, for consistency with */ /* the functions themselves. the user must call chkder twice, */ /* first with mode = 1 and then with mode = 2. */ /* mode = 1. on input, x must contain the point of evaluation. */ /* on output, xp is set to a neighboring point. */ /* mode = 2. on input, fvec must contain the functions and the */ /* rows of fjac must contain the gradients */ /* of the respective functions each evaluated */ /* at x, and fvecp must contain the functions */ /* evaluated at xp. */ /* on output, err contains measures of correctness of */ /* the respective gradients. */ /* the subroutine does not perform reliably if cancellation or */ /* rounding errors cause a severe loss of significance in the */ /* evaluation of a function. therefore, none of the components */ /* of x should be unusually small (in particular, zero) or any */ /* other value which may cause loss of significance. */ /* the subroutine statement is */ /* subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) */ /* where */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. */ /* x is an input array of length n. */ /* fvec is an array of length m. on input when mode = 2, */ /* fvec must contain the functions evaluated at x. */ /* fjac is an m by n array. on input when mode = 2, */ /* the rows of fjac must contain the gradients of */ /* the respective functions evaluated at x. */ /* ldfjac is a positive integer input parameter not less than m */ /* which specifies the leading dimension of the array fjac. */ /* xp is an array of length n. on output when mode = 1, */ /* xp is set to a neighboring point of x. */ /* fvecp is an array of length m. on input when mode = 2, */ /* fvecp must contain the functions evaluated at xp. */ /* mode is an integer input variable set to 1 on the first call */ /* and 2 on the second. other values of mode are equivalent */ /* to mode = 1. */ /* err is an array of length m. on output when mode = 2, */ /* err contains measures of correctness of the respective */ /* gradients. if there is no severe loss of significance, */ /* then if err(i) is 1.0 the i-th gradient is correct, */ /* while if err(i) is 0.0 the i-th gradient is incorrect. */ /* for values of err between 0.0 and 1.0, the categorization */ /* is less certain. in general, a value of err(i) greater */ /* than 0.5 indicates that the i-th gradient is probably */ /* correct, while a value of err(i) less than 0.5 indicates */ /* that the i-th gradient is probably incorrect. */ /* subprograms called */ /* minpack supplied ... dpmpar */ /* fortran supplied ... dabs,dlog10,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --err; --fvecp; --fvec; --xp; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); eps = sqrt(epsmch); if (*mode == 2) { goto L20; } /* mode = 1. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { temp = eps * fabs(x[j]); if (temp == 0.) { temp = eps; } xp[j] = x[j] + temp; /* L10: */ } /* goto L70; */ return; L20: /* mode = 2. */ epsf = factor * epsmch; epslog = log10e * log(eps); i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { err[i__] = 0.; /* L30: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { temp = fabs(x[j]); if (temp == 0.) { temp = 1.; } i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { err[i__] += temp * fjac[i__ + j * fjac_dim1]; /* L40: */ } /* L50: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { temp = 1.; if (fvec[i__] != 0. && fvecp[i__] != 0. && fabs(fvecp[i__] - fvec[i__]) >= epsf * fabs(fvec[i__])) { temp = eps * fabs((fvecp[i__] - fvec[i__]) / eps - err[i__]) / (fabs(fvec[i__]) + fabs(fvecp[i__])); } err[i__] = 1.; if (temp > epsmch && temp < eps) { err[i__] = (log10e * log(temp) - epslog) / epslog; } if (temp >= eps) { err[i__] = 0.; } /* L60: */ } /* L70: */ /* return 0; */ /* last card of subroutine chkder. */ } /* chkder_ */ cminpack-1.3.4/cmake/000755 000765 000765 00000000000 12303430314 014325 5ustar00devernay000000 000000 cminpack-1.3.4/CMakeLists.txt000644 000765 000765 00000005247 12341325535 016027 0ustar00devernay000000 000000 # The name of our project is "CMINPACK". CMakeLists files in this project can # refer to the root source directory of the project as ${CMINPACK_SOURCE_DIR} and # to the root binary directory of the project as ${CMINPACK_BINARY_DIR}. cmake_minimum_required (VERSION 2.6) project (CMINPACK) string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) include(${PROJECT_SOURCE_DIR}/cmake/cminpack_utils.cmake) # Set version and OS-specific settings set(CMINPACK_VERSION 1.3.4 CACHE STRING "CMinpack version") set(CMINPACK_SOVERSION 1 CACHE STRING "CMinpack API version") DISSECT_VERSION() GET_OS_INFO() # Add an "uninstall" target CONFIGURE_FILE ("${PROJECT_SOURCE_DIR}/cmake/uninstall_target.cmake.in" "${PROJECT_BINARY_DIR}/uninstall_target.cmake" IMMEDIATE @ONLY) ADD_CUSTOM_TARGET (uninstall "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/uninstall_target.cmake") enable_testing() if (OS_LINUX) option (USE_FPIC "Use the -fPIC compiler flag." ON) else (OS_LINUX) option (USE_FPIC "Use the -fPIC compiler flag." OFF) endif (OS_LINUX) option (SHARED_LIBS "Build shared libraries instead of static." OFF) if (SHARED_LIBS) message (STATUS "Building shared libraries.") set (LIB_TYPE SHARED) else (SHARED_LIBS) message (STATUS "Building static libraries.") set (LIB_TYPE STATIC) if(WIN32) add_definitions(-DCMINPACK_NO_DLL) endif(WIN32) endif (SHARED_LIBS) #set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../build) add_subdirectory (cmake) add_subdirectory (examples) set (cminpack_srcs cminpack.h cminpackP.h chkder.c enorm.c hybrd1.c hybrj.c lmdif1.c lmstr1.c qrfac.c r1updt.c dogleg.c fdjac1.c hybrd.c lmder1.c lmdif.c lmstr.c qrsolv.c rwupdt.c dpmpar.c fdjac2.c hybrj1.c lmder.c lmpar.c qform.c r1mpyq.c covar.c covar1.c minpack.h chkder_.c enorm_.c hybrd1_.c hybrj_.c lmdif1_.c lmstr1_.c qrfac_.c r1updt_.c dogleg_.c fdjac1_.c hybrd_.c lmder1_.c lmdif_.c lmstr_.c qrsolv_.c rwupdt_.c dpmpar_.c fdjac2_.c hybrj1_.c lmder_.c lmpar_.c qform_.c r1mpyq_.c covar_.c ) set (cminpack_hdrs cminpack.h minpack.h) add_library (cminpack ${LIB_TYPE} ${cminpack_srcs}) install (TARGETS cminpack LIBRARY DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library ARCHIVE DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library RUNTIME DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library) install (FILES ${cminpack_hdrs} DESTINATION ${CMINPACK_INCLUDE_INSTALL_DIR} COMPONENT cminpack_hdrs) if (USE_FPIC AND NOT SHARED_LIBS) set_target_properties (cminpack PROPERTIES COMPILE_FLAGS -fPIC) endif (USE_FPIC AND NOT SHARED_LIBS) set_target_properties(cminpack PROPERTIES VERSION ${CMINPACK_VERSION} SOVERSION ${CMINPACK_SOVERSION}) cminpack-1.3.4/cminpack.h000644 000765 000765 00000042650 12225167750 015230 0ustar00devernay000000 000000 /* Header file for cminpack, by Frederic Devernay. The documentation for all functions can be found in the file minpack-documentation.txt from the distribution, or in the source code of each function. */ #ifndef __CMINPACK_H__ #define __CMINPACK_H__ /* The default floating-point type is "double" for C/C++ and "float" for CUDA, but you can change this by defining one of the following symbols when compiling the library, and before including cminpack.h when using it: __cminpack_double__ for double __cminpack_float__ for float __cminpack_half__ for half from the OpenEXR library (in this case, you must compile cminpack with a C++ compiler) */ #ifdef __cminpack_double__ #define __cminpack_real__ double #endif #ifdef __cminpack_float__ #define __cminpack_real__ float #endif #ifdef __cminpack_half__ #include #define __cminpack_real__ half #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Cmake will define cminpack_EXPORTS on Windows when it configures to build a shared library. If you are going to use another build system on windows or create the visual studio projects by hand you need to define cminpack_EXPORTS when building a DLL on windows. */ #if defined (__GNUC__) #define CMINPACK_DECLSPEC_EXPORT __declspec(__dllexport__) #define CMINPACK_DECLSPEC_IMPORT __declspec(__dllimport__) #endif #if defined (_MSC_VER) || defined (__BORLANDC__) #define CMINPACK_DECLSPEC_EXPORT __declspec(dllexport) #define CMINPACK_DECLSPEC_IMPORT __declspec(dllimport) #endif #ifdef __WATCOMC__ #define CMINPACK_DECLSPEC_EXPORT __export #define CMINPACK_DECLSPEC_IMPORT __import #endif #ifdef __IBMC__ #define CMINPACK_DECLSPEC_EXPORT _Export #define CMINPACK_DECLSPEC_IMPORT _Import #endif #if !defined(CMINPACK_NO_DLL) && (defined(__WIN32__) || defined(WIN32) || defined (_WIN32)) #if defined(cminpack_EXPORTS) || defined(CMINPACK_EXPORTS) || defined(CMINPACK_DLL_EXPORTS) #define CMINPACK_EXPORT CMINPACK_DECLSPEC_EXPORT #else #define CMINPACK_EXPORT CMINPACK_DECLSPEC_IMPORT #endif /* cminpack_EXPORTS */ #else /* defined (_WIN32) */ #define CMINPACK_EXPORT #endif #if defined(__CUDA_ARCH__) || defined(__CUDACC__) #define __cminpack_attr__ __device__ #ifndef __cminpack_real__ #define __cminpack_float__ #define __cminpack_real__ float #endif #define __cminpack_type_fcn_nn__ __cminpack_attr__ int fcn_nn #define __cminpack_type_fcnder_nn__ __cminpack_attr__ int fcnder_nn #define __cminpack_type_fcn_mn__ __cminpack_attr__ int fcn_mn #define __cminpack_type_fcnder_mn__ __cminpack_attr__ int fcnder_mn #define __cminpack_type_fcnderstr_mn__ __cminpack_attr__ int fcnderstr_mn #define __cminpack_decl_fcn_nn__ #define __cminpack_decl_fcnder_nn__ #define __cminpack_decl_fcn_mn__ #define __cminpack_decl_fcnder_mn__ #define __cminpack_decl_fcnderstr_mn__ #define __cminpack_param_fcn_nn__ #define __cminpack_param_fcnder_nn__ #define __cminpack_param_fcn_mn__ #define __cminpack_param_fcnder_mn__ #define __cminpack_param_fcnderstr_mn__ #else #define __cminpack_attr__ #ifndef __cminpack_real__ #define __cminpack_double__ #define __cminpack_real__ double #endif #define __cminpack_type_fcn_nn__ typedef int (*cminpack_func_nn) #define __cminpack_type_fcnder_nn__ typedef int (*cminpack_funcder_nn) #define __cminpack_type_fcn_mn__ typedef int (*cminpack_func_mn) #define __cminpack_type_fcnder_mn__ typedef int (*cminpack_funcder_mn) #define __cminpack_type_fcnderstr_mn__ typedef int (*cminpack_funcderstr_mn) #define __cminpack_decl_fcn_nn__ cminpack_func_nn fcn_nn, #define __cminpack_decl_fcnder_nn__ cminpack_funcder_nn fcnder_nn, #define __cminpack_decl_fcn_mn__ cminpack_func_mn fcn_mn, #define __cminpack_decl_fcnder_mn__ cminpack_funcder_mn fcnder_mn, #define __cminpack_decl_fcnderstr_mn__ cminpack_funcderstr_mn fcnderstr_mn, #define __cminpack_param_fcn_nn__ fcn_nn, #define __cminpack_param_fcnder_nn__ fcnder_nn, #define __cminpack_param_fcn_mn__ fcn_mn, #define __cminpack_param_fcnder_mn__ fcnder_mn, #define __cminpack_param_fcnderstr_mn__ fcnderstr_mn, #endif #ifdef __cminpack_double__ #define __cminpack_func__(func) func #endif #ifdef __cminpack_float__ #define __cminpack_func__(func) s ## func #endif #ifdef __cminpack_half__ #define __cminpack_func__(func) h ## func #endif /* Declarations for minpack */ /* Function types: */ /* The first argument can be used to store extra function parameters, thus */ /* avoiding the use of global variables. */ /* the iflag parameter is input-only (with respect to the FORTRAN */ /* version), the output iflag value is the return value of the function. */ /* If iflag=0, the function shoulkd just print the current values (see */ /* the nprint parameters below). */ /* for hybrd1 and hybrd: */ /* calculate the functions at x and */ /* return this vector in fvec. */ /* return a negative value to terminate hybrd1/hybrd */ __cminpack_type_fcn_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int iflag ); /* for hybrj1 and hybrj */ /* 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 a negative value to terminate hybrj1/hybrj */ __cminpack_type_fcnder_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, int iflag ); /* for lmdif1 and lmdif */ /* calculate the functions at x and */ /* return this vector in fvec. */ /* if iflag = 1 the result is used to compute the residuals. */ /* if iflag = 2 the result is used to compute the Jacobian by finite differences. */ /* Jacobian computation requires exactly n function calls with iflag = 2. */ /* return a negative value to terminate lmdif1/lmdif */ __cminpack_type_fcn_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int iflag ); /* for lmder1 and lmder */ /* 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 a negative value to terminate lmder1/lmder */ __cminpack_type_fcnder_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, int iflag ); /* for lmstr1 and lmstr */ /* if iflag = 1 calculate the functions at x and */ /* return this vector in fvec. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* return a negative value to terminate lmstr1/lmstr */ __cminpack_type_fcnderstr_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjrow, int iflag ); /* MINPACK functions: */ /* the info parameter was removed from most functions: the return */ /* value of the function is used instead. */ /* The argument 'p' can be used to store extra function parameters, thus */ /* avoiding the use of global variables. You can also think of it as a */ /* 'this' pointer a la C++. */ /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (Jacobian calculated by a forward-difference approximation) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(hybrd1)( __cminpack_decl_fcn_nn__ void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol, __cminpack_real__ *wa, int lwa ); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (Jacobian calculated by a forward-difference approximation, more general). */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(hybrd)( __cminpack_decl_fcn_nn__ void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ xtol, int maxfev, int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint, int *nfev, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ *r, int lr, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (user-supplied Jacobian) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(hybrj1)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol, __cminpack_real__ *wa, int lwa ); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (user-supplied Jacobian, more general) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(hybrj)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ xtol, int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint, int *nfev, int *njev, __cminpack_real__ *r, int lr, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (Jacobian calculated by a forward-difference approximation) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmdif1)( __cminpack_decl_fcn_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol, int *iwa, __cminpack_real__ *wa, int lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (Jacobian calculated by a forward-difference approximation, more general) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmdif)( __cminpack_decl_fcn_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ epsfcn, __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint, int *nfev, __cminpack_real__ *fjac, int ldfjac, int *ipvt, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmder1)( __cminpack_decl_fcnder_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol, int *ipvt, __cminpack_real__ *wa, int lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, more general) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmder)( __cminpack_decl_fcnder_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint, int *nfev, int *njev, int *ipvt, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, minimal storage) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmstr1)( __cminpack_decl_fcnderstr_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol, int *ipvt, __cminpack_real__ *wa, int lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, minimal storage, more general) */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(lmstr)( __cminpack_decl_fcnderstr_mn__ void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint, int *nfev, int *njev, int *ipvt, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4 ); __cminpack_attr__ void CMINPACK_EXPORT __cminpack_func__(chkder)( int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ *xp, __cminpack_real__ *fvecp, int mode, __cminpack_real__ *err ); __cminpack_attr__ __cminpack_real__ CMINPACK_EXPORT __cminpack_func__(dpmpar)( int i ); __cminpack_attr__ __cminpack_real__ CMINPACK_EXPORT __cminpack_func__(enorm)( int n, const __cminpack_real__ *x ); /* compute a forward-difference approximation to the m by n jacobian matrix associated with a specified problem of m functions in n variables. */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__ void *p, int m, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ epsfcn, __cminpack_real__ *wa); /* compute a forward-difference approximation to the n by n jacobian matrix associated with a specified problem of n functions in n variables. if the jacobian has a banded form, then function evaluations are saved by only approximating the nonzero terms. */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__ void *p, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *wa1, __cminpack_real__ *wa2); /* compute inverse(JtJ) after a run of lmdif or lmder. The covariance matrix is obtained by scaling the result by enorm(y)**2/(m-n). If JtJ is singular and k = rank(J), the pseudo-inverse is computed, and the result has to be scaled by enorm(y)**2/(m-k). */ __cminpack_attr__ void CMINPACK_EXPORT __cminpack_func__(covar)(int n, __cminpack_real__ *r, int ldr, const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa); /* covar1 estimates the variance-covariance matrix: C = sigma**2 (JtJ)**+ where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank), and sigma**2 = fsumsq / (m - k) where fsumsq is the residual sum of squares and k is the rank of J. The function returns 0 if J has full rank, else the rank of J. */ __cminpack_attr__ int CMINPACK_EXPORT __cminpack_func__(covar1)(int m, int n, __cminpack_real__ fsumsq, __cminpack_real__ *r, int ldr, const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa); /* internal MINPACK subroutines */ __cminpack_attr__ void __cminpack_func__(dogleg)(int n, const __cminpack_real__ *r, int lr, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, __cminpack_real__ *x, __cminpack_real__ *wa1, __cminpack_real__ *wa2); __cminpack_attr__ void __cminpack_func__(qrfac)(int m, int n, __cminpack_real__ *a, int lda, int pivot, int *ipvt, int lipvt, __cminpack_real__ *rdiag, __cminpack_real__ *acnorm, __cminpack_real__ *wa); __cminpack_attr__ void __cminpack_func__(qrsolv)(int n, __cminpack_real__ *r, int ldr, const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ *x, __cminpack_real__ *sdiag, __cminpack_real__ *wa); __cminpack_attr__ void __cminpack_func__(qform)(int m, int n, __cminpack_real__ *q, int ldq, __cminpack_real__ *wa); __cminpack_attr__ void __cminpack_func__(r1updt)(int m, int n, __cminpack_real__ *s, int ls, const __cminpack_real__ *u, __cminpack_real__ *v, __cminpack_real__ *w, int *sing); __cminpack_attr__ void __cminpack_func__(r1mpyq)(int m, int n, __cminpack_real__ *a, int lda, const __cminpack_real__ *v, const __cminpack_real__ *w); __cminpack_attr__ void __cminpack_func__(lmpar)(int n, __cminpack_real__ *r, int ldr, const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, __cminpack_real__ *par, __cminpack_real__ *x, __cminpack_real__ *sdiag, __cminpack_real__ *wa1, __cminpack_real__ *wa2); __cminpack_attr__ void __cminpack_func__(rwupdt)(int n, __cminpack_real__ *r, int ldr, const __cminpack_real__ *w, __cminpack_real__ *b, __cminpack_real__ *alpha, __cminpack_real__ *cos, __cminpack_real__ *sin); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __CMINPACK_H__ */ cminpack-1.3.4/cminpack.sln000644 000765 000765 00000002475 12225167750 015576 0ustar00devernay000000 000000  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cminpack", "cminpack.vcproj", "{DFCA12EC-B869-49B9-920D-F14FFB48529F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cminpack_dll", "cminpack_dll.vcproj", "{7A715393-C1E6-41D2-9A47-DA8501440F71}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DFCA12EC-B869-49B9-920D-F14FFB48529F}.Debug|Win32.ActiveCfg = Debug|Win32 {DFCA12EC-B869-49B9-920D-F14FFB48529F}.Debug|Win32.Build.0 = Debug|Win32 {DFCA12EC-B869-49B9-920D-F14FFB48529F}.Release|Win32.ActiveCfg = Release|Win32 {DFCA12EC-B869-49B9-920D-F14FFB48529F}.Release|Win32.Build.0 = Release|Win32 {7A715393-C1E6-41D2-9A47-DA8501440F71}.Debug|Win32.ActiveCfg = Debug|Win32 {7A715393-C1E6-41D2-9A47-DA8501440F71}.Debug|Win32.Build.0 = Debug|Win32 {7A715393-C1E6-41D2-9A47-DA8501440F71}.Release|Win32.ActiveCfg = Release|Win32 {7A715393-C1E6-41D2-9A47-DA8501440F71}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal cminpack-1.3.4/cminpack.vcproj000644 000765 000765 00000025702 12265263114 016276 0ustar00devernay000000 000000 cminpack-1.3.4/cminpack.vcxproj000644 000765 000765 00000027400 12265263141 016463 0ustar00devernay000000 000000  Debug DLL Win32 Debug Win32 Release (no sbw) Win32 Release DLL Win32 Release Win32 {DFCA12EC-B869-49B9-920D-F14FFB48529F} cminpack Win32Proj StaticLibrary Dynamic MultiByte StaticLibrary Dynamic MultiByte StaticLibrary Dynamic MultiByte StaticLibrary Dynamic MultiByte StaticLibrary Dynamic MultiByte <_ProjectFileVersion>10.0.40219.1 $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ $(Configuration)\ Disabled %(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue Full AnySuitable true Speed true %(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions) MultiThreadedDLL Level3 Full AnySuitable true Speed true %(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions) MultiThreadedDLL Level3 Disabled %(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;cminpack_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue Full AnySuitable true Speed true %(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;cminpack_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 cminpack-1.3.4/cminpack.vcxproj.filters000644 000765 000765 00000012465 12265263163 020143 0ustar00devernay000000 000000  {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Header Files Header Files cminpack-1.3.4/cminpack.xcodeproj/000755 000765 000765 00000000000 12274444625 017047 5ustar00devernay000000 000000 cminpack-1.3.4/cminpack_dll.vcproj000644 000765 000765 00000015316 12225167750 017136 0ustar00devernay000000 000000 cminpack-1.3.4/cminpackP.h000644 000765 000765 00000004400 12274453163 015337 0ustar00devernay000000 000000 /* Internal header file for cminpack, by Frederic Devernay. */ #ifndef __CMINPACKP_H__ #define __CMINPACKP_H__ #ifndef __CMINPACK_H__ #error "cminpackP.h in an internal cminpack header, and must be included after all other headers (including cminpack.h)" #endif #if (defined (USE_CBLAS) || defined (USE_LAPACK)) && !defined (__cminpack_double__) #error "cminpack can use cblas and lapack only in double precision mode" #endif #ifdef USE_CBLAS #ifdef __APPLE__ #include #else #include #endif #define __cminpack_enorm__(n,x) cblas_dnrm2(n,x,1) #else #define __cminpack_enorm__(n,x) __cminpack_func__(enorm)(n,x) #endif #ifdef USE_LAPACK #ifdef __APPLE__ #include #else #if defined(__LP64__) /* In LP64 match sizes with the 32 bit ABI */ typedef int __CLPK_integer; typedef int __CLPK_logical; typedef float __CLPK_real; typedef double __CLPK_doublereal; typedef __CLPK_logical (*__CLPK_L_fp)(); typedef int __CLPK_ftnlen; #else typedef long int __CLPK_integer; typedef long int __CLPK_logical; typedef float __CLPK_real; typedef double __CLPK_doublereal; typedef __CLPK_logical (*__CLPK_L_fp)(); typedef long int __CLPK_ftnlen; #endif //extern void dlartg_(double *f, double *g, double *cs, double *sn, double *r__); int dlartg_(__CLPK_doublereal *f, __CLPK_doublereal *g, __CLPK_doublereal *cs, __CLPK_doublereal *sn, __CLPK_doublereal *r__); //extern void dgeqp3_(int *m, int *n, double *a, int *lda, int *jpvt, double *tau, double *work, int *lwork, int *info); int dgeqp3_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_doublereal *a, __CLPK_integer * lda, __CLPK_integer *jpvt, __CLPK_doublereal *tau, __CLPK_doublereal *work, __CLPK_integer *lwork, __CLPK_integer *info); //extern void dgeqrf_(int *m, int *n, double *a, int *lda, double *tau, double *work, int *lwork, int *info); int dgeqrf_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_doublereal *a, __CLPK_integer * lda, __CLPK_doublereal *tau, __CLPK_doublereal *work, __CLPK_integer *lwork, __CLPK_integer *info); #endif #endif #define real __cminpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define TRUE_ (1) #define FALSE_ (0) #endif /* !__CMINPACKP_H__ */ cminpack-1.3.4/CopyrightMINPACK.txt000644 000765 000765 00000004222 12225167750 016777 0ustar00devernay000000 000000 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. cminpack-1.3.4/covar.c000644 000765 000765 00000010756 12225167750 014552 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(covar)(int n, real *r, int ldr, const int *ipvt, real tol, real *wa) { /* Local variables */ int i, j, k, l, ii, jj; int sing; real temp, tolr; /* ********** */ /* subroutine covar */ /* given an m by n matrix a, the problem is to determine */ /* the covariance matrix corresponding to a, defined as */ /* t */ /* inverse(a *a) . */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then covar expects */ /* the full upper triangle of r and the permutation matrix p. */ /* the covariance matrix is then computed as */ /* t t */ /* p*inverse(r *r)*p . */ /* if a is nearly rank deficient, it may be desirable to compute */ /* the covariance matrix corresponding to the linearly independent */ /* columns of a. to define the numerical rank of a, covar uses */ /* the tolerance tol. if l is the largest integer such that */ /* abs(r(l,l)) .gt. tol*abs(r(1,1)) , */ /* then covar computes the covariance matrix corresponding to */ /* the first l columns of r. for k greater than l, column */ /* and row ipvt(k) of the covariance matrix are set to zero. */ /* the subroutine statement is */ /* subroutine covar(n,r,ldr,ipvt,tol,wa) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle must */ /* contain the full upper triangle of the matrix r. on output */ /* r contains the square symmetric covariance matrix. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* tol is a nonnegative input variable used to define the */ /* numerical rank of a in the manner described above. */ /* wa is a work array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs */ /* argonne national laboratory. minpack project. august 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ tolr = tol * fabs(r[0]); /* form the inverse of r in the full upper triangle of r. */ l = -1; for (k = 0; k < n; ++k) { if (fabs(r[k + k * ldr]) <= tolr) { break; } r[k + k * ldr] = 1. / r[k + k * ldr]; if (k > 0) { for (j = 0; j < k; ++j) { temp = r[k + k * ldr] * r[j + k * ldr]; r[j + k * ldr] = 0.; for (i = 0; i <= j; ++i) { r[i + k * ldr] -= temp * r[i + j * ldr]; } } } l = k; } /* form the full upper triangle of the inverse of (r transpose)*r */ /* in the full upper triangle of r. */ if (l >= 0) { for (k = 0; k <= l; ++k) { if (k > 0) { for (j = 0; j < k; ++j) { temp = r[j + k * ldr]; for (i = 0; i <= j; ++i) { r[i + j * ldr] += temp * r[i + k * ldr]; } } } temp = r[k + k * ldr]; for (i = 0; i <= k; ++i) { r[i + k * ldr] *= temp; } } } /* form the full lower triangle of the covariance matrix */ /* in the strict lower triangle of r and in wa. */ for (j = 0; j < n; ++j) { jj = ipvt[j]-1; sing = j > l; for (i = 0; i <= j; ++i) { if (sing) { r[i + j * ldr] = 0.; } ii = ipvt[i]-1; if (ii > jj) { r[ii + jj * ldr] = r[i + j * ldr]; } else if (ii < jj) { r[jj + ii * ldr] = r[i + j * ldr]; } } wa[jj] = r[j + j * ldr]; } /* symmetrize the covariance matrix in r. */ for (j = 0; j < n; ++j) { for (i = 0; i < j; ++i) { r[i + j * ldr] = r[j + i * ldr]; } r[j + j * ldr] = wa[j]; } /* last card of subroutine covar. */ } /* covar_ */ cminpack-1.3.4/covar1.c000644 000765 000765 00000011665 12225167750 014633 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" /* covar1 estimates the variance-covariance matrix: C = sigma**2 (JtJ)**+ where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank), and sigma**2 = fsumsq / (m - k) where fsumsq is the residual sum of squares and k is the rank of J. */ __cminpack_attr__ int __cminpack_func__(covar1)(int m, int n, real fsumsq, real *r, int ldr, const int *ipvt, real tol, real *wa) { /* Local variables */ int i, j, k, l, ii, jj; int sing; real temp, tolr; /* ********** */ /* subroutine covar */ /* given an m by n matrix a, the problem is to determine */ /* the covariance matrix corresponding to a, defined as */ /* t */ /* inverse(a *a) . */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then covar expects */ /* the full upper triangle of r and the permutation matrix p. */ /* the covariance matrix is then computed as */ /* t t */ /* p*inverse(r *r)*p . */ /* if a is nearly rank deficient, it may be desirable to compute */ /* the covariance matrix corresponding to the linearly independent */ /* columns of a. to define the numerical rank of a, covar uses */ /* the tolerance tol. if l is the largest integer such that */ /* abs(r(l,l)) .gt. tol*abs(r(1,1)) , */ /* then covar computes the covariance matrix corresponding to */ /* the first l columns of r. for k greater than l, column */ /* and row ipvt(k) of the covariance matrix are set to zero. */ /* the subroutine statement is */ /* subroutine covar(n,r,ldr,ipvt,tol,wa) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle must */ /* contain the full upper triangle of the matrix r. on output */ /* r contains the square symmetric covariance matrix. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* tol is a nonnegative input variable used to define the */ /* numerical rank of a in the manner described above. */ /* wa is a work array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs */ /* argonne national laboratory. minpack project. august 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ tolr = tol * fabs(r[0]); /* form the inverse of r in the full upper triangle of r. */ l = -1; for (k = 0; k < n; ++k) { if (fabs(r[k + k * ldr]) <= tolr) { break; } r[k + k * ldr] = 1. / r[k + k * ldr]; if (k > 0) { for (j = 0; j < k; ++j) { temp = r[k + k * ldr] * r[j + k * ldr]; r[j + k * ldr] = 0.; for (i = 0; i <= j; ++i) { r[i + k * ldr] -= temp * r[i + j * ldr]; } } } l = k; } /* form the full upper triangle of the inverse of (r transpose)*r */ /* in the full upper triangle of r. */ if (l >= 0) { for (k = 0; k <= l; ++k) { if (k > 0) { for (j = 0; j < k; ++j) { temp = r[j + k * ldr]; for (i = 0; i <= j; ++i) { r[i + j * ldr] += temp * r[i + k * ldr]; } } } temp = r[k + k * ldr]; for (i = 0; i <= k; ++i) { r[i + k * ldr] *= temp; } } } /* form the full lower triangle of the covariance matrix */ /* in the strict lower triangle of r and in wa. */ for (j = 0; j < n; ++j) { jj = ipvt[j]-1; sing = j > l; for (i = 0; i <= j; ++i) { if (sing) { r[i + j * ldr] = 0.; } ii = ipvt[i]-1; if (ii > jj) { r[ii + jj * ldr] = r[i + j * ldr]; } else if (ii < jj) { r[jj + ii * ldr] = r[i + j * ldr]; } } wa[jj] = r[j + j * ldr]; } /* symmetrize the covariance matrix in r. */ temp = fsumsq / (m - (l + 1)); for (j = 0; j < n; ++j) { for (i = 0; i < j; ++i) { r[j + i * ldr] *= temp; r[i + j * ldr] = r[j + i * ldr]; } r[j + j * ldr] = temp * wa[j]; } /* last card of subroutine covar. */ if (l == (n - 1)) { return 0; } return l + 1; } /* covar_ */ cminpack-1.3.4/covar_.c000644 000765 000765 00000013027 12225167750 014703 0ustar00devernay000000 000000 /* covar.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(covar)(const int *n, real *r__, const int *ldr, const int *ipvt, const real *tol, real *wa) { /* System generated locals */ int r_dim1, r_offset, i__1, i__2, i__3; /* Local variables */ int i__, j, k, l, ii, jj, km1; int sing; real temp, tolr; /* ********** */ /* subroutine covar */ /* given an m by n matrix a, the problem is to determine */ /* the covariance matrix corresponding to a, defined as */ /* t */ /* inverse(a *a) . */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then covar expects */ /* the full upper triangle of r and the permutation matrix p. */ /* the covariance matrix is then computed as */ /* t t */ /* p*inverse(r *r)*p . */ /* if a is nearly rank deficient, it may be desirable to compute */ /* the covariance matrix corresponding to the linearly independent */ /* columns of a. to define the numerical rank of a, covar uses */ /* the tolerance tol. if l is the largest integer such that */ /* abs(r(l,l)) .gt. tol*abs(r(1,1)) , */ /* then covar computes the covariance matrix corresponding to */ /* the first l columns of r. for k greater than l, column */ /* and row ipvt(k) of the covariance matrix are set to zero. */ /* the subroutine statement is */ /* subroutine covar(n,r,ldr,ipvt,tol,wa) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle must */ /* contain the full upper triangle of the matrix r. on output */ /* r contains the square symmetric covariance matrix. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* tol is a nonnegative input variable used to define the */ /* numerical rank of a in the manner described above. */ /* wa is a work array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs */ /* argonne national laboratory. minpack project. august 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; --ipvt; tolr = *tol * fabs(r__[0]); r_dim1 = *ldr; r_offset = 1 + r_dim1; r__ -= r_offset; /* Function Body */ /* form the inverse of r in the full upper triangle of r. */ l = 0; i__1 = *n; for (k = 1; k <= i__1; ++k) { if (fabs(r__[k + k * r_dim1]) <= tolr) { goto L50; } r__[k + k * r_dim1] = 1. / r__[k + k * r_dim1]; km1 = k - 1; if (km1 < 1) { goto L30; } i__2 = km1; for (j = 1; j <= i__2; ++j) { temp = r__[k + k * r_dim1] * r__[j + k * r_dim1]; r__[j + k * r_dim1] = 0.; i__3 = j; for (i__ = 1; i__ <= i__3; ++i__) { r__[i__ + k * r_dim1] -= temp * r__[i__ + j * r_dim1]; /* L10: */ } /* L20: */ } L30: l = k; /* L40: */ } L50: /* form the full upper triangle of the inverse of (r transpose)*r */ /* in the full upper triangle of r. */ if (l < 1) { goto L110; } i__1 = l; for (k = 1; k <= i__1; ++k) { km1 = k - 1; if (km1 < 1) { goto L80; } i__2 = km1; for (j = 1; j <= i__2; ++j) { temp = r__[j + k * r_dim1]; i__3 = j; for (i__ = 1; i__ <= i__3; ++i__) { r__[i__ + j * r_dim1] += temp * r__[i__ + k * r_dim1]; /* L60: */ } /* L70: */ } L80: temp = r__[k + k * r_dim1]; i__2 = k; for (i__ = 1; i__ <= i__2; ++i__) { r__[i__ + k * r_dim1] = temp * r__[i__ + k * r_dim1]; /* L90: */ } /* L100: */ } L110: /* form the full lower triangle of the covariance matrix */ /* in the strict lower triangle of r and in wa. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { jj = ipvt[j]; sing = j > l; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { if (sing) { r__[i__ + j * r_dim1] = 0.; } ii = ipvt[i__]; if (ii > jj) { r__[ii + jj * r_dim1] = r__[i__ + j * r_dim1]; } if (ii < jj) { r__[jj + ii * r_dim1] = r__[i__ + j * r_dim1]; } /* L120: */ } wa[jj] = r__[j + j * r_dim1]; /* L130: */ } /* symmetrize the covariance matrix in r. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { r__[i__ + j * r_dim1] = r__[j + i__ * r_dim1]; /* L140: */ } r__[j + j * r_dim1] = wa[j]; /* L150: */ } /*return 0;*/ /* last card of subroutine covar. */ } /* covar_ */ cminpack-1.3.4/cuda/000755 000765 000765 00000000000 12225167750 014177 5ustar00devernay000000 000000 cminpack-1.3.4/dist-exclude000644 000765 000765 00000001142 12274206574 015600 0ustar00devernay000000 000000 .DS_Store *.out lib*.a *.dSYM .gitattributes .gitignore .git .svn CVS *.o *~ #*# .#* cminpack-*.tar.gz build* CMakeFiles *.pbxuser *.perspectivev3 DerivedData/* *.xcworkspacedata *.xcworkspace xcuserdata *.patch tchkderc tfdjac2c thybrd1c thybrdc thybrj1c thybrjc tlmderc tlmdif1c tlmdifc tlmstr1c tlmstrc tchkder_ tfdjac2_ thybrd1_ thybrd_ thybrj1_ thybrj_ tlmder_ tlmdif1_ tlmdif_ tlmstr1_ tlmstr_ tchkder tfdjac2 thybrd1 thybrd thybrj1 thybrj tlmder tlmdif1 tlmdif tlmstr1 tlmstr chkdrv chkdrvc hybdrv hybdrvc hyjdrv hyjdrvc lmddrv lmddrvc lmfdrv lmfdrvc lmsdrv lmsdrvc tchkderc_box thybrjc_box tlmderc_box cminpack-1.3.4/doc/000755 000765 000765 00000000000 12341325455 014025 5ustar00devernay000000 000000 cminpack-1.3.4/dogleg.c000644 000765 000765 00000014144 12225167750 014674 0ustar00devernay000000 000000 /* dogleg.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" /* Table of constant values */ __cminpack_attr__ void __cminpack_func__(dogleg)(int n, const real *r, int lr, const real *diag, const real *qtb, real delta, real *x, real *wa1, real *wa2) { /* System generated locals */ real d1, d2, d3, d4; /* Local variables */ int i, j, k, l, jj, jp1; real sum, temp, alpha, bnorm; real gnorm, qnorm, epsmch; real sgnorm; /* ********** */ /* subroutine dogleg */ /* given an m by n matrix a, an n by n nonsingular diagonal */ /* matrix d, an m-vector b, and a positive number delta, the */ /* problem is to determine the convex combination x of the */ /* gauss-newton and scaled gradient directions that minimizes */ /* (a*x - b) in the least squares sense, subject to the */ /* restriction that the euclidean norm of d*x be at most delta. */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization of a. that is, if a = q*r, where q has */ /* orthogonal columns and r is an upper triangular matrix, */ /* then dogleg expects the full upper triangle of r and */ /* the first n components of (q transpose)*b. */ /* the subroutine statement is */ /* subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an input array of length lr which must contain the upper */ /* triangular matrix r stored by rows. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* delta is a positive input variable which specifies an upper */ /* bound on the euclidean norm of d*x. */ /* x is an output array of length n which contains the desired */ /* convex combination of the gauss-newton direction and the */ /* scaled gradient direction. */ /* wa1 and wa2 are work arrays of length n. */ /* subprograms called */ /* minpack-supplied ... dpmpar,enorm */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa2; --wa1; --x; --qtb; --diag; --r; (void)lr; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); /* first, calculate the gauss-newton direction. */ jj = n * (n + 1) / 2 + 1; for (k = 1; k <= n; ++k) { j = n - k + 1; jp1 = j + 1; jj -= k; l = jj + 1; sum = 0.; if (n >= jp1) { for (i = jp1; i <= n; ++i) { sum += r[l] * x[i]; ++l; } } temp = r[jj]; if (temp == 0.) { l = j; for (i = 1; i <= j; ++i) { /* Computing MAX */ d2 = fabs(r[l]); temp = max(temp,d2); l = l + n - i; } temp = epsmch * temp; if (temp == 0.) { temp = epsmch; } } x[j] = (qtb[j] - sum) / temp; } /* test whether the gauss-newton direction is acceptable. */ for (j = 1; j <= n; ++j) { wa1[j] = 0.; wa2[j] = diag[j] * x[j]; } qnorm = __cminpack_enorm__(n, &wa2[1]); if (qnorm <= delta) { return; } /* the gauss-newton direction is not acceptable. */ /* next, calculate the scaled gradient direction. */ l = 1; for (j = 1; j <= n; ++j) { temp = qtb[j]; for (i = j; i <= n; ++i) { wa1[i] += r[l] * temp; ++l; } wa1[j] /= diag[j]; } /* calculate the norm of the scaled gradient and test for */ /* the special case in which the scaled gradient is zero. */ gnorm = __cminpack_enorm__(n, &wa1[1]); sgnorm = 0.; alpha = delta / qnorm; if (gnorm != 0.) { /* calculate the point along the scaled gradient */ /* at which the quadratic is minimized. */ for (j = 1; j <= n; ++j) { wa1[j] = wa1[j] / gnorm / diag[j]; } l = 1; for (j = 1; j <= n; ++j) { sum = 0.; for (i = j; i <= n; ++i) { sum += r[l] * wa1[i]; ++l; } wa2[j] = sum; } temp = __cminpack_enorm__(n, &wa2[1]); sgnorm = gnorm / temp / temp; /* test whether the scaled gradient direction is acceptable. */ alpha = 0.; if (sgnorm < delta) { /* the scaled gradient direction is not acceptable. */ /* finally, calculate the point along the dogleg */ /* at which the quadratic is minimized. */ bnorm = __cminpack_enorm__(n, &qtb[1]); temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta); /* Computing 2nd power */ d1 = sgnorm / delta; /* Computing 2nd power */ d2 = temp - delta / qnorm; /* Computing 2nd power */ d3 = delta / qnorm; /* Computing 2nd power */ d4 = sgnorm / delta; temp = temp - delta / qnorm * (d1 * d1) + sqrt(d2 * d2 + (1. - d3 * d3) * (1. - d4 * d4)); /* Computing 2nd power */ d1 = sgnorm / delta; alpha = delta / qnorm * (1. - d1 * d1) / temp; } } /* form appropriate convex combination of the gauss-newton */ /* direction and the scaled gradient direction. */ temp = (1. - alpha) * min(sgnorm,delta); for (j = 1; j <= n; ++j) { x[j] = temp * wa1[j] + alpha * x[j]; } /* last card of subroutine dogleg. */ } /* dogleg_ */ cminpack-1.3.4/dogleg_.c000644 000765 000765 00000014475 12225167750 015042 0ustar00devernay000000 000000 /* dogleg.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) /* Table of constant values */ __minpack_attr__ void __minpack_func__(dogleg)(const int *n, const real *r__, const int *lr, const real *diag, const real *qtb, const real *delta, real *x, real *wa1, real *wa2) { /* System generated locals */ int i__1, i__2; real d__1, d__2, d__3, d__4; /* Local variables */ int i__, j, k, l, jj, jp1; real sum, temp, alpha, bnorm; real gnorm, qnorm, epsmch; real sgnorm; const int c__1 = 1; /* ********** */ /* subroutine dogleg */ /* given an m by n matrix a, an n by n nonsingular diagonal */ /* matrix d, an m-vector b, and a positive number delta, the */ /* problem is to determine the convex combination x of the */ /* gauss-newton and scaled gradient directions that minimizes */ /* (a*x - b) in the least squares sense, subject to the */ /* restriction that the euclidean norm of d*x be at most delta. */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization of a. that is, if a = q*r, where q has */ /* orthogonal columns and r is an upper triangular matrix, */ /* then dogleg expects the full upper triangle of r and */ /* the first n components of (q transpose)*b. */ /* the subroutine statement is */ /* subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an input array of length lr which must contain the upper */ /* triangular matrix r stored by rows. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* delta is a positive input variable which specifies an upper */ /* bound on the euclidean norm of d*x. */ /* x is an output array of length n which contains the desired */ /* convex combination of the gauss-newton direction and the */ /* scaled gradient direction. */ /* wa1 and wa2 are work arrays of length n. */ /* subprograms called */ /* minpack-supplied ... dpmpar,enorm */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa2; --wa1; --x; --qtb; --diag; --r__; (void)lr; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); /* first, calculate the gauss-newton direction. */ jj = *n * (*n + 1) / 2 + 1; i__1 = *n; for (k = 1; k <= i__1; ++k) { j = *n - k + 1; jp1 = j + 1; jj -= k; l = jj + 1; sum = 0.; if (*n < jp1) { goto L20; } i__2 = *n; for (i__ = jp1; i__ <= i__2; ++i__) { sum += r__[l] * x[i__]; ++l; /* L10: */ } L20: temp = r__[jj]; if (temp != 0.) { goto L40; } l = j; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { /* Computing MAX */ d__2 = temp, d__3 = fabs(r__[l]); temp = max(d__2,d__3); l = l + *n - i__; /* L30: */ } temp = epsmch * temp; if (temp == 0.) { temp = epsmch; } L40: x[j] = (qtb[j] - sum) / temp; /* L50: */ } /* test whether the gauss-newton direction is acceptable. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = 0.; wa2[j] = diag[j] * x[j]; /* L60: */ } qnorm = __minpack_func__(enorm)(n, &wa2[1]); if (qnorm <= *delta) { /* goto L140; */ return; } /* the gauss-newton direction is not acceptable. */ /* next, calculate the scaled gradient direction. */ l = 1; i__1 = *n; for (j = 1; j <= i__1; ++j) { temp = qtb[j]; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { wa1[i__] += r__[l] * temp; ++l; /* L70: */ } wa1[j] /= diag[j]; /* L80: */ } /* calculate the norm of the scaled gradient and test for */ /* the special case in which the scaled gradient is zero. */ gnorm = __minpack_func__(enorm)(n, &wa1[1]); sgnorm = 0.; alpha = *delta / qnorm; if (gnorm == 0.) { goto L120; } /* calculate the point along the scaled gradient */ /* at which the quadratic is minimized. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = wa1[j] / gnorm / diag[j]; /* L90: */ } l = 1; i__1 = *n; for (j = 1; j <= i__1; ++j) { sum = 0.; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { sum += r__[l] * wa1[i__]; ++l; /* L100: */ } wa2[j] = sum; /* L110: */ } temp = __minpack_func__(enorm)(n, &wa2[1]); sgnorm = gnorm / temp / temp; /* test whether the scaled gradient direction is acceptable. */ alpha = 0.; if (sgnorm >= *delta) { goto L120; } /* the scaled gradient direction is not acceptable. */ /* finally, calculate the point along the dogleg */ /* at which the quadratic is minimized. */ bnorm = __minpack_func__(enorm)(n, &qtb[1]); temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / *delta); /* Computing 2nd power */ d__1 = sgnorm / *delta; /* Computing 2nd power */ d__2 = temp - *delta / qnorm; /* Computing 2nd power */ d__3 = *delta / qnorm; /* Computing 2nd power */ d__4 = sgnorm / *delta; temp = temp - *delta / qnorm * (d__1 * d__1) + sqrt(d__2 * d__2 + (1. - d__3 * d__3) * (1. - d__4 * d__4)); /* Computing 2nd power */ d__1 = sgnorm / *delta; alpha = *delta / qnorm * (1. - d__1 * d__1) / temp; L120: /* form appropriate convex combination of the gauss-newton */ /* direction and the scaled gradient direction. */ temp = (1. - alpha) * min(sgnorm,*delta); i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = temp * wa1[j] + alpha * x[j]; /* L130: */ } /* L140: */ return; /* last card of subroutine dogleg. */ } /* dogleg_ */ cminpack-1.3.4/dpmpar.c000644 000765 000765 00000015056 12225167750 014721 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" #define double_EPSILON DBL_EPSILON #define double_MIN DBL_MIN #define double_MAX DBL_MAX #define float_EPSILON FLT_EPSILON #define float_MIN FLT_MIN #define float_MAX FLT_MAX #define half_EPSILON HALF_EPSILON #define half_MIN HALF_NRM_MIN #define half_MAX HALF_MAX #define DPMPAR(type,X) _DPMPAR(type,X) #define _DPMPAR(type,X) type ## _ ## X __cminpack_attr__ real __cminpack_func__(dpmpar)(int i) { /* ********** */ /* Function dpmpar */ /* This function provides double precision machine parameters */ /* when the appropriate set of data statements is activated (by */ /* removing the c from column 1) and all other data statements are */ /* rendered inactive. Most of the parameter values were obtained */ /* from the corresponding Bell Laboratories Port Library function. */ /* The function statement is */ /* double precision function dpmpar(i) */ /* where */ /* i is an integer input variable set to 1, 2, or 3 which */ /* selects the desired machine parameter. If the machine has */ /* t base b digits and its smallest and largest exponents are */ /* emin and emax, respectively, then these parameters are */ /* dpmpar(1) = b**(1 - t), the machine precision, */ /* dpmpar(2) = b**(emin - 1), the smallest magnitude, */ /* dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. */ /* Argonne National Laboratory. MINPACK Project. November 1996. */ /* Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' */ /* ********** */ /* Machine constants for the IBM 360/370 series, */ /* the Amdahl 470/V6, the ICL 2900, the Itel AS/6, */ /* the Xerox Sigma 5/7/9 and the Sel systems 85/86. */ /* data mcheps(1),mcheps(2) / z34100000, z00000000 / */ /* data minmag(1),minmag(2) / z00100000, z00000000 / */ /* data maxmag(1),maxmag(2) / z7fffffff, zffffffff / */ /* Machine constants for the Honeywell 600/6000 series. */ /* data mcheps(1),mcheps(2) / o606400000000, o000000000000 / */ /* data minmag(1),minmag(2) / o402400000000, o000000000000 / */ /* data maxmag(1),maxmag(2) / o376777777777, o777777777777 / */ /* Machine constants for the CDC 6000/7000 series. */ /* data mcheps(1) / 15614000000000000000b / */ /* data mcheps(2) / 15010000000000000000b / */ /* data minmag(1) / 00604000000000000000b / */ /* data minmag(2) / 00000000000000000000b / */ /* data maxmag(1) / 37767777777777777777b / */ /* data maxmag(2) / 37167777777777777777b / */ /* Machine constants for the PDP-10 (KA processor). */ /* data mcheps(1),mcheps(2) / "114400000000, "000000000000 / */ /* data minmag(1),minmag(2) / "033400000000, "000000000000 / */ /* data maxmag(1),maxmag(2) / "377777777777, "344777777777 / */ /* Machine constants for the PDP-10 (KI processor). */ /* data mcheps(1),mcheps(2) / "104400000000, "000000000000 / */ /* data minmag(1),minmag(2) / "000400000000, "000000000000 / */ /* data maxmag(1),maxmag(2) / "377777777777, "377777777777 / */ /* Machine constants for the PDP-11. */ /* data mcheps(1),mcheps(2) / 9472, 0 / */ /* data mcheps(3),mcheps(4) / 0, 0 / */ /* data minmag(1),minmag(2) / 128, 0 / */ /* data minmag(3),minmag(4) / 0, 0 / */ /* data maxmag(1),maxmag(2) / 32767, -1 / */ /* data maxmag(3),maxmag(4) / -1, -1 / */ /* Machine constants for the Burroughs 6700/7700 systems. */ /* data mcheps(1) / o1451000000000000 / */ /* data mcheps(2) / o0000000000000000 / */ /* data minmag(1) / o1771000000000000 / */ /* data minmag(2) / o7770000000000000 / */ /* data maxmag(1) / o0777777777777777 / */ /* data maxmag(2) / o7777777777777777 / */ /* Machine constants for the Burroughs 5700 system. */ /* data mcheps(1) / o1451000000000000 / */ /* data mcheps(2) / o0000000000000000 / */ /* data minmag(1) / o1771000000000000 / */ /* data minmag(2) / o0000000000000000 / */ /* data maxmag(1) / o0777777777777777 / */ /* data maxmag(2) / o0007777777777777 / */ /* Machine constants for the Burroughs 1700 system. */ /* data mcheps(1) / zcc6800000 / */ /* data mcheps(2) / z000000000 / */ /* data minmag(1) / zc00800000 / */ /* data minmag(2) / z000000000 / */ /* data maxmag(1) / zdffffffff / */ /* data maxmag(2) / zfffffffff / */ /* Machine constants for the Univac 1100 series. */ /* data mcheps(1),mcheps(2) / o170640000000, o000000000000 / */ /* data minmag(1),minmag(2) / o000040000000, o000000000000 / */ /* data maxmag(1),maxmag(2) / o377777777777, o777777777777 / */ /* Machine constants for the Data General Eclipse S/200. */ /* Note - it may be appropriate to include the following card - */ /* static dmach(3) */ /* data minmag/20k,3*0/,maxmag/77777k,3*177777k/ */ /* data mcheps/32020k,3*0/ */ /* Machine constants for the Harris 220. */ /* data mcheps(1),mcheps(2) / '20000000, '00000334 / */ /* data minmag(1),minmag(2) / '20000000, '00000201 / */ /* data maxmag(1),maxmag(2) / '37777777, '37777577 / */ /* Machine constants for the Cray-1. */ /* data mcheps(1) / 0376424000000000000000b / */ /* data mcheps(2) / 0000000000000000000000b / */ /* data minmag(1) / 0200034000000000000000b / */ /* data minmag(2) / 0000000000000000000000b / */ /* data maxmag(1) / 0577777777777777777777b / */ /* data maxmag(2) / 0000007777777777777776b / */ /* Machine constants for the Prime 400. */ /* data mcheps(1),mcheps(2) / :10000000000, :00000000123 / */ /* data minmag(1),minmag(2) / :10000000000, :00000100000 / */ /* data maxmag(1),maxmag(2) / :17777777777, :37777677776 / */ /* Machine constants for the VAX-11. */ /* data mcheps(1),mcheps(2) / 9472, 0 / */ /* data minmag(1),minmag(2) / 128, 0 / */ /* data maxmag(1),maxmag(2) / -32769, -1 / */ /* Machine constants for IEEE machines. */ /* data dmach(1) /2.22044604926d-16/ */ /* data dmach(2) /2.22507385852d-308/ */ /* data dmach(3) /1.79769313485d+308/ */ switch(i) { case 1: return DPMPAR(real,EPSILON); /* 2.2204460492503131e-16 | 1.19209290e-07F */ case 2: return DPMPAR(real,MIN); /* 2.2250738585072014e-308 | 1.17549435e-38F */ default: return DPMPAR(real,MAX); /* 1.7976931348623157e+308 | 3.40282347e+38F */ } /* Last card of function dpmpar. */ } /* dpmpar_ */ #undef mcheps #undef maxmag #undef minmag #undef dmach cminpack-1.3.4/dpmpar_.c000644 000765 000765 00000015320 12225167750 015052 0ustar00devernay000000 000000 /* dpmpar.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define double_EPSILON DBL_EPSILON #define double_MIN DBL_MIN #define double_MAX DBL_MAX #define float_EPSILON FLT_EPSILON #define float_MIN FLT_MIN #define float_MAX FLT_MAX #define half_EPSILON HALF_EPSILON #define half_MIN HALF_NRM_MIN #define half_MAX HALF_MAX #define DPMPAR(type,X) _DPMPAR(type,X) #define _DPMPAR(type,X) type ## _ ## X __minpack_attr__ real __minpack_func__(dpmpar)(const int *i) { /* ********** */ /* Function dpmpar */ /* This function provides double precision machine parameters */ /* when the appropriate set of data statements is activated (by */ /* removing the c from column 1) and all other data statements are */ /* rendered inactive. Most of the parameter values were obtained */ /* from the corresponding Bell Laboratories Port Library function. */ /* The function statement is */ /* double precision function dpmpar(i) */ /* where */ /* i is an integer input variable set to 1, 2, or 3 which */ /* selects the desired machine parameter. If the machine has */ /* t base b digits and its smallest and largest exponents are */ /* emin and emax, respectively, then these parameters are */ /* dpmpar(1) = b**(1 - t), the machine precision, */ /* dpmpar(2) = b**(emin - 1), the smallest magnitude, */ /* dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. */ /* Argonne National Laboratory. MINPACK Project. November 1996. */ /* Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' */ /* ********** */ /* Machine constants for the IBM 360/370 series, */ /* the Amdahl 470/V6, the ICL 2900, the Itel AS/6, */ /* the Xerox Sigma 5/7/9 and the Sel systems 85/86. */ /* data mcheps(1),mcheps(2) / z34100000, z00000000 / */ /* data minmag(1),minmag(2) / z00100000, z00000000 / */ /* data maxmag(1),maxmag(2) / z7fffffff, zffffffff / */ /* Machine constants for the Honeywell 600/6000 series. */ /* data mcheps(1),mcheps(2) / o606400000000, o000000000000 / */ /* data minmag(1),minmag(2) / o402400000000, o000000000000 / */ /* data maxmag(1),maxmag(2) / o376777777777, o777777777777 / */ /* Machine constants for the CDC 6000/7000 series. */ /* data mcheps(1) / 15614000000000000000b / */ /* data mcheps(2) / 15010000000000000000b / */ /* data minmag(1) / 00604000000000000000b / */ /* data minmag(2) / 00000000000000000000b / */ /* data maxmag(1) / 37767777777777777777b / */ /* data maxmag(2) / 37167777777777777777b / */ /* Machine constants for the PDP-10 (KA processor). */ /* data mcheps(1),mcheps(2) / "114400000000, "000000000000 / */ /* data minmag(1),minmag(2) / "033400000000, "000000000000 / */ /* data maxmag(1),maxmag(2) / "377777777777, "344777777777 / */ /* Machine constants for the PDP-10 (KI processor). */ /* data mcheps(1),mcheps(2) / "104400000000, "000000000000 / */ /* data minmag(1),minmag(2) / "000400000000, "000000000000 / */ /* data maxmag(1),maxmag(2) / "377777777777, "377777777777 / */ /* Machine constants for the PDP-11. */ /* data mcheps(1),mcheps(2) / 9472, 0 / */ /* data mcheps(3),mcheps(4) / 0, 0 / */ /* data minmag(1),minmag(2) / 128, 0 / */ /* data minmag(3),minmag(4) / 0, 0 / */ /* data maxmag(1),maxmag(2) / 32767, -1 / */ /* data maxmag(3),maxmag(4) / -1, -1 / */ /* Machine constants for the Burroughs 6700/7700 systems. */ /* data mcheps(1) / o1451000000000000 / */ /* data mcheps(2) / o0000000000000000 / */ /* data minmag(1) / o1771000000000000 / */ /* data minmag(2) / o7770000000000000 / */ /* data maxmag(1) / o0777777777777777 / */ /* data maxmag(2) / o7777777777777777 / */ /* Machine constants for the Burroughs 5700 system. */ /* data mcheps(1) / o1451000000000000 / */ /* data mcheps(2) / o0000000000000000 / */ /* data minmag(1) / o1771000000000000 / */ /* data minmag(2) / o0000000000000000 / */ /* data maxmag(1) / o0777777777777777 / */ /* data maxmag(2) / o0007777777777777 / */ /* Machine constants for the Burroughs 1700 system. */ /* data mcheps(1) / zcc6800000 / */ /* data mcheps(2) / z000000000 / */ /* data minmag(1) / zc00800000 / */ /* data minmag(2) / z000000000 / */ /* data maxmag(1) / zdffffffff / */ /* data maxmag(2) / zfffffffff / */ /* Machine constants for the Univac 1100 series. */ /* data mcheps(1),mcheps(2) / o170640000000, o000000000000 / */ /* data minmag(1),minmag(2) / o000040000000, o000000000000 / */ /* data maxmag(1),maxmag(2) / o377777777777, o777777777777 / */ /* Machine constants for the Data General Eclipse S/200. */ /* Note - it may be appropriate to include the following card - */ /* static dmach(3) */ /* data minmag/20k,3*0/,maxmag/77777k,3*177777k/ */ /* data mcheps/32020k,3*0/ */ /* Machine constants for the Harris 220. */ /* data mcheps(1),mcheps(2) / '20000000, '00000334 / */ /* data minmag(1),minmag(2) / '20000000, '00000201 / */ /* data maxmag(1),maxmag(2) / '37777777, '37777577 / */ /* Machine constants for the Cray-1. */ /* data mcheps(1) / 0376424000000000000000b / */ /* data mcheps(2) / 0000000000000000000000b / */ /* data minmag(1) / 0200034000000000000000b / */ /* data minmag(2) / 0000000000000000000000b / */ /* data maxmag(1) / 0577777777777777777777b / */ /* data maxmag(2) / 0000007777777777777776b / */ /* Machine constants for the Prime 400. */ /* data mcheps(1),mcheps(2) / :10000000000, :00000000123 / */ /* data minmag(1),minmag(2) / :10000000000, :00000100000 / */ /* data maxmag(1),maxmag(2) / :17777777777, :37777677776 / */ /* Machine constants for the VAX-11. */ /* data mcheps(1),mcheps(2) / 9472, 0 / */ /* data minmag(1),minmag(2) / 128, 0 / */ /* data maxmag(1),maxmag(2) / -32769, -1 / */ /* Machine constants for IEEE machines. */ /* data dmach(1) /2.22044604926d-16/ */ /* data dmach(2) /2.22507385852d-308/ */ /* data dmach(3) /1.79769313485d+308/ */ switch(*i) { case 1: return DPMPAR(real,EPSILON); /* 2.2204460492503131e-16 | 1.19209290e-07F */ case 2: return DPMPAR(real,MIN); /* 2.2250738585072014e-308 | 1.17549435e-38F */ default: return DPMPAR(real,MAX); /* 1.7976931348623157e+308 | 3.40282347e+38F */ } /* Last card of function dpmpar. */ } /* dpmpar_ */ #undef mcheps #undef maxmag #undef minmag #undef dmach cminpack-1.3.4/enorm.c000644 000765 000765 00000011154 12275177300 014546 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" /* About the values for rdwarf and rgiant. The original values, both in single-precision FORTRAN source code and in double-precision code were: #define rdwarf 3.834e-20 #define rgiant 1.304e19 See for example: http://www.netlib.org/slatec/src/denorm.f http://www.netlib.org/slatec/src/enorm.f However, rdwarf is smaller than sqrt(FLT_MIN) = 1.0842021724855044e-19, so that rdwarf**2 will underflow. This contradicts the constraints expressed in the comments below. We changed these constants to those proposed by the implementation found in MPFIT http://cow.physics.wisc.edu/~craigm/idl/fitting.html cmpfit-1.2 proposes the following definitions: rdwarf = sqrt(dpmpar(2)*1.5) * 10 rgiant = sqrt(dpmpar(3)) * 0.1 The half version does not really worked that way, so we use for half: rdwarf = sqrt(dpmpar(2)) * 2 rgiant = sqrt(dpmpar(3)) * 0.5 Any suggestion is welcome. Half CMINPACK is really only a proof-of-concept anyway. See the example/tenorm*c, which computes these values */ #define double_dwarf (1.82691291192569e-153) #define double_giant (1.34078079299426e+153) #define float_dwarf (1.327871072777421e-18f) #define float_giant (1.844674297419792e+18f) #define half_dwarf (0.015625f) #define half_giant (127.9375f) #define dwarf(type) _dwarf(type) #define _dwarf(type) type ## _dwarf #define giant(type) _giant(type) #define _giant(type) type ## _giant #define rdwarf dwarf(real) #define rgiant giant(real) __cminpack_attr__ real __cminpack_func__(enorm)(int n, const real *x) { #ifdef USE_CBLAS return cblas_dnrm2(n, x, 1); #else /* !USE_CBLAS */ /* System generated locals */ real ret_val, d1; /* Local variables */ int i; real s1, s2, s3, xabs, x1max, x3max, agiant; /* ********** */ /* function enorm */ /* given an n-vector x, this function calculates the */ /* euclidean norm of x. */ /* the euclidean norm is computed by accumulating the sum of */ /* squares in three different sums. the sums of squares for the */ /* small and large components are scaled so that no overflows */ /* occur. non-destructive underflows are permitted. underflows */ /* and overflows do not occur in the computation of the unscaled */ /* sum of squares for the intermediate components. */ /* the definitions of small, intermediate and large components */ /* depend on two constants, rdwarf and rgiant. the main */ /* restrictions on these constants are that rdwarf**2 not */ /* underflow and rgiant**2 not overflow. the constants */ /* given here are suitable for every known computer. */ /* the function statement is */ /* double precision function enorm(n,x) */ /* where */ /* n is a positive integer input variable. */ /* x is an input array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ s1 = 0.; s2 = 0.; s3 = 0.; x1max = 0.; x3max = 0.; agiant = rgiant / (real)n; for (i = 0; i < n; ++i) { xabs = fabs(x[i]); if (xabs >= agiant) { /* sum for large components. */ if (xabs > x1max) { /* Computing 2nd power */ d1 = x1max / xabs; s1 = 1. + s1 * (d1 * d1); x1max = xabs; } else { /* Computing 2nd power */ d1 = xabs / x1max; s1 += d1 * d1; } } else if (xabs <= rdwarf) { /* sum for small components. */ if (xabs > x3max) { /* Computing 2nd power */ d1 = x3max / xabs; s3 = 1. + s3 * (d1 * d1); x3max = xabs; } else if (xabs != 0.) { /* Computing 2nd power */ d1 = xabs / x3max; s3 += d1 * d1; } } else { /* sum for intermediate components. */ /* Computing 2nd power */ s2 += xabs * xabs; } } /* calculation of norm. */ if (s1 != 0.) { ret_val = x1max * sqrt(s1 + (s2 / x1max) / x1max); } else if (s2 != 0.) { if (s2 >= x3max) { ret_val = sqrt(s2 * (1. + (x3max / s2) * (x3max * s3))); } else { ret_val = sqrt(x3max * ((s2 / x3max) + (x3max * s3))); } } else { ret_val = x3max * sqrt(s3); } return ret_val; /* last card of function enorm. */ #endif /* !USE_CBLAS */ } /* enorm_ */ cminpack-1.3.4/enorm_.c000644 000765 000765 00000011333 12275201532 014677 0ustar00devernay000000 000000 /* enorm.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ /* About the values for rdwarf and rgiant. The original values, both in single-precision FORTRAN source code and in double-precision code were: #define rdwarf 3.834e-20 #define rgiant 1.304e19 See for example: http://www.netlib.org/slatec/src/denorm.f http://www.netlib.org/slatec/src/enorm.f However, rdwarf is smaller than sqrt(FLT_MIN) = 1.0842021724855044e-19, so that rdwarf**2 will underflow. This contradicts the constraints expressed in the comments below. We changed these constants to those proposed by the implementation found in MPFIT http://cow.physics.wisc.edu/~craigm/idl/fitting.html cmpfit-1.2 proposes the following definitions: rdwarf = sqrt(dpmpar(2)*1.5) * 10 rgiant = sqrt(dpmpar(3)) * 0.1 The half version does not really worked that way, so we use for half: rdwarf = sqrt(dpmpar(2)) * 2 rgiant = sqrt(dpmpar(3)) * 0.5 Any suggestion is welcome. Half CMINPACK is really only a proof-of-concept anyway. See the example/tenorm*c, which computes these values */ #define double_dwarf (1.82691291192569e-153) #define double_giant (1.34078079299426e+153) #define float_dwarf (1.327871072777421e-18f) #define float_giant (1.844674297419792e+18f) #define half_dwarf (0.015625f) #define half_giant (127.9375f) #define dwarf(type) _dwarf(type) #define _dwarf(type) type ## _dwarf #define giant(type) _giant(type) #define _giant(type) type ## _giant #define rdwarf dwarf(real) #define rgiant giant(real) __minpack_attr__ real __minpack_func__(enorm)(const int *n, const real *x) { /* System generated locals */ int i__1; real ret_val, d__1; /* Local variables */ int i__; real s1, s2, s3, xabs, x1max, x3max, agiant, floatn; /* ********** */ /* function enorm */ /* given an n-vector x, this function calculates the */ /* euclidean norm of x. */ /* the euclidean norm is computed by accumulating the sum of */ /* squares in three different sums. the sums of squares for the */ /* small and large components are scaled so that no overflows */ /* occur. non-destructive underflows are permitted. underflows */ /* and overflows do not occur in the computation of the unscaled */ /* sum of squares for the intermediate components. */ /* the definitions of small, intermediate and large components */ /* depend on two constants, rdwarf and rgiant. the main */ /* restrictions on these constants are that rdwarf**2 not */ /* underflow and rgiant**2 not overflow. the constants */ /* given here are suitable for every known computer. */ /* the function statement is */ /* double precision function enorm(n,x) */ /* where */ /* n is a positive integer input variable. */ /* x is an input array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; /* Function Body */ s1 = 0.; s2 = 0.; s3 = 0.; x1max = 0.; x3max = 0.; floatn = (real) (*n); agiant = rgiant / floatn; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { xabs = fabs(x[i__]); if (xabs > rdwarf && xabs < agiant) { goto L70; } if (xabs <= rdwarf) { goto L30; } /* sum for large components. */ if (xabs <= x1max) { goto L10; } /* Computing 2nd power */ d__1 = x1max / xabs; s1 = 1. + s1 * (d__1 * d__1); x1max = xabs; goto L20; L10: /* Computing 2nd power */ d__1 = xabs / x1max; s1 += d__1 * d__1; L20: goto L60; L30: /* sum for small components. */ if (xabs <= x3max) { goto L40; } /* Computing 2nd power */ d__1 = x3max / xabs; s3 = 1. + s3 * (d__1 * d__1); x3max = xabs; goto L50; L40: if (xabs != 0.) { /* Computing 2nd power */ d__1 = xabs / x3max; s3 += d__1 * d__1; } L50: L60: goto L80; L70: /* sum for intermediate components. */ /* Computing 2nd power */ d__1 = xabs; s2 += d__1 * d__1; L80: /* L90: */ ; } /* calculation of norm. */ if (s1 == 0.) { goto L100; } ret_val = x1max * sqrt(s1 + s2 / x1max / x1max); goto L130; L100: if (s2 == 0.) { goto L110; } if (s2 >= x3max) { ret_val = sqrt(s2 * (1. + x3max / s2 * (x3max * s3))); } if (s2 < x3max) { ret_val = sqrt(x3max * (s2 / x3max + x3max * s3)); } goto L120; L110: ret_val = x3max * sqrt(s3); L120: L130: return ret_val; /* last card of function enorm. */ } /* enorm_ */ cminpack-1.3.4/examples/000755 000765 000765 00000000000 12303616441 015072 5ustar00devernay000000 000000 cminpack-1.3.4/fdjac1.c000644 000765 000765 00000013241 12225167750 014560 0ustar00devernay000000 000000 /* fdjac1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, const real * fvec, real *fjac, int ldfjac, int ml, int mu, real epsfcn, real *wa1, real *wa2) { /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ real h; int i, j, k; real eps, temp; int msum; real epsmch; int iflag = 0; /* ********** */ /* subroutine fdjac1 */ /* this subroutine computes a forward-difference approximation */ /* to the n by n jacobian matrix associated with a specified */ /* problem of n functions in n variables. if the jacobian has */ /* a banded form, then function evaluations are saved by only */ /* approximating the nonzero terms. */ /* the subroutine statement is */ /* subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, */ /* wa1,wa2) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of fdjac1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an input array of length n. */ /* fvec is an input array of length n which must contain the */ /* functions evaluated at x. */ /* fjac is an output n by n array which contains the */ /* approximation to the jacobian matrix evaluated at x. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* iflag is an integer variable which can be used to terminate */ /* the execution of fdjac1. see description of fcn. */ /* ml 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 */ /* ml to at least n - 1. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* mu 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 n - 1. */ /* wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at */ /* least n, then the jacobian is considered dense, and wa2 is */ /* not referenced. */ /* subprograms called */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dmax1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa2; --wa1; --fvec; --x; fjac_dim1 = ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); eps = sqrt((max(epsfcn,epsmch))); msum = ml + mu + 1; if (msum >= n) { /* computation of dense approximate jacobian. */ for (j = 1; j <= n; ++j) { temp = x[j]; h = eps * fabs(temp); if (h == 0.) { h = eps; } x[j] = temp + h; /* the last parameter of fcn_nn() is set to 2 to tell calls made to compute the function from calls made to compute the Jacobian (see fcn() in tlmfdrv.c) */ iflag = fcn_nn(p, n, &x[1], &wa1[1], 2); if (iflag < 0) { return iflag; } x[j] = temp; for (i = 1; i <= n; ++i) { fjac[i + j * fjac_dim1] = (wa1[i] - fvec[i]) / h; } } return 0; } /* computation of banded approximate jacobian. */ for (k = 1; k <= msum; ++k) { for (j = k; msum < 0 ? j >= n : j <= n; j += msum) { wa2[j] = x[j]; h = eps * fabs(wa2[j]); if (h == 0.) { h = eps; } x[j] = wa2[j] + h; } iflag = fcn_nn(p, n, &x[1], &wa1[1], 1); if (iflag < 0) { return iflag; } for (j = k; msum < 0 ? j >= n : j <= n; j += msum) { x[j] = wa2[j]; h = eps * fabs(wa2[j]); if (h == 0.) { h = eps; } for (i = 1; i <= n; ++i) { fjac[i + j * fjac_dim1] = 0.; if (i >= j - mu && i <= j + ml) { fjac[i + j * fjac_dim1] = (wa1[i] - fvec[i]) / h; } } } } return 0; /* last card of subroutine fdjac1. */ } /* fdjac1_ */ cminpack-1.3.4/fdjac1_.c000644 000765 000765 00000013425 12225167750 014723 0ustar00devernay000000 000000 /* fdjac1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define max(a,b) ((a) >= (b) ? (a) : (b)) __minpack_attr__ void __minpack_func__(fdjac1)(__minpack_decl_fcn_nn__ const int *n, real *x, const real * fvec, real *fjac, const int *ldfjac, int *iflag, const int *ml, const int *mu, const real *epsfcn, real *wa1, real *wa2) { /* Table of constant values */ const int c__1 = 1; /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2, i__3, i__4; /* Local variables */ real h__; int i__, j, k; real eps, temp; int msum; real epsmch; /* ********** */ /* subroutine fdjac1 */ /* this subroutine computes a forward-difference approximation */ /* to the n by n jacobian matrix associated with a specified */ /* problem of n functions in n variables. if the jacobian has */ /* a banded form, then function evaluations are saved by only */ /* approximating the nonzero terms. */ /* the subroutine statement is */ /* subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, */ /* wa1,wa2) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of fdjac1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an input array of length n. */ /* fvec is an input array of length n which must contain the */ /* functions evaluated at x. */ /* fjac is an output n by n array which contains the */ /* approximation to the jacobian matrix evaluated at x. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* iflag is an integer variable which can be used to terminate */ /* the execution of fdjac1. see description of fcn. */ /* ml 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 */ /* ml to at least n - 1. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* mu 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 n - 1. */ /* wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at */ /* least n, then the jacobian is considered dense, and wa2 is */ /* not referenced. */ /* subprograms called */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dmax1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa2; --wa1; --fvec; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); eps = sqrt((max(*epsfcn,epsmch))); msum = *ml + *mu + 1; if (msum < *n) { goto L40; } /* computation of dense approximate jacobian. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { temp = x[j]; h__ = eps * fabs(temp); if (h__ == 0.) { h__ = eps; } x[j] = temp + h__; fcn_nn(n, &x[1], &wa1[1], iflag); if (*iflag < 0) { goto L30; } x[j] = temp; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { fjac[i__ + j * fjac_dim1] = (wa1[i__] - fvec[i__]) / h__; /* L10: */ } /* L20: */ } L30: /* goto L110; */ return; L40: /* computation of banded approximate jacobian. */ i__1 = msum; for (k = 1; k <= i__1; ++k) { i__2 = *n; i__3 = msum; for (j = k; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3) { wa2[j] = x[j]; h__ = eps * fabs(wa2[j]); if (h__ == 0.) { h__ = eps; } x[j] = wa2[j] + h__; /* L60: */ } fcn_nn(n, &x[1], &wa1[1], iflag); if (*iflag < 0) { /* goto L100; */ return; } i__3 = *n; i__2 = msum; for (j = k; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2) { x[j] = wa2[j]; h__ = eps * fabs(wa2[j]); if (h__ == 0.) { h__ = eps; } i__4 = *n; for (i__ = 1; i__ <= i__4; ++i__) { fjac[i__ + j * fjac_dim1] = 0.; if (i__ >= j - *mu && i__ <= j + *ml) { fjac[i__ + j * fjac_dim1] = (wa1[i__] - fvec[i__]) / h__; } /* L70: */ } /* L80: */ } /* L90: */ } /* L100: */ /* L110: */ return; /* last card of subroutine fdjac1. */ } /* fdjac1_ */ cminpack-1.3.4/fdjac2.c000644 000765 000765 00000007222 12225167750 014563 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, const real *fvec, real *fjac, int ldfjac, real epsfcn, real *wa) { /* Local variables */ real h; int i, j; real eps, temp, epsmch; int iflag; /* ********** */ /* subroutine fdjac2 */ /* this subroutine computes a forward-difference approximation */ /* to the m by n jacobian matrix associated with a specified */ /* problem of m functions in n variables. */ /* the subroutine statement is */ /* subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of fdjac2. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an input array of length n. */ /* fvec is an input array of length m which must contain the */ /* functions evaluated at x. */ /* fjac is an output m by n array which contains the */ /* approximation to the jacobian matrix evaluated at x. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* iflag is an integer variable which can be used to terminate */ /* the execution of fdjac2. see description of fcn. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* wa is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dmax1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); eps = sqrt((max(epsfcn,epsmch))); for (j = 0; j < n; ++j) { temp = x[j]; h = eps * fabs(temp); if (h == 0.) { h = eps; } x[j] = temp + h; /* the last parameter of fcn_mn() is set to 2 to tell calls made to compute the function from calls made to compute the Jacobian (see fcn() in tlmfdrv.c) */ iflag = fcn_mn(p, m, n, x, wa, 2); if (iflag < 0) { return iflag; } x[j] = temp; for (i = 0; i < m; ++i) { fjac[i + j * ldfjac] = (wa[i] - fvec[i]) / h; } } return 0; /* last card of subroutine fdjac2. */ } /* fdjac2_ */ cminpack-1.3.4/fdjac2_.c000644 000765 000765 00000010133 12225167750 014715 0ustar00devernay000000 000000 /* fdjac2.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define max(a,b) ((a) >= (b) ? (a) : (b)) __minpack_attr__ void __minpack_func__(fdjac2)(__minpack_decl_fcn_mn__ const int *m, const int *n, real *x, const real *fvec, real *fjac, const int *ldfjac, int *iflag, const real *epsfcn, real *wa) { /* Table of constant values */ const int c__1 = 1; /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; /* Local variables */ real h__; int i__, j; real eps, temp, epsmch; /* ********** */ /* subroutine fdjac2 */ /* this subroutine computes a forward-difference approximation */ /* to the m by n jacobian matrix associated with a specified */ /* problem of m functions in n variables. */ /* the subroutine statement is */ /* subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of fdjac2. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an input array of length n. */ /* fvec is an input array of length m which must contain the */ /* functions evaluated at x. */ /* fjac is an output m by n array which contains the */ /* approximation to the jacobian matrix evaluated at x. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* iflag is an integer variable which can be used to terminate */ /* the execution of fdjac2. see description of fcn. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* wa is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dmax1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; --fvec; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); eps = sqrt((max(*epsfcn,epsmch))); i__1 = *n; for (j = 1; j <= i__1; ++j) { temp = x[j]; h__ = eps * fabs(temp); if (h__ == 0.) { h__ = eps; } x[j] = temp + h__; fcn_mn(m, n, &x[1], &wa[1], iflag); if (*iflag < 0) { /* goto L30; */ return; } x[j] = temp; i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { fjac[i__ + j * fjac_dim1] = (wa[i__] - fvec[i__]) / h__; /* L10: */ } /* L20: */ } /* L30: */ return; /* last card of subroutine fdjac2. */ } /* fdjac2_ */ cminpack-1.3.4/fortran/000755 000765 000765 00000000000 12303616330 014724 5ustar00devernay000000 000000 cminpack-1.3.4/hybrd.c000644 000765 000765 00000042306 12225167750 014544 0ustar00devernay000000 000000 /* hybrd.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(hybrd)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, real * fvec, real xtol, int maxfev, int ml, int mu, real epsfcn, real *diag, int mode, real factor, int nprint, int *nfev, real * fjac, int ldfjac, real *r, int lr, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p001 .001 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset, i1; real d1, d2; /* Local variables */ int i, j, l, jm1, iwa[1]; real sum; int sing; int iter; real temp; int msum, iflag; real delta = 0.; int jeval; int ncsuc; real ratio; real fnorm; real pnorm, xnorm = 0., fnorm1; int nslow1, nslow2; int ncfail; real actred, epsmch, prered; int info; /* ********** */ /* subroutine hybrd */ /* the purpose of hybrd is to find a zero of a system of */ /* n nonlinear functions in n 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. */ /* the subroutine statement is */ /* subroutine 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) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrd. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn is at least maxfev */ /* by the end of an iteration. */ /* ml 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 */ /* ml to at least n - 1. */ /* mu 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 n - 1. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 2 number of calls to fcn has reached or exceeded */ /* maxfev. */ /* info = 3 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* five jacobian evaluations. */ /* info = 5 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* ten iterations. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* r is an output array of length lr which contains the */ /* upper triangular matrix produced by the qr factorization */ /* of the final approximate jacobian, stored rowwise. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* qtf is an output array of length n which contains */ /* the vector (q transpose)*fvec. */ /* wa1, wa2, wa3, and wa4 are work arrays of length n. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dogleg,dpmpar,enorm,fdjac1, */ /* qform,qrfac,r1mpyq,r1updt */ /* fortran-supplied ... dabs,dmax1,dmin1,min0,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --wa3; --wa2; --wa1; --qtf; --diag; --fvec; --x; fjac_dim1 = ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --r; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); info = 0; iflag = 0; *nfev = 0; /* check the input parameters for errors. */ if (n <= 0 || xtol < 0. || maxfev <= 0 || ml < 0 || mu < 0 || factor <= 0. || ldfjac < n || lr < n * (n + 1) / 2) { goto TERMINATE; } if (mode == 2) { for (j = 1; j <= n; ++j) { if (diag[j] <= 0.) { goto TERMINATE; } } } /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = fcn_nn(p, n, &x[1], &fvec[1], 1); *nfev = 1; if (iflag < 0) { goto TERMINATE; } fnorm = __cminpack_enorm__(n, &fvec[1]); /* determine the number of calls to fcn needed to compute */ /* the jacobian matrix. */ /* Computing MIN */ i1 = ml + mu + 1; msum = min(i1,n); /* initialize iteration counter and monitors. */ iter = 1; ncsuc = 0; ncfail = 0; nslow1 = 0; nslow2 = 0; /* beginning of the outer loop. */ for (;;) { jeval = TRUE_; /* calculate the jacobian matrix. */ iflag = __cminpack_func__(fdjac1)(__cminpack_param_fcn_nn__ p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, ml, mu, epsfcn, &wa1[1], &wa2[1]); *nfev += msum; if (iflag < 0) { goto TERMINATE; } /* compute the qr factorization of the jacobian. */ __cminpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, FALSE_, iwa, 1, &wa1[1], &wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter == 1) { if (mode != 2) { for (j = 1; j <= n; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } } } /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ for (j = 1; j <= n; ++j) { wa3[j] = diag[j] * x[j]; } xnorm = __cminpack_enorm__(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; } } /* form (q transpose)*fvec and store in qtf. */ for (i = 1; i <= n; ++i) { qtf[i] = fvec[i]; } for (j = 1; j <= n; ++j) { if (fjac[j + j * fjac_dim1] != 0.) { sum = 0.; for (i = j; i <= n; ++i) { sum += fjac[i + j * fjac_dim1] * qtf[i]; } temp = -sum / fjac[j + j * fjac_dim1]; for (i = j; i <= n; ++i) { qtf[i] += fjac[i + j * fjac_dim1] * temp; } } } /* copy the triangular factor of the qr factorization into r. */ sing = FALSE_; for (j = 1; j <= n; ++j) { l = j; jm1 = j - 1; if (jm1 >= 1) { for (i = 1; i <= jm1; ++i) { r[l] = fjac[i + j * fjac_dim1]; l = l + n - i; } } r[l] = wa1[j]; if (wa1[j] == 0.) { sing = TRUE_; } } /* accumulate the orthogonal factor in fjac. */ __cminpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]); /* rescale if necessary. */ if (mode != 2) { for (j = 1; j <= n; ++j) { /* Computing MAX */ d1 = diag[j], d2 = wa2[j]; diag[j] = max(d1,d2); } } /* beginning of the inner loop. */ for (;;) { /* if requested, call fcn to enable printing of iterates. */ if (nprint > 0) { iflag = 0; if ((iter - 1) % nprint == 0) { iflag = fcn_nn(p, n, &x[1], &fvec[1], 0); } if (iflag < 0) { goto TERMINATE; } } /* determine the direction p. */ __cminpack_func__(dogleg)(n, &r[1], lr, &diag[1], &qtf[1], delta, &wa1[1], &wa2[1], &wa3[1]); /* store the direction p and x + p. calculate the norm of p. */ for (j = 1; j <= n; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; } pnorm = __cminpack_enorm__(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = fcn_nn(p, n, &wa2[1], &wa4[1], 1); ++(*nfev); if (iflag < 0) { goto TERMINATE; } fnorm1 = __cminpack_enorm__(n, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) { /* Computing 2nd power */ d1 = fnorm1 / fnorm; actred = 1. - d1 * d1; } /* compute the scaled predicted reduction. */ l = 1; for (i = 1; i <= n; ++i) { sum = 0.; for (j = i; j <= n; ++j) { sum += r[l] * wa1[j]; ++l; } wa3[i] = qtf[i] + sum; } temp = __cminpack_enorm__(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ d1 = temp / fnorm; prered = 1. - d1 * d1; } /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered > 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio < p1) { ncsuc = 0; ++ncfail; delta = p5 * delta; } else { ncfail = 0; ++ncsuc; if (ratio >= p5 || ncsuc > 1) { /* Computing MAX */ d1 = pnorm / p5; delta = max(delta,d1); } if (fabs(ratio - 1.) <= p1) { delta = pnorm / p5; } } /* test for successful iteration. */ if (ratio >= p0001) { /* successful iteration. update x, fvec, and their norms. */ for (j = 1; j <= n; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; fvec[j] = wa4[j]; } xnorm = __cminpack_enorm__(n, &wa2[1]); fnorm = fnorm1; ++iter; } /* determine the progress of the iteration. */ ++nslow1; if (actred >= p001) { nslow1 = 0; } if (jeval) { ++nslow2; } if (actred >= p1) { nslow2 = 0; } /* test for convergence. */ if (delta <= xtol * xnorm || fnorm == 0.) { info = 1; } if (info != 0) { goto TERMINATE; } /* tests for termination and stringent tolerances. */ if (*nfev >= maxfev) { info = 2; } /* Computing MAX */ d1 = p1 * delta; if (p1 * max(d1,pnorm) <= epsmch * xnorm) { info = 3; } if (nslow2 == 5) { info = 4; } if (nslow1 == 10) { info = 5; } if (info != 0) { goto TERMINATE; } /* criterion for recalculating jacobian approximation */ /* by forward differences. */ if (ncfail == 2) { goto TERMINATE_INNER_LOOP; } /* calculate the rank one modification to the jacobian */ /* and update qtf if necessary. */ for (j = 1; j <= n; ++j) { sum = 0.; for (i = 1; i <= n; ++i) { sum += fjac[i + j * fjac_dim1] * wa4[i]; } wa2[j] = (sum - wa3[j]) / pnorm; wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm); if (ratio >= p0001) { qtf[j] = sum; } } /* compute the qr factorization of the updated jacobian. */ __cminpack_func__(r1updt)(n, n, &r[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing); __cminpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]); __cminpack_func__(r1mpyq)(1, n, &qtf[1], 1, &wa2[1], &wa3[1]); /* end of the inner loop. */ jeval = FALSE_; } TERMINATE_INNER_LOOP: ; /* end of the outer loop. */ } TERMINATE: /* termination, either normal or user imposed. */ if (iflag < 0) { info = iflag; } if (nprint > 0) { fcn_nn(p, n, &x[1], &fvec[1], 0); } return info; /* last card of subroutine hybrd. */ } /* hybrd_ */ cminpack-1.3.4/hybrd1.c000644 000765 000765 00000010635 12225167750 014625 0ustar00devernay000000 000000 /* hybrd1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(hybrd1)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, real * fvec, real tol, real *wa, int lwa) { /* Initialized data */ const real factor = 100.; /* Local variables */ int j, ml, lr, mu, mode, nfev; real xtol; int index; real epsfcn; int maxfev, nprint; int info; /* ********** */ /* subroutine hybrd1 */ /* the purpose of hybrd1 is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. this is done by using the */ /* more general nonlinear equation solver hybrd. the user */ /* must provide a subroutine which calculates the functions. */ /* the jacobian is then calculated by a forward-difference */ /* approximation. */ /* the subroutine statement is */ /* subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrd1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 2 number of calls to fcn has reached or exceeded */ /* 200*(n+1). */ /* info = 3 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* (n*(3*n+13))/2. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... hybrd */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; --wa; /* Function Body */ /* check the input parameters for errors. */ if (n <= 0 || tol < 0. || lwa < n * (n * 3 + 13) / 2) { return 0; } /* call hybrd. */ maxfev = (n + 1) * 200; xtol = tol; ml = n - 1; mu = n - 1; epsfcn = 0.; mode = 2; for (j = 1; j <= n; ++j) { wa[j] = 1.; } nprint = 0; lr = n * (n + 1) / 2; index = n * 6 + lr; info = __cminpack_func__(hybrd)(__cminpack_param_fcn_nn__ p, n, &x[1], &fvec[1], xtol, maxfev, ml, mu, epsfcn, & wa[1], mode, factor, nprint, &nfev, &wa[index + 1], n, & wa[n * 6 + 1], lr, &wa[n + 1], &wa[(n << 1) + 1], &wa[n * 3 + 1], &wa[(n << 2) + 1], &wa[n * 5 + 1]); if (info == 5) { info = 4; } return info; /* last card of subroutine hybrd1. */ } /* hybrd1_ */ cminpack-1.3.4/hybrd1_.c000644 000765 000765 00000011106 12225167750 014756 0ustar00devernay000000 000000 /* hybrd1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(hybrd1)(__minpack_decl_fcn_nn__ const int *n, real *x, real * fvec, const real *tol, int *info, real *wa, const int *lwa) { /* Initialized data */ const real factor = 100.; /* System generated locals */ int i__1; /* Local variables */ int j, ml, lr, mu, mode, nfev; real xtol; int index; real epsfcn; int maxfev, nprint; /* ********** */ /* subroutine hybrd1 */ /* the purpose of hybrd1 is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. this is done by using the */ /* more general nonlinear equation solver hybrd. the user */ /* must provide a subroutine which calculates the functions. */ /* the jacobian is then calculated by a forward-difference */ /* approximation. */ /* the subroutine statement is */ /* subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrd1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 2 number of calls to fcn has reached or exceeded */ /* 200*(n+1). */ /* info = 3 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* (n*(3*n+13))/2. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... hybrd */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; --wa; /* Function Body */ *info = 0; /* check the input parameters for errors. */ if (*n <= 0 || *tol < 0. || *lwa < *n * (*n * 3 + 13) / 2) { /* goto L20; */ return; } /* call hybrd. */ maxfev = (*n + 1) * 200; xtol = *tol; ml = *n - 1; mu = *n - 1; epsfcn = 0.; mode = 2; i__1 = *n; for (j = 1; j <= i__1; ++j) { wa[j] = 1.; /* L10: */ } nprint = 0; lr = *n * (*n + 1) / 2; index = *n * 6 + lr; __minpack_func__(hybrd)(__minpack_param_fcn_nn__ n, &x[1], &fvec[1], &xtol, &maxfev, &ml, &mu, &epsfcn, & wa[1], &mode, &factor, &nprint, info, &nfev, &wa[index + 1], n, & wa[*n * 6 + 1], &lr, &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]); if (*info == 5) { *info = 4; } /* L20: */ return; /* last card of subroutine hybrd1. */ } /* hybrd1_ */ cminpack-1.3.4/hybrd_.c000644 000765 000765 00000040156 12225167750 014704 0ustar00devernay000000 000000 /* hybrd.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(hybrd)(__minpack_decl_fcn_nn__ const int *n, real *x, real * fvec, const real *xtol, const int *maxfev, const int *ml, const int *mu, const real *epsfcn, real *diag, const int *mode, const real * factor, const int *nprint, int *info, int *nfev, real * fjac, const int *ldfjac, real *r__, const int *lr, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Table of constant values */ const int c__1 = 1; const int c_false = FALSE_; /* Initialized data */ #define p1 .1 #define p5 .5 #define p001 .001 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; real d__1, d__2; /* Local variables */ int i__, j, l, jm1, iwa[1]; real sum; int sing; int iter; real temp; int msum, iflag; real delta; int jeval; int ncsuc; real ratio; real fnorm; real pnorm, xnorm, fnorm1; int nslow1, nslow2; int ncfail; real actred, epsmch, prered; /* ********** */ /* subroutine hybrd */ /* the purpose of hybrd is to find a zero of a system of */ /* n nonlinear functions in n 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. */ /* the subroutine statement is */ /* subroutine 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) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrd. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn is at least maxfev */ /* by the end of an iteration. */ /* ml 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 */ /* ml to at least n - 1. */ /* mu 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 n - 1. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 2 number of calls to fcn has reached or exceeded */ /* maxfev. */ /* info = 3 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* five jacobian evaluations. */ /* info = 5 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* ten iterations. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* r is an output array of length lr which contains the */ /* upper triangular matrix produced by the qr factorization */ /* of the final approximate jacobian, stored rowwise. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* qtf is an output array of length n which contains */ /* the vector (q transpose)*fvec. */ /* wa1, wa2, wa3, and wa4 are work arrays of length n. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dogleg,dpmpar,enorm,fdjac1, */ /* qform,qrfac,r1mpyq,r1updt */ /* fortran-supplied ... dabs,dmax1,dmin1,min0,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --wa3; --wa2; --wa1; --qtf; --diag; --fvec; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --r__; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); *info = 0; iflag = 0; *nfev = 0; /* check the input parameters for errors. */ if (*n <= 0 || *xtol < 0. || *maxfev <= 0 || *ml < 0 || *mu < 0 || * factor <= 0. || *ldfjac < *n || *lr < *n * (*n + 1) / 2) { goto L300; } if (*mode != 2) { goto L20; } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (diag[j] <= 0.) { goto L300; } /* L10: */ } L20: /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = 1; fcn_nn(n, &x[1], &fvec[1], &iflag); *nfev = 1; if (iflag < 0) { goto L300; } fnorm = __minpack_func__(enorm)(n, &fvec[1]); /* determine the number of calls to fcn needed to compute */ /* the jacobian matrix. */ /* Computing MIN */ i__1 = *ml + *mu + 1; msum = min(i__1,*n); /* initialize iteration counter and monitors. */ iter = 1; ncsuc = 0; ncfail = 0; nslow1 = 0; nslow2 = 0; /* beginning of the outer loop. */ L30: jeval = TRUE_; /* calculate the jacobian matrix. */ iflag = 2; __minpack_func__(fdjac1)(__minpack_param_fcn_nn__ n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag, ml, mu, epsfcn, &wa1[1], &wa2[1]); *nfev += msum; if (iflag < 0) { goto L300; } /* compute the qr factorization of the jacobian. */ __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_false, iwa, &c__1, &wa1[1], & wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter != 1) { goto L70; } if (*mode == 2) { goto L50; } i__1 = *n; for (j = 1; j <= i__1; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } /* L40: */ } L50: /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = diag[j] * x[j]; /* L60: */ } xnorm = __minpack_func__(enorm)(n, &wa3[1]); delta = *factor * xnorm; if (delta == 0.) { delta = *factor; } L70: /* form (q transpose)*fvec and store in qtf. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { qtf[i__] = fvec[i__]; /* L80: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { goto L110; } sum = 0.; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * qtf[i__]; /* L90: */ } temp = -sum / fjac[j + j * fjac_dim1]; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { qtf[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L100: */ } L110: /* L120: */ ; } /* copy the triangular factor of the qr factorization into r. */ sing = FALSE_; i__1 = *n; for (j = 1; j <= i__1; ++j) { l = j; jm1 = j - 1; if (jm1 < 1) { goto L140; } i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { r__[l] = fjac[i__ + j * fjac_dim1]; l = l + *n - i__; /* L130: */ } L140: r__[l] = wa1[j]; if (wa1[j] == 0.) { sing = TRUE_; } /* L150: */ } /* accumulate the orthogonal factor in fjac. */ __minpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]); /* rescale if necessary. */ if (*mode == 2) { goto L170; } i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MAX */ d__1 = diag[j], d__2 = wa2[j]; diag[j] = max(d__1,d__2); /* L160: */ } L170: /* beginning of the inner loop. */ L180: /* if requested, call fcn to enable printing of iterates. */ if (*nprint <= 0) { goto L190; } iflag = 0; if ((iter - 1) % *nprint == 0) { fcn_nn(n, &x[1], &fvec[1], &iflag); } if (iflag < 0) { goto L300; } L190: /* determine the direction p. */ __minpack_func__(dogleg)(n, &r__[1], lr, &diag[1], &qtf[1], &delta, &wa1[1], &wa2[1], &wa3[ 1]); /* store the direction p and x + p. calculate the norm of p. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; /* L200: */ } pnorm = __minpack_func__(enorm)(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = 1; fcn_nn(n, &wa2[1], &wa4[1], &iflag); ++(*nfev); if (iflag < 0) { goto L300; } fnorm1 = __minpack_func__(enorm)(n, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) { /* Computing 2nd power */ d__1 = fnorm1 / fnorm; actred = 1. - d__1 * d__1; } /* compute the scaled predicted reduction. */ l = 1; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { sum = 0.; i__2 = *n; for (j = i__; j <= i__2; ++j) { sum += r__[l] * wa1[j]; ++l; /* L210: */ } wa3[i__] = qtf[i__] + sum; /* L220: */ } temp = __minpack_func__(enorm)(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ d__1 = temp / fnorm; prered = 1. - d__1 * d__1; } /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered > 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio >= p1) { goto L230; } ncsuc = 0; ++ncfail; delta = p5 * delta; goto L240; L230: ncfail = 0; ++ncsuc; if (ratio >= p5 || ncsuc > 1) { /* Computing MAX */ d__1 = delta, d__2 = pnorm / p5; delta = max(d__1,d__2); } if (fabs(ratio - 1.) <= p1) { delta = pnorm / p5; } L240: /* test for successful iteration. */ if (ratio < p0001) { goto L260; } /* successful iteration. update x, fvec, and their norms. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; fvec[j] = wa4[j]; /* L250: */ } xnorm = __minpack_func__(enorm)(n, &wa2[1]); fnorm = fnorm1; ++iter; L260: /* determine the progress of the iteration. */ ++nslow1; if (actred >= p001) { nslow1 = 0; } if (jeval) { ++nslow2; } if (actred >= p1) { nslow2 = 0; } /* test for convergence. */ if (delta <= *xtol * xnorm || fnorm == 0.) { *info = 1; } if (*info != 0) { goto L300; } /* tests for termination and stringent tolerances. */ if (*nfev >= *maxfev) { *info = 2; } /* Computing MAX */ d__1 = p1 * delta; if (p1 * max(d__1,pnorm) <= epsmch * xnorm) { *info = 3; } if (nslow2 == 5) { *info = 4; } if (nslow1 == 10) { *info = 5; } if (*info != 0) { goto L300; } /* criterion for recalculating jacobian approximation */ /* by forward differences. */ if (ncfail == 2) { goto L290; } /* calculate the rank one modification to the jacobian */ /* and update qtf if necessary. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { sum = 0.; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * wa4[i__]; /* L270: */ } wa2[j] = (sum - wa3[j]) / pnorm; wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm); if (ratio >= p0001) { qtf[j] = sum; } /* L280: */ } /* compute the qr factorization of the updated jacobian. */ __minpack_func__(r1updt)(n, n, &r__[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing); __minpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]); __minpack_func__(r1mpyq)(&c__1, n, &qtf[1], &c__1, &wa2[1], &wa3[1]); /* end of the inner loop. */ jeval = FALSE_; goto L180; L290: /* end of the outer loop. */ goto L30; L300: /* termination, either normal or user imposed. */ if (iflag < 0) { *info = iflag; } iflag = 0; if (*nprint > 0) { fcn_nn(n, &x[1], &fvec[1], &iflag); } return; /* last card of subroutine hybrd. */ } /* hybrd_ */ cminpack-1.3.4/hybrj.c000644 000765 000765 00000040547 12225167750 014557 0ustar00devernay000000 000000 /* hybrj.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(hybrj)(__cminpack_decl_fcnder_nn__ void *p, int n, real *x, real * fvec, real *fjac, int ldfjac, real xtol, int maxfev, real *diag, int mode, real factor, int nprint, int *nfev, int *njev, real *r, int lr, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p001 .001 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset; real d1, d2; /* Local variables */ int i, j, l, jm1, iwa[1]; real sum; int sing; int iter; real temp; int iflag; real delta = 0.; int jeval; int ncsuc; real ratio; real fnorm; real pnorm, xnorm = 0., fnorm1; int nslow1, nslow2; int ncfail; real actred, epsmch, prered; int info; /* ********** */ /* subroutine hybrj */ /* the purpose of hybrj is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, */ /* mode,factor,nprint,info,nfev,njev,r,lr,qtf, */ /* wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrj. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. fvec and fjac should not be altered. */ /* if nprint is not positive, no special calls of fcn */ /* with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 2 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 3 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* five jacobian evaluations. */ /* info = 5 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* ten iterations. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* r is an output array of length lr which contains the */ /* upper triangular matrix produced by the qr factorization */ /* of the final approximate jacobian, stored rowwise. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* qtf is an output array of length n which contains */ /* the vector (q transpose)*fvec. */ /* wa1, wa2, wa3, and wa4 are work arrays of length n. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dogleg,dpmpar,enorm, */ /* qform,qrfac,r1mpyq,r1updt */ /* fortran-supplied ... dabs,dmax1,dmin1,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --wa3; --wa2; --wa1; --qtf; --diag; --fvec; --x; fjac_dim1 = ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --r; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (n <= 0 || ldfjac < n || xtol < 0. || maxfev <= 0 || factor <= 0. || lr < n * (n + 1) / 2) { goto TERMINATE; } if (mode == 2) { for (j = 1; j <= n; ++j) { if (diag[j] <= 0.) { goto TERMINATE; } } } /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 1); *nfev = 1; if (iflag < 0) { goto TERMINATE; } fnorm = __cminpack_enorm__(n, &fvec[1]); /* initialize iteration counter and monitors. */ iter = 1; ncsuc = 0; ncfail = 0; nslow1 = 0; nslow2 = 0; /* beginning of the outer loop. */ for (;;) { jeval = TRUE_; /* calculate the jacobian matrix. */ iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 2); ++(*njev); if (iflag < 0) { goto TERMINATE; } /* compute the qr factorization of the jacobian. */ __cminpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, FALSE_, iwa, 1, &wa1[1], &wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter == 1) { if (mode != 2) { for (j = 1; j <= n; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } } } /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ for (j = 1; j <= n; ++j) { wa3[j] = diag[j] * x[j]; } xnorm = __cminpack_enorm__(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; } } /* form (q transpose)*fvec and store in qtf. */ for (i = 1; i <= n; ++i) { qtf[i] = fvec[i]; } for (j = 1; j <= n; ++j) { if (fjac[j + j * fjac_dim1] != 0.) { sum = 0.; for (i = j; i <= n; ++i) { sum += fjac[i + j * fjac_dim1] * qtf[i]; } temp = -sum / fjac[j + j * fjac_dim1]; for (i = j; i <= n; ++i) { qtf[i] += fjac[i + j * fjac_dim1] * temp; } } } /* copy the triangular factor of the qr factorization into r. */ sing = FALSE_; for (j = 1; j <= n; ++j) { l = j; jm1 = j - 1; if (jm1 >= 1) { for (i = 1; i <= jm1; ++i) { r[l] = fjac[i + j * fjac_dim1]; l = l + n - i; } } r[l] = wa1[j]; if (wa1[j] == 0.) { sing = TRUE_; } } /* accumulate the orthogonal factor in fjac. */ __cminpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]); /* rescale if necessary. */ if (mode != 2) { for (j = 1; j <= n; ++j) { /* Computing MAX */ d1 = diag[j], d2 = wa2[j]; diag[j] = max(d1,d2); } } /* beginning of the inner loop. */ for (;;) { /* if requested, call fcn to enable printing of iterates. */ if (nprint > 0) { iflag = 0; if ((iter - 1) % nprint == 0) { iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 0); } if (iflag < 0) { goto TERMINATE; } } /* determine the direction p. */ __cminpack_func__(dogleg)(n, &r[1], lr, &diag[1], &qtf[1], delta, &wa1[1], &wa2[1], &wa3[1]); /* store the direction p and x + p. calculate the norm of p. */ for (j = 1; j <= n; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; } pnorm = __cminpack_enorm__(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = fcnder_nn(p, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, 1); ++(*nfev); if (iflag < 0) { goto TERMINATE; } fnorm1 = __cminpack_enorm__(n, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) { /* Computing 2nd power */ d1 = fnorm1 / fnorm; actred = 1. - d1 * d1; } /* compute the scaled predicted reduction. */ l = 1; for (i = 1; i <= n; ++i) { sum = 0.; for (j = i; j <= n; ++j) { sum += r[l] * wa1[j]; ++l; } wa3[i] = qtf[i] + sum; } temp = __cminpack_enorm__(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ d1 = temp / fnorm; prered = 1. - d1 * d1; } /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered > 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio < p1) { ncsuc = 0; ++ncfail; delta = p5 * delta; } else { ncfail = 0; ++ncsuc; if (ratio >= p5 || ncsuc > 1) { /* Computing MAX */ d1 = pnorm / p5; delta = max(delta,d1); } if (fabs(ratio - 1.) <= p1) { delta = pnorm / p5; } } /* test for successful iteration. */ if (ratio >= p0001) { /* successful iteration. update x, fvec, and their norms. */ for (j = 1; j <= n; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; fvec[j] = wa4[j]; } xnorm = __cminpack_enorm__(n, &wa2[1]); fnorm = fnorm1; ++iter; } /* determine the progress of the iteration. */ ++nslow1; if (actred >= p001) { nslow1 = 0; } if (jeval) { ++nslow2; } if (actred >= p1) { nslow2 = 0; } /* test for convergence. */ if (delta <= xtol * xnorm || fnorm == 0.) { info = 1; } if (info != 0) { goto TERMINATE; } /* tests for termination and stringent tolerances. */ if (*nfev >= maxfev) { info = 2; } /* Computing MAX */ d1 = p1 * delta; if (p1 * max(d1,pnorm) <= epsmch * xnorm) { info = 3; } if (nslow2 == 5) { info = 4; } if (nslow1 == 10) { info = 5; } if (info != 0) { goto TERMINATE; } /* criterion for recalculating jacobian. */ if (ncfail == 2) { goto TERMINATE_INNER_LOOP; } /* calculate the rank one modification to the jacobian */ /* and update qtf if necessary. */ for (j = 1; j <= n; ++j) { sum = 0.; for (i = 1; i <= n; ++i) { sum += fjac[i + j * fjac_dim1] * wa4[i]; } wa2[j] = (sum - wa3[j]) / pnorm; wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm); if (ratio >= p0001) { qtf[j] = sum; } } /* compute the qr factorization of the updated jacobian. */ __cminpack_func__(r1updt)(n, n, &r[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing); __cminpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]); __cminpack_func__(r1mpyq)(1, n, &qtf[1], 1, &wa2[1], &wa3[1]); /* end of the inner loop. */ jeval = FALSE_; } TERMINATE_INNER_LOOP: ; /* end of the outer loop. */ } TERMINATE: /* termination, either normal or user imposed. */ if (iflag < 0) { info = iflag; } if (nprint > 0) { fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 0); } return info; /* last card of subroutine hybrj. */ } /* hybrj_ */ cminpack-1.3.4/hybrj1.c000644 000765 000765 00000011731 12225167750 014631 0ustar00devernay000000 000000 /* hybrj1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(hybrj1)(__cminpack_decl_fcnder_nn__ void *p, int n, real *x, real * fvec, real *fjac, int ldfjac, real tol, real *wa, int lwa) { /* Initialized data */ const real factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ int j, lr, mode, nfev, njev; real xtol; int maxfev, nprint; int info; /* ********** */ /* subroutine hybrj1 */ /* the purpose of hybrj1 is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. this is done by using the */ /* more general nonlinear equation solver hybrj. the user */ /* must provide a subroutine which calculates the functions */ /* and the jacobian. */ /* the subroutine statement is */ /* subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrj1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 2 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 3 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* (n*(n+13))/2. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... hybrj */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; fjac_dim1 = ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --wa; /* Function Body */ /* check the input parameters for errors. */ if (n <= 0 || ldfjac < n || tol < 0. || lwa < n * (n + 13) / 2) { return 0; } /* call hybrj. */ maxfev = (n + 1) * 100; xtol = tol; mode = 2; for (j = 1; j <= n; ++j) { wa[j] = 1.; /* L10: */ } nprint = 0; lr = n * (n + 1) / 2; info = __cminpack_func__(hybrj)(__cminpack_param_fcnder_nn__ p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, xtol, maxfev, &wa[1], mode, factor, nprint, &nfev, &njev, &wa[ n * 6 + 1], lr, &wa[n + 1], &wa[(n << 1) + 1], &wa[n * 3 + 1], &wa[(n << 2) + 1], &wa[n * 5 + 1]); if (info == 5) { info = 4; } return info; /* last card of subroutine hybrj1. */ } /* hybrj1_ */ cminpack-1.3.4/hybrj1_.c000644 000765 000765 00000012121 12225167750 014762 0ustar00devernay000000 000000 /* hybrj1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(hybrj1)(__minpack_decl_fcnder_nn__ const int *n, real *x, real * fvec, real *fjac, const int *ldfjac, const real *tol, int * info, real *wa, const int *lwa) { /* Initialized data */ const real factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset, i__1; /* Local variables */ int j, lr, mode, nfev, njev; real xtol; int maxfev, nprint; /* ********** */ /* subroutine hybrj1 */ /* the purpose of hybrj1 is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. this is done by using the */ /* more general nonlinear equation solver hybrj. the user */ /* must provide a subroutine which calculates the functions */ /* and the jacobian. */ /* the subroutine statement is */ /* subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrj1. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 2 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 3 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* (n*(n+13))/2. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... hybrj */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --wa; /* Function Body */ *info = 0; /* check the input parameters for errors. */ if (*n <= 0 || *ldfjac < *n || *tol < 0. || *lwa < *n * (*n + 13) / 2) { /* goto L20; */ return; } /* call hybrj. */ maxfev = (*n + 1) * 100; xtol = *tol; mode = 2; i__1 = *n; for (j = 1; j <= i__1; ++j) { wa[j] = 1.; /* L10: */ } nprint = 0; lr = *n * (*n + 1) / 2; __minpack_func__(hybrj)(__minpack_param_fcnder_nn__ n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &xtol, & maxfev, &wa[1], &mode, &factor, &nprint, info, &nfev, &njev, &wa[* n * 6 + 1], &lr, &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]); if (*info == 5) { *info = 4; } /* L20: */ return; /* last card of subroutine hybrj1. */ } /* hybrj1_ */ cminpack-1.3.4/hybrj_.c000644 000765 000765 00000036341 12225167750 014713 0ustar00devernay000000 000000 /* hybrj.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(hybrj)(__minpack_decl_fcnder_nn__ const int *n, real *x, real * fvec, real *fjac, const int *ldfjac, const real *xtol, const int * maxfev, real *diag, const int *mode, const real *factor, const int * nprint, int *info, int *nfev, int *njev, real *r__, const int *lr, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p001 .001 #define p0001 1e-4 const int c_false = FALSE_; const int c__1 = 1; /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; real d__1, d__2; /* Local variables */ int i__, j, l, jm1, iwa[1]; real sum; int sing; int iter; real temp; int iflag; real delta; int jeval; int ncsuc; real ratio; real fnorm; real pnorm, xnorm, fnorm1; int nslow1, nslow2; int ncfail; real actred, epsmch, prered; /* ********** */ /* subroutine hybrj */ /* the purpose of hybrj is to find a zero of a system of */ /* n nonlinear functions in n variables by a modification */ /* of the powell hybrid method. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, */ /* mode,factor,nprint,info,nfev,njev,r,lr,qtf, */ /* wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of hybrj. */ /* in this case set iflag to a negative integer. */ /* n is a positive integer input variable set to the number */ /* of functions and variables. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length n which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array which contains the */ /* orthogonal matrix q produced by the qr factorization */ /* of the final approximate jacobian. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. fvec and fjac should not be altered. */ /* if nprint is not positive, no special calls of fcn */ /* with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 2 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 3 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 4 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* five jacobian evaluations. */ /* info = 5 iteration is not making good progress, as */ /* measured by the improvement from the last */ /* ten iterations. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* r is an output array of length lr which contains the */ /* upper triangular matrix produced by the qr factorization */ /* of the final approximate jacobian, stored rowwise. */ /* lr is a positive integer input variable not less than */ /* (n*(n+1))/2. */ /* qtf is an output array of length n which contains */ /* the vector (q transpose)*fvec. */ /* wa1, wa2, wa3, and wa4 are work arrays of length n. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dogleg,dpmpar,enorm, */ /* qform,qrfac,r1mpyq,r1updt */ /* fortran-supplied ... dabs,dmax1,dmin1,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --wa3; --wa2; --wa1; --qtf; --diag; --fvec; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --r__; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); *info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (*n <= 0 || *ldfjac < *n || *xtol < 0. || *maxfev <= 0 || *factor <= 0. || *lr < *n * (*n + 1) / 2) { goto L300; } if (*mode != 2) { goto L20; } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (diag[j] <= 0.) { goto L300; } /* L10: */ } L20: /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = 1; fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); *nfev = 1; if (iflag < 0) { goto L300; } fnorm = __minpack_func__(enorm)(n, &fvec[1]); /* initialize iteration counter and monitors. */ iter = 1; ncsuc = 0; ncfail = 0; nslow1 = 0; nslow2 = 0; /* beginning of the outer loop. */ L30: jeval = TRUE_; /* calculate the jacobian matrix. */ iflag = 2; fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); ++(*njev); if (iflag < 0) { goto L300; } /* compute the qr factorization of the jacobian. */ __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_false, iwa, &c__1, &wa1[1], & wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter != 1) { goto L70; } if (*mode == 2) { goto L50; } i__1 = *n; for (j = 1; j <= i__1; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } /* L40: */ } L50: /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = diag[j] * x[j]; /* L60: */ } xnorm = __minpack_func__(enorm)(n, &wa3[1]); delta = *factor * xnorm; if (delta == 0.) { delta = *factor; } L70: /* form (q transpose)*fvec and store in qtf. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { qtf[i__] = fvec[i__]; /* L80: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { goto L110; } sum = 0.; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * qtf[i__]; /* L90: */ } temp = -sum / fjac[j + j * fjac_dim1]; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { qtf[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L100: */ } L110: /* L120: */ ; } /* copy the triangular factor of the qr factorization into r. */ sing = FALSE_; i__1 = *n; for (j = 1; j <= i__1; ++j) { l = j; jm1 = j - 1; if (jm1 < 1) { goto L140; } i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { r__[l] = fjac[i__ + j * fjac_dim1]; l = l + *n - i__; /* L130: */ } L140: r__[l] = wa1[j]; if (wa1[j] == 0.) { sing = TRUE_; } /* L150: */ } /* accumulate the orthogonal factor in fjac. */ __minpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]); /* rescale if necessary. */ if (*mode == 2) { goto L170; } i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MAX */ d__1 = diag[j], d__2 = wa2[j]; diag[j] = max(d__1,d__2); /* L160: */ } L170: /* beginning of the inner loop. */ L180: /* if requested, call fcn to enable printing of iterates. */ if (*nprint <= 0) { goto L190; } iflag = 0; if ((iter - 1) % *nprint == 0) { fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); } if (iflag < 0) { goto L300; } L190: /* determine the direction p. */ __minpack_func__(dogleg)(n, &r__[1], lr, &diag[1], &qtf[1], &delta, &wa1[1], &wa2[1], &wa3[ 1]); /* store the direction p and x + p. calculate the norm of p. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; /* L200: */ } pnorm = __minpack_func__(enorm)(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = 1; fcnder_nn(n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, &iflag); ++(*nfev); if (iflag < 0) { goto L300; } fnorm1 = __minpack_func__(enorm)(n, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) { /* Computing 2nd power */ d__1 = fnorm1 / fnorm; actred = 1. - d__1 * d__1; } /* compute the scaled predicted reduction. */ l = 1; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { sum = 0.; i__2 = *n; for (j = i__; j <= i__2; ++j) { sum += r__[l] * wa1[j]; ++l; /* L210: */ } wa3[i__] = qtf[i__] + sum; /* L220: */ } temp = __minpack_func__(enorm)(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ d__1 = temp / fnorm; prered = 1. - d__1 * d__1; } /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered > 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio >= p1) { goto L230; } ncsuc = 0; ++ncfail; delta = p5 * delta; goto L240; L230: ncfail = 0; ++ncsuc; if (ratio >= p5 || ncsuc > 1) { /* Computing MAX */ d__1 = delta, d__2 = pnorm / p5; delta = max(d__1,d__2); } if (fabs(ratio - 1.) <= p1) { delta = pnorm / p5; } L240: /* test for successful iteration. */ if (ratio < p0001) { goto L260; } /* successful iteration. update x, fvec, and their norms. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; fvec[j] = wa4[j]; /* L250: */ } xnorm = __minpack_func__(enorm)(n, &wa2[1]); fnorm = fnorm1; ++iter; L260: /* determine the progress of the iteration. */ ++nslow1; if (actred >= p001) { nslow1 = 0; } if (jeval) { ++nslow2; } if (actred >= p1) { nslow2 = 0; } /* test for convergence. */ if (delta <= *xtol * xnorm || fnorm == 0.) { *info = 1; } if (*info != 0) { goto L300; } /* tests for termination and stringent tolerances. */ if (*nfev >= *maxfev) { *info = 2; } /* Computing MAX */ d__1 = p1 * delta; if (p1 * max(d__1,pnorm) <= epsmch * xnorm) { *info = 3; } if (nslow2 == 5) { *info = 4; } if (nslow1 == 10) { *info = 5; } if (*info != 0) { goto L300; } /* criterion for recalculating jacobian. */ if (ncfail == 2) { goto L290; } /* calculate the rank one modification to the jacobian */ /* and update qtf if necessary. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { sum = 0.; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * wa4[i__]; /* L270: */ } wa2[j] = (sum - wa3[j]) / pnorm; wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm); if (ratio >= p0001) { qtf[j] = sum; } /* L280: */ } /* compute the qr factorization of the updated jacobian. */ __minpack_func__(r1updt)(n, n, &r__[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing); __minpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]); __minpack_func__(r1mpyq)(&c__1, n, &qtf[1], &c__1, &wa2[1], &wa3[1]); /* end of the inner loop. */ jeval = FALSE_; goto L180; L290: /* end of the outer loop. */ goto L30; L300: /* termination, either normal or user imposed. */ if (iflag < 0) { *info = iflag; } iflag = 0; if (*nprint > 0) { fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); } return; /* last card of subroutine hybrj. */ } /* hybrj_ */ cminpack-1.3.4/lmder.c000644 000765 000765 00000041417 12225167750 014541 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmder)(__cminpack_decl_fcnder_mn__ void *p, int m, int n, real *x, real *fvec, real *fjac, int ldfjac, real ftol, real xtol, real gtol, int maxfev, real * diag, int mode, real factor, int nprint, int *nfev, int *njev, int *ipvt, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ real d1, d2; /* Local variables */ int i, j, l; real par, sum; int iter; real temp, temp1, temp2; int iflag; real delta = 0.; real ratio; real fnorm, gnorm, pnorm, xnorm = 0., fnorm1, actred, dirder, epsmch, prered; int info; /* ********** */ /* subroutine lmder */ /* the purpose of lmder is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */ /* maxfev,diag,mode,factor,nprint,info,nfev, */ /* njev,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */ /* integer m,n,ldfjac,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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmder. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.).100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x, fvec, and fjac */ /* available for printing. fvec and fjac should not be */ /* altered. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,lmpar,qrfac */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (n <= 0 || m < n || ldfjac < m || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.) { goto TERMINATE; } if (mode == 2) { for (j = 0; j < n; ++j) { if (diag[j] <= 0.) { goto TERMINATE; } } } /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 1); *nfev = 1; if (iflag < 0) { goto TERMINATE; } fnorm = __cminpack_enorm__(m, fvec); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ for (;;) { /* calculate the jacobian matrix. */ iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 2); ++(*njev); if (iflag < 0) { goto TERMINATE; } /* if requested, call fcn to enable printing of iterates. */ if (nprint > 0) { iflag = 0; if ((iter - 1) % nprint == 0) { iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 0); } if (iflag < 0) { goto TERMINATE; } } /* compute the qr factorization of the jacobian. */ __cminpack_func__(qrfac)(m, n, fjac, ldfjac, TRUE_, ipvt, n, wa1, wa2, wa3); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter == 1) { if (mode != 2) { for (j = 0; j < n; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } } } /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ for (j = 0; j < n; ++j) { wa3[j] = diag[j] * x[j]; } xnorm = __cminpack_enorm__(n, wa3); delta = factor * xnorm; if (delta == 0.) { delta = factor; } } /* form (q transpose)*fvec and store the first n components in */ /* qtf. */ for (i = 0; i < m; ++i) { wa4[i] = fvec[i]; } for (j = 0; j < n; ++j) { if (fjac[j + j * ldfjac] != 0.) { sum = 0.; for (i = j; i < m; ++i) { sum += fjac[i + j * ldfjac] * wa4[i]; } temp = -sum / fjac[j + j * ldfjac]; for (i = j; i < m; ++i) { wa4[i] += fjac[i + j * ldfjac] * temp; } } fjac[j + j * ldfjac] = wa1[j]; qtf[j] = wa4[j]; } /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm != 0.) { for (j = 0; j < n; ++j) { l = ipvt[j]-1; if (wa2[l] != 0.) { sum = 0.; for (i = 0; i <= j; ++i) { sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm); } /* Computing MAX */ d1 = fabs(sum / wa2[l]); gnorm = max(gnorm,d1); } } } /* test for convergence of the gradient norm. */ if (gnorm <= gtol) { info = 4; } if (info != 0) { goto TERMINATE; } /* rescale if necessary. */ if (mode != 2) { for (j = 0; j < n; ++j) { /* Computing MAX */ d1 = diag[j], d2 = wa2[j]; diag[j] = max(d1,d2); } } /* beginning of the inner loop. */ do { /* determine the levenberg-marquardt parameter. */ __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta, &par, wa1, wa2, wa3, wa4); /* store the direction p and x + p. calculate the norm of p. */ for (j = 0; j < n; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; } pnorm = __cminpack_enorm__(n, wa3); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = fcnder_mn(p, m, n, wa2, wa4, fjac, ldfjac, 1); ++(*nfev); if (iflag < 0) { goto TERMINATE; } fnorm1 = __cminpack_enorm__(m, wa4); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d1 = fnorm1 / fnorm; actred = 1. - d1 * d1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ for (j = 0; j < n; ++j) { wa3[j] = 0.; l = ipvt[j]-1; temp = wa1[l]; for (i = 0; i <= j; ++i) { wa3[i] += fjac[i + j * ldfjac] * temp; } } temp1 = __cminpack_enorm__(n, wa3) / fnorm; temp2 = (sqrt(par) * pnorm) / fnorm; prered = temp1 * temp1 + temp2 * temp2 / p5; dirder = -(temp1 * temp1 + temp2 * temp2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio <= p25) { if (actred >= 0.) { temp = p5; } else { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d1 = pnorm / p1; delta = temp * min(delta,d1); par /= temp; } else { if (par == 0. || ratio >= p75) { delta = pnorm / p5; par = p5 * par; } } /* test for successful iteration. */ if (ratio >= p0001) { /* successful iteration. update x, fvec, and their norms. */ for (j = 0; j < n; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; } for (i = 0; i < m; ++i) { fvec[i] = wa4[i]; } xnorm = __cminpack_enorm__(n, wa2); fnorm = fnorm1; ++iter; } /* tests for convergence. */ if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } if (info != 0) { goto TERMINATE; } /* tests for termination and stringent tolerances. */ if (*nfev >= maxfev) { info = 5; } if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { info = 6; } if (delta <= epsmch * xnorm) { info = 7; } if (gnorm <= epsmch) { info = 8; } if (info != 0) { goto TERMINATE; } /* end of the inner loop. repeat if iteration unsuccessful. */ } while (ratio < p0001); /* end of the outer loop. */ } TERMINATE: /* termination, either normal or user imposed. */ if (iflag < 0) { info = iflag; } if (nprint > 0) { fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 0); } return info; /* last card of subroutine lmder. */ } /* lmder_ */ cminpack-1.3.4/lmder1.c000644 000765 000765 00000013623 12225167750 014620 0ustar00devernay000000 000000 #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmder1)(__cminpack_decl_fcnder_mn__ void *p, int m, int n, real *x, real *fvec, real *fjac, int ldfjac, real tol, int *ipvt, real *wa, int lwa) { /* Initialized data */ const real factor = 100.; /* Local variables */ int mode, nfev, njev; real ftol, gtol, xtol; int maxfev, nprint; int info; /* ********** */ /* subroutine lmder1 */ /* the purpose of lmder1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of the */ /* levenberg-marquardt algorithm. this is done by using the more */ /* general least-squares solver lmder. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */ /* ipvt,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */ /* integer m,n,ldfjac,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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmder1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than 5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmder */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* check the input parameters for errors. */ if (n <= 0 || m < n || ldfjac < m || tol < 0. || lwa < n * 5 + m) { return 0; } /* call lmder. */ maxfev = (n + 1) * 100; ftol = tol; xtol = tol; gtol = 0.; mode = 1; nprint = 0; info = __cminpack_func__(lmder)(__cminpack_param_fcnder_mn__ p, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, wa, mode, factor, nprint, &nfev, &njev, ipvt, &wa[n], &wa[(n << 1)], & wa[n * 3], &wa[(n << 2)], &wa[n * 5]); if (info == 8) { info = 4; } return info; /* last card of subroutine lmder1. */ } /* lmder1_ */ cminpack-1.3.4/lmder1_.c000644 000765 000765 00000014704 12225167750 014760 0ustar00devernay000000 000000 /* lmder1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(lmder1)(__minpack_decl_fcnder_mn__ const int *m, const int *n, real *x, real *fvec, real *fjac, const int *ldfjac, const real *tol, int *info, int *ipvt, real *wa, const int *lwa) { /* Initialized data */ const real factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ int mode, nfev, njev; real ftol, gtol, xtol; int maxfev, nprint; /* ********** */ /* subroutine lmder1 */ /* the purpose of lmder1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of the */ /* levenberg-marquardt algorithm. this is done by using the more */ /* general least-squares solver lmder. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */ /* ipvt,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */ /* integer m,n,ldfjac,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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmder1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than 5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmder */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --ipvt; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --wa; /* Function Body */ *info = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *ldfjac < *m || *tol < 0. || *lwa < *n * 5 + * m) { /* goto L10; */ return; } /* call lmder. */ maxfev = (*n + 1) * 100; ftol = *tol; xtol = *tol; gtol = 0.; mode = 1; nprint = 0; __minpack_func__(lmder)(__minpack_param_fcnder_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, & ftol, &xtol, >ol, &maxfev, &wa[1], &mode, &factor, &nprint, info, &nfev, &njev, &ipvt[1], &wa[*n + 1], &wa[(*n << 1) + 1], & wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]); if (*info == 8) { *info = 4; } /* L10: */ return; /* last card of subroutine lmder1. */ } /* lmder1_ */ cminpack-1.3.4/lmder_.c000644 000765 000765 00000041360 12225167750 014675 0ustar00devernay000000 000000 /* lmder.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(lmder)(__minpack_decl_fcnder_mn__ const int *m, const int *n, real *x, real *fvec, real *fjac, const int *ldfjac, const real *ftol, const real *xtol, const real *gtol, const int *maxfev, real * diag, const int *mode, const real *factor, const int *nprint, int * info, int *nfev, int *njev, int *ipvt, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Table of constant values */ const int c__1 = 1; const int c_true = TRUE_; /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; real d__1, d__2, d__3; /* Local variables */ int i__, j, l; real par, sum; int iter; real temp, temp1, temp2; int iflag; real delta; real ratio; real fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, epsmch, prered; /* ********** */ /* subroutine lmder */ /* the purpose of lmder is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm. the user must provide a */ /* subroutine which calculates the functions and the jacobian. */ /* the subroutine statement is */ /* subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */ /* maxfev,diag,mode,factor,nprint,info,nfev, */ /* njev,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the jacobian. fcn must */ /* be declared in an external statement in the user */ /* calling program, and should be written as follows. */ /* subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */ /* integer m,n,ldfjac,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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmder. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.).100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x, fvec, and fjac */ /* available for printing. fvec and fjac should not be */ /* altered. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,lmpar,qrfac */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --fvec; --wa3; --wa2; --wa1; --qtf; --ipvt; --diag; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); *info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *ldfjac < *m || *ftol < 0. || *xtol < 0. || *gtol < 0. || *maxfev <= 0 || *factor <= 0.) { goto L300; } if (*mode != 2) { goto L20; } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (diag[j] <= 0.) { goto L300; } /* L10: */ } L20: /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = 1; fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); *nfev = 1; if (iflag < 0) { goto L300; } fnorm = __minpack_func__(enorm)(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ L30: /* calculate the jacobian matrix. */ iflag = 2; fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); ++(*njev); if (iflag < 0) { goto L300; } /* if requested, call fcn to enable printing of iterates. */ if (*nprint <= 0) { goto L40; } iflag = 0; if ((iter - 1) % *nprint == 0) { fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); } if (iflag < 0) { goto L300; } L40: /* compute the qr factorization of the jacobian. */ __minpack_func__(qrfac)(m, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], & wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter != 1) { goto L80; } if (*mode == 2) { goto L60; } i__1 = *n; for (j = 1; j <= i__1; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } /* L50: */ } L60: /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = diag[j] * x[j]; /* L70: */ } xnorm = __minpack_func__(enorm)(n, &wa3[1]); delta = *factor * xnorm; if (delta == 0.) { delta = *factor; } L80: /* form (q transpose)*fvec and store the first n components in */ /* qtf. */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { wa4[i__] = fvec[i__]; /* L90: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { goto L120; } sum = 0.; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * wa4[i__]; /* L100: */ } temp = -sum / fjac[j + j * fjac_dim1]; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { wa4[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L110: */ } L120: fjac[j + j * fjac_dim1] = wa1[j]; qtf[j] = wa4[j]; /* L130: */ } /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm == 0.) { goto L170; } i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; if (wa2[l] == 0.) { goto L150; } sum = 0.; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm); /* L140: */ } /* Computing MAX */ d__2 = gnorm, d__3 = fabs(sum / wa2[l]); gnorm = max(d__2,d__3); L150: /* L160: */ ; } L170: /* test for convergence of the gradient norm. */ if (gnorm <= *gtol) { *info = 4; } if (*info != 0) { goto L300; } /* rescale if necessary. */ if (*mode == 2) { goto L190; } i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MAX */ d__1 = diag[j], d__2 = wa2[j]; diag[j] = max(d__1,d__2); /* L180: */ } L190: /* beginning of the inner loop. */ L200: /* determine the levenberg-marquardt parameter. */ __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta, &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]); /* store the direction p and x + p. calculate the norm of p. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; /* L210: */ } pnorm = __minpack_func__(enorm)(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = 1; fcnder_mn(m, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, &iflag); ++(*nfev); if (iflag < 0) { goto L300; } fnorm1 = __minpack_func__(enorm)(m, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d__1 = fnorm1 / fnorm; actred = 1. - d__1 * d__1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = 0.; l = ipvt[j]; temp = wa1[l]; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { wa3[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L220: */ } /* L230: */ } temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; prered = d__1 * d__1 + d__2 * d__2 / p5; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; dirder = -(d__1 * d__1 + d__2 * d__2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio > p25) { goto L240; } if (actred >= 0.) { temp = p5; } if (actred < 0.) { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d__1 = delta, d__2 = pnorm / p1; delta = temp * min(d__1,d__2); par /= temp; goto L260; L240: if (par != 0. && ratio < p75) { goto L250; } delta = pnorm / p5; par = p5 * par; L250: L260: /* test for successful iteration. */ if (ratio < p0001) { goto L290; } /* successful iteration. update x, fvec, and their norms. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; /* L270: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { fvec[i__] = wa4[i__]; /* L280: */ } xnorm = __minpack_func__(enorm)(n, &wa2[1]); fnorm = fnorm1; ++iter; L290: /* tests for convergence. */ if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) { *info = 1; } if (delta <= *xtol * xnorm) { *info = 2; } if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info == 2) { *info = 3; } if (*info != 0) { goto L300; } /* tests for termination and stringent tolerances. */ if (*nfev >= *maxfev) { *info = 5; } if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { *info = 6; } if (delta <= epsmch * xnorm) { *info = 7; } if (gnorm <= epsmch) { *info = 8; } if (*info != 0) { goto L300; } /* end of the inner loop. repeat if iteration unsuccessful. */ if (ratio < p0001) { goto L200; } /* end of the outer loop. */ goto L30; L300: /* termination, either normal or user imposed. */ if (iflag < 0) { *info = iflag; } iflag = 0; if (*nprint > 0) { fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag); } return; /* last card of subroutine lmder. */ } /* lmder_ */ cminpack-1.3.4/lmdif.c000644 000765 000765 00000041637 12225167750 014535 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmdif)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, real *fvec, real ftol, real xtol, real gtol, int maxfev, real epsfcn, real *diag, int mode, real factor, int nprint, int * nfev, real *fjac, int ldfjac, int *ipvt, real * qtf, real *wa1, real *wa2, real *wa3, real * wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ real d1, d2; /* Local variables */ int i, j, l; real par, sum; int iter; real temp, temp1, temp2; int iflag; real delta = 0.; real ratio; real fnorm, gnorm; real pnorm, xnorm = 0., fnorm1, actred, dirder, epsmch, prered; int info; /* ********** */ /* subroutine lmdif */ /* the purpose of lmdif is to minimize the sum of the squares of */ /* m nonlinear functions in n 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. */ /* the subroutine statement is */ /* subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, */ /* diag,mode,factor,nprint,info,nfev,fjac, */ /* ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmdif. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn is at least */ /* maxfev by the end of an iteration. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn has reached or */ /* exceeded maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); info = 0; iflag = 0; *nfev = 0; /* check the input parameters for errors. */ if (n <= 0 || m < n || ldfjac < m || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.) { goto TERMINATE; } if (mode == 2) { for (j = 0; j < n; ++j) { if (diag[j] <= 0.) { goto TERMINATE; } } } /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = fcn_mn(p, m, n, x, fvec, 1); *nfev = 1; if (iflag < 0) { goto TERMINATE; } fnorm = __cminpack_enorm__(m, fvec); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ for (;;) { /* calculate the jacobian matrix. */ iflag = __cminpack_func__(fdjac2)(__cminpack_param_fcn_mn__ p, m, n, x, fvec, fjac, ldfjac, epsfcn, wa4); *nfev += n; if (iflag < 0) { goto TERMINATE; } /* if requested, call fcn to enable printing of iterates. */ if (nprint > 0) { iflag = 0; if ((iter - 1) % nprint == 0) { iflag = fcn_mn(p, m, n, x, fvec, 0); } if (iflag < 0) { goto TERMINATE; } } /* compute the qr factorization of the jacobian. */ __cminpack_func__(qrfac)(m, n, fjac, ldfjac, TRUE_, ipvt, n, wa1, wa2, wa3); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter == 1) { if (mode != 2) { for (j = 0; j < n; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } } } /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ for (j = 0; j < n; ++j) { wa3[j] = diag[j] * x[j]; } xnorm = __cminpack_enorm__(n, wa3); delta = factor * xnorm; if (delta == 0.) { delta = factor; } } /* form (q transpose)*fvec and store the first n components in */ /* qtf. */ for (i = 0; i < m; ++i) { wa4[i] = fvec[i]; } for (j = 0; j < n; ++j) { if (fjac[j + j * ldfjac] != 0.) { sum = 0.; for (i = j; i < m; ++i) { sum += fjac[i + j * ldfjac] * wa4[i]; } temp = -sum / fjac[j + j * ldfjac]; for (i = j; i < m; ++i) { wa4[i] += fjac[i + j * ldfjac] * temp; } } fjac[j + j * ldfjac] = wa1[j]; qtf[j] = wa4[j]; } /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm != 0.) { for (j = 0; j < n; ++j) { l = ipvt[j]-1; if (wa2[l] != 0.) { sum = 0.; for (i = 0; i <= j; ++i) { sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm); } /* Computing MAX */ d1 = fabs(sum / wa2[l]); gnorm = max(gnorm,d1); } } } /* test for convergence of the gradient norm. */ if (gnorm <= gtol) { info = 4; } if (info != 0) { goto TERMINATE; } /* rescale if necessary. */ if (mode != 2) { for (j = 0; j < n; ++j) { /* Computing MAX */ d1 = diag[j], d2 = wa2[j]; diag[j] = max(d1,d2); } } /* beginning of the inner loop. */ do { /* determine the levenberg-marquardt parameter. */ __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta, &par, wa1, wa2, wa3, wa4); /* store the direction p and x + p. calculate the norm of p. */ for (j = 0; j < n; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; } pnorm = __cminpack_enorm__(n, wa3); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = fcn_mn(p, m, n, wa2, wa4, 1); ++(*nfev); if (iflag < 0) { goto TERMINATE; } fnorm1 = __cminpack_enorm__(m, wa4); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d1 = fnorm1 / fnorm; actred = 1. - d1 * d1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ for (j = 0; j < n; ++j) { wa3[j] = 0.; l = ipvt[j]-1; temp = wa1[l]; for (i = 0; i <= j; ++i) { wa3[i] += fjac[i + j * ldfjac] * temp; } } temp1 = __cminpack_enorm__(n, wa3) / fnorm; temp2 = (sqrt(par) * pnorm) / fnorm; prered = temp1 * temp1 + temp2 * temp2 / p5; dirder = -(temp1 * temp1 + temp2 * temp2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio <= p25) { if (actred >= 0.) { temp = p5; } else { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d1 = pnorm / p1; delta = temp * min(delta,d1); par /= temp; } else { if (par == 0. || ratio >= p75) { delta = pnorm / p5; par = p5 * par; } } /* test for successful iteration. */ if (ratio >= p0001) { /* successful iteration. update x, fvec, and their norms. */ for (j = 0; j < n; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; } for (i = 0; i < m; ++i) { fvec[i] = wa4[i]; } xnorm = __cminpack_enorm__(n, wa2); fnorm = fnorm1; ++iter; } /* tests for convergence. */ if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } if (info != 0) { goto TERMINATE; } /* tests for termination and stringent tolerances. */ if (*nfev >= maxfev) { info = 5; } if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { info = 6; } if (delta <= epsmch * xnorm) { info = 7; } if (gnorm <= epsmch) { info = 8; } if (info != 0) { goto TERMINATE; } /* end of the inner loop. repeat if iteration unsuccessful. */ } while (ratio < p0001); /* end of the outer loop. */ } TERMINATE: /* termination, either normal or user imposed. */ if (iflag < 0) { info = iflag; } if (nprint > 0) { fcn_mn(p, m, n, x, fvec, 0); } return info; /* last card of subroutine lmdif. */ } /* lmdif_ */ cminpack-1.3.4/lmdif1.c000644 000765 000765 00000011257 12225167750 014611 0ustar00devernay000000 000000 #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmdif1)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, real *fvec, real tol, int *iwa, real *wa, int lwa) { /* Initialized data */ const real factor = 100.; int mp5n, mode, nfev; real ftol, gtol, xtol; real epsfcn; int maxfev, nprint; int info; /* ********** */ /* subroutine lmdif1 */ /* the purpose of lmdif1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of the */ /* levenberg-marquardt algorithm. this is done by using the more */ /* general least-squares solver lmdif. the user must provide a */ /* subroutine which calculates the functions. the jacobian is */ /* then calculated by a forward-difference approximation. */ /* the subroutine statement is */ /* subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmdif1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn has reached or */ /* exceeded 200*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* iwa is an integer work array of length n. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* m*n+5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmdif */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* check the input parameters for errors. */ if (n <= 0 || m < n || tol < 0. || lwa < m * n + n * 5 + m) { return 0; } /* call lmdif. */ maxfev = (n + 1) * 200; ftol = tol; xtol = tol; gtol = 0.; epsfcn = 0.; mode = 1; nprint = 0; mp5n = m + n * 5; info = __cminpack_func__(lmdif)(__cminpack_param_fcn_mn__ p, m, n, x, fvec, ftol, xtol, gtol, maxfev, epsfcn, wa, mode, factor, nprint, &nfev, &wa[mp5n], m, iwa, &wa[n], &wa[(n << 1)], &wa[n * 3], &wa[(n << 2)], &wa[n * 5]); if (info == 8) { info = 4; } return info; /* last card of subroutine lmdif1. */ } /* lmdif1_ */ cminpack-1.3.4/lmdif1_.c000644 000765 000765 00000012054 12225167750 014744 0ustar00devernay000000 000000 /* lmdif1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(lmdif1)(__minpack_decl_fcn_mn__ const int *m, const int *n, real *x, real *fvec, const real *tol, int *info, int *iwa, real *wa, const int *lwa) { /* Initialized data */ const real factor = 100.; int mp5n, mode, nfev; real ftol, gtol, xtol; real epsfcn; int maxfev, nprint; /* ********** */ /* subroutine lmdif1 */ /* the purpose of lmdif1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of the */ /* levenberg-marquardt algorithm. this is done by using the more */ /* general least-squares solver lmdif. the user must provide a */ /* subroutine which calculates the functions. the jacobian is */ /* then calculated by a forward-difference approximation. */ /* the subroutine statement is */ /* subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmdif1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn has reached or */ /* exceeded 200*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* iwa is an integer work array of length n. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than */ /* m*n+5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmdif */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --iwa; --x; --wa; /* Function Body */ *info = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *tol < 0. || *lwa < *m * *n + *n * 5 + *m) { /* goto L10; */ return; } /* call lmdif. */ maxfev = (*n + 1) * 200; ftol = *tol; xtol = *tol; gtol = 0.; epsfcn = 0.; mode = 1; nprint = 0; mp5n = *m + *n * 5; __minpack_func__(lmdif)(__minpack_param_fcn_mn__ m, n, &x[1], &fvec[1], &ftol, &xtol, >ol, &maxfev, & epsfcn, &wa[1], &mode, &factor, &nprint, info, &nfev, &wa[mp5n + 1], m, &iwa[1], &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]); if (*info == 8) { *info = 4; } /* L10: */ return; /* last card of subroutine lmdif1. */ } /* lmdif1_ */ cminpack-1.3.4/lmdif_.c000644 000765 000765 00000041505 12225167750 014666 0ustar00devernay000000 000000 /* lmdif.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(lmdif)(__minpack_decl_fcn_mn__ const int *m, const int *n, real *x, real *fvec, const real *ftol, const real *xtol, const real * gtol, const int *maxfev, const real *epsfcn, real *diag, const int * mode, const real *factor, const int *nprint, int *info, int * nfev, real *fjac, const int *ldfjac, int *ipvt, real * qtf, real *wa1, real *wa2, real *wa3, real * wa4) { /* Table of constant values */ const int c__1 = 1; const int c_true = TRUE_; /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; real d__1, d__2, d__3; /* Local variables */ int i__, j, l; real par, sum; int iter; real temp, temp1, temp2; int iflag; real delta; real ratio; real fnorm, gnorm; real pnorm, xnorm, fnorm1, actred, dirder, epsmch, prered; /* ********** */ /* subroutine lmdif */ /* the purpose of lmdif is to minimize the sum of the squares of */ /* m nonlinear functions in n 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. */ /* the subroutine statement is */ /* subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, */ /* diag,mode,factor,nprint,info,nfev,fjac, */ /* ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions. fcn must be declared */ /* in an external statement in the user calling */ /* program, and should be written as follows. */ /* 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 */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmdif. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn is at least */ /* maxfev by the end of an iteration. */ /* epsfcn 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 epsfcn. if epsfcn is less */ /* than the machine precision, it is assumed that the relative */ /* errors in the functions are of the order of the machine */ /* precision. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn has reached or */ /* exceeded maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn. */ /* fjac is an output m by n array. the upper n by n submatrix */ /* of fjac contains an upper triangular matrix r with */ /* diagonal elements of nonincreasing magnitude such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower trapezoidal */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular */ /* with diagonal elements of nonincreasing magnitude. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --fvec; --wa3; --wa2; --wa1; --qtf; --ipvt; --diag; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); *info = 0; iflag = 0; *nfev = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *ldfjac < *m || *ftol < 0. || *xtol < 0. || *gtol < 0. || *maxfev <= 0 || *factor <= 0.) { goto L300; } if (*mode != 2) { goto L20; } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (diag[j] <= 0.) { goto L300; } /* L10: */ } L20: /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = 1; fcn_mn(m, n, &x[1], &fvec[1], &iflag); *nfev = 1; if (iflag < 0) { goto L300; } fnorm = __minpack_func__(enorm)(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ L30: /* calculate the jacobian matrix. */ iflag = 2; __minpack_func__(fdjac2)(__minpack_param_fcn_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, & iflag, epsfcn, &wa4[1]); *nfev += *n; if (iflag < 0) { goto L300; } /* if requested, call fcn to enable printing of iterates. */ if (*nprint <= 0) { goto L40; } iflag = 0; if ((iter - 1) % *nprint == 0) { fcn_mn(m, n, &x[1], &fvec[1], &iflag); } if (iflag < 0) { goto L300; } L40: /* compute the qr factorization of the jacobian. */ __minpack_func__(qrfac)(m, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], & wa2[1], &wa3[1]); /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter != 1) { goto L80; } if (*mode == 2) { goto L60; } i__1 = *n; for (j = 1; j <= i__1; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } /* L50: */ } L60: /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = diag[j] * x[j]; /* L70: */ } xnorm = __minpack_func__(enorm)(n, &wa3[1]); delta = *factor * xnorm; if (delta == 0.) { delta = *factor; } L80: /* form (q transpose)*fvec and store the first n components in */ /* qtf. */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { wa4[i__] = fvec[i__]; /* L90: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { goto L120; } sum = 0.; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * wa4[i__]; /* L100: */ } temp = -sum / fjac[j + j * fjac_dim1]; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { wa4[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L110: */ } L120: fjac[j + j * fjac_dim1] = wa1[j]; qtf[j] = wa4[j]; /* L130: */ } /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm == 0.) { goto L170; } i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; if (wa2[l] == 0.) { goto L150; } sum = 0.; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm); /* L140: */ } /* Computing MAX */ d__2 = gnorm, d__3 = fabs(sum / wa2[l]); gnorm = max(d__2,d__3); L150: /* L160: */ ; } L170: /* test for convergence of the gradient norm. */ if (gnorm <= *gtol) { *info = 4; } if (*info != 0) { goto L300; } /* rescale if necessary. */ if (*mode == 2) { goto L190; } i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MAX */ d__1 = diag[j], d__2 = wa2[j]; diag[j] = max(d__1,d__2); /* L180: */ } L190: /* beginning of the inner loop. */ L200: /* determine the levenberg-marquardt parameter. */ __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta, &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]); /* store the direction p and x + p. calculate the norm of p. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; /* L210: */ } pnorm = __minpack_func__(enorm)(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = 1; fcn_mn(m, n, &wa2[1], &wa4[1], &iflag); ++(*nfev); if (iflag < 0) { goto L300; } fnorm1 = __minpack_func__(enorm)(m, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d__1 = fnorm1 / fnorm; actred = 1. - d__1 * d__1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = 0.; l = ipvt[j]; temp = wa1[l]; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { wa3[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L220: */ } /* L230: */ } temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; prered = d__1 * d__1 + d__2 * d__2 / p5; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; dirder = -(d__1 * d__1 + d__2 * d__2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio > p25) { goto L240; } if (actred >= 0.) { temp = p5; } if (actred < 0.) { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d__1 = delta, d__2 = pnorm / p1; delta = temp * min(d__1,d__2); par /= temp; goto L260; L240: if (par != 0. && ratio < p75) { goto L250; } delta = pnorm / p5; par = p5 * par; L250: L260: /* test for successful iteration. */ if (ratio < p0001) { goto L290; } /* successful iteration. update x, fvec, and their norms. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; /* L270: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { fvec[i__] = wa4[i__]; /* L280: */ } xnorm = __minpack_func__(enorm)(n, &wa2[1]); fnorm = fnorm1; ++iter; L290: /* tests for convergence. */ if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) { *info = 1; } if (delta <= *xtol * xnorm) { *info = 2; } if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info == 2) { *info = 3; } if (*info != 0) { goto L300; } /* tests for termination and stringent tolerances. */ if (*nfev >= *maxfev) { *info = 5; } if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { *info = 6; } if (delta <= epsmch * xnorm) { *info = 7; } if (gnorm <= epsmch) { *info = 8; } if (*info != 0) { goto L300; } /* end of the inner loop. repeat if iteration unsuccessful. */ if (ratio < p0001) { goto L200; } /* end of the outer loop. */ goto L30; L300: /* termination, either normal or user imposed. */ if (iflag < 0) { *info = iflag; } iflag = 0; if (*nprint > 0) { fcn_mn(m, n, &x[1], &fvec[1], &iflag); } return; /* last card of subroutine lmdif. */ } /* lmdif_ */ cminpack-1.3.4/lmpar.c000644 000765 000765 00000023532 12225167750 014547 0ustar00devernay000000 000000 /* lmpar.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(lmpar)(int n, real *r, int ldr, const int *ipvt, const real *diag, const real *qtb, real delta, real *par, real *x, real *sdiag, real *wa1, real *wa2) { /* Initialized data */ #define p1 .1 #define p001 .001 /* System generated locals */ real d1, d2; /* Local variables */ int j, l; real fp; real parc, parl; int iter; real temp, paru, dwarf; int nsing; real gnorm; real dxnorm; /* ********** */ /* subroutine lmpar */ /* given an m by n matrix a, an n by n nonsingular diagonal */ /* matrix d, an m-vector b, and a positive number delta, */ /* the problem is to determine a value for the parameter */ /* par such that if x solves the system */ /* a*x = b , sqrt(par)*d*x = 0 , */ /* in the least squares sense, and dxnorm is the euclidean */ /* norm of d*x, then either par is zero and */ /* (dxnorm-delta) .le. 0.1*delta , */ /* or par is positive and */ /* abs(dxnorm-delta) .le. 0.1*delta . */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then lmpar expects */ /* the full upper triangle of r, the permutation matrix p, */ /* and the first n components of (q transpose)*b. on output */ /* lmpar also provides an upper triangular matrix s such that */ /* t t t */ /* p *(a *a + par*d*d)*p = s *s . */ /* s is employed within lmpar and may be of separate interest. */ /* only a few iterations are generally needed for convergence */ /* of the algorithm. if, however, the limit of 10 iterations */ /* is reached, then the output par will contain the best */ /* value obtained so far. */ /* the subroutine statement is */ /* subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag, */ /* wa1,wa2) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle */ /* must contain the full upper triangle of the matrix r. */ /* on output the full upper triangle is unaltered, and the */ /* strict lower triangle contains the strict upper triangle */ /* (transposed) of the upper triangular matrix s. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* delta is a positive input variable which specifies an upper */ /* bound on the euclidean norm of d*x. */ /* par is a nonnegative variable. on input par contains an */ /* initial estimate of the levenberg-marquardt parameter. */ /* on output par contains the final estimate. */ /* x is an output array of length n which contains the least */ /* squares solution of the system a*x = b, sqrt(par)*d*x = 0, */ /* for the output par. */ /* sdiag is an output array of length n which contains the */ /* diagonal elements of the upper triangular matrix s. */ /* wa1 and wa2 are work arrays of length n. */ /* subprograms called */ /* minpack-supplied ... dpmpar,enorm,qrsolv */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* dwarf is the smallest positive magnitude. */ dwarf = __cminpack_func__(dpmpar)(2); /* compute and store in x the gauss-newton direction. if the */ /* jacobian is rank-deficient, obtain a least squares solution. */ nsing = n; for (j = 0; j < n; ++j) { wa1[j] = qtb[j]; if (r[j + j * ldr] == 0. && nsing == n) { nsing = j; } if (nsing < n) { wa1[j] = 0.; } } # ifdef USE_CBLAS cblas_dtrsv(CblasColMajor, CblasUpper, CblasNoTrans, CblasNonUnit, nsing, r, ldr, wa1, 1); # else if (nsing >= 1) { int k; for (k = 1; k <= nsing; ++k) { j = nsing - k; wa1[j] /= r[j + j * ldr]; temp = wa1[j]; if (j >= 1) { int i; for (i = 0; i < j; ++i) { wa1[i] -= r[i + j * ldr] * temp; } } } } # endif for (j = 0; j < n; ++j) { l = ipvt[j]-1; x[l] = wa1[j]; } /* initialize the iteration counter. */ /* evaluate the function at the origin, and test */ /* for acceptance of the gauss-newton direction. */ iter = 0; for (j = 0; j < n; ++j) { wa2[j] = diag[j] * x[j]; } dxnorm = __cminpack_enorm__(n, wa2); fp = dxnorm - delta; if (fp <= p1 * delta) { goto TERMINATE; } /* if the jacobian is not rank deficient, the newton */ /* step provides a lower bound, parl, for the zero of */ /* the function. otherwise set this bound to zero. */ parl = 0.; if (nsing >= n) { for (j = 0; j < n; ++j) { l = ipvt[j]-1; wa1[j] = diag[l] * (wa2[l] / dxnorm); } # ifdef USE_CBLAS cblas_dtrsv(CblasColMajor, CblasUpper, CblasTrans, CblasNonUnit, n, r, ldr, wa1, 1); # else for (j = 0; j < n; ++j) { real sum = 0.; if (j >= 1) { int i; for (i = 0; i < j; ++i) { sum += r[i + j * ldr] * wa1[i]; } } wa1[j] = (wa1[j] - sum) / r[j + j * ldr]; } # endif temp = __cminpack_enorm__(n, wa1); parl = fp / delta / temp / temp; } /* calculate an upper bound, paru, for the zero of the function. */ for (j = 0; j < n; ++j) { real sum; # ifdef USE_CBLAS sum = cblas_ddot(j+1, &r[j*ldr], 1, qtb, 1); # else int i; sum = 0.; for (i = 0; i <= j; ++i) { sum += r[i + j * ldr] * qtb[i]; } # endif l = ipvt[j]-1; wa1[j] = sum / diag[l]; } gnorm = __cminpack_enorm__(n, wa1); paru = gnorm / delta; if (paru == 0.) { paru = dwarf / min(delta,(real)p1) /* / p001 ??? */; } /* if the input par lies outside of the interval (parl,paru), */ /* set par to the closer endpoint. */ *par = max(*par,parl); *par = min(*par,paru); if (*par == 0.) { *par = gnorm / dxnorm; } /* beginning of an iteration. */ for (;;) { ++iter; /* evaluate the function at the current value of par. */ if (*par == 0.) { /* Computing MAX */ d1 = dwarf, d2 = p001 * paru; *par = max(d1,d2); } temp = sqrt(*par); for (j = 0; j < n; ++j) { wa1[j] = temp * diag[j]; } __cminpack_func__(qrsolv)(n, r, ldr, ipvt, wa1, qtb, x, sdiag, wa2); for (j = 0; j < n; ++j) { wa2[j] = diag[j] * x[j]; } dxnorm = __cminpack_enorm__(n, wa2); temp = fp; fp = dxnorm - delta; /* if the function is small enough, accept the current value */ /* of par. also test for the exceptional cases where parl */ /* is zero or the number of iterations has reached 10. */ if (fabs(fp) <= p1 * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) { goto TERMINATE; } /* compute the newton correction. */ # ifdef USE_CBLAS for (j = 0; j < nsing; ++j) { l = ipvt[j]-1; wa1[j] = diag[l] * (wa2[l] / dxnorm); } for (j = nsing; j < n; ++j) { wa1[j] = 0.; } /* exchange the diagonal of r with sdiag */ cblas_dswap(n, r, ldr+1, sdiag, 1); /* solve lower(r).x = wa1, result id put in wa1 */ cblas_dtrsv(CblasColMajor, CblasLower, CblasNoTrans, CblasNonUnit, nsing, r, ldr, wa1, 1); /* exchange the diagonal of r with sdiag */ cblas_dswap( n, r, ldr+1, sdiag, 1); # else /* !USE_CBLAS */ for (j = 0; j < n; ++j) { l = ipvt[j]-1; wa1[j] = diag[l] * (wa2[l] / dxnorm); } for (j = 0; j < n; ++j) { wa1[j] /= sdiag[j]; temp = wa1[j]; if (n > j+1) { int i; for (i = j+1; i < n; ++i) { wa1[i] -= r[i + j * ldr] * temp; } } } # endif /* !USE_CBLAS */ temp = __cminpack_enorm__(n, wa1); parc = fp / delta / temp / temp; /* depending on the sign of the function, update parl or paru. */ if (fp > 0.) { parl = max(parl,*par); } if (fp < 0.) { paru = min(paru,*par); } /* compute an improved estimate for par. */ /* Computing MAX */ d1 = parl, d2 = *par + parc; *par = max(d1,d2); /* end of an iteration. */ } TERMINATE: /* termination. */ if (iter == 0) { *par = 0.; } /* last card of subroutine lmpar. */ } /* lmpar_ */ cminpack-1.3.4/lmpar_.c000644 000765 000765 00000022613 12225167750 014705 0ustar00devernay000000 000000 /* lmpar.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define abs(x) ((x) >= 0 ? (x) : -(x)) __minpack_attr__ void __minpack_func__(lmpar)(const int *n, real *r__, const int *ldr, const int *ipvt, const real *diag, const real *qtb, const real *delta, real *par, real *x, real *sdiag, real *wa1, real *wa2) { /* Table of constant values */ const int c__2 = 2; /* Initialized data */ #define p1 .1 #define p001 .001 /* System generated locals */ int r_dim1, r_offset, i__1, i__2; real d__1, d__2; /* Local variables */ int i__, j, k, l; real fp; int jm1, jp1; real sum, parc, parl; int iter; real temp, paru, dwarf; int nsing; real gnorm; real dxnorm; /* ********** */ /* subroutine lmpar */ /* given an m by n matrix a, an n by n nonsingular diagonal */ /* matrix d, an m-vector b, and a positive number delta, */ /* the problem is to determine a value for the parameter */ /* par such that if x solves the system */ /* a*x = b , sqrt(par)*d*x = 0 , */ /* in the least squares sense, and dxnorm is the euclidean */ /* norm of d*x, then either par is zero and */ /* (dxnorm-delta) .le. 0.1*delta , */ /* or par is positive and */ /* abs(dxnorm-delta) .le. 0.1*delta . */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then lmpar expects */ /* the full upper triangle of r, the permutation matrix p, */ /* and the first n components of (q transpose)*b. on output */ /* lmpar also provides an upper triangular matrix s such that */ /* t t t */ /* p *(a *a + par*d*d)*p = s *s . */ /* s is employed within lmpar and may be of separate interest. */ /* only a few iterations are generally needed for convergence */ /* of the algorithm. if, however, the limit of 10 iterations */ /* is reached, then the output par will contain the best */ /* value obtained so far. */ /* the subroutine statement is */ /* subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag, */ /* wa1,wa2) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle */ /* must contain the full upper triangle of the matrix r. */ /* on output the full upper triangle is unaltered, and the */ /* strict lower triangle contains the strict upper triangle */ /* (transposed) of the upper triangular matrix s. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* delta is a positive input variable which specifies an upper */ /* bound on the euclidean norm of d*x. */ /* par is a nonnegative variable. on input par contains an */ /* initial estimate of the levenberg-marquardt parameter. */ /* on output par contains the final estimate. */ /* x is an output array of length n which contains the least */ /* squares solution of the system a*x = b, sqrt(par)*d*x = 0, */ /* for the output par. */ /* sdiag is an output array of length n which contains the */ /* diagonal elements of the upper triangular matrix s. */ /* wa1 and wa2 are work arrays of length n. */ /* subprograms called */ /* minpack-supplied ... dpmpar,enorm,qrsolv */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa2; --wa1; --sdiag; --x; --qtb; --diag; --ipvt; r_dim1 = *ldr; r_offset = 1 + r_dim1 * 1; r__ -= r_offset; /* Function Body */ /* dwarf is the smallest positive magnitude. */ dwarf = __minpack_func__(dpmpar)(&c__2); /* compute and store in x the gauss-newton direction. if the */ /* jacobian is rank-deficient, obtain a least squares solution. */ nsing = *n; i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = qtb[j]; if (r__[j + j * r_dim1] == 0. && nsing == *n) { nsing = j - 1; } if (nsing < *n) { wa1[j] = 0.; } /* L10: */ } if (nsing < 1) { goto L50; } i__1 = nsing; for (k = 1; k <= i__1; ++k) { j = nsing - k + 1; wa1[j] /= r__[j + j * r_dim1]; temp = wa1[j]; jm1 = j - 1; if (jm1 < 1) { goto L30; } i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { wa1[i__] -= r__[i__ + j * r_dim1] * temp; /* L20: */ } L30: /* L40: */ ; } L50: i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; x[l] = wa1[j]; /* L60: */ } /* initialize the iteration counter. */ /* evaluate the function at the origin, and test */ /* for acceptance of the gauss-newton direction. */ iter = 0; i__1 = *n; for (j = 1; j <= i__1; ++j) { wa2[j] = diag[j] * x[j]; /* L70: */ } dxnorm = __minpack_func__(enorm)(n, &wa2[1]); fp = dxnorm - *delta; if (fp <= p1 * *delta) { goto L220; } /* if the jacobian is not rank deficient, the newton */ /* step provides a lower bound, parl, for the zero of */ /* the function. otherwise set this bound to zero. */ parl = 0.; if (nsing < *n) { goto L120; } i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; wa1[j] = diag[l] * (wa2[l] / dxnorm); /* L80: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { sum = 0.; jm1 = j - 1; if (jm1 < 1) { goto L100; } i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { sum += r__[i__ + j * r_dim1] * wa1[i__]; /* L90: */ } L100: wa1[j] = (wa1[j] - sum) / r__[j + j * r_dim1]; /* L110: */ } temp = __minpack_func__(enorm)(n, &wa1[1]); parl = fp / *delta / temp / temp; L120: /* calculate an upper bound, paru, for the zero of the function. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { sum = 0.; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { sum += r__[i__ + j * r_dim1] * qtb[i__]; /* L130: */ } l = ipvt[j]; wa1[j] = sum / diag[l]; /* L140: */ } gnorm = __minpack_func__(enorm)(n, &wa1[1]); paru = gnorm / *delta; if (paru == 0.) { paru = dwarf / min(*delta,(real)p1); } /* if the input par lies outside of the interval (parl,paru), */ /* set par to the closer endpoint. */ *par = max(*par,parl); *par = min(*par,paru); if (*par == 0.) { *par = gnorm / dxnorm; } /* beginning of an iteration. */ L150: ++iter; /* evaluate the function at the current value of par. */ if (*par == 0.) { /* Computing MAX */ d__1 = dwarf, d__2 = p001 * paru; *par = max(d__1,d__2); } temp = sqrt(*par); i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = temp * diag[j]; /* L160: */ } __minpack_func__(qrsolv)(n, &r__[r_offset], ldr, &ipvt[1], &wa1[1], &qtb[1], &x[1], &sdiag[ 1], &wa2[1]); i__1 = *n; for (j = 1; j <= i__1; ++j) { wa2[j] = diag[j] * x[j]; /* L170: */ } dxnorm = __minpack_func__(enorm)(n, &wa2[1]); temp = fp; fp = dxnorm - *delta; /* if the function is small enough, accept the current value */ /* of par. also test for the exceptional cases where parl */ /* is zero or the number of iterations has reached 10. */ if (abs(fp) <= p1 * *delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) { goto L220; } /* compute the newton correction. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; wa1[j] = diag[l] * (wa2[l] / dxnorm); /* L180: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] /= sdiag[j]; temp = wa1[j]; jp1 = j + 1; if (*n < jp1) { goto L200; } i__2 = *n; for (i__ = jp1; i__ <= i__2; ++i__) { wa1[i__] -= r__[i__ + j * r_dim1] * temp; /* L190: */ } L200: /* L210: */ ; } temp = __minpack_func__(enorm)(n, &wa1[1]); parc = fp / *delta / temp / temp; /* depending on the sign of the function, update parl or paru. */ if (fp > 0.) { parl = max(parl,*par); } if (fp < 0.) { paru = min(paru,*par); } /* compute an improved estimate for par. */ /* Computing MAX */ d__1 = parl, d__2 = *par + parc; *par = max(d__1,d__2); /* end of an iteration. */ goto L150; L220: /* termination. */ if (iter == 0) { *par = 0.; } return; /* last card of subroutine lmpar. */ } /* lmpar_ */ cminpack-1.3.4/lmstr.c000644 000765 000765 00000042600 12225167750 014572 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmstr)(__cminpack_decl_fcnderstr_mn__ void *p, int m, int n, real *x, real *fvec, real *fjac, int ldfjac, real ftol, real xtol, real gtol, int maxfev, real * diag, int mode, real factor, int nprint, int *nfev, int *njev, int *ipvt, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ real d1, d2; /* Local variables */ int i, j, l; real par, sum; int sing; int iter; real temp, temp1, temp2; int iflag; real delta = 0.; real ratio; real fnorm, gnorm, pnorm, xnorm = 0., fnorm1, actred, dirder, epsmch, prered; int info; /* ********** */ /* subroutine lmstr */ /* the purpose of lmstr is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm which uses minimal storage. */ /* the user must provide a subroutine which calculates the */ /* functions and the rows of the jacobian. */ /* the subroutine statement is */ /* subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */ /* maxfev,diag,mode,factor,nprint,info,nfev, */ /* njev,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the rows of the jacobian. */ /* fcn must be declared in an external statement in the */ /* user calling program, and should be written as follows. */ /* 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. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* ---------- */ /* return */ /* end */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmstr. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array. the upper triangle of fjac */ /* contains an upper triangular matrix r such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower triangular */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* epsmch is the machine precision. */ epsmch = __cminpack_func__(dpmpar)(1); info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (n <= 0 || m < n || ldfjac < n || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.) { goto TERMINATE; } if (mode == 2) { for (j = 0; j < n; ++j) { if (diag[j] <= 0.) { goto TERMINATE; } } } /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = fcnderstr_mn(p, m, n, x, fvec, wa3, 1); *nfev = 1; if (iflag < 0) { goto TERMINATE; } fnorm = __cminpack_enorm__(m, fvec); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ for (;;) { /* if requested, call fcn to enable printing of iterates. */ if (nprint > 0) { iflag = 0; if ((iter - 1) % nprint == 0) { iflag = fcnderstr_mn(p, m, n, x, fvec, wa3, 0); } if (iflag < 0) { goto TERMINATE; } } /* compute the qr factorization of the jacobian matrix */ /* calculated one row at a time, while simultaneously */ /* forming (q transpose)*fvec and storing the first */ /* n components in qtf. */ for (j = 0; j < n; ++j) { qtf[j] = 0.; for (i = 0; i < n; ++i) { fjac[i + j * ldfjac] = 0.; } } iflag = 2; for (i = 0; i < m; ++i) { if (fcnderstr_mn(p, m, n, x, fvec, wa3, iflag) < 0) { goto TERMINATE; } temp = fvec[i]; __cminpack_func__(rwupdt)(n, fjac, ldfjac, wa3, qtf, &temp, wa1, wa2); ++iflag; } ++(*njev); /* if the jacobian is rank deficient, call qrfac to */ /* reorder its columns and update the components of qtf. */ sing = FALSE_; for (j = 0; j < n; ++j) { if (fjac[j + j * ldfjac] == 0.) { sing = TRUE_; } ipvt[j] = j+1; wa2[j] = __cminpack_enorm__(j+1, &fjac[j * ldfjac + 0]); } if (sing) { __cminpack_func__(qrfac)(n, n, fjac, ldfjac, TRUE_, ipvt, n, wa1, wa2, wa3); for (j = 0; j < n; ++j) { if (fjac[j + j * ldfjac] != 0.) { sum = 0.; for (i = j; i < n; ++i) { sum += fjac[i + j * ldfjac] * qtf[i]; } temp = -sum / fjac[j + j * ldfjac]; for (i = j; i < n; ++i) { qtf[i] += fjac[i + j * ldfjac] * temp; } } fjac[j + j * ldfjac] = wa1[j]; } } /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter == 1) { if (mode != 2) { for (j = 0; j < n; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } } } /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ for (j = 0; j < n; ++j) { wa3[j] = diag[j] * x[j]; } xnorm = __cminpack_enorm__(n, wa3); delta = factor * xnorm; if (delta == 0.) { delta = factor; } } /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm != 0.) { for (j = 0; j < n; ++j) { l = ipvt[j]-1; if (wa2[l] != 0.) { sum = 0.; for (i = 0; i <= j; ++i) { sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm); } /* Computing MAX */ d1 = fabs(sum / wa2[l]); gnorm = max(gnorm,d1); } } } /* test for convergence of the gradient norm. */ if (gnorm <= gtol) { info = 4; } if (info != 0) { goto TERMINATE; } /* rescale if necessary. */ if (mode != 2) { for (j = 0; j < n; ++j) { /* Computing MAX */ d1 = diag[j], d2 = wa2[j]; diag[j] = max(d1,d2); } } /* beginning of the inner loop. */ do { /* determine the levenberg-marquardt parameter. */ __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta, &par, wa1, wa2, wa3, wa4); /* store the direction p and x + p. calculate the norm of p. */ for (j = 0; j < n; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; } pnorm = __cminpack_enorm__(n, wa3); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = fcnderstr_mn(p, m, n, wa2, wa4, wa3, 1); ++(*nfev); if (iflag < 0) { goto TERMINATE; } fnorm1 = __cminpack_enorm__(m, wa4); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d1 = fnorm1 / fnorm; actred = 1. - d1 * d1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ for (j = 0; j < n; ++j) { wa3[j] = 0.; l = ipvt[j]-1; temp = wa1[l]; for (i = 0; i <= j; ++i) { wa3[i] += fjac[i + j * ldfjac] * temp; } } temp1 = __cminpack_enorm__(n, wa3) / fnorm; temp2 = (sqrt(par) * pnorm) / fnorm; prered = temp1 * temp1 + temp2 * temp2 / p5; dirder = -(temp1 * temp1 + temp2 * temp2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio <= p25) { if (actred >= 0.) { temp = p5; } else { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d1 = pnorm / p1; delta = temp * min(delta,d1); par /= temp; } else { if (par == 0. || ratio >= p75) { delta = pnorm / p5; par = p5 * par; } } /* test for successful iteration. */ if (ratio >= p0001) { /* successful iteration. update x, fvec, and their norms. */ for (j = 0; j < n; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; } for (i = 0; i < m; ++i) { fvec[i] = wa4[i]; } xnorm = __cminpack_enorm__(n, wa2); fnorm = fnorm1; ++iter; } /* tests for convergence. */ if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } if (info != 0) { goto TERMINATE; } /* tests for termination and stringent tolerances. */ if (*nfev >= maxfev) { info = 5; } if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { info = 6; } if (delta <= epsmch * xnorm) { info = 7; } if (gnorm <= epsmch) { info = 8; } if (info != 0) { goto TERMINATE; } /* end of the inner loop. repeat if iteration unsuccessful. */ } while (ratio < p0001); /* end of the outer loop. */ } TERMINATE: /* termination, either normal or user imposed. */ if (iflag < 0) { info = iflag; } if (nprint > 0) { fcnderstr_mn(p, m, n, x, fvec, wa3, 0); } return info; /* last card of subroutine lmstr. */ } /* lmstr_ */ cminpack-1.3.4/lmstr1.c000644 000765 000765 00000013510 12225167750 014651 0ustar00devernay000000 000000 #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ int __cminpack_func__(lmstr1)(__cminpack_decl_fcnderstr_mn__ void *p, int m, int n, real *x, real *fvec, real *fjac, int ldfjac, real tol, int *ipvt, real *wa, int lwa) { /* Initialized data */ const real factor = 100.; /* Local variables */ int mode, nfev, njev; real ftol, gtol, xtol; int maxfev, nprint; int info; /* ********** */ /* subroutine lmstr1 */ /* the purpose of lmstr1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm which uses minimal storage. */ /* this is done by using the more general least-squares solver */ /* lmstr. the user must provide a subroutine which calculates */ /* the functions and the rows of the jacobian. */ /* the subroutine statement is */ /* subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */ /* ipvt,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the rows of the jacobian. */ /* fcn must be declared in an external statement in the */ /* user calling program, and should be written as follows. */ /* 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. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* ---------- */ /* return */ /* end */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmstr1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array. the upper triangle of fjac */ /* contains an upper triangular matrix r such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower triangular */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than 5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmstr */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* check the input parameters for errors. */ if (n <= 0 || m < n || ldfjac < n || tol < 0. || lwa < n * 5 + m) { return 0; } /* call lmstr. */ maxfev = (n + 1) * 100; ftol = tol; xtol = tol; gtol = 0.; mode = 1; nprint = 0; info = __cminpack_func__(lmstr)(__cminpack_param_fcnderstr_mn__ p, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, wa, mode, factor, nprint, &nfev, &njev, ipvt, &wa[n], &wa[(n << 1)], & wa[n * 3], &wa[(n << 2)], &wa[n * 5]); if (info == 8) { info = 4; } return info; /* last card of subroutine lmstr1. */ } /* lmstr1_ */ cminpack-1.3.4/lmstr1_.c000644 000765 000765 00000014572 12225167750 015021 0ustar00devernay000000 000000 /* lmstr1.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ __minpack_attr__ void __minpack_func__(lmstr1)(__minpack_decl_fcnderstr_mn__ const int *m, const int *n, real *x, real *fvec, real *fjac, const int *ldfjac, const real *tol, int *info, int *ipvt, real *wa, const int *lwa) { /* Initialized data */ const real factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ int mode, nfev, njev; real ftol, gtol, xtol; int maxfev, nprint; /* ********** */ /* subroutine lmstr1 */ /* the purpose of lmstr1 is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm which uses minimal storage. */ /* this is done by using the more general least-squares solver */ /* lmstr. the user must provide a subroutine which calculates */ /* the functions and the rows of the jacobian. */ /* the subroutine statement is */ /* subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */ /* ipvt,wa,lwa) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the rows of the jacobian. */ /* fcn must be declared in an external statement in the */ /* user calling program, and should be written as follows. */ /* 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. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* ---------- */ /* return */ /* end */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmstr1. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array. the upper triangle of fjac */ /* contains an upper triangular matrix r such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower triangular */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* tol is a nonnegative input variable. termination occurs */ /* when the algorithm estimates either that the relative */ /* error in the sum of squares is at most tol or that */ /* the relative error between x and the solution is at */ /* most tol. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 algorithm estimates that the relative error */ /* in the sum of squares is at most tol. */ /* info = 2 algorithm estimates that the relative error */ /* between x and the solution is at most tol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 fvec is orthogonal to the columns of the */ /* jacobian to machine precision. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached 100*(n+1). */ /* info = 6 tol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 tol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* wa is a work array of length lwa. */ /* lwa is a positive integer input variable not less than 5*n+m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... lmstr */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --ipvt; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; --wa; /* Function Body */ *info = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *ldfjac < *n || *tol < 0. || *lwa < *n * 5 + * m) { /* goto L10; */ return; } /* call lmstr. */ maxfev = (*n + 1) * 100; ftol = *tol; xtol = *tol; gtol = 0.; mode = 1; nprint = 0; __minpack_func__(lmstr)(__minpack_param_fcnderstr_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, & ftol, &xtol, >ol, &maxfev, &wa[1], &mode, &factor, &nprint, info, &nfev, &njev, &ipvt[1], &wa[*n + 1], &wa[(*n << 1) + 1], & wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]); if (*info == 8) { *info = 4; } /* L10: */ return; /* last card of subroutine lmstr1. */ } /* lmstr1_ */ cminpack-1.3.4/lmstr_.c000644 000765 000765 00000042430 12225167750 014732 0ustar00devernay000000 000000 /* lmstr.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define abs(x) ((x) >= 0 ? (x) : -(x)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(lmstr)(__minpack_decl_fcnderstr_mn__ const int *m, const int *n, real *x, real *fvec, real *fjac, const int *ldfjac, const real *ftol, const real *xtol, const real *gtol, const int *maxfev, real * diag, const int *mode, const real *factor, const int *nprint, int * info, int *nfev, int *njev, int *ipvt, real *qtf, real *wa1, real *wa2, real *wa3, real *wa4) { /* Table of constant values */ const int c__1 = 1; const int c_true = TRUE_; /* Initialized data */ #define p1 .1 #define p5 .5 #define p25 .25 #define p75 .75 #define p0001 1e-4 /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; real d__1, d__2, d__3; /* Local variables */ int i__, j, l; real par, sum; int sing; int iter; real temp, temp1, temp2; int iflag; real delta; real ratio; real fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, epsmch, prered; /* ********** */ /* subroutine lmstr */ /* the purpose of lmstr is to minimize the sum of the squares of */ /* m nonlinear functions in n variables by a modification of */ /* the levenberg-marquardt algorithm which uses minimal storage. */ /* the user must provide a subroutine which calculates the */ /* functions and the rows of the jacobian. */ /* the subroutine statement is */ /* subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */ /* maxfev,diag,mode,factor,nprint,info,nfev, */ /* njev,ipvt,qtf,wa1,wa2,wa3,wa4) */ /* where */ /* fcn is the name of the user-supplied subroutine which */ /* calculates the functions and the rows of the jacobian. */ /* fcn must be declared in an external statement in the */ /* user calling program, and should be written as follows. */ /* 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. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* ---------- */ /* return */ /* end */ /* the value of iflag should not be changed by fcn unless */ /* the user wants to terminate execution of lmstr. */ /* in this case set iflag to a negative integer. */ /* m is a positive integer input variable set to the number */ /* of functions. */ /* n is a positive integer input variable set to the number */ /* of variables. n must not exceed m. */ /* x is an array of length n. on input x must contain */ /* an initial estimate of the solution vector. on output x */ /* contains the final estimate of the solution vector. */ /* fvec is an output array of length m which contains */ /* the functions evaluated at the output x. */ /* fjac is an output n by n array. the upper triangle of fjac */ /* contains an upper triangular matrix r such that */ /* t t t */ /* p *(jac *jac)*p = r *r, */ /* where p is a permutation matrix and jac is the final */ /* calculated jacobian. column j of p is column ipvt(j) */ /* (see below) of the identity matrix. the lower triangular */ /* part of fjac contains information generated during */ /* the computation of r. */ /* ldfjac is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* ftol is a nonnegative input variable. termination */ /* occurs when both the actual and predicted relative */ /* reductions in the sum of squares are at most ftol. */ /* therefore, ftol measures the relative error desired */ /* in the sum of squares. */ /* xtol is a nonnegative input variable. termination */ /* occurs when the relative error between two consecutive */ /* iterates is at most xtol. therefore, xtol measures the */ /* relative error desired in the approximate solution. */ /* gtol is a nonnegative input variable. termination */ /* occurs when the cosine of the angle between fvec and */ /* any column of the jacobian is at most gtol in absolute */ /* value. therefore, gtol measures the orthogonality */ /* desired between the function vector and the columns */ /* of the jacobian. */ /* maxfev is a positive integer input variable. termination */ /* occurs when the number of calls to fcn with iflag = 1 */ /* has reached maxfev. */ /* diag is an array of length n. if mode = 1 (see */ /* below), diag is internally set. if mode = 2, diag */ /* must contain positive entries that serve as */ /* multiplicative scale factors for the variables. */ /* mode is an integer input variable. if mode = 1, the */ /* variables will be scaled internally. if mode = 2, */ /* the scaling is specified by the input diag. other */ /* values of mode are equivalent to mode = 1. */ /* factor is a positive input variable used in determining the */ /* initial step bound. this bound is set to the product of */ /* factor and the euclidean norm of diag*x if nonzero, or else */ /* to factor itself. in most cases factor should lie in the */ /* interval (.1,100.). 100. is a generally recommended value. */ /* nprint is an integer input variable that enables controlled */ /* printing of iterates if it is positive. in this case, */ /* fcn is called with iflag = 0 at the beginning of the first */ /* iteration and every nprint iterations thereafter and */ /* immediately prior to return, with x and fvec available */ /* for printing. if nprint is not positive, no special calls */ /* of fcn with iflag = 0 are made. */ /* info 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. */ /* info = 0 improper input parameters. */ /* info = 1 both actual and predicted relative reductions */ /* in the sum of squares are at most ftol. */ /* info = 2 relative error between two consecutive iterates */ /* is at most xtol. */ /* info = 3 conditions for info = 1 and info = 2 both hold. */ /* info = 4 the cosine of the angle between fvec and any */ /* column of the jacobian is at most gtol in */ /* absolute value. */ /* info = 5 number of calls to fcn with iflag = 1 has */ /* reached maxfev. */ /* info = 6 ftol is too small. no further reduction in */ /* the sum of squares is possible. */ /* info = 7 xtol is too small. no further improvement in */ /* the approximate solution x is possible. */ /* info = 8 gtol is too small. fvec is orthogonal to the */ /* columns of the jacobian to machine precision. */ /* nfev is an integer output variable set to the number of */ /* calls to fcn with iflag = 1. */ /* njev is an integer output variable set to the number of */ /* calls to fcn with iflag = 2. */ /* ipvt is an integer output array of length n. ipvt */ /* defines a permutation matrix p such that jac*p = q*r, */ /* where jac is the final calculated jacobian, q is */ /* orthogonal (not stored), and r is upper triangular. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* qtf is an output array of length n which contains */ /* the first n elements of the vector (q transpose)*fvec. */ /* wa1, wa2, and wa3 are work arrays of length n. */ /* wa4 is a work array of length m. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt */ /* fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa4; --fvec; --wa3; --wa2; --wa1; --qtf; --ipvt; --diag; --x; fjac_dim1 = *ldfjac; fjac_offset = 1 + fjac_dim1 * 1; fjac -= fjac_offset; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); *info = 0; iflag = 0; *nfev = 0; *njev = 0; /* check the input parameters for errors. */ if (*n <= 0 || *m < *n || *ldfjac < *n || *ftol < 0. || *xtol < 0. || *gtol < 0. || *maxfev <= 0 || *factor <= 0.) { goto L340; } if (*mode != 2) { goto L20; } i__1 = *n; for (j = 1; j <= i__1; ++j) { if (diag[j] <= 0.) { goto L340; } /* L10: */ } L20: /* evaluate the function at the starting point */ /* and calculate its norm. */ iflag = 1; fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag); *nfev = 1; if (iflag < 0) { goto L340; } fnorm = __minpack_func__(enorm)(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ par = 0.; iter = 1; /* beginning of the outer loop. */ L30: /* if requested, call fcn to enable printing of iterates. */ if (*nprint <= 0) { goto L40; } iflag = 0; if ((iter - 1) % *nprint == 0) { fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag); } if (iflag < 0) { goto L340; } L40: /* compute the qr factorization of the jacobian matrix */ /* calculated one row at a time, while simultaneously */ /* forming (q transpose)*fvec and storing the first */ /* n components in qtf. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { qtf[j] = 0.; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { fjac[i__ + j * fjac_dim1] = 0.; /* L50: */ } /* L60: */ } iflag = 2; i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag); if (iflag < 0) { goto L340; } temp = fvec[i__]; __minpack_func__(rwupdt)(n, &fjac[fjac_offset], ldfjac, &wa3[1], &qtf[1], &temp, &wa1[ 1], &wa2[1]); ++iflag; /* L70: */ } ++(*njev); /* if the jacobian is rank deficient, call qrfac to */ /* reorder its columns and update the components of qtf. */ sing = FALSE_; i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { sing = TRUE_; } ipvt[j] = j; wa2[j] = __minpack_func__(enorm)(&j, &fjac[j * fjac_dim1 + 1]); /* L80: */ } if (! sing) { goto L130; } __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], & wa2[1], &wa3[1]); i__1 = *n; for (j = 1; j <= i__1; ++j) { if (fjac[j + j * fjac_dim1] == 0.) { goto L110; } sum = 0.; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * qtf[i__]; /* L90: */ } temp = -sum / fjac[j + j * fjac_dim1]; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { qtf[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L100: */ } L110: fjac[j + j * fjac_dim1] = wa1[j]; /* L120: */ } L130: /* on the first iteration and if mode is 1, scale according */ /* to the norms of the columns of the initial jacobian. */ if (iter != 1) { goto L170; } if (*mode == 2) { goto L150; } i__1 = *n; for (j = 1; j <= i__1; ++j) { diag[j] = wa2[j]; if (wa2[j] == 0.) { diag[j] = 1.; } /* L140: */ } L150: /* on the first iteration, calculate the norm of the scaled x */ /* and initialize the step bound delta. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = diag[j] * x[j]; /* L160: */ } xnorm = __minpack_func__(enorm)(n, &wa3[1]); delta = *factor * xnorm; if (delta == 0.) { delta = *factor; } L170: /* compute the norm of the scaled gradient. */ gnorm = 0.; if (fnorm == 0.) { goto L210; } i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; if (wa2[l] == 0.) { goto L190; } sum = 0.; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm); /* L180: */ } /* Computing MAX */ d__2 = gnorm, d__3 = (d__1 = sum / wa2[l], abs(d__1)); gnorm = max(d__2,d__3); L190: /* L200: */ ; } L210: /* test for convergence of the gradient norm. */ if (gnorm <= *gtol) { *info = 4; } if (*info != 0) { goto L340; } /* rescale if necessary. */ if (*mode == 2) { goto L230; } i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MAX */ d__1 = diag[j], d__2 = wa2[j]; diag[j] = max(d__1,d__2); /* L220: */ } L230: /* beginning of the inner loop. */ L240: /* determine the levenberg-marquardt parameter. */ __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta, &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]); /* store the direction p and x + p. calculate the norm of p. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa1[j] = -wa1[j]; wa2[j] = x[j] + wa1[j]; wa3[j] = diag[j] * wa1[j]; /* L250: */ } pnorm = __minpack_func__(enorm)(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ if (iter == 1) { delta = min(delta,pnorm); } /* evaluate the function at x + p and calculate its norm. */ iflag = 1; fcnderstr_mn(m, n, &wa2[1], &wa4[1], &wa3[1], &iflag); ++(*nfev); if (iflag < 0) { goto L340; } fnorm1 = __minpack_func__(enorm)(m, &wa4[1]); /* compute the scaled actual reduction. */ actred = -1.; if (p1 * fnorm1 < fnorm) { /* Computing 2nd power */ d__1 = fnorm1 / fnorm; actred = 1. - d__1 * d__1; } /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { wa3[j] = 0.; l = ipvt[j]; temp = wa1[l]; i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { wa3[i__] += fjac[i__ + j * fjac_dim1] * temp; /* L260: */ } /* L270: */ } temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; prered = d__1 * d__1 + d__2 * d__2 / p5; /* Computing 2nd power */ d__1 = temp1; /* Computing 2nd power */ d__2 = temp2; dirder = -(d__1 * d__1 + d__2 * d__2); /* compute the ratio of the actual to the predicted */ /* reduction. */ ratio = 0.; if (prered != 0.) { ratio = actred / prered; } /* update the step bound. */ if (ratio > p25) { goto L280; } if (actred >= 0.) { temp = p5; } if (actred < 0.) { temp = p5 * dirder / (dirder + p5 * actred); } if (p1 * fnorm1 >= fnorm || temp < p1) { temp = p1; } /* Computing MIN */ d__1 = delta, d__2 = pnorm / p1; delta = temp * min(d__1,d__2); par /= temp; goto L300; L280: if (par != 0. && ratio < p75) { goto L290; } delta = pnorm / p5; par = p5 * par; L290: L300: /* test for successful iteration. */ if (ratio < p0001) { goto L330; } /* successful iteration. update x, fvec, and their norms. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { x[j] = wa2[j]; wa2[j] = diag[j] * x[j]; /* L310: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { fvec[i__] = wa4[i__]; /* L320: */ } xnorm = __minpack_func__(enorm)(n, &wa2[1]); fnorm = fnorm1; ++iter; L330: /* tests for convergence. */ if (abs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) { *info = 1; } if (delta <= *xtol * xnorm) { *info = 2; } if (abs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info == 2) { *info = 3; } if (*info != 0) { goto L340; } /* tests for termination and stringent tolerances. */ if (*nfev >= *maxfev) { *info = 5; } if (abs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) { *info = 6; } if (delta <= epsmch * xnorm) { *info = 7; } if (gnorm <= epsmch) { *info = 8; } if (*info != 0) { goto L340; } /* end of the inner loop. repeat if iteration unsuccessful. */ if (ratio < p0001) { goto L240; } /* end of the outer loop. */ goto L30; L340: /* termination, either normal or user imposed. */ if (iflag < 0) { *info = iflag; } iflag = 0; if (*nprint > 0) { fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag); } return; /* last card of subroutine lmstr. */ } /* lmstr_ */ cminpack-1.3.4/Makefile000644 000765 000765 00000010136 12341325470 014716 0ustar00devernay000000 000000 PACKAGE=cminpack VERSION=1.3.4 CC=gcc CFLAGS= -O3 -g -Wall -Wextra ### The default configuration is to compile the double precision version ### configuration for the LAPACK/BLAS (double precision) version: ## make LIBSUFFIX= CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" #LIBSUFFIX=s #CFLAGS="-O3 -g -Wall -Wextra -DUSE_CBLAS -DUSE_LAPACK" CFLAGS_L=$(CFLAGS) -DUSE_CBLAS -DUSE_LAPACK LDADD_L=-framework Accelerate ### configuration for the float (single precision) version: ## make LIBSUFFIX=s CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" #LIBSUFFIX=s #CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" CFLAGS_F=$(CFLAGS) -D__cminpack_float__ ### configuration for the half (half precision) version: ## make LIBSUFFIX=h CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" LDADD="-L/opt/local/lib -lHalf" CC=g++ #LIBSUFFIX=h #CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" #LDADD="-L/opt/local/lib -lHalf" #CC=g++ CFLAGS_H=$(CFLAGS) -I/opt/local/include -D__cminpack_half__ LDADD_H=-L/opt/local/lib -lHalf CC_H=$(CXX) OBJS = \ $(LIBSUFFIX)chkder.o $(LIBSUFFIX)enorm.o $(LIBSUFFIX)hybrd1.o $(LIBSUFFIX)hybrj.o \ $(LIBSUFFIX)lmdif1.o $(LIBSUFFIX)lmstr1.o $(LIBSUFFIX)qrfac.o $(LIBSUFFIX)r1updt.o \ $(LIBSUFFIX)dogleg.o $(LIBSUFFIX)fdjac1.o $(LIBSUFFIX)hybrd.o $(LIBSUFFIX)lmder1.o \ $(LIBSUFFIX)lmdif.o $(LIBSUFFIX)lmstr.o $(LIBSUFFIX)qrsolv.o $(LIBSUFFIX)rwupdt.o \ $(LIBSUFFIX)dpmpar.o $(LIBSUFFIX)fdjac2.o $(LIBSUFFIX)hybrj1.o $(LIBSUFFIX)lmder.o \ $(LIBSUFFIX)lmpar.o $(LIBSUFFIX)qform.o $(LIBSUFFIX)r1mpyq.o $(LIBSUFFIX)covar.o $(LIBSUFFIX)covar1.o \ $(LIBSUFFIX)chkder_.o $(LIBSUFFIX)enorm_.o $(LIBSUFFIX)hybrd1_.o $(LIBSUFFIX)hybrj_.o \ $(LIBSUFFIX)lmdif1_.o $(LIBSUFFIX)lmstr1_.o $(LIBSUFFIX)qrfac_.o $(LIBSUFFIX)r1updt_.o \ $(LIBSUFFIX)dogleg_.o $(LIBSUFFIX)fdjac1_.o $(LIBSUFFIX)hybrd_.o $(LIBSUFFIX)lmder1_.o \ $(LIBSUFFIX)lmdif_.o $(LIBSUFFIX)lmstr_.o $(LIBSUFFIX)qrsolv_.o $(LIBSUFFIX)rwupdt_.o \ $(LIBSUFFIX)dpmpar_.o $(LIBSUFFIX)fdjac2_.o $(LIBSUFFIX)hybrj1_.o $(LIBSUFFIX)lmder_.o \ $(LIBSUFFIX)lmpar_.o $(LIBSUFFIX)qform_.o $(LIBSUFFIX)r1mpyq_.o $(LIBSUFFIX)covar_.o # target dir for install DESTDIR=/usr/local # # Static library target # all: libcminpack$(LIBSUFFIX).a double: $(MAKE) LIBSUFFIX= lapack: $(MAKE) LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)" float: $(MAKE) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" half: $(MAKE) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" fortran: $(MAKE) -C fortran cuda: $(MAKE) -C cuda check: $(MAKE) -C examples check checkdouble: $(MAKE) -C examples checkdouble checklapack: $(MAKE) -C examples checklapack checkfloat: $(MAKE) -C examples checkfloat checkhalf: $(MAKE) -C examples checkhalf checkfail: $(MAKE) -C examples checkfail libcminpack$(LIBSUFFIX).a: $(OBJS) ar r $@ $(OBJS); ranlib $@ $(LIBSUFFIX)%.o: %.c ${CC} ${CFLAGS} -c -o $@ $< install: libcminpack$(LIBSUFFIX).a cp libcminpack$(LIBSUFFIX).a ${DESTDIR}/lib chmod 644 ${DESTDIR}/lib/libcminpack$(LIBSUFFIX).a ranlib -t ${DESTDIR}/lib/libcminpack$(LIBSUFFIX).a # might be unnecessary cp minpack.h ${DESTDIR}/include chmod 644 ${DESTDIR}/include/minpack.h cp cminpack.h ${DESTDIR}/include chmod 644 ${DESTDIR}/include/cminpack.h clean: rm -f $(OBJS) libcminpack$(LIBSUFFIX).a make -C examples clean make -C fortran clean veryclean: clean rm -f *.o libcminpack*.a *.gcno *.gcda *~ #*# make -C examples veryclean make -C examples veryclean LIBSUFFIX=s make -C examples veryclean LIBSUFFIX=h make -C examples veryclean LIBSUFFIX=l make -C fortran veryclean .PHONY: dist all double lapack float half fortran cuda check checkhalf checkfail clean veryclean # COPYFILE_DISABLE=true and COPY_EXTENDED_ATTRIBUTES_DISABLE=true are used to disable inclusion # of file attributes (._* files) in the tar file on MacOSX dist: mkdir $(PACKAGE)-$(VERSION) env COPYFILE_DISABLE=true COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar --exclude-from dist-exclude --exclude $(PACKAGE)-$(VERSION) -cf - . | (cd $(PACKAGE)-$(VERSION); tar xf -) tar zcvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) rm -rf $(PACKAGE)-$(VERSION) cminpack-1.3.4/minpack.h000644 000765 000765 00000037026 12225167750 015066 0ustar00devernay000000 000000 #ifndef __MINPACK_H__ #define __MINPACK_H__ #include "cminpack.h" /* The default floating-point type is "double" for C/C++ and "float" for CUDA, but you can change this by defining one of the following symbols when compiling the library, and before including cminpack.h when using it: __cminpack_double__ for double __cminpack_float__ for float __cminpack_half__ for half from the OpenEXR library (in this case, you must compile cminpack with a C++ compiler) */ #ifdef __cminpack_double__ #define __minpack_func__(func) func ## _ #endif #ifdef __cminpack_float__ #define __minpack_func__(func) s ## func ## _ #endif #ifdef __cminpack_half__ #define __minpack_func__(func) h ## func ## _ #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #define MINPACK_EXPORT CMINPACK_EXPORT #define __minpack_real__ __cminpack_real__ #define __minpack_attr__ __cminpack_attr__ #if defined(__CUDA_ARCH__) || defined(__CUDACC__) #define __minpack_type_fcn_nn__ __minpack_attr__ void fcn_nn #define __minpack_type_fcnder_nn__ __minpack_attr__ void fcnder_nn #define __minpack_type_fcn_mn__ __minpack_attr__ void fcn_mn #define __minpack_type_fcnder_mn__ __minpack_attr__ void fcnder_mn #define __minpack_type_fcnderstr_mn__ __minpack_attr__ void fcnderstr_mn #define __minpack_decl_fcn_nn__ #define __minpack_decl_fcnder_nn__ #define __minpack_decl_fcn_mn__ #define __minpack_decl_fcnder_mn__ #define __minpack_decl_fcnderstr_mn__ #define __minpack_param_fcn_nn__ #define __minpack_param_fcnder_nn__ #define __minpack_param_fcn_mn__ #define __minpack_param_fcnder_mn__ #define __minpack_param_fcnderstr_mn__ #else #define __minpack_type_fcn_nn__ typedef void (*minpack_func_nn) #define __minpack_type_fcnder_nn__ typedef void (*minpack_funcder_nn) #define __minpack_type_fcn_mn__ typedef void (*minpack_func_mn) #define __minpack_type_fcnder_mn__ typedef void (*minpack_funcder_mn) #define __minpack_type_fcnderstr_mn__ typedef void (*minpack_funcderstr_mn) #define __minpack_decl_fcn_nn__ minpack_func_nn fcn_nn, #define __minpack_decl_fcnder_nn__ minpack_funcder_nn fcnder_nn, #define __minpack_decl_fcn_mn__ minpack_func_mn fcn_mn, #define __minpack_decl_fcnder_mn__ minpack_funcder_mn fcnder_mn, #define __minpack_decl_fcnderstr_mn__ minpack_funcderstr_mn fcnderstr_mn, #define __minpack_param_fcn_nn__ fcn_nn, #define __minpack_param_fcnder_nn__ fcnder_nn, #define __minpack_param_fcn_mn__ fcn_mn, #define __minpack_param_fcnder_mn__ fcnder_mn, #define __minpack_param_fcnderstr_mn__ fcnderstr_mn, #endif #undef __cminpack_type_fcn_nn__ #undef __cminpack_type_fcnder_nn__ #undef __cminpack_type_fcn_mn__ #undef __cminpack_type_fcnder_mn__ #undef __cminpack_type_fcnderstr_mn__ #undef __cminpack_decl_fcn_nn__ #undef __cminpack_decl_fcnder_nn__ #undef __cminpack_decl_fcn_mn__ #undef __cminpack_decl_fcnder_mn__ #undef __cminpack_decl_fcnderstr_mn__ #undef __cminpack_param_fcn_nn__ #undef __cminpack_param_fcnder_nn__ #undef __cminpack_param_fcn_mn__ #undef __cminpack_param_fcnder_mn__ #undef __cminpack_param_fcnderstr_mn__ /* Declarations for minpack */ /* Function types: */ /* the iflag parameter is input-only (with respect to the FORTRAN */ /* version), the output iflag value is the return value of the function. */ /* If iflag=0, the function shoulkd just print the current values (see */ /* the nprint parameters below). */ /* for hybrd1 and hybrd: */ /* calculate the functions at x and */ /* return this vector in fvec. */ /* return a negative value to terminate hybrd1/hybrd */ __minpack_type_fcn_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, int *iflag ); /* for hybrj1 and hybrj */ /* 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 a negative value to terminate hybrj1/hybrj */ __minpack_type_fcnder_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, int *iflag ); /* for lmdif1 and lmdif */ /* calculate the functions at x and */ /* return this vector in fvec. */ /* if iflag = 1 the result is used to compute the residuals. */ /* if iflag = 2 the result is used to compute the Jacobian by finite differences. */ /* Jacobian computation requires exactly n function calls with iflag = 2. */ /* return a negative value to terminate lmdif1/lmdif */ __minpack_type_fcn_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, int *iflag ); /* for lmder1 and lmder */ /* 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 a negative value to terminate lmder1/lmder */ __minpack_type_fcnder_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, int *iflag ); /* for lmstr1 and lmstr */ /* if iflag = 1 calculate the functions at x and */ /* return this vector in fvec. */ /* if iflag = i calculate the (i-1)-st row of the */ /* jacobian at x and return this vector in fjrow. */ /* return a negative value to terminate lmstr1/lmstr */ __minpack_type_fcnderstr_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjrow, int *iflag ); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (Jacobian calculated by a forward-difference approximation) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(hybrd1)( __minpack_decl_fcn_nn__ const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol, int *info, __minpack_real__ *wa, const int *lwa ); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (Jacobian calculated by a forward-difference approximation, more general). */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(hybrd)( __minpack_decl_fcn_nn__ const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *xtol, const int *maxfev, const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint, int *info, int *nfev, __minpack_real__ *fjac, const int *ldfjac, __minpack_real__ *r, const int *lr, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (user-supplied Jacobian) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(hybrj1)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *tol, int *info, __minpack_real__ *wa, const int *lwa ); /* find a zero of a system of N nonlinear functions in N variables by a modification of the Powell hybrid method (user-supplied Jacobian, more general) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(hybrj)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *xtol, const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint, int *info, int *nfev, int *njev, __minpack_real__ *r, const int *lr, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (Jacobian calculated by a forward-difference approximation) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmdif1)( __minpack_decl_fcn_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol, int *info, int *iwa, __minpack_real__ *wa, const int *lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (Jacobian calculated by a forward-difference approximation, more general) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmdif)( __minpack_decl_fcn_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol, const int *maxfev, const __minpack_real__ *epsfcn, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint, int *info, int *nfev, __minpack_real__ *fjac, const int *ldfjac, int *ipvt, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmder1)( __minpack_decl_fcnder_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, const __minpack_real__ *tol, int *info, int *ipvt, __minpack_real__ *wa, const int *lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, more general) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmder)( __minpack_decl_fcnder_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol, const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint, int *info, int *nfev, int *njev, int *ipvt, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4 ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, minimal storage) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmstr1)( __minpack_decl_fcnderstr_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, const __minpack_real__ *tol, int *info, int *ipvt, __minpack_real__ *wa, const int *lwa ); /* minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm (user-supplied Jacobian, minimal storage, more general) */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(lmstr)( __minpack_decl_fcnderstr_mn__ const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol, const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint, int *info, int *nfev, int *njev, int *ipvt, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4 ); __minpack_attr__ void MINPACK_EXPORT __minpack_func__(chkder)( const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, __minpack_real__ *xp, __minpack_real__ *fvecp, const int *mode, __minpack_real__ *err ); __minpack_attr__ __minpack_real__ MINPACK_EXPORT __minpack_func__(dpmpar)( const int *i ); __minpack_attr__ __minpack_real__ MINPACK_EXPORT __minpack_func__(enorm)( const int *n, const __minpack_real__ *x ); /* compute a forward-difference approximation to the m by n jacobian matrix associated with a specified problem of m functions in n variables. */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(fdjac2)(__minpack_decl_fcn_mn__ const int *m, const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, int *iflag, const __minpack_real__ *epsfcn, __minpack_real__ *wa); /* compute a forward-difference approximation to the n by n jacobian matrix associated with a specified problem of n functions in n variables. if the jacobian has a banded form, then function evaluations are saved by only approximating the nonzero terms. */ __minpack_attr__ void MINPACK_EXPORT __minpack_func__(fdjac1)(__minpack_decl_fcn_nn__ const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac, int *iflag, const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *wa1, __minpack_real__ *wa2); /* internal MINPACK subroutines */ __minpack_attr__ void __minpack_func__(dogleg)(const int *n, const __minpack_real__ *r, const int *lr, const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, __minpack_real__ *x, __minpack_real__ *wa1, __minpack_real__ *wa2); __minpack_attr__ void __minpack_func__(qrfac)(const int *m, const int *n, __minpack_real__ *a, const int * lda, const int *pivot, int *ipvt, const int *lipvt, __minpack_real__ *rdiag, __minpack_real__ *acnorm, __minpack_real__ *wa); __minpack_attr__ void __minpack_func__(qrsolv)(const int *n, __minpack_real__ *r, const int *ldr, const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, __minpack_real__ *x, __minpack_real__ *sdiag, __minpack_real__ *wa); __minpack_attr__ void __minpack_func__(qform)(const int *m, const int *n, __minpack_real__ *q, const int * ldq, __minpack_real__ *wa); __minpack_attr__ void __minpack_func__(r1updt)(const int *m, const int *n, __minpack_real__ *s, const int * ls, const __minpack_real__ *u, __minpack_real__ *v, __minpack_real__ *w, int *sing); __minpack_attr__ void __minpack_func__(r1mpyq)(const int *m, const int *n, __minpack_real__ *a, const int * lda, const __minpack_real__ *v, const __minpack_real__ *w); __minpack_attr__ void __minpack_func__(lmpar)(const int *n, __minpack_real__ *r, const int *ldr, const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, __minpack_real__ *par, __minpack_real__ *x, __minpack_real__ *sdiag, __minpack_real__ *wa1, __minpack_real__ *wa2); __minpack_attr__ void __minpack_func__(rwupdt)(const int *n, __minpack_real__ *r, const int *ldr, const __minpack_real__ *w, __minpack_real__ *b, __minpack_real__ *alpha, __minpack_real__ *cos, __minpack_real__ *sin); __minpack_attr__ void __minpack_func__(covar)(const int *n, __minpack_real__ *r, const int *ldr, const int *ipvt, const __minpack_real__ *tol, __minpack_real__ *wa); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __MINPACK_H__ */ cminpack-1.3.4/qform.c000644 000765 000765 00000005660 12225167750 014562 0ustar00devernay000000 000000 /* qform.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(qform)(int m, int n, real *q, int ldq, real *wa) { /* System generated locals */ int q_dim1, q_offset; /* Local variables */ int i, j, k, l, jm1, np1; real sum, temp; int minmn; /* ********** */ /* subroutine qform */ /* this subroutine proceeds from the computed qr factorization of */ /* an m by n matrix a to accumulate the m by m orthogonal matrix */ /* q from its factored form. */ /* the subroutine statement is */ /* subroutine qform(m,n,q,ldq,wa) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of a and the order of q. */ /* n is a positive integer input variable set to the number */ /* of columns of a. */ /* q is an m by m array. on input the full lower trapezoid in */ /* the first min(m,n) columns of q contains the factored form. */ /* on output q has been accumulated into a square matrix. */ /* ldq is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array q. */ /* wa is a work array of length m. */ /* subprograms called */ /* fortran-supplied ... min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; q_dim1 = ldq; q_offset = 1 + q_dim1 * 1; q -= q_offset; /* Function Body */ /* zero out upper triangle of q in the first min(m,n) columns. */ minmn = min(m,n); if (minmn >= 2) { for (j = 2; j <= minmn; ++j) { jm1 = j - 1; for (i = 1; i <= jm1; ++i) { q[i + j * q_dim1] = 0.; } } } /* initialize remaining columns to those of the identity matrix. */ np1 = n + 1; if (m >= np1) { for (j = np1; j <= m; ++j) { for (i = 1; i <= m; ++i) { q[i + j * q_dim1] = 0.; } q[j + j * q_dim1] = 1.; } } /* accumulate q from its factored form. */ for (l = 1; l <= minmn; ++l) { k = minmn - l + 1; for (i = k; i <= m; ++i) { wa[i] = q[i + k * q_dim1]; q[i + k * q_dim1] = 0.; } q[k + k * q_dim1] = 1.; if (wa[k] != 0.) { for (j = k; j <= m; ++j) { sum = 0.; for (i = k; i <= m; ++i) { sum += q[i + j * q_dim1] * wa[i]; } temp = sum / wa[k]; for (i = k; i <= m; ++i) { q[i + j * q_dim1] -= temp * wa[i]; } } } } /* last card of subroutine qform. */ } /* qform_ */ cminpack-1.3.4/qform_.c000644 000765 000765 00000006242 12225167750 014716 0ustar00devernay000000 000000 /* qform.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) __minpack_attr__ void __minpack_func__(qform)(const int *m, const int *n, real *q, const int * ldq, real *wa) { /* System generated locals */ int q_dim1, q_offset, i__1, i__2, i__3; /* Local variables */ int i__, j, k, l, jm1, np1; real sum, temp; int minmn; /* ********** */ /* subroutine qform */ /* this subroutine proceeds from the computed qr factorization of */ /* an m by n matrix a to accumulate the m by m orthogonal matrix */ /* q from its factored form. */ /* the subroutine statement is */ /* subroutine qform(m,n,q,ldq,wa) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of a and the order of q. */ /* n is a positive integer input variable set to the number */ /* of columns of a. */ /* q is an m by m array. on input the full lower trapezoid in */ /* the first min(m,n) columns of q contains the factored form. */ /* on output q has been accumulated into a square matrix. */ /* ldq is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array q. */ /* wa is a work array of length m. */ /* subprograms called */ /* fortran-supplied ... min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; q_dim1 = *ldq; q_offset = 1 + q_dim1 * 1; q -= q_offset; /* Function Body */ /* zero out upper triangle of q in the first min(m,n) columns. */ minmn = min(*m,*n); if (minmn < 2) { goto L30; } i__1 = minmn; for (j = 2; j <= i__1; ++j) { jm1 = j - 1; i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { q[i__ + j * q_dim1] = 0.; /* L10: */ } /* L20: */ } L30: /* initialize remaining columns to those of the identity matrix. */ np1 = *n + 1; if (*m < np1) { goto L60; } i__1 = *m; for (j = np1; j <= i__1; ++j) { i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { q[i__ + j * q_dim1] = 0.; /* L40: */ } q[j + j * q_dim1] = 1.; /* L50: */ } L60: /* accumulate q from its factored form. */ i__1 = minmn; for (l = 1; l <= i__1; ++l) { k = minmn - l + 1; i__2 = *m; for (i__ = k; i__ <= i__2; ++i__) { wa[i__] = q[i__ + k * q_dim1]; q[i__ + k * q_dim1] = 0.; /* L70: */ } q[k + k * q_dim1] = 1.; if (wa[k] == 0.) { goto L110; } i__2 = *m; for (j = k; j <= i__2; ++j) { sum = 0.; i__3 = *m; for (i__ = k; i__ <= i__3; ++i__) { sum += q[i__ + j * q_dim1] * wa[i__]; /* L80: */ } temp = sum / wa[k]; i__3 = *m; for (i__ = k; i__ <= i__3; ++i__) { q[i__ + j * q_dim1] -= temp * wa[i__]; /* L90: */ } /* L100: */ } L110: /* L120: */ ; } return; /* last card of subroutine qform. */ } /* qform_ */ cminpack-1.3.4/qrfac.c000644 000765 000765 00000021052 12232712371 014514 0ustar00devernay000000 000000 #include "cminpack.h" #include #ifdef USE_LAPACK #include #include #include #endif #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(qrfac)(int m, int n, real *a, int lda, int pivot, int *ipvt, int lipvt, real *rdiag, real *acnorm, real *wa) { #ifdef USE_LAPACK __CLPK_integer m_ = m; __CLPK_integer n_ = n; __CLPK_integer lda_ = lda; __CLPK_integer *jpvt; int i, j, k; double t; double* tau = wa; const __CLPK_integer ltau = m > n ? n : m; __CLPK_integer lwork = -1; __CLPK_integer info = 0; double* work; if (pivot) { assert( lipvt >= n ); if (sizeof(__CLPK_integer) != sizeof(ipvt[0])) { jpvt = malloc(n*sizeof(__CLPK_integer)); } else { /* __CLPK_integer is actually an int, just do a cast */ jpvt = (__CLPK_integer *)ipvt; } /* set all columns free */ memset(jpvt, 0, sizeof(int)*n); } /* query optimal size of work */ lwork = -1; if (pivot) { dgeqp3_(&m_,&n_,a,&lda_,jpvt,tau,tau,&lwork,&info); lwork = (int)tau[0]; assert( lwork >= 3*n+1 ); } else { dgeqrf_(&m_,&n_,a,&lda_,tau,tau,&lwork,&info); lwork = (int)tau[0]; assert( lwork >= 1 && lwork >= n ); } assert( info == 0 ); /* alloc work area */ work = (double *)malloc(sizeof(double)*lwork); assert(work != NULL); /* set acnorm first (from the doc of qrfac, acnorm may point to the same area as rdiag) */ if (acnorm != rdiag) { for (j = 0; j < n; ++j) { acnorm[j] = __cminpack_enorm__(m, &a[j * lda]); } } /* QR decomposition */ if (pivot) { dgeqp3_(&m_,&n_,a,&lda_,jpvt,tau,work,&lwork,&info); } else { dgeqrf_(&m_,&n_,a,&lda_,tau,work,&lwork,&info); } assert(info == 0); /* set rdiag, before the diagonal is replaced */ memset(rdiag, 0, sizeof(double)*n); for(i=0 ; i rdiag[kmax]) { kmax = k; } } if (kmax != j) { for (i = 0; i < m; ++i) { temp = a[i + j * lda]; a[i + j * lda] = a[i + kmax * lda]; a[i + kmax * lda] = temp; } rdiag[kmax] = rdiag[j]; wa[kmax] = wa[j]; k = ipvt[j]; ipvt[j] = ipvt[kmax]; ipvt[kmax] = k; } } /* compute the householder transformation to reduce the */ /* j-th column of a to a multiple of the j-th unit vector. */ ajnorm = __cminpack_enorm__(m - (j+1) + 1, &a[j + j * lda]); if (ajnorm != 0.) { if (a[j + j * lda] < 0.) { ajnorm = -ajnorm; } for (i = j; i < m; ++i) { a[i + j * lda] /= ajnorm; } a[j + j * lda] += 1.; /* apply the transformation to the remaining columns */ /* and update the norms. */ jp1 = j + 1; if (n > jp1) { for (k = jp1; k < n; ++k) { sum = 0.; for (i = j; i < m; ++i) { sum += a[i + j * lda] * a[i + k * lda]; } temp = sum / a[j + j * lda]; for (i = j; i < m; ++i) { a[i + k * lda] -= temp * a[i + j * lda]; } if (pivot && rdiag[k] != 0.) { temp = a[j + k * lda] / rdiag[k]; /* Computing MAX */ d1 = 1. - temp * temp; rdiag[k] *= sqrt((max((real)0.,d1))); /* Computing 2nd power */ d1 = rdiag[k] / wa[k]; if (p05 * (d1 * d1) <= epsmch) { rdiag[k] = __cminpack_enorm__(m - (j+1), &a[jp1 + k * lda]); wa[k] = rdiag[k]; } } } } } rdiag[j] = -ajnorm; } /* last card of subroutine qrfac. */ #endif /* !USE_LAPACK */ } /* qrfac_ */ cminpack-1.3.4/qrfac_.c000644 000765 000765 00000015004 12225167750 014662 0ustar00devernay000000 000000 /* qrfac.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) __minpack_attr__ void __minpack_func__(qrfac)(const int *m, const int *n, real *a, const int * lda, const int *pivot, int *ipvt, const int *lipvt, real *rdiag, real *acnorm, real *wa) { /* Initialized data */ #define p05 .05 const int c__1 = 1; /* System generated locals */ int a_dim1, a_offset, i__1, i__2, i__3; real d__1, d__2, d__3; /* Local variables */ int i__, j, k, jp1; real sum; int kmax; real temp; int minmn; real epsmch; real ajnorm; /* ********** */ /* subroutine qrfac */ /* this subroutine uses householder transformations with column */ /* pivoting (optional) to compute a qr factorization of the */ /* m by n matrix a. that is, qrfac determines an orthogonal */ /* matrix q, a permutation matrix p, and an upper trapezoidal */ /* matrix r with diagonal elements of nonincreasing magnitude, */ /* such that a*p = q*r. the householder transformation for */ /* column k, k = 1,2,...,min(m,n), is of the form */ /* t */ /* i - (1/u(k))*u*u */ /* where u has zeros in the first k-1 positions. the form of */ /* this transformation and the method of pivoting first */ /* appeared in the corresponding linpack subroutine. */ /* the subroutine statement is */ /* subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of a. */ /* n is a positive integer input variable set to the number */ /* of columns of a. */ /* a is an m by n array. on input a contains the matrix for */ /* which the qr factorization is to be computed. on output */ /* the strict upper trapezoidal part of a contains the strict */ /* upper trapezoidal part of r, and the lower trapezoidal */ /* part of a contains a factored form of q (the non-trivial */ /* elements of the u vectors described above). */ /* lda is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array a. */ /* pivot is a logical input variable. if pivot is set true, */ /* then column pivoting is enforced. if pivot is set false, */ /* then no column pivoting is done. */ /* ipvt is an integer output array of length lipvt. ipvt */ /* defines the permutation matrix p such that a*p = q*r. */ /* column j of p is column ipvt(j) of the identity matrix. */ /* if pivot is false, ipvt is not referenced. */ /* lipvt is a positive integer input variable. if pivot is false, */ /* then lipvt may be as small as 1. if pivot is true, then */ /* lipvt must be at least n. */ /* rdiag is an output array of length n which contains the */ /* diagonal elements of r. */ /* acnorm is an output array of length n which contains the */ /* norms of the corresponding columns of the input matrix a. */ /* if this information is not needed, then acnorm can coincide */ /* with rdiag. */ /* wa is a work array of length n. if pivot is false, then wa */ /* can coincide with rdiag. */ /* subprograms called */ /* minpack-supplied ... dpmpar,enorm */ /* fortran-supplied ... dmax1,dsqrt,min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; --acnorm; --rdiag; a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --ipvt; (void)lipvt; /* Function Body */ /* epsmch is the machine precision. */ epsmch = __minpack_func__(dpmpar)(&c__1); /* compute the initial column norms and initialize several arrays. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { acnorm[j] = __minpack_func__(enorm)(m, &a[j * a_dim1 + 1]); rdiag[j] = acnorm[j]; wa[j] = rdiag[j]; if (*pivot) { ipvt[j] = j; } /* L10: */ } /* reduce a to r with householder transformations. */ minmn = min(*m,*n); i__1 = minmn; for (j = 1; j <= i__1; ++j) { if (! (*pivot)) { goto L40; } /* bring the column of largest norm into the pivot position. */ kmax = j; i__2 = *n; for (k = j; k <= i__2; ++k) { if (rdiag[k] > rdiag[kmax]) { kmax = k; } /* L20: */ } if (kmax == j) { goto L40; } i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { temp = a[i__ + j * a_dim1]; a[i__ + j * a_dim1] = a[i__ + kmax * a_dim1]; a[i__ + kmax * a_dim1] = temp; /* L30: */ } rdiag[kmax] = rdiag[j]; wa[kmax] = wa[j]; k = ipvt[j]; ipvt[j] = ipvt[kmax]; ipvt[kmax] = k; L40: /* compute the householder transformation to reduce the */ /* j-th column of a to a multiple of the j-th unit vector. */ i__2 = *m - j + 1; ajnorm = __minpack_func__(enorm)(&i__2, &a[j + j * a_dim1]); if (ajnorm == 0.) { goto L100; } if (a[j + j * a_dim1] < 0.) { ajnorm = -ajnorm; } i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { a[i__ + j * a_dim1] /= ajnorm; /* L50: */ } a[j + j * a_dim1] += 1.; /* apply the transformation to the remaining columns */ /* and update the norms. */ jp1 = j + 1; if (*n < jp1) { goto L100; } i__2 = *n; for (k = jp1; k <= i__2; ++k) { sum = 0.; i__3 = *m; for (i__ = j; i__ <= i__3; ++i__) { sum += a[i__ + j * a_dim1] * a[i__ + k * a_dim1]; /* L60: */ } temp = sum / a[j + j * a_dim1]; i__3 = *m; for (i__ = j; i__ <= i__3; ++i__) { a[i__ + k * a_dim1] -= temp * a[i__ + j * a_dim1]; /* L70: */ } if (! (*pivot) || rdiag[k] == 0.) { goto L80; } temp = a[j + k * a_dim1] / rdiag[k]; /* Computing MAX */ /* Computing 2nd power */ d__3 = temp; d__1 = 0., d__2 = 1. - d__3 * d__3; rdiag[k] *= sqrt((max(d__1,d__2))); /* Computing 2nd power */ d__1 = rdiag[k] / wa[k]; if (p05 * (d__1 * d__1) > epsmch) { goto L80; } i__3 = *m - j; rdiag[k] = __minpack_func__(enorm)(&i__3, &a[jp1 + k * a_dim1]); wa[k] = rdiag[k]; L80: /* L90: */ ; } L100: rdiag[j] = -ajnorm; /* L110: */ } return; /* last card of subroutine qrfac. */ } /* qrfac_ */ cminpack-1.3.4/qrsolv.c000644 000765 000765 00000015742 12225167750 014766 0ustar00devernay000000 000000 #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(qrsolv)(int n, real *r, int ldr, const int *ipvt, const real *diag, const real *qtb, real *x, real *sdiag, real *wa) { /* Initialized data */ #define p5 .5 #define p25 .25 /* Local variables */ int i, j, k, l; real cos, sin, sum, temp; int nsing; real qtbpj; /* ********** */ /* subroutine qrsolv */ /* given an m by n matrix a, an n by n diagonal matrix d, */ /* and an m-vector b, the problem is to determine an x which */ /* solves the system */ /* a*x = b , d*x = 0 , */ /* in the least squares sense. */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then qrsolv expects */ /* the full upper triangle of r, the permutation matrix p, */ /* and the first n components of (q transpose)*b. the system */ /* a*x = b, d*x = 0, is then equivalent to */ /* t t */ /* r*z = q *b , p *d*p*z = 0 , */ /* where x = p*z. if this system does not have full rank, */ /* then a least squares solution is obtained. on output qrsolv */ /* also provides an upper triangular matrix s such that */ /* t t t */ /* p *(a *a + d*d)*p = s *s . */ /* s is computed within qrsolv and may be of separate interest. */ /* the subroutine statement is */ /* subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle */ /* must contain the full upper triangle of the matrix r. */ /* on output the full upper triangle is unaltered, and the */ /* strict lower triangle contains the strict upper triangle */ /* (transposed) of the upper triangular matrix s. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* x is an output array of length n which contains the least */ /* squares solution of the system a*x = b, d*x = 0. */ /* sdiag is an output array of length n which contains the */ /* diagonal elements of the upper triangular matrix s. */ /* wa is a work array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* copy r and (q transpose)*b to preserve input and initialize s. */ /* in particular, save the diagonal elements of r in x. */ for (j = 0; j < n; ++j) { for (i = j; i < n; ++i) { r[i + j * ldr] = r[j + i * ldr]; } x[j] = r[j + j * ldr]; wa[j] = qtb[j]; } /* eliminate the diagonal matrix d using a givens rotation. */ for (j = 0; j < n; ++j) { /* prepare the row of d to be eliminated, locating the */ /* diagonal element using p from the qr factorization. */ l = ipvt[j]-1; if (diag[l] != 0.) { for (k = j; k < n; ++k) { sdiag[k] = 0.; } sdiag[j] = diag[l]; /* the transformations to eliminate the row of d */ /* modify only a single element of (q transpose)*b */ /* beyond the first n, which is initially zero. */ qtbpj = 0.; for (k = j; k < n; ++k) { /* determine a givens rotation which eliminates the */ /* appropriate element in the current row of d. */ if (sdiag[k] != 0.) { # ifdef USE_LAPACK dlartg_( &r[k + k * ldr], &sdiag[k], &cos, &sin, &temp ); # else /* !USE_LAPACK */ if (fabs(r[k + k * ldr]) < fabs(sdiag[k])) { real cotan; cotan = r[k + k * ldr] / sdiag[k]; sin = p5 / sqrt(p25 + p25 * (cotan * cotan)); cos = sin * cotan; } else { real tan; tan = sdiag[k] / r[k + k * ldr]; cos = p5 / sqrt(p25 + p25 * (tan * tan)); sin = cos * tan; } /* compute the modified diagonal element of r and */ /* the modified element of ((q transpose)*b,0). */ # endif /* !USE_LAPACK */ temp = cos * wa[k] + sin * qtbpj; qtbpj = -sin * wa[k] + cos * qtbpj; wa[k] = temp; /* accumulate the tranformation in the row of s. */ # ifdef USE_CBLAS cblas_drot( n-k, &r[k + k * ldr], 1, &sdiag[k], 1, cos, sin ); # else /* !USE_CBLAS */ r[k + k * ldr] = cos * r[k + k * ldr] + sin * sdiag[k]; if (n > k+1) { for (i = k+1; i < n; ++i) { temp = cos * r[i + k * ldr] + sin * sdiag[i]; sdiag[i] = -sin * r[i + k * ldr] + cos * sdiag[i]; r[i + k * ldr] = temp; } } # endif /* !USE_CBLAS */ } } } /* store the diagonal element of s and restore */ /* the corresponding diagonal element of r. */ sdiag[j] = r[j + j * ldr]; r[j + j * ldr] = x[j]; } /* solve the triangular system for z. if the system is */ /* singular, then obtain a least squares solution. */ nsing = n; for (j = 0; j < n; ++j) { if (sdiag[j] == 0. && nsing == n) { nsing = j; } if (nsing < n) { wa[j] = 0.; } } if (nsing >= 1) { for (k = 1; k <= nsing; ++k) { j = nsing - k; sum = 0.; if (nsing > j+1) { for (i = j+1; i < nsing; ++i) { sum += r[i + j * ldr] * wa[i]; } } wa[j] = (wa[j] - sum) / sdiag[j]; } } /* permute the components of z back to components of x. */ for (j = 0; j < n; ++j) { l = ipvt[j]-1; x[l] = wa[j]; } return; /* last card of subroutine qrsolv. */ } /* qrsolv_ */ cminpack-1.3.4/qrsolv_.c000644 000765 000765 00000016300 12225167750 015114 0ustar00devernay000000 000000 /* qrsolv.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define abs(x) ((x) >= 0 ? (x) : -(x)) __minpack_attr__ void __minpack_func__(qrsolv)(const int *n, real *r__, const int *ldr, const int *ipvt, const real *diag, const real *qtb, real *x, real *sdiag, real *wa) { /* Initialized data */ #define p5 .5 #define p25 .25 /* System generated locals */ int r_dim1, r_offset, i__1, i__2, i__3; real d__1, d__2; /* Local variables */ int i__, j, k, l, jp1, kp1; real tan__, cos__, sin__, sum, temp, cotan; int nsing; real qtbpj; /* ********** */ /* subroutine qrsolv */ /* given an m by n matrix a, an n by n diagonal matrix d, */ /* and an m-vector b, the problem is to determine an x which */ /* solves the system */ /* a*x = b , d*x = 0 , */ /* in the least squares sense. */ /* this subroutine completes the solution of the problem */ /* if it is provided with the necessary information from the */ /* qr factorization, with column pivoting, of a. that is, if */ /* a*p = q*r, where p is a permutation matrix, q has orthogonal */ /* columns, and r is an upper triangular matrix with diagonal */ /* elements of nonincreasing magnitude, then qrsolv expects */ /* the full upper triangle of r, the permutation matrix p, */ /* and the first n components of (q transpose)*b. the system */ /* a*x = b, d*x = 0, is then equivalent to */ /* t t */ /* r*z = q *b , p *d*p*z = 0 , */ /* where x = p*z. if this system does not have full rank, */ /* then a least squares solution is obtained. on output qrsolv */ /* also provides an upper triangular matrix s such that */ /* t t t */ /* p *(a *a + d*d)*p = s *s . */ /* s is computed within qrsolv and may be of separate interest. */ /* the subroutine statement is */ /* subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the full upper triangle */ /* must contain the full upper triangle of the matrix r. */ /* on output the full upper triangle is unaltered, and the */ /* strict lower triangle contains the strict upper triangle */ /* (transposed) of the upper triangular matrix s. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* ipvt is an integer input array of length n which defines the */ /* permutation matrix p such that a*p = q*r. column j of p */ /* is column ipvt(j) of the identity matrix. */ /* diag is an input array of length n which must contain the */ /* diagonal elements of the matrix d. */ /* qtb is an input array of length n which must contain the first */ /* n elements of the vector (q transpose)*b. */ /* x is an output array of length n which contains the least */ /* squares solution of the system a*x = b, d*x = 0. */ /* sdiag is an output array of length n which contains the */ /* diagonal elements of the upper triangular matrix s. */ /* wa is a work array of length n. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --wa; --sdiag; --x; --qtb; --diag; --ipvt; r_dim1 = *ldr; r_offset = 1 + r_dim1 * 1; r__ -= r_offset; /* Function Body */ /* copy r and (q transpose)*b to preserve input and initialize s. */ /* in particular, save the diagonal elements of r in x. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { r__[i__ + j * r_dim1] = r__[j + i__ * r_dim1]; /* L10: */ } x[j] = r__[j + j * r_dim1]; wa[j] = qtb[j]; /* L20: */ } /* eliminate the diagonal matrix d using a givens rotation. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { /* prepare the row of d to be eliminated, locating the */ /* diagonal element using p from the qr factorization. */ l = ipvt[j]; if (diag[l] == 0.) { goto L90; } i__2 = *n; for (k = j; k <= i__2; ++k) { sdiag[k] = 0.; /* L30: */ } sdiag[j] = diag[l]; /* the transformations to eliminate the row of d */ /* modify only a single element of (q transpose)*b */ /* beyond the first n, which is initially zero. */ qtbpj = 0.; i__2 = *n; for (k = j; k <= i__2; ++k) { /* determine a givens rotation which eliminates the */ /* appropriate element in the current row of d. */ if (sdiag[k] == 0.) { goto L70; } if ((d__1 = r__[k + k * r_dim1], abs(d__1)) >= (d__2 = sdiag[k], abs(d__2))) { goto L40; } cotan = r__[k + k * r_dim1] / sdiag[k]; /* Computing 2nd power */ d__1 = cotan; sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); cos__ = sin__ * cotan; goto L50; L40: tan__ = sdiag[k] / r__[k + k * r_dim1]; /* Computing 2nd power */ d__1 = tan__; cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); sin__ = cos__ * tan__; L50: /* compute the modified diagonal element of r and */ /* the modified element of ((q transpose)*b,0). */ r__[k + k * r_dim1] = cos__ * r__[k + k * r_dim1] + sin__ * sdiag[ k]; temp = cos__ * wa[k] + sin__ * qtbpj; qtbpj = -sin__ * wa[k] + cos__ * qtbpj; wa[k] = temp; /* accumulate the tranformation in the row of s. */ kp1 = k + 1; if (*n < kp1) { goto L70; } i__3 = *n; for (i__ = kp1; i__ <= i__3; ++i__) { temp = cos__ * r__[i__ + k * r_dim1] + sin__ * sdiag[i__]; sdiag[i__] = -sin__ * r__[i__ + k * r_dim1] + cos__ * sdiag[ i__]; r__[i__ + k * r_dim1] = temp; /* L60: */ } L70: /* L80: */ ; } L90: /* store the diagonal element of s and restore */ /* the corresponding diagonal element of r. */ sdiag[j] = r__[j + j * r_dim1]; r__[j + j * r_dim1] = x[j]; /* L100: */ } /* solve the triangular system for z. if the system is */ /* singular, then obtain a least squares solution. */ nsing = *n; i__1 = *n; for (j = 1; j <= i__1; ++j) { if (sdiag[j] == 0. && nsing == *n) { nsing = j - 1; } if (nsing < *n) { wa[j] = 0.; } /* L110: */ } if (nsing < 1) { goto L150; } i__1 = nsing; for (k = 1; k <= i__1; ++k) { j = nsing - k + 1; sum = 0.; jp1 = j + 1; if (nsing < jp1) { goto L130; } i__2 = nsing; for (i__ = jp1; i__ <= i__2; ++i__) { sum += r__[i__ + j * r_dim1] * wa[i__]; /* L120: */ } L130: wa[j] = (wa[j] - sum) / sdiag[j]; /* L140: */ } L150: /* permute the components of z back to components of x. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { l = ipvt[j]; x[l] = wa[j]; /* L160: */ } return; /* last card of subroutine qrsolv. */ } /* qrsolv_ */ cminpack-1.3.4/r1mpyq.c000644 000765 000765 00000006401 12225167750 014661 0ustar00devernay000000 000000 /* r1mpyq.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(r1mpyq)(int m, int n, real *a, int lda, const real *v, const real *w) { /* System generated locals */ int a_dim1, a_offset; /* Local variables */ int i, j, nm1, nmj; real cos, sin, temp; /* ********** */ /* subroutine r1mpyq */ /* given an m by n matrix a, this subroutine computes a*q where */ /* q is the product of 2*(n - 1) transformations */ /* gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */ /* and gv(i), gw(i) are givens rotations in the (i,n) plane which */ /* eliminate elements in the i-th and n-th planes, respectively. */ /* q itself is not given, rather the information to recover the */ /* gv, gw rotations is supplied. */ /* the subroutine statement is */ /* subroutine r1mpyq(m,n,a,lda,v,w) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of a. */ /* n is a positive integer input variable set to the number */ /* of columns of a. */ /* a is an m by n array. on input a must contain the matrix */ /* to be postmultiplied by the orthogonal matrix q */ /* described above. on output a*q has replaced a. */ /* lda is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array a. */ /* v is an input array of length n. v(i) must contain the */ /* information necessary to recover the givens rotation gv(i) */ /* described above. */ /* w is an input array of length n. w(i) must contain the */ /* information necessary to recover the givens rotation gw(i) */ /* described above. */ /* subroutines called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --w; --v; a_dim1 = lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; /* Function Body */ /* apply the first set of givens rotations to a. */ nm1 = n - 1; if (nm1 < 1) { return; } for (nmj = 1; nmj <= nm1; ++nmj) { j = n - nmj; if (fabs(v[j]) > 1.) { cos = 1. / v[j]; sin = sqrt(1. - cos * cos); } else { sin = v[j]; cos = sqrt(1. - sin * sin); } for (i = 1; i <= m; ++i) { temp = cos * a[i + j * a_dim1] - sin * a[i + n * a_dim1]; a[i + n * a_dim1] = sin * a[i + j * a_dim1] + cos * a[ i + n * a_dim1]; a[i + j * a_dim1] = temp; } } /* apply the second set of givens rotations to a. */ for (j = 1; j <= nm1; ++j) { if (fabs(w[j]) > 1.) { cos = 1. / w[j]; sin = sqrt(1. - cos * cos); } else { sin = w[j]; cos = sqrt(1. - sin * sin); } for (i = 1; i <= m; ++i) { temp = cos * a[i + j * a_dim1] + sin * a[i + n * a_dim1]; a[i + n * a_dim1] = -sin * a[i + j * a_dim1] + cos * a[i + n * a_dim1]; a[i + j * a_dim1] = temp; } } /* last card of subroutine r1mpyq. */ } /* r1mpyq_ */ cminpack-1.3.4/r1mpyq_.c000644 000765 000765 00000010020 12225167750 015010 0ustar00devernay000000 000000 /* r1mpyq.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define abs(x) ((x) >= 0 ? (x) : -(x)) __minpack_attr__ void __minpack_func__(r1mpyq)(const int *m, const int *n, real *a, const int * lda, const real *v, const real *w) { /* System generated locals */ int a_dim1, a_offset, i__1, i__2; real d__1, d__2; /* Local variables */ int i__, j, nm1, nmj; real cos__, sin__, temp; /* ********** */ /* subroutine r1mpyq */ /* given an m by n matrix a, this subroutine computes a*q where */ /* q is the product of 2*(n - 1) transformations */ /* gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */ /* and gv(i), gw(i) are givens rotations in the (i,n) plane which */ /* eliminate elements in the i-th and n-th planes, respectively. */ /* q itself is not given, rather the information to recover the */ /* gv, gw rotations is supplied. */ /* the subroutine statement is */ /* subroutine r1mpyq(m,n,a,lda,v,w) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of a. */ /* n is a positive integer input variable set to the number */ /* of columns of a. */ /* a is an m by n array. on input a must contain the matrix */ /* to be postmultiplied by the orthogonal matrix q */ /* described above. on output a*q has replaced a. */ /* lda is a positive integer input variable not less than m */ /* which specifies the leading dimension of the array a. */ /* v is an input array of length n. v(i) must contain the */ /* information necessary to recover the givens rotation gv(i) */ /* described above. */ /* w is an input array of length n. w(i) must contain the */ /* information necessary to recover the givens rotation gw(i) */ /* described above. */ /* subroutines called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --w; --v; a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; /* Function Body */ /* apply the first set of givens rotations to a. */ nm1 = *n - 1; if (nm1 < 1) { /* goto L50; */ return; } i__1 = nm1; for (nmj = 1; nmj <= i__1; ++nmj) { j = *n - nmj; if ((d__1 = v[j], abs(d__1)) > 1.) { cos__ = 1. / v[j]; } if ((d__1 = v[j], abs(d__1)) > 1.) { /* Computing 2nd power */ d__2 = cos__; sin__ = sqrt(1. - d__2 * d__2); } if ((d__1 = v[j], abs(d__1)) <= 1.) { sin__ = v[j]; } if ((d__1 = v[j], abs(d__1)) <= 1.) { /* Computing 2nd power */ d__2 = sin__; cos__ = sqrt(1. - d__2 * d__2); } i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { temp = cos__ * a[i__ + j * a_dim1] - sin__ * a[i__ + *n * a_dim1]; a[i__ + *n * a_dim1] = sin__ * a[i__ + j * a_dim1] + cos__ * a[ i__ + *n * a_dim1]; a[i__ + j * a_dim1] = temp; /* L10: */ } /* L20: */ } /* apply the second set of givens rotations to a. */ i__1 = nm1; for (j = 1; j <= i__1; ++j) { if ((d__1 = w[j], abs(d__1)) > 1.) { cos__ = 1. / w[j]; } if ((d__1 = w[j], abs(d__1)) > 1.) { /* Computing 2nd power */ d__2 = cos__; sin__ = sqrt(1. - d__2 * d__2); } if ((d__1 = w[j], abs(d__1)) <= 1.) { sin__ = w[j]; } if ((d__1 = w[j], abs(d__1)) <= 1.) { /* Computing 2nd power */ d__2 = sin__; cos__ = sqrt(1. - d__2 * d__2); } i__2 = *m; for (i__ = 1; i__ <= i__2; ++i__) { temp = cos__ * a[i__ + j * a_dim1] + sin__ * a[i__ + *n * a_dim1]; a[i__ + *n * a_dim1] = -sin__ * a[i__ + j * a_dim1] + cos__ * a[ i__ + *n * a_dim1]; a[i__ + j * a_dim1] = temp; /* L30: */ } /* L40: */ } /* L50: */ return; /* last card of subroutine r1mpyq. */ } /* r1mpyq_ */ cminpack-1.3.4/r1updt.c000644 000765 000765 00000014674 12225167750 014662 0ustar00devernay000000 000000 /* r1updt.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(r1updt)(int m, int n, real *s, int ls, const real *u, real *v, real *w, int *sing) { /* Initialized data */ #define p5 .5 #define p25 .25 /* Local variables */ int i, j, l, jj, nm1; real tan; int nmj; real cos, sin, tau, temp, giant, cotan; /* ********** */ /* subroutine r1updt */ /* given an m by n lower trapezoidal matrix s, an m-vector u, */ /* and an n-vector v, the problem is to determine an */ /* orthogonal matrix q such that */ /* t */ /* (s + u*v )*q */ /* is again lower trapezoidal. */ /* this subroutine determines q as the product of 2*(n - 1) */ /* transformations */ /* gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */ /* where gv(i), gw(i) are givens rotations in the (i,n) plane */ /* which eliminate elements in the i-th and n-th planes, */ /* respectively. q itself is not accumulated, rather the */ /* information to recover the gv, gw rotations is returned. */ /* the subroutine statement is */ /* subroutine r1updt(m,n,s,ls,u,v,w,sing) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of s. */ /* n is a positive integer input variable set to the number */ /* of columns of s. n must not exceed m. */ /* s is an array of length ls. on input s must contain the lower */ /* trapezoidal matrix s stored by columns. on output s contains */ /* the lower trapezoidal matrix produced as described above. */ /* ls is a positive integer input variable not less than */ /* (n*(2*m-n+1))/2. */ /* u is an input array of length m which must contain the */ /* vector u. */ /* v is an array of length n. on input v must contain the vector */ /* v. on output v(i) contains the information necessary to */ /* recover the givens rotation gv(i) described above. */ /* w is an output array of length m. w(i) contains information */ /* necessary to recover the givens rotation gw(i) described */ /* above. */ /* sing is a logical output variable. sing is set true if any */ /* of the diagonal elements of the output s are zero. otherwise */ /* sing is set false. */ /* subprograms called */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more, */ /* john l. nazareth */ /* ********** */ /* Parameter adjustments */ --w; --u; --v; --s; (void)ls; /* Function Body */ /* giant is the largest magnitude. */ giant = __cminpack_func__(dpmpar)(3); /* initialize the diagonal element pointer. */ jj = n * ((m << 1) - n + 1) / 2 - (m - n); /* move the nontrivial part of the last column of s into w. */ l = jj; for (i = n; i <= m; ++i) { w[i] = s[l]; ++l; } /* rotate the vector v into a multiple of the n-th unit vector */ /* in such a way that a spike is introduced into w. */ nm1 = n - 1; if (nm1 >= 1) { for (nmj = 1; nmj <= nm1; ++nmj) { j = n - nmj; jj -= m - j + 1; w[j] = 0.; if (v[j] != 0.) { /* determine a givens rotation which eliminates the */ /* j-th element of v. */ if (fabs(v[n]) < fabs(v[j])) { cotan = v[n] / v[j]; sin = p5 / sqrt(p25 + p25 * (cotan * cotan)); cos = sin * cotan; tau = 1.; if (fabs(cos) * giant > 1.) { tau = 1. / cos; } } else { tan = v[j] / v[n]; cos = p5 / sqrt(p25 + p25 * (tan * tan)); sin = cos * tan; tau = sin; } /* apply the transformation to v and store the information */ /* necessary to recover the givens rotation. */ v[n] = sin * v[j] + cos * v[n]; v[j] = tau; /* apply the transformation to s and extend the spike in w. */ l = jj; for (i = j; i <= m; ++i) { temp = cos * s[l] - sin * w[i]; w[i] = sin * s[l] + cos * w[i]; s[l] = temp; ++l; } } } } /* add the spike from the rank 1 update to w. */ for (i = 1; i <= m; ++i) { w[i] += v[n] * u[i]; } /* eliminate the spike. */ *sing = FALSE_; if (nm1 >= 1) { for (j = 1; j <= nm1; ++j) { if (w[j] != 0.) { /* determine a givens rotation which eliminates the */ /* j-th element of the spike. */ if (fabs(s[jj]) < fabs(w[j])) { cotan = s[jj] / w[j]; sin = p5 / sqrt(p25 + p25 * (cotan * cotan)); cos = sin * cotan; tau = 1.; if (fabs(cos) * giant > 1.) { tau = 1. / cos; } } else { tan = w[j] / s[jj]; cos = p5 / sqrt(p25 + p25 * (tan * tan)); sin = cos * tan; tau = sin; } /* apply the transformation to s and reduce the spike in w. */ l = jj; for (i = j; i <= m; ++i) { temp = cos * s[l] + sin * w[i]; w[i] = -sin * s[l] + cos * w[i]; s[l] = temp; ++l; } /* store the information necessary to recover the */ /* givens rotation. */ w[j] = tau; } /* test for zero diagonal elements in the output s. */ if (s[jj] == 0.) { *sing = TRUE_; } jj += m - j + 1; } } /* move w back into the last column of the output s. */ l = jj; for (i = n; i <= m; ++i) { s[l] = w[i]; ++l; } if (s[jj] == 0.) { *sing = TRUE_; } /* last card of subroutine r1updt. */ } /* __minpack_func__(r1updt) */ cminpack-1.3.4/r1updt_.c000644 000765 000765 00000014661 12225167750 015015 0ustar00devernay000000 000000 /* r1updt.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define abs(x) ((x) >= 0 ? (x) : -(x)) #define TRUE_ (1) #define FALSE_ (0) __minpack_attr__ void __minpack_func__(r1updt)(const int *m, const int *n, real *s, const int * ls, const real *u, real *v, real *w, int *sing) { /* Initialized data */ #define p5 .5 #define p25 .25 const int c__3 = 3; /* System generated locals */ int i__1, i__2; real d__1, d__2; /* Local variables */ int i__, j, l, jj, nm1; real tan__; int nmj; real cos__, sin__, tau, temp, giant, cotan; /* ********** */ /* subroutine r1updt */ /* given an m by n lower trapezoidal matrix s, an m-vector u, */ /* and an n-vector v, the problem is to determine an */ /* orthogonal matrix q such that */ /* t */ /* (s + u*v )*q */ /* is again lower trapezoidal. */ /* this subroutine determines q as the product of 2*(n - 1) */ /* transformations */ /* gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */ /* where gv(i), gw(i) are givens rotations in the (i,n) plane */ /* which eliminate elements in the i-th and n-th planes, */ /* respectively. q itself is not accumulated, rather the */ /* information to recover the gv, gw rotations is returned. */ /* the subroutine statement is */ /* subroutine r1updt(m,n,s,ls,u,v,w,sing) */ /* where */ /* m is a positive integer input variable set to the number */ /* of rows of s. */ /* n is a positive integer input variable set to the number */ /* of columns of s. n must not exceed m. */ /* s is an array of length ls. on input s must contain the lower */ /* trapezoidal matrix s stored by columns. on output s contains */ /* the lower trapezoidal matrix produced as described above. */ /* ls is a positive integer input variable not less than */ /* (n*(2*m-n+1))/2. */ /* u is an input array of length m which must contain the */ /* vector u. */ /* v is an array of length n. on input v must contain the vector */ /* v. on output v(i) contains the information necessary to */ /* recover the givens rotation gv(i) described above. */ /* w is an output array of length m. w(i) contains information */ /* necessary to recover the givens rotation gw(i) described */ /* above. */ /* sing is a logical output variable. sing is set true if any */ /* of the diagonal elements of the output s are zero. otherwise */ /* sing is set false. */ /* subprograms called */ /* minpack-supplied ... dpmpar */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more, */ /* john l. nazareth */ /* ********** */ /* Parameter adjustments */ --w; --u; --v; --s; (void)ls; /* Function Body */ /* giant is the largest magnitude. */ giant = __minpack_func__(dpmpar)(&c__3); /* initialize the diagonal element pointer. */ jj = *n * ((*m << 1) - *n + 1) / 2 - (*m - *n); /* move the nontrivial part of the last column of s into w. */ l = jj; i__1 = *m; for (i__ = *n; i__ <= i__1; ++i__) { w[i__] = s[l]; ++l; /* L10: */ } /* rotate the vector v into a multiple of the n-th unit vector */ /* in such a way that a spike is introduced into w. */ nm1 = *n - 1; if (nm1 < 1) { goto L70; } i__1 = nm1; for (nmj = 1; nmj <= i__1; ++nmj) { j = *n - nmj; jj -= *m - j + 1; w[j] = 0.; if (v[j] == 0.) { goto L50; } /* determine a givens rotation which eliminates the */ /* j-th element of v. */ if ((d__1 = v[*n], abs(d__1)) >= (d__2 = v[j], abs(d__2))) { goto L20; } cotan = v[*n] / v[j]; /* Computing 2nd power */ d__1 = cotan; sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); cos__ = sin__ * cotan; tau = 1.; if (abs(cos__) * giant > 1.) { tau = 1. / cos__; } goto L30; L20: tan__ = v[j] / v[*n]; /* Computing 2nd power */ d__1 = tan__; cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); sin__ = cos__ * tan__; tau = sin__; L30: /* apply the transformation to v and store the information */ /* necessary to recover the givens rotation. */ v[*n] = sin__ * v[j] + cos__ * v[*n]; v[j] = tau; /* apply the transformation to s and extend the spike in w. */ l = jj; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { temp = cos__ * s[l] - sin__ * w[i__]; w[i__] = sin__ * s[l] + cos__ * w[i__]; s[l] = temp; ++l; /* L40: */ } L50: /* L60: */ ; } L70: /* add the spike from the rank 1 update to w. */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { w[i__] += v[*n] * u[i__]; /* L80: */ } /* eliminate the spike. */ *sing = FALSE_; if (nm1 < 1) { goto L140; } i__1 = nm1; for (j = 1; j <= i__1; ++j) { if (w[j] == 0.) { goto L120; } /* determine a givens rotation which eliminates the */ /* j-th element of the spike. */ if ((d__1 = s[jj], abs(d__1)) >= (d__2 = w[j], abs(d__2))) { goto L90; } cotan = s[jj] / w[j]; /* Computing 2nd power */ d__1 = cotan; sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); cos__ = sin__ * cotan; tau = 1.; if (abs(cos__) * giant > 1.) { tau = 1. / cos__; } goto L100; L90: tan__ = w[j] / s[jj]; /* Computing 2nd power */ d__1 = tan__; cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1)); sin__ = cos__ * tan__; tau = sin__; L100: /* apply the transformation to s and reduce the spike in w. */ l = jj; i__2 = *m; for (i__ = j; i__ <= i__2; ++i__) { temp = cos__ * s[l] + sin__ * w[i__]; w[i__] = -sin__ * s[l] + cos__ * w[i__]; s[l] = temp; ++l; /* L110: */ } /* store the information necessary to recover the */ /* givens rotation. */ w[j] = tau; L120: /* test for zero diagonal elements in the output s. */ if (s[jj] == 0.) { *sing = TRUE_; } jj += *m - j + 1; /* L130: */ } L140: /* move w back into the last column of the output s. */ l = jj; i__1 = *m; for (i__ = *n; i__ <= i__1; ++i__) { s[l] = w[i__]; ++l; /* L150: */ } if (s[jj] == 0.) { *sing = TRUE_; } return; /* last card of subroutine r1updt. */ } /* r1updt_ */ cminpack-1.3.4/README.md000644 000765 000765 00000013417 12341325506 014542 0ustar00devernay000000 000000 C/C++ Minpack [![Build Status](https://api.travis-ci.org/devernay/cminpack.png?branch=master)](https://travis-ci.org/devernay/cminpack) [![Coverage Status](https://coveralls.io/repos/devernay/cminpack/badge.png?branch=master)](https://coveralls.io/r/devernay/cminpack?branch=master) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/devernay/cminpack/trend.png)](https://bitdeli.com/free "Bitdeli Badge") ========== This is a C version of the minpack minimization package. It has been derived from the fortran code using f2c and some limited manual editing. Note that you need to link against libf2c to use this version of minpack. Extern "C" linkage permits the package routines to be called from C++. Check ftp://netlib.bell-labs.com/netlib/f2c for the latest f2c version. For general minpack info and test programs, see the accompanying readme.txt and http://www.netlib.org/minpack/. Type `make` to compile and `make install` to install in /usr/local or modify the makefile to suit your needs. This software has been tested on a RedHat 7.3 Linux machine - usual 'use at your own risk' warnings apply. Manolis Lourakis -- lourakis at ics forth gr, July 2002 Institute of Computer Science, Foundation for Research and Technology - Hellas Heraklion, Crete, Greece Repackaging by Frederic Devernay -- frederic dot devernay at m4x dot org The project home page is at http://devernay.free.fr/hacks/cminpack/ History ------ * version 1.3.4 (28/05/2014): - Add FindCMinpack.cmake cmake module. If you use the cmake install, finding CMinpack from your `CMakeLists.txt` is as easy as `find_package(CMinpack)`. * version 1.3.3 (04/02/2014): - Add documentation and examples abouts how to add box constraints to the variables. - continuous integration https://travis-ci.org/devernay/cminpack * version 1.3.2 (27/10/2013): - Minor change in the CMake build: also set SOVERSION. * version 1.3.1 (02/10/2013): - Fix CUDA examples compilation, and remove non-free files. * version 1.3.0 (09/06/2012): - Optionally use LAPACK and CBLAS in lmpar, qrfac, and qrsolv. Added "make lapack" to build the LAPACK-based cminpack and "make checklapack" to test it (results of the test may depend on the underlying LAPACK and BLAS implementations). On 64-bits architectures, the preprocessor symbol __LP64__ must be defined (see cminpackP.h) if the LAPACK library uses the LP64 interface (i.e. 32-bits integer, vhereas the ILP interface uses 64 bits integers). * version 1.2.2 (16/05/2012): - Update Makefiles and documentation (see "Using CMinpack" above) for easier building and testing. * version 1.2.1 (15/05/2012): - The library can now be built as double, float or half versions. Standard tests in the "examples" directory can now be lauched using "make check" (to run common tests, including against the float version), "make checkhalf" (to test the half version) and "make checkfail" (to run all the tests, even those that fail). * version 1.2.0 (14/05/2012): - Added original FORTRAN sources for better testing (type "make" in directory fortran, then "make" in examples and follow the instructions). Added driver tests lmsdrv, chkdrv, hyjdrv, hybdrv. Typing "make alltest" in the examples directory will run all possible test combinations (make sure you have gfortran installed). * version 1.1.5 (04/05/2012): - cminpack now works in CUDA, thanks to Jordi Bataller Mascarell, type "make" in the "cuda" subdir (be careful, though: this is a straightforward port from C, and each problem is solved using a single thread). cminpack can now also be compiled with single-precision floating point computation (define __cminpack_real__ to float when compiling and using the library). Fix cmake support for CMINPACK_LIB_INSTALL_DIR. Update the reference files for tests. * version 1.1.4 (30/10/2011): - Translated all the Levenberg-Marquardt code (lmder, lmdif, lmstr, lmder1, lmdif1, lmstr1, lmpar, qrfac, qrsolv, fdjac2, chkder) to use C-style indices. * version 1.1.3 (16/03/2011): - Minor fix: Change non-standard strnstr() to strstr() in genf77tests.c. * version 1.1.2 (07/01/2011): - Fix Windows DLL building (David Graeff) and document covar in cminpack.h. * version 1.1.1 (04/12/2010): - Complete rewrite of the C functions (without trailing underscore in the function name). Using the original FORTRAN code, the original algorithms structure was recovered, and many goto's were converted to if...then...else. The code should now be both more readable and easier to optimize, both for humans and for compilers. Added lmddrv and lmfdrv test drivers, which test a lot of difficult functions (these functions are explained in Testing Unconstrained Optimization Software by Moré et al.). Also added the pkg-config files to the cmake build, as well as an "uninstall" target, contributed by Geoffrey Biggs. * version 1.0.4 (18/10/2010): - Support for shared library building using CMake, thanks to Goeffrey Biggs and Radu Bogdan Rusu from Willow Garage. Shared libraries can be enabled using cmake options, as in; cmake -DUSE_FPIC=ON -DSHARED_LIBS=ON -DBUILD_EXAMPLES=OFF path_to_sources * version 1.0.3 (18/03/2010): - Added CMake support. - XCode build is now Universal. - Added tfdjac2_ and tfdjac2c examples, which test the accuracy of a finite-differences approximation of the Jacobian. - Bug fix in tlmstr1 (signaled by Thomas Capricelli). * version 1.0.2 (27/02/2009): - Added Xcode and Visual Studio project files * version 1.0.1 (17/12/2007): - bug fix in covar() and covar_(), the computation of tolr caused a segfault (signaled by Timo Hartmann). * version 1.0.0 (24/04/2007): - Added fortran and C examples - Added documentation from Debian man pages - Wrote pure C version - Added covar() and covar_(), and use it in tlmdef/tlmdif cminpack-1.3.4/readme.txt000644 000765 000765 00000001261 12225167750 015261 0ustar00devernay000000 000000 ====== readme for minpack ====== 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 directory contains the double-precision versions. Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. cminpack-1.3.4/rwupdt.c000644 000765 000765 00000010577 12225167750 014766 0ustar00devernay000000 000000 /* rwupdt.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "cminpack.h" #include #include "cminpackP.h" __cminpack_attr__ void __cminpack_func__(rwupdt)(int n, real *r, int ldr, const real *w, real *b, real *alpha, real *cos, real *sin) { /* Initialized data */ #define p5 .5 #define p25 .25 /* System generated locals */ int r_dim1, r_offset; /* Local variables */ int i, j, jm1; real tan, temp, rowj, cotan; /* ********** */ /* subroutine rwupdt */ /* given an n by n upper triangular matrix r, this subroutine */ /* computes the qr decomposition of the matrix formed when a row */ /* is added to r. if the row is specified by the vector w, then */ /* rwupdt determines an orthogonal matrix q such that when the */ /* n+1 by n matrix composed of r augmented by w is premultiplied */ /* by (q transpose), the resulting matrix is upper trapezoidal. */ /* the matrix (q transpose) is the product of n transformations */ /* g(n)*g(n-1)* ... *g(1) */ /* where g(i) is a givens rotation in the (i,n+1) plane which */ /* eliminates elements in the (n+1)-st plane. rwupdt also */ /* computes the product (q transpose)*c where c is the */ /* (n+1)-vector (b,alpha). q itself is not accumulated, rather */ /* the information to recover the g rotations is supplied. */ /* the subroutine statement is */ /* subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the upper triangular part of */ /* r must contain the matrix to be updated. on output r */ /* contains the updated triangular matrix. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* w is an input array of length n which must contain the row */ /* vector to be added to r. */ /* b is an array of length n. on input b must contain the */ /* first n elements of the vector c. on output b contains */ /* the first n elements of the vector (q transpose)*c. */ /* alpha is a variable. on input alpha must contain the */ /* (n+1)-st element of the vector c. on output alpha contains */ /* the (n+1)-st element of the vector (q transpose)*c. */ /* cos is an output array of length n which contains the */ /* cosines of the transforming givens rotations. */ /* sin is an output array of length n which contains the */ /* sines of the transforming givens rotations. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* Parameter adjustments */ --sin; --cos; --b; --w; r_dim1 = ldr; r_offset = 1 + r_dim1 * 1; r -= r_offset; /* Function Body */ for (j = 1; j <= n; ++j) { rowj = w[j]; jm1 = j - 1; /* apply the previous transformations to */ /* r(i,j), i=1,2,...,j-1, and to w(j). */ if (jm1 >= 1) { for (i = 1; i <= jm1; ++i) { temp = cos[i] * r[i + j * r_dim1] + sin[i] * rowj; rowj = -sin[i] * r[i + j * r_dim1] + cos[i] * rowj; r[i + j * r_dim1] = temp; } } /* determine a givens rotation which eliminates w(j). */ cos[j] = 1.; sin[j] = 0.; if (rowj != 0.) { if (fabs(r[j + j * r_dim1]) < fabs(rowj)) { cotan = r[j + j * r_dim1] / rowj; sin[j] = p5 / sqrt(p25 + p25 * (cotan * cotan)); cos[j] = sin[j] * cotan; } else { tan = rowj / r[j + j * r_dim1]; cos[j] = p5 / sqrt(p25 + p25 * (tan * tan)); sin[j] = cos[j] * tan; } /* apply the current transformation to r(j,j), b(j), and alpha. */ r[j + j * r_dim1] = cos[j] * r[j + j * r_dim1] + sin[j] * rowj; temp = cos[j] * b[j] + sin[j] * *alpha; *alpha = -sin[j] * b[j] + cos[j] * *alpha; b[j] = temp; } } /* last card of subroutine rwupdt. */ } /* rwupdt_ */ cminpack-1.3.4/rwupdt_.c000644 000765 000765 00000011056 12225167750 015116 0ustar00devernay000000 000000 /* rwupdt.f -- translated by f2c (version 20020621). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "minpack.h" #include #define real __minpack_real__ #define abs(x) ((x) >= 0 ? (x) : -(x)) __minpack_attr__ void __minpack_func__(rwupdt)(const int *n, real *r__, const int *ldr, const real *w, real *b, real *alpha, real *cos__, real *sin__) { /* Initialized data */ #define p5 .5 #define p25 .25 /* System generated locals */ int r_dim1, r_offset, i__1, i__2; real d__1; /* Local variables */ int i__, j, jm1; real tan__, temp, rowj, cotan; /* ********** */ /* subroutine rwupdt */ /* given an n by n upper triangular matrix r, this subroutine */ /* computes the qr decomposition of the matrix formed when a row */ /* is added to r. if the row is specified by the vector w, then */ /* rwupdt determines an orthogonal matrix q such that when the */ /* n+1 by n matrix composed of r augmented by w is premultiplied */ /* by (q transpose), the resulting matrix is upper trapezoidal. */ /* the matrix (q transpose) is the product of n transformations */ /* g(n)*g(n-1)* ... *g(1) */ /* where g(i) is a givens rotation in the (i,n+1) plane which */ /* eliminates elements in the (n+1)-st plane. rwupdt also */ /* computes the product (q transpose)*c where c is the */ /* (n+1)-vector (b,alpha). q itself is not accumulated, rather */ /* the information to recover the g rotations is supplied. */ /* the subroutine statement is */ /* subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) */ /* where */ /* n is a positive integer input variable set to the order of r. */ /* r is an n by n array. on input the upper triangular part of */ /* r must contain the matrix to be updated. on output r */ /* contains the updated triangular matrix. */ /* ldr is a positive integer input variable not less than n */ /* which specifies the leading dimension of the array r. */ /* w is an input array of length n which must contain the row */ /* vector to be added to r. */ /* b is an array of length n. on input b must contain the */ /* first n elements of the vector c. on output b contains */ /* the first n elements of the vector (q transpose)*c. */ /* alpha is a variable. on input alpha must contain the */ /* (n+1)-st element of the vector c. on output alpha contains */ /* the (n+1)-st element of the vector (q transpose)*c. */ /* cos is an output array of length n which contains the */ /* cosines of the transforming givens rotations. */ /* sin is an output array of length n which contains the */ /* sines of the transforming givens rotations. */ /* subprograms called */ /* fortran-supplied ... dabs,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */ /* jorge j. more */ /* ********** */ /* Parameter adjustments */ --sin__; --cos__; --b; --w; r_dim1 = *ldr; r_offset = 1 + r_dim1 * 1; r__ -= r_offset; /* Function Body */ i__1 = *n; for (j = 1; j <= i__1; ++j) { rowj = w[j]; jm1 = j - 1; /* apply the previous transformations to */ /* r(i,j), i=1,2,...,j-1, and to w(j). */ if (jm1 < 1) { goto L20; } i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { temp = cos__[i__] * r__[i__ + j * r_dim1] + sin__[i__] * rowj; rowj = -sin__[i__] * r__[i__ + j * r_dim1] + cos__[i__] * rowj; r__[i__ + j * r_dim1] = temp; /* L10: */ } L20: /* determine a givens rotation which eliminates w(j). */ cos__[j] = 1.; sin__[j] = 0.; if (rowj == 0.) { goto L50; } if ((d__1 = r__[j + j * r_dim1], abs(d__1)) >= abs(rowj)) { goto L30; } cotan = r__[j + j * r_dim1] / rowj; /* Computing 2nd power */ d__1 = cotan; sin__[j] = p5 / sqrt(p25 + p25 * (d__1 * d__1)); cos__[j] = sin__[j] * cotan; goto L40; L30: tan__ = rowj / r__[j + j * r_dim1]; /* Computing 2nd power */ d__1 = tan__; cos__[j] = p5 / sqrt(p25 + p25 * (d__1 * d__1)); sin__[j] = cos__[j] * tan__; L40: /* apply the current transformation to r(j,j), b(j), and alpha. */ r__[j + j * r_dim1] = cos__[j] * r__[j + j * r_dim1] + sin__[j] * rowj; temp = cos__[j] * b[j] + sin__[j] * *alpha; *alpha = -sin__[j] * b[j] + cos__[j] * *alpha; b[j] = temp; L50: /* L60: */ ; } return; /* last card of subroutine rwupdt. */ } /* rwupdt_ */ cminpack-1.3.4/fortran/chkder.f000644 000765 000765 00000011434 12225167750 016350 0ustar00devernay000000 000000 subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) integer m,n,ldfjac,mode double precision x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m), * err(m) c ********** c c subroutine chkder c c this subroutine checks the gradients of m nonlinear functions c in n variables, evaluated at a point x, for consistency with c the functions themselves. the user must call chkder twice, c first with mode = 1 and then with mode = 2. c c mode = 1. on input, x must contain the point of evaluation. c on output, xp is set to a neighboring point. c c mode = 2. on input, fvec must contain the functions and the c rows of fjac must contain the gradients c of the respective functions each evaluated c at x, and fvecp must contain the functions c evaluated at xp. c on output, err contains measures of correctness of c the respective gradients. c c the subroutine does not perform reliably if cancellation or c rounding errors cause a severe loss of significance in the c evaluation of a function. therefore, none of the components c of x should be unusually small (in particular, zero) or any c other value which may cause loss of significance. c c the subroutine statement is c c subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) c c where c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. c c x is an input array of length n. c c fvec is an array of length m. on input when mode = 2, c fvec must contain the functions evaluated at x. c c fjac is an m by n array. on input when mode = 2, c the rows of fjac must contain the gradients of c the respective functions evaluated at x. c c ldfjac is a positive integer input parameter not less than m c which specifies the leading dimension of the array fjac. c c xp is an array of length n. on output when mode = 1, c xp is set to a neighboring point of x. c c fvecp is an array of length m. on input when mode = 2, c fvecp must contain the functions evaluated at xp. c c mode is an integer input variable set to 1 on the first call c and 2 on the second. other values of mode are equivalent c to mode = 1. c c err is an array of length m. on output when mode = 2, c err contains measures of correctness of the respective c gradients. if there is no severe loss of significance, c then if err(i) is 1.0 the i-th gradient is correct, c while if err(i) is 0.0 the i-th gradient is incorrect. c for values of err between 0.0 and 1.0, the categorization c is less certain. in general, a value of err(i) greater c than 0.5 indicates that the i-th gradient is probably c correct, while a value of err(i) less than 0.5 indicates c that the i-th gradient is probably incorrect. c c subprograms called c c minpack supplied ... dpmpar c c fortran supplied ... dabs,dlog10,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j double precision eps,epsf,epslog,epsmch,factor,one,temp,zero double precision dpmpar data factor,one,zero /1.0d2,1.0d0,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c eps = dsqrt(epsmch) c if (mode .eq. 2) go to 20 c c mode = 1. c do 10 j = 1, n temp = eps*dabs(x(j)) if (temp .eq. zero) temp = eps xp(j) = x(j) + temp 10 continue go to 70 20 continue c c mode = 2. c epsf = factor*epsmch epslog = dlog10(eps) do 30 i = 1, m err(i) = zero 30 continue do 50 j = 1, n temp = dabs(x(j)) if (temp .eq. zero) temp = one do 40 i = 1, m err(i) = err(i) + temp*fjac(i,j) 40 continue 50 continue do 60 i = 1, m temp = one if (fvec(i) .ne. zero .and. fvecp(i) .ne. zero * .and. dabs(fvecp(i)-fvec(i)) .ge. epsf*dabs(fvec(i))) * temp = eps*dabs((fvecp(i)-fvec(i))/eps-err(i)) * /(dabs(fvec(i)) + dabs(fvecp(i))) err(i) = one if (temp .gt. epsmch .and. temp .lt. eps) * err(i) = (dlog10(temp) - epslog)/epslog if (temp .ge. eps) err(i) = zero 60 continue 70 continue c return c c last card of subroutine chkder. c end cminpack-1.3.4/fortran/covar.f000644 000765 000765 00000010431 12225167750 016216 0ustar00devernay000000 000000 subroutine covar(n,r,ldr,ipvt,tol,wa) integer n,ldr integer ipvt(n) double precision tol double precision r(ldr,n),wa(n) c ********** c c subroutine covar c c given an m by n matrix a, the problem is to determine c the covariance matrix corresponding to a, defined as c c t c inverse(a *a) . c c this subroutine completes the solution of the problem c if it is provided with the necessary information from the c qr factorization, with column pivoting, of a. that is, if c a*p = q*r, where p is a permutation matrix, q has orthogonal c columns, and r is an upper triangular matrix with diagonal c elements of nonincreasing magnitude, then covar expects c the full upper triangle of r and the permutation matrix p. c the covariance matrix is then computed as c c t t c p*inverse(r *r)*p . c c if a is nearly rank deficient, it may be desirable to compute c the covariance matrix corresponding to the linearly independent c columns of a. to define the numerical rank of a, covar uses c the tolerance tol. if l is the largest integer such that c c abs(r(l,l)) .gt. tol*abs(r(1,1)) , c c then covar computes the covariance matrix corresponding to c the first l columns of r. for k greater than l, column c and row ipvt(k) of the covariance matrix are set to zero. c c the subroutine statement is c c subroutine covar(n,r,ldr,ipvt,tol,wa) c c where c c n is a positive integer input variable set to the order of r. c c r is an n by n array. on input the full upper triangle must c contain the full upper triangle of the matrix r. on output c r contains the square symmetric covariance matrix. c c ldr is a positive integer input variable not less than n c which specifies the leading dimension of the array r. c c ipvt is an integer input array of length n which defines the c permutation matrix p such that a*p = q*r. column j of p c is column ipvt(j) of the identity matrix. c c tol is a nonnegative input variable used to define the c numerical rank of a in the manner described above. c c wa is a work array of length n. c c subprograms called c c fortran-supplied ... dabs c c argonne national laboratory. minpack project. august 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ii,j,jj,k,km1,l logical sing double precision one,temp,tolr,zero data one,zero /1.0d0,0.0d0/ c c form the inverse of r in the full upper triangle of r. c tolr = tol*dabs(r(1,1)) l = 0 do 40 k = 1, n if (dabs(r(k,k)) .le. tolr) go to 50 r(k,k) = one/r(k,k) km1 = k - 1 if (km1 .lt. 1) go to 30 do 20 j = 1, km1 temp = r(k,k)*r(j,k) r(j,k) = zero do 10 i = 1, j r(i,k) = r(i,k) - temp*r(i,j) 10 continue 20 continue 30 continue l = k 40 continue 50 continue c c form the full upper triangle of the inverse of (r transpose)*r c in the full upper triangle of r. c if (l .lt. 1) go to 110 do 100 k = 1, l km1 = k - 1 if (km1 .lt. 1) go to 80 do 70 j = 1, km1 temp = r(j,k) do 60 i = 1, j r(i,j) = r(i,j) + temp*r(i,k) 60 continue 70 continue 80 continue temp = r(k,k) do 90 i = 1, k r(i,k) = temp*r(i,k) 90 continue 100 continue 110 continue c c form the full lower triangle of the covariance matrix c in the strict lower triangle of r and in wa. c do 130 j = 1, n jj = ipvt(j) sing = j .gt. l do 120 i = 1, j if (sing) r(i,j) = zero ii = ipvt(i) if (ii .gt. jj) r(ii,jj) = r(i,j) if (ii .lt. jj) r(jj,ii) = r(i,j) 120 continue wa(jj) = r(j,j) 130 continue c c symmetrize the covariance matrix in r. c do 150 j = 1, n do 140 i = 1, j r(i,j) = r(j,i) 140 continue r(j,j) = wa(j) 150 continue return c c last card of subroutine covar. c end cminpack-1.3.4/fortran/dogleg.f000644 000765 000765 00000012267 12225167750 016356 0ustar00devernay000000 000000 subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) integer n,lr double precision delta double precision r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n) c ********** c c subroutine dogleg c c given an m by n matrix a, an n by n nonsingular diagonal c matrix d, an m-vector b, and a positive number delta, the c problem is to determine the convex combination x of the c gauss-newton and scaled gradient directions that minimizes c (a*x - b) in the least squares sense, subject to the c restriction that the euclidean norm of d*x be at most delta. c c this subroutine completes the solution of the problem c if it is provided with the necessary information from the c qr factorization of a. that is, if a = q*r, where q has c orthogonal columns and r is an upper triangular matrix, c then dogleg expects the full upper triangle of r and c the first n components of (q transpose)*b. c c the subroutine statement is c c subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) c c where c c n is a positive integer input variable set to the order of r. c c r is an input array of length lr which must contain the upper c triangular matrix r stored by rows. c c lr is a positive integer input variable not less than c (n*(n+1))/2. c c diag is an input array of length n which must contain the c diagonal elements of the matrix d. c c qtb is an input array of length n which must contain the first c n elements of the vector (q transpose)*b. c c delta is a positive input variable which specifies an upper c bound on the euclidean norm of d*x. c c x is an output array of length n which contains the desired c convex combination of the gauss-newton direction and the c scaled gradient direction. c c wa1 and wa2 are work arrays of length n. c c subprograms called c c minpack-supplied ... dpmpar,enorm c c fortran-supplied ... dabs,dmax1,dmin1,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,jj,jp1,k,l double precision alpha,bnorm,epsmch,gnorm,one,qnorm,sgnorm,sum, * temp,zero double precision dpmpar,enorm data one,zero /1.0d0,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c c first, calculate the gauss-newton direction. c jj = (n*(n + 1))/2 + 1 do 50 k = 1, n j = n - k + 1 jp1 = j + 1 jj = jj - k l = jj + 1 sum = zero if (n .lt. jp1) go to 20 do 10 i = jp1, n sum = sum + r(l)*x(i) l = l + 1 10 continue 20 continue temp = r(jj) if (temp .ne. zero) go to 40 l = j do 30 i = 1, j temp = dmax1(temp,dabs(r(l))) l = l + n - i 30 continue temp = epsmch*temp if (temp .eq. zero) temp = epsmch 40 continue x(j) = (qtb(j) - sum)/temp 50 continue c c test whether the gauss-newton direction is acceptable. c do 60 j = 1, n wa1(j) = zero wa2(j) = diag(j)*x(j) 60 continue qnorm = enorm(n,wa2) if (qnorm .le. delta) go to 140 c c the gauss-newton direction is not acceptable. c next, calculate the scaled gradient direction. c l = 1 do 80 j = 1, n temp = qtb(j) do 70 i = j, n wa1(i) = wa1(i) + r(l)*temp l = l + 1 70 continue wa1(j) = wa1(j)/diag(j) 80 continue c c calculate the norm of the scaled gradient and test for c the special case in which the scaled gradient is zero. c gnorm = enorm(n,wa1) sgnorm = zero alpha = delta/qnorm if (gnorm .eq. zero) go to 120 c c calculate the point along the scaled gradient c at which the quadratic is minimized. c do 90 j = 1, n wa1(j) = (wa1(j)/gnorm)/diag(j) 90 continue l = 1 do 110 j = 1, n sum = zero do 100 i = j, n sum = sum + r(l)*wa1(i) l = l + 1 100 continue wa2(j) = sum 110 continue temp = enorm(n,wa2) sgnorm = (gnorm/temp)/temp c c test whether the scaled gradient direction is acceptable. c alpha = zero if (sgnorm .ge. delta) go to 120 c c the scaled gradient direction is not acceptable. c finally, calculate the point along the dogleg c at which the quadratic is minimized. c bnorm = enorm(n,qtb) temp = (bnorm/gnorm)*(bnorm/qnorm)*(sgnorm/delta) temp = temp - (delta/qnorm)*(sgnorm/delta)**2 * + dsqrt((temp-(delta/qnorm))**2 * +(one-(delta/qnorm)**2)*(one-(sgnorm/delta)**2)) alpha = ((delta/qnorm)*(one - (sgnorm/delta)**2))/temp 120 continue c c form appropriate convex combination of the gauss-newton c direction and the scaled gradient direction. c temp = (one - alpha)*dmin1(sgnorm,delta) do 130 j = 1, n x(j) = temp*wa1(j) + alpha*x(j) 130 continue 140 continue return c c last card of subroutine dogleg. c end cminpack-1.3.4/fortran/dpmpar.f000644 000765 000765 00000013550 12225167750 016374 0ustar00devernay000000 000000 double precision function dpmpar(i) integer i c ********** c c Function dpmpar c c This function provides double precision machine parameters c when the appropriate set of data statements is activated (by c removing the c from column 1) and all other data statements are c rendered inactive. Most of the parameter values were obtained c from the corresponding Bell Laboratories Port Library function. c c The function statement is c c double precision function dpmpar(i) c c where c c i is an integer input variable set to 1, 2, or 3 which c selects the desired machine parameter. If the machine has c t base b digits and its smallest and largest exponents are c emin and emax, respectively, then these parameters are c c dpmpar(1) = b**(1 - t), the machine precision, c c dpmpar(2) = b**(emin - 1), the smallest magnitude, c c dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. c c Argonne National Laboratory. MINPACK Project. November 1996. c Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' c c ********** integer mcheps(4) integer minmag(4) integer maxmag(4) double precision dmach(3) equivalence (dmach(1),mcheps(1)) equivalence (dmach(2),minmag(1)) equivalence (dmach(3),maxmag(1)) c c Machine constants for the IBM 360/370 series, c the Amdahl 470/V6, the ICL 2900, the Itel AS/6, c the Xerox Sigma 5/7/9 and the Sel systems 85/86. c c data mcheps(1),mcheps(2) / z34100000, z00000000 / c data minmag(1),minmag(2) / z00100000, z00000000 / c data maxmag(1),maxmag(2) / z7fffffff, zffffffff / c c Machine constants for the Honeywell 600/6000 series. c c data mcheps(1),mcheps(2) / o606400000000, o000000000000 / c data minmag(1),minmag(2) / o402400000000, o000000000000 / c data maxmag(1),maxmag(2) / o376777777777, o777777777777 / c c Machine constants for the CDC 6000/7000 series. c c data mcheps(1) / 15614000000000000000b / c data mcheps(2) / 15010000000000000000b / c c data minmag(1) / 00604000000000000000b / c data minmag(2) / 00000000000000000000b / c c data maxmag(1) / 37767777777777777777b / c data maxmag(2) / 37167777777777777777b / c c Machine constants for the PDP-10 (KA processor). c c data mcheps(1),mcheps(2) / "114400000000, "000000000000 / c data minmag(1),minmag(2) / "033400000000, "000000000000 / c data maxmag(1),maxmag(2) / "377777777777, "344777777777 / c c Machine constants for the PDP-10 (KI processor). c c data mcheps(1),mcheps(2) / "104400000000, "000000000000 / c data minmag(1),minmag(2) / "000400000000, "000000000000 / c data maxmag(1),maxmag(2) / "377777777777, "377777777777 / c c Machine constants for the PDP-11. c c data mcheps(1),mcheps(2) / 9472, 0 / c data mcheps(3),mcheps(4) / 0, 0 / c c data minmag(1),minmag(2) / 128, 0 / c data minmag(3),minmag(4) / 0, 0 / c c data maxmag(1),maxmag(2) / 32767, -1 / c data maxmag(3),maxmag(4) / -1, -1 / c c Machine constants for the Burroughs 6700/7700 systems. c c data mcheps(1) / o1451000000000000 / c data mcheps(2) / o0000000000000000 / c c data minmag(1) / o1771000000000000 / c data minmag(2) / o7770000000000000 / c c data maxmag(1) / o0777777777777777 / c data maxmag(2) / o7777777777777777 / c c Machine constants for the Burroughs 5700 system. c c data mcheps(1) / o1451000000000000 / c data mcheps(2) / o0000000000000000 / c c data minmag(1) / o1771000000000000 / c data minmag(2) / o0000000000000000 / c c data maxmag(1) / o0777777777777777 / c data maxmag(2) / o0007777777777777 / c c Machine constants for the Burroughs 1700 system. c c data mcheps(1) / zcc6800000 / c data mcheps(2) / z000000000 / c c data minmag(1) / zc00800000 / c data minmag(2) / z000000000 / c c data maxmag(1) / zdffffffff / c data maxmag(2) / zfffffffff / c c Machine constants for the Univac 1100 series. c c data mcheps(1),mcheps(2) / o170640000000, o000000000000 / c data minmag(1),minmag(2) / o000040000000, o000000000000 / c data maxmag(1),maxmag(2) / o377777777777, o777777777777 / c c Machine constants for the Data General Eclipse S/200. c c Note - it may be appropriate to include the following card - c static dmach(3) c c data minmag/20k,3*0/,maxmag/77777k,3*177777k/ c data mcheps/32020k,3*0/ c c Machine constants for the Harris 220. c c data mcheps(1),mcheps(2) / '20000000, '00000334 / c data minmag(1),minmag(2) / '20000000, '00000201 / c data maxmag(1),maxmag(2) / '37777777, '37777577 / c c Machine constants for the Cray-1. c c data mcheps(1) / 0376424000000000000000b / c data mcheps(2) / 0000000000000000000000b / c c data minmag(1) / 0200034000000000000000b / c data minmag(2) / 0000000000000000000000b / c c data maxmag(1) / 0577777777777777777777b / c data maxmag(2) / 0000007777777777777776b / c c Machine constants for the Prime 400. c c data mcheps(1),mcheps(2) / :10000000000, :00000000123 / c data minmag(1),minmag(2) / :10000000000, :00000100000 / c data maxmag(1),maxmag(2) / :17777777777, :37777677776 / c c Machine constants for the VAX-11. c c data mcheps(1),mcheps(2) / 9472, 0 / c data minmag(1),minmag(2) / 128, 0 / c data maxmag(1),maxmag(2) / -32769, -1 / c c Machine constants for IEEE machines. c c These values were not accurate enough, according to MACHAR c data dmach(1) /2.22044604926d-16/ c data dmach(2) /2.22507385852d-308/ c data dmach(3) /1.79769313485d+308/ data dmach(1) /2.2204460492503131d-16/ data dmach(2) /2.2250738585072014d-308/ data dmach(3) /1.7976931348623158d+308/ c dpmpar = dmach(i) return c c Last card of function dpmpar. c end cminpack-1.3.4/fortran/enorm.f000644 000765 000765 00000006077 12225167750 016237 0ustar00devernay000000 000000 double precision function enorm(n,x) integer n double precision x(n) c ********** c c function enorm c c given an n-vector x, this function calculates the c euclidean norm of x. c c the euclidean norm is computed by accumulating the sum of c squares in three different sums. the sums of squares for the c small and large components are scaled so that no overflows c occur. non-destructive underflows are permitted. underflows c and overflows do not occur in the computation of the unscaled c sum of squares for the intermediate components. c the definitions of small, intermediate and large components c depend on two constants, rdwarf and rgiant. the main c restrictions on these constants are that rdwarf**2 not c underflow and rgiant**2 not overflow. the constants c given here are suitable for every known computer. c c the function statement is c c double precision function enorm(n,x) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c subprograms called c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i double precision agiant,floatn,one,rdwarf,rgiant,s1,s2,s3,xabs, * x1max,x3max,zero data one,zero,rdwarf,rgiant /1.0d0,0.0d0,3.834d-20,1.304d19/ s1 = zero s2 = zero s3 = zero x1max = zero x3max = zero floatn = n agiant = rgiant/floatn do 90 i = 1, n xabs = dabs(x(i)) if (xabs .gt. rdwarf .and. xabs .lt. agiant) go to 70 if (xabs .le. rdwarf) go to 30 c c sum for large components. c if (xabs .le. x1max) go to 10 s1 = one + s1*(x1max/xabs)**2 x1max = xabs go to 20 10 continue s1 = s1 + (xabs/x1max)**2 20 continue go to 60 30 continue c c sum for small components. c if (xabs .le. x3max) go to 40 s3 = one + s3*(x3max/xabs)**2 x3max = xabs go to 50 40 continue if (xabs .ne. zero) s3 = s3 + (xabs/x3max)**2 50 continue 60 continue go to 80 70 continue c c sum for intermediate components. c s2 = s2 + xabs**2 80 continue 90 continue c c calculation of norm. c if (s1 .eq. zero) go to 100 enorm = x1max*dsqrt(s1+(s2/x1max)/x1max) go to 130 100 continue if (s2 .eq. zero) go to 110 if (s2 .ge. x3max) * enorm = dsqrt(s2*(one+(x3max/s2)*(x3max*s3))) if (s2 .lt. x3max) * enorm = dsqrt(x3max*((s2/x3max)+(x3max*s3))) go to 120 110 continue enorm = x3max*dsqrt(s3) 120 continue 130 continue return c c last card of function enorm. c end cminpack-1.3.4/fortran/fdjac1.f000644 000765 000765 00000011526 12225167750 016242 0ustar00devernay000000 000000 subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, * wa1,wa2) integer n,ldfjac,iflag,ml,mu double precision epsfcn double precision x(n),fvec(n),fjac(ldfjac,n),wa1(n),wa2(n) c ********** c c subroutine fdjac1 c c this subroutine computes a forward-difference approximation c to the n by n jacobian matrix associated with a specified c problem of n functions in n variables. if the jacobian has c a banded form, then function evaluations are saved by only c approximating the nonzero terms. c c the subroutine statement is c c subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, c wa1,wa2) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(n,x,fvec,iflag) c integer n,iflag c double precision x(n),fvec(n) c ---------- c calculate the functions at x and c return this vector in fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of fdjac1. c in this case set iflag to a negative integer. c c n is a positive integer input variable set to the number c of functions and variables. c c x is an input array of length n. c c fvec is an input array of length n which must contain the c functions evaluated at x. c c fjac is an output n by n array which contains the c approximation to the jacobian matrix evaluated at x. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c iflag is an integer variable which can be used to terminate c the execution of fdjac1. see description of fcn. c c ml is a nonnegative integer input variable which specifies c the number of subdiagonals within the band of the c jacobian matrix. if the jacobian is not banded, set c ml to at least n - 1. c c epsfcn is an input variable used in determining a suitable c step length for the forward-difference approximation. this c approximation assumes that the relative errors in the c functions are of the order of epsfcn. if epsfcn is less c than the machine precision, it is assumed that the relative c errors in the functions are of the order of the machine c precision. c c mu is a nonnegative integer input variable which specifies c the number of superdiagonals within the band of the c jacobian matrix. if the jacobian is not banded, set c mu to at least n - 1. c c wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at c least n, then the jacobian is considered dense, and wa2 is c not referenced. c c subprograms called c c minpack-supplied ... dpmpar c c fortran-supplied ... dabs,dmax1,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,k,msum double precision eps,epsmch,h,temp,zero double precision dpmpar data zero /0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c eps = dsqrt(dmax1(epsfcn,epsmch)) msum = ml + mu + 1 if (msum .lt. n) go to 40 c c computation of dense approximate jacobian. c do 20 j = 1, n temp = x(j) h = eps*dabs(temp) if (h .eq. zero) h = eps x(j) = temp + h call fcn(n,x,wa1,iflag) if (iflag .lt. 0) go to 30 x(j) = temp do 10 i = 1, n fjac(i,j) = (wa1(i) - fvec(i))/h 10 continue 20 continue 30 continue go to 110 40 continue c c computation of banded approximate jacobian. c do 90 k = 1, msum do 60 j = k, n, msum wa2(j) = x(j) h = eps*dabs(wa2(j)) if (h .eq. zero) h = eps x(j) = wa2(j) + h 60 continue call fcn(n,x,wa1,iflag) if (iflag .lt. 0) go to 100 do 80 j = k, n, msum x(j) = wa2(j) h = eps*dabs(wa2(j)) if (h .eq. zero) h = eps do 70 i = 1, n fjac(i,j) = zero if (i .ge. j - mu .and. i .le. j + ml) * fjac(i,j) = (wa1(i) - fvec(i))/h 70 continue 80 continue 90 continue 100 continue 110 continue return c c last card of subroutine fdjac1. c end cminpack-1.3.4/fortran/fdjac2.f000644 000765 000765 00000006414 12225167750 016243 0ustar00devernay000000 000000 subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) integer m,n,ldfjac,iflag double precision epsfcn double precision x(n),fvec(m),fjac(ldfjac,n),wa(m) c ********** c c subroutine fdjac2 c c this subroutine computes a forward-difference approximation c to the m by n jacobian matrix associated with a specified c problem of m functions in n variables. c c the subroutine statement is c c subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,iflag) c integer m,n,iflag c double precision x(n),fvec(m) c ---------- c calculate the functions at x and c return this vector in fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of fdjac2. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an input array of length n. c c fvec is an input array of length m which must contain the c functions evaluated at x. c c fjac is an output m by n array which contains the c approximation to the jacobian matrix evaluated at x. c c ldfjac is a positive integer input variable not less than m c which specifies the leading dimension of the array fjac. c c iflag is an integer variable which can be used to terminate c the execution of fdjac2. see description of fcn. c c epsfcn is an input variable used in determining a suitable c step length for the forward-difference approximation. this c approximation assumes that the relative errors in the c functions are of the order of epsfcn. if epsfcn is less c than the machine precision, it is assumed that the relative c errors in the functions are of the order of the machine c precision. c c wa is a work array of length m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar c c fortran-supplied ... dabs,dmax1,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j double precision eps,epsmch,h,temp,zero double precision dpmpar data zero /0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c eps = dsqrt(dmax1(epsfcn,epsmch)) do 20 j = 1, n temp = x(j) h = eps*dabs(temp) if (h .eq. zero) h = eps x(j) = temp + h call fcn(m,n,x,wa,iflag) if (iflag .lt. 0) go to 30 x(j) = temp do 10 i = 1, m fjac(i,j) = (wa(i) - fvec(i))/h 10 continue 20 continue 30 continue return c c last card of subroutine fdjac2. c end cminpack-1.3.4/fortran/hybrd.f000644 000765 000765 00000035054 12225167750 016224 0ustar00devernay000000 000000 subroutine 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) integer n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr double precision xtol,epsfcn,factor double precision x(n),fvec(n),diag(n),fjac(ldfjac,n),r(lr), * qtf(n),wa1(n),wa2(n),wa3(n),wa4(n) external fcn c ********** c c subroutine hybrd c c the purpose of hybrd is to find a zero of a system of c n nonlinear functions in n variables by a modification c of the powell hybrid method. the user must provide a c subroutine which calculates the functions. the jacobian is c then calculated by a forward-difference approximation. c c the subroutine statement is c c subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn, c diag,mode,factor,nprint,info,nfev,fjac, c ldfjac,r,lr,qtf,wa1,wa2,wa3,wa4) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(n,x,fvec,iflag) c integer n,iflag c double precision x(n),fvec(n) c ---------- c calculate the functions at x and c return this vector in fvec. c --------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of hybrd. c in this case set iflag to a negative integer. c c n is a positive integer input variable set to the number c of functions and variables. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length n which contains c the functions evaluated at the output x. c c xtol is a nonnegative input variable. termination c occurs when the relative error between two consecutive c iterates is at most xtol. c c maxfev is a positive integer input variable. termination c occurs when the number of calls to fcn is at least maxfev c by the end of an iteration. c c ml is a nonnegative integer input variable which specifies c the number of subdiagonals within the band of the c jacobian matrix. if the jacobian is not banded, set c ml to at least n - 1. c c mu is a nonnegative integer input variable which specifies c the number of superdiagonals within the band of the c jacobian matrix. if the jacobian is not banded, set c mu to at least n - 1. c c epsfcn is an input variable used in determining a suitable c step length for the forward-difference approximation. this c approximation assumes that the relative errors in the c functions are of the order of epsfcn. if epsfcn is less c than the machine precision, it is assumed that the relative c errors in the functions are of the order of the machine c precision. c c diag is an array of length n. if mode = 1 (see c below), diag is internally set. if mode = 2, diag c must contain positive entries that serve as c multiplicative scale factors for the variables. c c mode is an integer input variable. if mode = 1, the c variables will be scaled internally. if mode = 2, c the scaling is specified by the input diag. other c values of mode are equivalent to mode = 1. c c factor is a positive input variable used in determining the c initial step bound. this bound is set to the product of c factor and the euclidean norm of diag*x if nonzero, or else c to factor itself. in most cases factor should lie in the c interval (.1,100.). 100. is a generally recommended value. c c nprint is an integer input variable that enables controlled c printing of iterates if it is positive. in this case, c fcn is called with iflag = 0 at the beginning of the first c iteration and every nprint iterations thereafter and c immediately prior to return, with x and fvec available c for printing. if nprint is not positive, no special calls c of fcn with iflag = 0 are made. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 relative error between two consecutive iterates c is at most xtol. c c info = 2 number of calls to fcn has reached or exceeded c maxfev. c c info = 3 xtol is too small. no further improvement in c the approximate solution x is possible. c c info = 4 iteration is not making good progress, as c measured by the improvement from the last c five jacobian evaluations. c c info = 5 iteration is not making good progress, as c measured by the improvement from the last c ten iterations. c c nfev is an integer output variable set to the number of c calls to fcn. c c fjac is an output n by n array which contains the c orthogonal matrix q produced by the qr factorization c of the final approximate jacobian. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c r is an output array of length lr which contains the c upper triangular matrix produced by the qr factorization c of the final approximate jacobian, stored rowwise. c c lr is a positive integer input variable not less than c (n*(n+1))/2. c c qtf is an output array of length n which contains c the vector (q transpose)*fvec. c c wa1, wa2, wa3, and wa4 are work arrays of length n. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dogleg,dpmpar,enorm,fdjac1, c qform,qrfac,r1mpyq,r1updt c c fortran-supplied ... dabs,dmax1,dmin1,min0,mod c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iflag,iter,j,jm1,l,msum,ncfail,ncsuc,nslow1,nslow2 integer iwa(1) logical jeval,sing double precision actred,delta,epsmch,fnorm,fnorm1,one,pnorm, * prered,p1,p5,p001,p0001,ratio,sum,temp,xnorm, * zero double precision dpmpar,enorm data one,p1,p5,p001,p0001,zero * /1.0d0,1.0d-1,5.0d-1,1.0d-3,1.0d-4,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c info = 0 iflag = 0 nfev = 0 c c check the input parameters for errors. c if (n .le. 0 .or. xtol .lt. zero .or. maxfev .le. 0 * .or. ml .lt. 0 .or. mu .lt. 0 .or. factor .le. zero * .or. ldfjac .lt. n .or. lr .lt. (n*(n + 1))/2) go to 300 if (mode .ne. 2) go to 20 do 10 j = 1, n if (diag(j) .le. zero) go to 300 10 continue 20 continue c c evaluate the function at the starting point c and calculate its norm. c iflag = 1 call fcn(n,x,fvec,iflag) nfev = 1 if (iflag .lt. 0) go to 300 fnorm = enorm(n,fvec) c c determine the number of calls to fcn needed to compute c the jacobian matrix. c msum = min0(ml+mu+1,n) c c initialize iteration counter and monitors. c iter = 1 ncsuc = 0 ncfail = 0 nslow1 = 0 nslow2 = 0 c c beginning of the outer loop. c 30 continue jeval = .true. c c calculate the jacobian matrix. c iflag = 2 call fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,wa1, * wa2) nfev = nfev + msum if (iflag .lt. 0) go to 300 c c compute the qr factorization of the jacobian. c call qrfac(n,n,fjac,ldfjac,.false.,iwa,1,wa1,wa2,wa3) c c on the first iteration and if mode is 1, scale according c to the norms of the columns of the initial jacobian. c if (iter .ne. 1) go to 70 if (mode .eq. 2) go to 50 do 40 j = 1, n diag(j) = wa2(j) if (wa2(j) .eq. zero) diag(j) = one 40 continue 50 continue c c on the first iteration, calculate the norm of the scaled x c and initialize the step bound delta. c do 60 j = 1, n wa3(j) = diag(j)*x(j) 60 continue xnorm = enorm(n,wa3) delta = factor*xnorm if (delta .eq. zero) delta = factor 70 continue c c form (q transpose)*fvec and store in qtf. c do 80 i = 1, n qtf(i) = fvec(i) 80 continue do 120 j = 1, n if (fjac(j,j) .eq. zero) go to 110 sum = zero do 90 i = j, n sum = sum + fjac(i,j)*qtf(i) 90 continue temp = -sum/fjac(j,j) do 100 i = j, n qtf(i) = qtf(i) + fjac(i,j)*temp 100 continue 110 continue 120 continue c c copy the triangular factor of the qr factorization into r. c sing = .false. do 150 j = 1, n l = j jm1 = j - 1 if (jm1 .lt. 1) go to 140 do 130 i = 1, jm1 r(l) = fjac(i,j) l = l + n - i 130 continue 140 continue r(l) = wa1(j) if (wa1(j) .eq. zero) sing = .true. 150 continue c c accumulate the orthogonal factor in fjac. c call qform(n,n,fjac,ldfjac,wa1) c c rescale if necessary. c if (mode .eq. 2) go to 170 do 160 j = 1, n diag(j) = dmax1(diag(j),wa2(j)) 160 continue 170 continue c c beginning of the inner loop. c 180 continue c c if requested, call fcn to enable printing of iterates. c if (nprint .le. 0) go to 190 iflag = 0 if (mod(iter-1,nprint) .eq. 0) call fcn(n,x,fvec,iflag) if (iflag .lt. 0) go to 300 190 continue c c determine the direction p. c call dogleg(n,r,lr,diag,qtf,delta,wa1,wa2,wa3) c c store the direction p and x + p. calculate the norm of p. c do 200 j = 1, n wa1(j) = -wa1(j) wa2(j) = x(j) + wa1(j) wa3(j) = diag(j)*wa1(j) 200 continue pnorm = enorm(n,wa3) c c on the first iteration, adjust the initial step bound. c if (iter .eq. 1) delta = dmin1(delta,pnorm) c c evaluate the function at x + p and calculate its norm. c iflag = 1 call fcn(n,wa2,wa4,iflag) nfev = nfev + 1 if (iflag .lt. 0) go to 300 fnorm1 = enorm(n,wa4) c c compute the scaled actual reduction. c actred = -one if (fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2 c c compute the scaled predicted reduction. c l = 1 do 220 i = 1, n sum = zero do 210 j = i, n sum = sum + r(l)*wa1(j) l = l + 1 210 continue wa3(i) = qtf(i) + sum 220 continue temp = enorm(n,wa3) prered = zero if (temp .lt. fnorm) prered = one - (temp/fnorm)**2 c c compute the ratio of the actual to the predicted c reduction. c ratio = zero if (prered .gt. zero) ratio = actred/prered c c update the step bound. c if (ratio .ge. p1) go to 230 ncsuc = 0 ncfail = ncfail + 1 delta = p5*delta go to 240 230 continue ncfail = 0 ncsuc = ncsuc + 1 if (ratio .ge. p5 .or. ncsuc .gt. 1) * delta = dmax1(delta,pnorm/p5) if (dabs(ratio-one) .le. p1) delta = pnorm/p5 240 continue c c test for successful iteration. c if (ratio .lt. p0001) go to 260 c c successful iteration. update x, fvec, and their norms. c do 250 j = 1, n x(j) = wa2(j) wa2(j) = diag(j)*x(j) fvec(j) = wa4(j) 250 continue xnorm = enorm(n,wa2) fnorm = fnorm1 iter = iter + 1 260 continue c c determine the progress of the iteration. c nslow1 = nslow1 + 1 if (actred .ge. p001) nslow1 = 0 if (jeval) nslow2 = nslow2 + 1 if (actred .ge. p1) nslow2 = 0 c c test for convergence. c if (delta .le. xtol*xnorm .or. fnorm .eq. zero) info = 1 if (info .ne. 0) go to 300 c c tests for termination and stringent tolerances. c if (nfev .ge. maxfev) info = 2 if (p1*dmax1(p1*delta,pnorm) .le. epsmch*xnorm) info = 3 if (nslow2 .eq. 5) info = 4 if (nslow1 .eq. 10) info = 5 if (info .ne. 0) go to 300 c c criterion for recalculating jacobian approximation c by forward differences. c if (ncfail .eq. 2) go to 290 c c calculate the rank one modification to the jacobian c and update qtf if necessary. c do 280 j = 1, n sum = zero do 270 i = 1, n sum = sum + fjac(i,j)*wa4(i) 270 continue wa2(j) = (sum - wa3(j))/pnorm wa1(j) = diag(j)*((diag(j)*wa1(j))/pnorm) if (ratio .ge. p0001) qtf(j) = sum 280 continue c c compute the qr factorization of the updated jacobian. c call r1updt(n,n,r,lr,wa1,wa2,wa3,sing) call r1mpyq(n,n,fjac,ldfjac,wa2,wa3) call r1mpyq(1,n,qtf,1,wa2,wa3) c c end of the inner loop. c jeval = .false. go to 180 290 continue c c end of the outer loop. c go to 30 300 continue c c termination, either normal or user imposed. c if (iflag .lt. 0) info = iflag iflag = 0 if (nprint .gt. 0) call fcn(n,x,fvec,iflag) return c c last card of subroutine hybrd. c end cminpack-1.3.4/fortran/hybrd1.f000644 000765 000765 00000007524 12225167750 016306 0ustar00devernay000000 000000 subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) integer n,info,lwa double precision tol double precision x(n),fvec(n),wa(lwa) external fcn c ********** c c subroutine hybrd1 c c the purpose of hybrd1 is to find a zero of a system of c n nonlinear functions in n variables by a modification c of the powell hybrid method. this is done by using the c more general nonlinear equation solver hybrd. the user c must provide a subroutine which calculates the functions. c the jacobian is then calculated by a forward-difference c approximation. c c the subroutine statement is c c subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(n,x,fvec,iflag) c integer n,iflag c double precision x(n),fvec(n) c ---------- c calculate the functions at x and c return this vector in fvec. c --------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of hybrd1. c in this case set iflag to a negative integer. c c n is a positive integer input variable set to the number c of functions and variables. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length n which contains c the functions evaluated at the output x. c c tol is a nonnegative input variable. termination occurs c when the algorithm estimates that the relative error c between x and the solution is at most tol. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 algorithm estimates that the relative error c between x and the solution is at most tol. c c info = 2 number of calls to fcn has reached or exceeded c 200*(n+1). c c info = 3 tol is too small. no further improvement in c the approximate solution x is possible. c c info = 4 iteration is not making good progress. c c wa is a work array of length lwa. c c lwa is a positive integer input variable not less than c (n*(3*n+13))/2. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... hybrd c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer index,j,lr,maxfev,ml,mode,mu,nfev,nprint double precision epsfcn,factor,one,xtol,zero data factor,one,zero /1.0d2,1.0d0,0.0d0/ info = 0 c c check the input parameters for errors. c if (n .le. 0 .or. tol .lt. zero .or. lwa .lt. (n*(3*n + 13))/2) * go to 20 c c call hybrd. c maxfev = 200*(n + 1) xtol = tol ml = n - 1 mu = n - 1 epsfcn = zero mode = 2 do 10 j = 1, n wa(j) = one 10 continue nprint = 0 lr = (n*(n + 1))/2 index = 6*n + lr call hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,wa(1),mode, * factor,nprint,info,nfev,wa(index+1),n,wa(6*n+1),lr, * wa(n+1),wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1)) if (info .eq. 5) info = 4 20 continue return c c last card of subroutine hybrd1. c end cminpack-1.3.4/fortran/hybrj.f000644 000765 000765 00000033375 12225167750 016236 0ustar00devernay000000 000000 subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode, * factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2, * wa3,wa4) integer n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr double precision xtol,factor double precision x(n),fvec(n),fjac(ldfjac,n),diag(n),r(lr), * qtf(n),wa1(n),wa2(n),wa3(n),wa4(n) c ********** c c subroutine hybrj c c the purpose of hybrj is to find a zero of a system of c n nonlinear functions in n variables by a modification c of the powell hybrid method. the user must provide a c subroutine which calculates the functions and the jacobian. c c the subroutine statement is c c subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, c mode,factor,nprint,info,nfev,njev,r,lr,qtf, c wa1,wa2,wa3,wa4) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the jacobian. fcn must c be declared in an external statement in the user c calling program, and should be written as follows. c c subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) c integer n,ldfjac,iflag c double precision x(n),fvec(n),fjac(ldfjac,n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. do not alter fjac. c if iflag = 2 calculate the jacobian at x and c return this matrix in fjac. do not alter fvec. c --------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of hybrj. c in this case set iflag to a negative integer. c c n is a positive integer input variable set to the number c of functions and variables. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length n which contains c the functions evaluated at the output x. c c fjac is an output n by n array which contains the c orthogonal matrix q produced by the qr factorization c of the final approximate jacobian. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c xtol is a nonnegative input variable. termination c occurs when the relative error between two consecutive c iterates is at most xtol. c c maxfev is a positive integer input variable. termination c occurs when the number of calls to fcn with iflag = 1 c has reached maxfev. c c diag is an array of length n. if mode = 1 (see c below), diag is internally set. if mode = 2, diag c must contain positive entries that serve as c multiplicative scale factors for the variables. c c mode is an integer input variable. if mode = 1, the c variables will be scaled internally. if mode = 2, c the scaling is specified by the input diag. other c values of mode are equivalent to mode = 1. c c factor is a positive input variable used in determining the c initial step bound. this bound is set to the product of c factor and the euclidean norm of diag*x if nonzero, or else c to factor itself. in most cases factor should lie in the c interval (.1,100.). 100. is a generally recommended value. c c nprint is an integer input variable that enables controlled c printing of iterates if it is positive. in this case, c fcn is called with iflag = 0 at the beginning of the first c iteration and every nprint iterations thereafter and c immediately prior to return, with x and fvec available c for printing. fvec and fjac should not be altered. c if nprint is not positive, no special calls of fcn c with iflag = 0 are made. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 relative error between two consecutive iterates c is at most xtol. c c info = 2 number of calls to fcn with iflag = 1 has c reached maxfev. c c info = 3 xtol is too small. no further improvement in c the approximate solution x is possible. c c info = 4 iteration is not making good progress, as c measured by the improvement from the last c five jacobian evaluations. c c info = 5 iteration is not making good progress, as c measured by the improvement from the last c ten iterations. c c nfev is an integer output variable set to the number of c calls to fcn with iflag = 1. c c njev is an integer output variable set to the number of c calls to fcn with iflag = 2. c c r is an output array of length lr which contains the c upper triangular matrix produced by the qr factorization c of the final approximate jacobian, stored rowwise. c c lr is a positive integer input variable not less than c (n*(n+1))/2. c c qtf is an output array of length n which contains c the vector (q transpose)*fvec. c c wa1, wa2, wa3, and wa4 are work arrays of length n. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dogleg,dpmpar,enorm, c qform,qrfac,r1mpyq,r1updt c c fortran-supplied ... dabs,dmax1,dmin1,mod c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iflag,iter,j,jm1,l,ncfail,ncsuc,nslow1,nslow2 integer iwa(1) logical jeval,sing double precision actred,delta,epsmch,fnorm,fnorm1,one,pnorm, * prered,p1,p5,p001,p0001,ratio,sum,temp,xnorm, * zero double precision dpmpar,enorm data one,p1,p5,p001,p0001,zero * /1.0d0,1.0d-1,5.0d-1,1.0d-3,1.0d-4,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c info = 0 iflag = 0 nfev = 0 njev = 0 c c check the input parameters for errors. c if (n .le. 0 .or. ldfjac .lt. n .or. xtol .lt. zero * .or. maxfev .le. 0 .or. factor .le. zero * .or. lr .lt. (n*(n + 1))/2) go to 300 if (mode .ne. 2) go to 20 do 10 j = 1, n if (diag(j) .le. zero) go to 300 10 continue 20 continue c c evaluate the function at the starting point c and calculate its norm. c iflag = 1 call fcn(n,x,fvec,fjac,ldfjac,iflag) nfev = 1 if (iflag .lt. 0) go to 300 fnorm = enorm(n,fvec) c c initialize iteration counter and monitors. c iter = 1 ncsuc = 0 ncfail = 0 nslow1 = 0 nslow2 = 0 c c beginning of the outer loop. c 30 continue jeval = .true. c c calculate the jacobian matrix. c iflag = 2 call fcn(n,x,fvec,fjac,ldfjac,iflag) njev = njev + 1 if (iflag .lt. 0) go to 300 c c compute the qr factorization of the jacobian. c call qrfac(n,n,fjac,ldfjac,.false.,iwa,1,wa1,wa2,wa3) c c on the first iteration and if mode is 1, scale according c to the norms of the columns of the initial jacobian. c if (iter .ne. 1) go to 70 if (mode .eq. 2) go to 50 do 40 j = 1, n diag(j) = wa2(j) if (wa2(j) .eq. zero) diag(j) = one 40 continue 50 continue c c on the first iteration, calculate the norm of the scaled x c and initialize the step bound delta. c do 60 j = 1, n wa3(j) = diag(j)*x(j) 60 continue xnorm = enorm(n,wa3) delta = factor*xnorm if (delta .eq. zero) delta = factor 70 continue c c form (q transpose)*fvec and store in qtf. c do 80 i = 1, n qtf(i) = fvec(i) 80 continue do 120 j = 1, n if (fjac(j,j) .eq. zero) go to 110 sum = zero do 90 i = j, n sum = sum + fjac(i,j)*qtf(i) 90 continue temp = -sum/fjac(j,j) do 100 i = j, n qtf(i) = qtf(i) + fjac(i,j)*temp 100 continue 110 continue 120 continue c c copy the triangular factor of the qr factorization into r. c sing = .false. do 150 j = 1, n l = j jm1 = j - 1 if (jm1 .lt. 1) go to 140 do 130 i = 1, jm1 r(l) = fjac(i,j) l = l + n - i 130 continue 140 continue r(l) = wa1(j) if (wa1(j) .eq. zero) sing = .true. 150 continue c c accumulate the orthogonal factor in fjac. c call qform(n,n,fjac,ldfjac,wa1) c c rescale if necessary. c if (mode .eq. 2) go to 170 do 160 j = 1, n diag(j) = dmax1(diag(j),wa2(j)) 160 continue 170 continue c c beginning of the inner loop. c 180 continue c c if requested, call fcn to enable printing of iterates. c if (nprint .le. 0) go to 190 iflag = 0 if (mod(iter-1,nprint) .eq. 0) * call fcn(n,x,fvec,fjac,ldfjac,iflag) if (iflag .lt. 0) go to 300 190 continue c c determine the direction p. c call dogleg(n,r,lr,diag,qtf,delta,wa1,wa2,wa3) c c store the direction p and x + p. calculate the norm of p. c do 200 j = 1, n wa1(j) = -wa1(j) wa2(j) = x(j) + wa1(j) wa3(j) = diag(j)*wa1(j) 200 continue pnorm = enorm(n,wa3) c c on the first iteration, adjust the initial step bound. c if (iter .eq. 1) delta = dmin1(delta,pnorm) c c evaluate the function at x + p and calculate its norm. c iflag = 1 call fcn(n,wa2,wa4,fjac,ldfjac,iflag) nfev = nfev + 1 if (iflag .lt. 0) go to 300 fnorm1 = enorm(n,wa4) c c compute the scaled actual reduction. c actred = -one if (fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2 c c compute the scaled predicted reduction. c l = 1 do 220 i = 1, n sum = zero do 210 j = i, n sum = sum + r(l)*wa1(j) l = l + 1 210 continue wa3(i) = qtf(i) + sum 220 continue temp = enorm(n,wa3) prered = zero if (temp .lt. fnorm) prered = one - (temp/fnorm)**2 c c compute the ratio of the actual to the predicted c reduction. c ratio = zero if (prered .gt. zero) ratio = actred/prered c c update the step bound. c if (ratio .ge. p1) go to 230 ncsuc = 0 ncfail = ncfail + 1 delta = p5*delta go to 240 230 continue ncfail = 0 ncsuc = ncsuc + 1 if (ratio .ge. p5 .or. ncsuc .gt. 1) * delta = dmax1(delta,pnorm/p5) if (dabs(ratio-one) .le. p1) delta = pnorm/p5 240 continue c c test for successful iteration. c if (ratio .lt. p0001) go to 260 c c successful iteration. update x, fvec, and their norms. c do 250 j = 1, n x(j) = wa2(j) wa2(j) = diag(j)*x(j) fvec(j) = wa4(j) 250 continue xnorm = enorm(n,wa2) fnorm = fnorm1 iter = iter + 1 260 continue c c determine the progress of the iteration. c nslow1 = nslow1 + 1 if (actred .ge. p001) nslow1 = 0 if (jeval) nslow2 = nslow2 + 1 if (actred .ge. p1) nslow2 = 0 c c test for convergence. c if (delta .le. xtol*xnorm .or. fnorm .eq. zero) info = 1 if (info .ne. 0) go to 300 c c tests for termination and stringent tolerances. c if (nfev .ge. maxfev) info = 2 if (p1*dmax1(p1*delta,pnorm) .le. epsmch*xnorm) info = 3 if (nslow2 .eq. 5) info = 4 if (nslow1 .eq. 10) info = 5 if (info .ne. 0) go to 300 c c criterion for recalculating jacobian. c if (ncfail .eq. 2) go to 290 c c calculate the rank one modification to the jacobian c and update qtf if necessary. c do 280 j = 1, n sum = zero do 270 i = 1, n sum = sum + fjac(i,j)*wa4(i) 270 continue wa2(j) = (sum - wa3(j))/pnorm wa1(j) = diag(j)*((diag(j)*wa1(j))/pnorm) if (ratio .ge. p0001) qtf(j) = sum 280 continue c c compute the qr factorization of the updated jacobian. c call r1updt(n,n,r,lr,wa1,wa2,wa3,sing) call r1mpyq(n,n,fjac,ldfjac,wa2,wa3) call r1mpyq(1,n,qtf,1,wa2,wa3) c c end of the inner loop. c jeval = .false. go to 180 290 continue c c end of the outer loop. c go to 30 300 continue c c termination, either normal or user imposed. c if (iflag .lt. 0) info = iflag iflag = 0 if (nprint .gt. 0) call fcn(n,x,fvec,fjac,ldfjac,iflag) return c c last card of subroutine hybrj. c end cminpack-1.3.4/fortran/hybrj1.f000644 000765 000765 00000010350 12225167750 016303 0ustar00devernay000000 000000 subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) integer n,ldfjac,info,lwa double precision tol double precision x(n),fvec(n),fjac(ldfjac,n),wa(lwa) external fcn c ********** c c subroutine hybrj1 c c the purpose of hybrj1 is to find a zero of a system of c n nonlinear functions in n variables by a modification c of the powell hybrid method. this is done by using the c more general nonlinear equation solver hybrj. the user c must provide a subroutine which calculates the functions c and the jacobian. c c the subroutine statement is c c subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the jacobian. fcn must c be declared in an external statement in the user c calling program, and should be written as follows. c c subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) c integer n,ldfjac,iflag c double precision x(n),fvec(n),fjac(ldfjac,n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. do not alter fjac. c if iflag = 2 calculate the jacobian at x and c return this matrix in fjac. do not alter fvec. c --------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of hybrj1. c in this case set iflag to a negative integer. c c n is a positive integer input variable set to the number c of functions and variables. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length n which contains c the functions evaluated at the output x. c c fjac is an output n by n array which contains the c orthogonal matrix q produced by the qr factorization c of the final approximate jacobian. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c tol is a nonnegative input variable. termination occurs c when the algorithm estimates that the relative error c between x and the solution is at most tol. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 algorithm estimates that the relative error c between x and the solution is at most tol. c c info = 2 number of calls to fcn with iflag = 1 has c reached 100*(n+1). c c info = 3 tol is too small. no further improvement in c the approximate solution x is possible. c c info = 4 iteration is not making good progress. c c wa is a work array of length lwa. c c lwa is a positive integer input variable not less than c (n*(n+13))/2. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... hybrj c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer j,lr,maxfev,mode,nfev,njev,nprint double precision factor,one,xtol,zero data factor,one,zero /1.0d2,1.0d0,0.0d0/ info = 0 c c check the input parameters for errors. c if (n .le. 0 .or. ldfjac .lt. n .or. tol .lt. zero * .or. lwa .lt. (n*(n + 13))/2) go to 20 c c call hybrj. c maxfev = 100*(n + 1) xtol = tol mode = 2 do 10 j = 1, n wa(j) = one 10 continue nprint = 0 lr = (n*(n + 1))/2 call hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,wa(1),mode, * factor,nprint,info,nfev,njev,wa(6*n+1),lr,wa(n+1), * wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1)) if (info .eq. 5) info = 4 20 continue return c c last card of subroutine hybrj1. c end cminpack-1.3.4/fortran/lmder.f000644 000765 000765 00000036123 12225167750 016215 0ustar00devernay000000 000000 subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, * maxfev,diag,mode,factor,nprint,info,nfev,njev, * ipvt,qtf,wa1,wa2,wa3,wa4) integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev integer ipvt(n) double precision ftol,xtol,gtol,factor double precision x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), * wa1(n),wa2(n),wa3(n),wa4(m) c ********** c c subroutine lmder c c the purpose of lmder is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of c the levenberg-marquardt algorithm. the user must provide a c subroutine which calculates the functions and the jacobian. c c the subroutine statement is c c subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, c maxfev,diag,mode,factor,nprint,info,nfev, c njev,ipvt,qtf,wa1,wa2,wa3,wa4) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the jacobian. fcn must c be declared in an external statement in the user c calling program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) c integer m,n,ldfjac,iflag c double precision x(n),fvec(m),fjac(ldfjac,n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. do not alter fjac. c if iflag = 2 calculate the jacobian at x and c return this matrix in fjac. do not alter fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmder. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c fjac is an output m by n array. the upper n by n submatrix c of fjac contains an upper triangular matrix r with c diagonal elements of nonincreasing magnitude such that c c t t t c p *(jac *jac)*p = r *r, c c where p is a permutation matrix and jac is the final c calculated jacobian. column j of p is column ipvt(j) c (see below) of the identity matrix. the lower trapezoidal c part of fjac contains information generated during c the computation of r. c c ldfjac is a positive integer input variable not less than m c which specifies the leading dimension of the array fjac. c c ftol is a nonnegative input variable. termination c occurs when both the actual and predicted relative c reductions in the sum of squares are at most ftol. c therefore, ftol measures the relative error desired c in the sum of squares. c c xtol is a nonnegative input variable. termination c occurs when the relative error between two consecutive c iterates is at most xtol. therefore, xtol measures the c relative error desired in the approximate solution. c c gtol is a nonnegative input variable. termination c occurs when the cosine of the angle between fvec and c any column of the jacobian is at most gtol in absolute c value. therefore, gtol measures the orthogonality c desired between the function vector and the columns c of the jacobian. c c maxfev is a positive integer input variable. termination c occurs when the number of calls to fcn with iflag = 1 c has reached maxfev. c c diag is an array of length n. if mode = 1 (see c below), diag is internally set. if mode = 2, diag c must contain positive entries that serve as c multiplicative scale factors for the variables. c c mode is an integer input variable. if mode = 1, the c variables will be scaled internally. if mode = 2, c the scaling is specified by the input diag. other c values of mode are equivalent to mode = 1. c c factor is a positive input variable used in determining the c initial step bound. this bound is set to the product of c factor and the euclidean norm of diag*x if nonzero, or else c to factor itself. in most cases factor should lie in the c interval (.1,100.).100. is a generally recommended value. c c nprint is an integer input variable that enables controlled c printing of iterates if it is positive. in this case, c fcn is called with iflag = 0 at the beginning of the first c iteration and every nprint iterations thereafter and c immediately prior to return, with x, fvec, and fjac c available for printing. fvec and fjac should not be c altered. if nprint is not positive, no special calls c of fcn with iflag = 0 are made. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 both actual and predicted relative reductions c in the sum of squares are at most ftol. c c info = 2 relative error between two consecutive iterates c is at most xtol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 the cosine of the angle between fvec and any c column of the jacobian is at most gtol in c absolute value. c c info = 5 number of calls to fcn with iflag = 1 has c reached maxfev. c c info = 6 ftol is too small. no further reduction in c the sum of squares is possible. c c info = 7 xtol is too small. no further improvement in c the approximate solution x is possible. c c info = 8 gtol is too small. fvec is orthogonal to the c columns of the jacobian to machine precision. c c nfev is an integer output variable set to the number of c calls to fcn with iflag = 1. c c njev is an integer output variable set to the number of c calls to fcn with iflag = 2. c c ipvt is an integer output array of length n. ipvt c defines a permutation matrix p such that jac*p = q*r, c where jac is the final calculated jacobian, q is c orthogonal (not stored), and r is upper triangular c with diagonal elements of nonincreasing magnitude. c column j of p is column ipvt(j) of the identity matrix. c c qtf is an output array of length n which contains c the first n elements of the vector (q transpose)*fvec. c c wa1, wa2, and wa3 are work arrays of length n. c c wa4 is a work array of length m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,lmpar,qrfac c c fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iflag,iter,j,l double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm, * one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio, * sum,temp,temp1,temp2,xnorm,zero double precision dpmpar,enorm data one,p1,p5,p25,p75,p0001,zero * /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c info = 0 iflag = 0 nfev = 0 njev = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m * .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero * .or. maxfev .le. 0 .or. factor .le. zero) go to 300 if (mode .ne. 2) go to 20 do 10 j = 1, n if (diag(j) .le. zero) go to 300 10 continue 20 continue c c evaluate the function at the starting point c and calculate its norm. c iflag = 1 call fcn(m,n,x,fvec,fjac,ldfjac,iflag) nfev = 1 if (iflag .lt. 0) go to 300 fnorm = enorm(m,fvec) c c initialize levenberg-marquardt parameter and iteration counter. c par = zero iter = 1 c c beginning of the outer loop. c 30 continue c c calculate the jacobian matrix. c iflag = 2 call fcn(m,n,x,fvec,fjac,ldfjac,iflag) njev = njev + 1 if (iflag .lt. 0) go to 300 c c if requested, call fcn to enable printing of iterates. c if (nprint .le. 0) go to 40 iflag = 0 if (mod(iter-1,nprint) .eq. 0) * call fcn(m,n,x,fvec,fjac,ldfjac,iflag) if (iflag .lt. 0) go to 300 40 continue c c compute the qr factorization of the jacobian. c call qrfac(m,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3) c c on the first iteration and if mode is 1, scale according c to the norms of the columns of the initial jacobian. c if (iter .ne. 1) go to 80 if (mode .eq. 2) go to 60 do 50 j = 1, n diag(j) = wa2(j) if (wa2(j) .eq. zero) diag(j) = one 50 continue 60 continue c c on the first iteration, calculate the norm of the scaled x c and initialize the step bound delta. c do 70 j = 1, n wa3(j) = diag(j)*x(j) 70 continue xnorm = enorm(n,wa3) delta = factor*xnorm if (delta .eq. zero) delta = factor 80 continue c c form (q transpose)*fvec and store the first n components in c qtf. c do 90 i = 1, m wa4(i) = fvec(i) 90 continue do 130 j = 1, n if (fjac(j,j) .eq. zero) go to 120 sum = zero do 100 i = j, m sum = sum + fjac(i,j)*wa4(i) 100 continue temp = -sum/fjac(j,j) do 110 i = j, m wa4(i) = wa4(i) + fjac(i,j)*temp 110 continue 120 continue fjac(j,j) = wa1(j) qtf(j) = wa4(j) 130 continue c c compute the norm of the scaled gradient. c gnorm = zero if (fnorm .eq. zero) go to 170 do 160 j = 1, n l = ipvt(j) if (wa2(l) .eq. zero) go to 150 sum = zero do 140 i = 1, j sum = sum + fjac(i,j)*(qtf(i)/fnorm) 140 continue gnorm = dmax1(gnorm,dabs(sum/wa2(l))) 150 continue 160 continue 170 continue c c test for convergence of the gradient norm. c if (gnorm .le. gtol) info = 4 if (info .ne. 0) go to 300 c c rescale if necessary. c if (mode .eq. 2) go to 190 do 180 j = 1, n diag(j) = dmax1(diag(j),wa2(j)) 180 continue 190 continue c c beginning of the inner loop. c 200 continue c c determine the levenberg-marquardt parameter. c call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2, * wa3,wa4) c c store the direction p and x + p. calculate the norm of p. c do 210 j = 1, n wa1(j) = -wa1(j) wa2(j) = x(j) + wa1(j) wa3(j) = diag(j)*wa1(j) 210 continue pnorm = enorm(n,wa3) c c on the first iteration, adjust the initial step bound. c if (iter .eq. 1) delta = dmin1(delta,pnorm) c c evaluate the function at x + p and calculate its norm. c iflag = 1 call fcn(m,n,wa2,wa4,fjac,ldfjac,iflag) nfev = nfev + 1 if (iflag .lt. 0) go to 300 fnorm1 = enorm(m,wa4) c c compute the scaled actual reduction. c actred = -one if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2 c c compute the scaled predicted reduction and c the scaled directional derivative. c do 230 j = 1, n wa3(j) = zero l = ipvt(j) temp = wa1(l) do 220 i = 1, j wa3(i) = wa3(i) + fjac(i,j)*temp 220 continue 230 continue temp1 = enorm(n,wa3)/fnorm temp2 = (dsqrt(par)*pnorm)/fnorm prered = temp1**2 + temp2**2/p5 dirder = -(temp1**2 + temp2**2) c c compute the ratio of the actual to the predicted c reduction. c ratio = zero if (prered .ne. zero) ratio = actred/prered c c update the step bound. c if (ratio .gt. p25) go to 240 if (actred .ge. zero) temp = p5 if (actred .lt. zero) * temp = p5*dirder/(dirder + p5*actred) if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1 delta = temp*dmin1(delta,pnorm/p1) par = par/temp go to 260 240 continue if (par .ne. zero .and. ratio .lt. p75) go to 250 delta = pnorm/p5 par = p5*par 250 continue 260 continue c c test for successful iteration. c if (ratio .lt. p0001) go to 290 c c successful iteration. update x, fvec, and their norms. c do 270 j = 1, n x(j) = wa2(j) wa2(j) = diag(j)*x(j) 270 continue do 280 i = 1, m fvec(i) = wa4(i) 280 continue xnorm = enorm(n,wa2) fnorm = fnorm1 iter = iter + 1 290 continue c c tests for convergence. c if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one) info = 1 if (delta .le. xtol*xnorm) info = 2 if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one .and. info .eq. 2) info = 3 if (info .ne. 0) go to 300 c c tests for termination and stringent tolerances. c if (nfev .ge. maxfev) info = 5 if (dabs(actred) .le. epsmch .and. prered .le. epsmch * .and. p5*ratio .le. one) info = 6 if (delta .le. epsmch*xnorm) info = 7 if (gnorm .le. epsmch) info = 8 if (info .ne. 0) go to 300 c c end of the inner loop. repeat if iteration unsuccessful. c if (ratio .lt. p0001) go to 200 c c end of the outer loop. c go to 30 300 continue c c termination, either normal or user imposed. c if (iflag .lt. 0) info = iflag iflag = 0 if (nprint .gt. 0) call fcn(m,n,x,fvec,fjac,ldfjac,iflag) return c c last card of subroutine lmder. c end cminpack-1.3.4/fortran/lmder1.f000644 000765 000765 00000013052 12225167750 016272 0ustar00devernay000000 000000 subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, * lwa) integer m,n,ldfjac,info,lwa integer ipvt(n) double precision tol double precision x(n),fvec(m),fjac(ldfjac,n),wa(lwa) external fcn c ********** c c subroutine lmder1 c c the purpose of lmder1 is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of the c levenberg-marquardt algorithm. this is done by using the more c general least-squares solver lmder. the user must provide a c subroutine which calculates the functions and the jacobian. c c the subroutine statement is c c subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, c ipvt,wa,lwa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the jacobian. fcn must c be declared in an external statement in the user c calling program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) c integer m,n,ldfjac,iflag c double precision x(n),fvec(m),fjac(ldfjac,n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. do not alter fjac. c if iflag = 2 calculate the jacobian at x and c return this matrix in fjac. do not alter fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmder1. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c fjac is an output m by n array. the upper n by n submatrix c of fjac contains an upper triangular matrix r with c diagonal elements of nonincreasing magnitude such that c c t t t c p *(jac *jac)*p = r *r, c c where p is a permutation matrix and jac is the final c calculated jacobian. column j of p is column ipvt(j) c (see below) of the identity matrix. the lower trapezoidal c part of fjac contains information generated during c the computation of r. c c ldfjac is a positive integer input variable not less than m c which specifies the leading dimension of the array fjac. c c tol is a nonnegative input variable. termination occurs c when the algorithm estimates either that the relative c error in the sum of squares is at most tol or that c the relative error between x and the solution is at c most tol. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 algorithm estimates that the relative error c in the sum of squares is at most tol. c c info = 2 algorithm estimates that the relative error c between x and the solution is at most tol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 fvec is orthogonal to the columns of the c jacobian to machine precision. c c info = 5 number of calls to fcn with iflag = 1 has c reached 100*(n+1). c c info = 6 tol is too small. no further reduction in c the sum of squares is possible. c c info = 7 tol is too small. no further improvement in c the approximate solution x is possible. c c ipvt is an integer output array of length n. ipvt c defines a permutation matrix p such that jac*p = q*r, c where jac is the final calculated jacobian, q is c orthogonal (not stored), and r is upper triangular c with diagonal elements of nonincreasing magnitude. c column j of p is column ipvt(j) of the identity matrix. c c wa is a work array of length lwa. c c lwa is a positive integer input variable not less than 5*n+m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... lmder c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer maxfev,mode,nfev,njev,nprint double precision factor,ftol,gtol,xtol,zero data factor,zero /1.0d2,0.0d0/ info = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m .or. tol .lt. zero * .or. lwa .lt. 5*n + m) go to 10 c c call lmder. c maxfev = 100*(n + 1) ftol = tol xtol = tol gtol = zero mode = 1 nprint = 0 call lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,maxfev, * wa(1),mode,factor,nprint,info,nfev,njev,ipvt,wa(n+1), * wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1)) if (info .eq. 8) info = 4 10 continue return c c last card of subroutine lmder1. c end cminpack-1.3.4/fortran/lmdif.f000644 000765 000765 00000036270 12225167750 016210 0ustar00devernay000000 000000 subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, * diag,mode,factor,nprint,info,nfev,fjac,ldfjac, * ipvt,qtf,wa1,wa2,wa3,wa4) integer m,n,maxfev,mode,nprint,info,nfev,ldfjac integer ipvt(n) double precision ftol,xtol,gtol,epsfcn,factor double precision x(n),fvec(m),diag(n),fjac(ldfjac,n),qtf(n), * wa1(n),wa2(n),wa3(n),wa4(m) external fcn c ********** c c subroutine lmdif c c the purpose of lmdif is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of c the levenberg-marquardt algorithm. the user must provide a c subroutine which calculates the functions. the jacobian is c then calculated by a forward-difference approximation. c c the subroutine statement is c c subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, c diag,mode,factor,nprint,info,nfev,fjac, c ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,iflag) c integer m,n,iflag c double precision x(n),fvec(m) c ---------- c calculate the functions at x and c return this vector in fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmdif. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c ftol is a nonnegative input variable. termination c occurs when both the actual and predicted relative c reductions in the sum of squares are at most ftol. c therefore, ftol measures the relative error desired c in the sum of squares. c c xtol is a nonnegative input variable. termination c occurs when the relative error between two consecutive c iterates is at most xtol. therefore, xtol measures the c relative error desired in the approximate solution. c c gtol is a nonnegative input variable. termination c occurs when the cosine of the angle between fvec and c any column of the jacobian is at most gtol in absolute c value. therefore, gtol measures the orthogonality c desired between the function vector and the columns c of the jacobian. c c maxfev is a positive integer input variable. termination c occurs when the number of calls to fcn is at least c maxfev by the end of an iteration. c c epsfcn is an input variable used in determining a suitable c step length for the forward-difference approximation. this c approximation assumes that the relative errors in the c functions are of the order of epsfcn. if epsfcn is less c than the machine precision, it is assumed that the relative c errors in the functions are of the order of the machine c precision. c c diag is an array of length n. if mode = 1 (see c below), diag is internally set. if mode = 2, diag c must contain positive entries that serve as c multiplicative scale factors for the variables. c c mode is an integer input variable. if mode = 1, the c variables will be scaled internally. if mode = 2, c the scaling is specified by the input diag. other c values of mode are equivalent to mode = 1. c c factor is a positive input variable used in determining the c initial step bound. this bound is set to the product of c factor and the euclidean norm of diag*x if nonzero, or else c to factor itself. in most cases factor should lie in the c interval (.1,100.). 100. is a generally recommended value. c c nprint is an integer input variable that enables controlled c printing of iterates if it is positive. in this case, c fcn is called with iflag = 0 at the beginning of the first c iteration and every nprint iterations thereafter and c immediately prior to return, with x and fvec available c for printing. if nprint is not positive, no special calls c of fcn with iflag = 0 are made. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 both actual and predicted relative reductions c in the sum of squares are at most ftol. c c info = 2 relative error between two consecutive iterates c is at most xtol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 the cosine of the angle between fvec and any c column of the jacobian is at most gtol in c absolute value. c c info = 5 number of calls to fcn has reached or c exceeded maxfev. c c info = 6 ftol is too small. no further reduction in c the sum of squares is possible. c c info = 7 xtol is too small. no further improvement in c the approximate solution x is possible. c c info = 8 gtol is too small. fvec is orthogonal to the c columns of the jacobian to machine precision. c c nfev is an integer output variable set to the number of c calls to fcn. c c fjac is an output m by n array. the upper n by n submatrix c of fjac contains an upper triangular matrix r with c diagonal elements of nonincreasing magnitude such that c c t t t c p *(jac *jac)*p = r *r, c c where p is a permutation matrix and jac is the final c calculated jacobian. column j of p is column ipvt(j) c (see below) of the identity matrix. the lower trapezoidal c part of fjac contains information generated during c the computation of r. c c ldfjac is a positive integer input variable not less than m c which specifies the leading dimension of the array fjac. c c ipvt is an integer output array of length n. ipvt c defines a permutation matrix p such that jac*p = q*r, c where jac is the final calculated jacobian, q is c orthogonal (not stored), and r is upper triangular c with diagonal elements of nonincreasing magnitude. c column j of p is column ipvt(j) of the identity matrix. c c qtf is an output array of length n which contains c the first n elements of the vector (q transpose)*fvec. c c wa1, wa2, and wa3 are work arrays of length n. c c wa4 is a work array of length m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac c c fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iflag,iter,j,l double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm, * one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio, * sum,temp,temp1,temp2,xnorm,zero double precision dpmpar,enorm data one,p1,p5,p25,p75,p0001,zero * /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c info = 0 iflag = 0 nfev = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m * .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero * .or. maxfev .le. 0 .or. factor .le. zero) go to 300 if (mode .ne. 2) go to 20 do 10 j = 1, n if (diag(j) .le. zero) go to 300 10 continue 20 continue c c evaluate the function at the starting point c and calculate its norm. c iflag = 1 call fcn(m,n,x,fvec,iflag) nfev = 1 if (iflag .lt. 0) go to 300 fnorm = enorm(m,fvec) c c initialize levenberg-marquardt parameter and iteration counter. c par = zero iter = 1 c c beginning of the outer loop. c 30 continue c c calculate the jacobian matrix. c iflag = 2 call fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa4) nfev = nfev + n if (iflag .lt. 0) go to 300 c c if requested, call fcn to enable printing of iterates. c if (nprint .le. 0) go to 40 iflag = 0 if (mod(iter-1,nprint) .eq. 0) call fcn(m,n,x,fvec,iflag) if (iflag .lt. 0) go to 300 40 continue c c compute the qr factorization of the jacobian. c call qrfac(m,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3) c c on the first iteration and if mode is 1, scale according c to the norms of the columns of the initial jacobian. c if (iter .ne. 1) go to 80 if (mode .eq. 2) go to 60 do 50 j = 1, n diag(j) = wa2(j) if (wa2(j) .eq. zero) diag(j) = one 50 continue 60 continue c c on the first iteration, calculate the norm of the scaled x c and initialize the step bound delta. c do 70 j = 1, n wa3(j) = diag(j)*x(j) 70 continue xnorm = enorm(n,wa3) delta = factor*xnorm if (delta .eq. zero) delta = factor 80 continue c c form (q transpose)*fvec and store the first n components in c qtf. c do 90 i = 1, m wa4(i) = fvec(i) 90 continue do 130 j = 1, n if (fjac(j,j) .eq. zero) go to 120 sum = zero do 100 i = j, m sum = sum + fjac(i,j)*wa4(i) 100 continue temp = -sum/fjac(j,j) do 110 i = j, m wa4(i) = wa4(i) + fjac(i,j)*temp 110 continue 120 continue fjac(j,j) = wa1(j) qtf(j) = wa4(j) 130 continue c c compute the norm of the scaled gradient. c gnorm = zero if (fnorm .eq. zero) go to 170 do 160 j = 1, n l = ipvt(j) if (wa2(l) .eq. zero) go to 150 sum = zero do 140 i = 1, j sum = sum + fjac(i,j)*(qtf(i)/fnorm) 140 continue gnorm = dmax1(gnorm,dabs(sum/wa2(l))) 150 continue 160 continue 170 continue c c test for convergence of the gradient norm. c if (gnorm .le. gtol) info = 4 if (info .ne. 0) go to 300 c c rescale if necessary. c if (mode .eq. 2) go to 190 do 180 j = 1, n diag(j) = dmax1(diag(j),wa2(j)) 180 continue 190 continue c c beginning of the inner loop. c 200 continue c c determine the levenberg-marquardt parameter. c call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2, * wa3,wa4) c c store the direction p and x + p. calculate the norm of p. c do 210 j = 1, n wa1(j) = -wa1(j) wa2(j) = x(j) + wa1(j) wa3(j) = diag(j)*wa1(j) 210 continue pnorm = enorm(n,wa3) c c on the first iteration, adjust the initial step bound. c if (iter .eq. 1) delta = dmin1(delta,pnorm) c c evaluate the function at x + p and calculate its norm. c iflag = 1 call fcn(m,n,wa2,wa4,iflag) nfev = nfev + 1 if (iflag .lt. 0) go to 300 fnorm1 = enorm(m,wa4) c c compute the scaled actual reduction. c actred = -one if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2 c c compute the scaled predicted reduction and c the scaled directional derivative. c do 230 j = 1, n wa3(j) = zero l = ipvt(j) temp = wa1(l) do 220 i = 1, j wa3(i) = wa3(i) + fjac(i,j)*temp 220 continue 230 continue temp1 = enorm(n,wa3)/fnorm temp2 = (dsqrt(par)*pnorm)/fnorm prered = temp1**2 + temp2**2/p5 dirder = -(temp1**2 + temp2**2) c c compute the ratio of the actual to the predicted c reduction. c ratio = zero if (prered .ne. zero) ratio = actred/prered c c update the step bound. c if (ratio .gt. p25) go to 240 if (actred .ge. zero) temp = p5 if (actred .lt. zero) * temp = p5*dirder/(dirder + p5*actred) if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1 delta = temp*dmin1(delta,pnorm/p1) par = par/temp go to 260 240 continue if (par .ne. zero .and. ratio .lt. p75) go to 250 delta = pnorm/p5 par = p5*par 250 continue 260 continue c c test for successful iteration. c if (ratio .lt. p0001) go to 290 c c successful iteration. update x, fvec, and their norms. c do 270 j = 1, n x(j) = wa2(j) wa2(j) = diag(j)*x(j) 270 continue do 280 i = 1, m fvec(i) = wa4(i) 280 continue xnorm = enorm(n,wa2) fnorm = fnorm1 iter = iter + 1 290 continue c c tests for convergence. c if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one) info = 1 if (delta .le. xtol*xnorm) info = 2 if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one .and. info .eq. 2) info = 3 if (info .ne. 0) go to 300 c c tests for termination and stringent tolerances. c if (nfev .ge. maxfev) info = 5 if (dabs(actred) .le. epsmch .and. prered .le. epsmch * .and. p5*ratio .le. one) info = 6 if (delta .le. epsmch*xnorm) info = 7 if (gnorm .le. epsmch) info = 8 if (info .ne. 0) go to 300 c c end of the inner loop. repeat if iteration unsuccessful. c if (ratio .lt. p0001) go to 200 c c end of the outer loop. c go to 30 300 continue c c termination, either normal or user imposed. c if (iflag .lt. 0) info = iflag iflag = 0 if (nprint .gt. 0) call fcn(m,n,x,fvec,iflag) return c c last card of subroutine lmdif. c end cminpack-1.3.4/fortran/lmdif1.f000644 000765 000765 00000010563 12225167750 016266 0ustar00devernay000000 000000 subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) integer m,n,info,lwa integer iwa(n) double precision tol double precision x(n),fvec(m),wa(lwa) external fcn c ********** c c subroutine lmdif1 c c the purpose of lmdif1 is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of the c levenberg-marquardt algorithm. this is done by using the more c general least-squares solver lmdif. the user must provide a c subroutine which calculates the functions. the jacobian is c then calculated by a forward-difference approximation. c c the subroutine statement is c c subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions. fcn must be declared c in an external statement in the user calling c program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,iflag) c integer m,n,iflag c double precision x(n),fvec(m) c ---------- c calculate the functions at x and c return this vector in fvec. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmdif1. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c tol is a nonnegative input variable. termination occurs c when the algorithm estimates either that the relative c error in the sum of squares is at most tol or that c the relative error between x and the solution is at c most tol. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 algorithm estimates that the relative error c in the sum of squares is at most tol. c c info = 2 algorithm estimates that the relative error c between x and the solution is at most tol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 fvec is orthogonal to the columns of the c jacobian to machine precision. c c info = 5 number of calls to fcn has reached or c exceeded 200*(n+1). c c info = 6 tol is too small. no further reduction in c the sum of squares is possible. c c info = 7 tol is too small. no further improvement in c the approximate solution x is possible. c c iwa is an integer work array of length n. c c wa is a work array of length lwa. c c lwa is a positive integer input variable not less than c m*n+5*n+m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... lmdif c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer maxfev,mode,mp5n,nfev,nprint double precision epsfcn,factor,ftol,gtol,xtol,zero data factor,zero /1.0d2,0.0d0/ info = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. tol .lt. zero * .or. lwa .lt. m*n + 5*n + m) go to 10 c c call lmdif. c maxfev = 200*(n + 1) ftol = tol xtol = tol gtol = zero epsfcn = zero mode = 1 nprint = 0 mp5n = m + 5*n call lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,wa(1), * mode,factor,nprint,info,nfev,wa(mp5n+1),m,iwa, * wa(n+1),wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1)) if (info .eq. 8) info = 4 10 continue return c c last card of subroutine lmdif1. c end cminpack-1.3.4/fortran/lmpar.f000644 000765 000765 00000020063 12225167750 016221 0ustar00devernay000000 000000 subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1, * wa2) integer n,ldr integer ipvt(n) double precision delta,par double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa1(n), * wa2(n) c ********** c c subroutine lmpar c c given an m by n matrix a, an n by n nonsingular diagonal c matrix d, an m-vector b, and a positive number delta, c the problem is to determine a value for the parameter c par such that if x solves the system c c a*x = b , sqrt(par)*d*x = 0 , c c in the least squares sense, and dxnorm is the euclidean c norm of d*x, then either par is zero and c c (dxnorm-delta) .le. 0.1*delta , c c or par is positive and c c abs(dxnorm-delta) .le. 0.1*delta . c c this subroutine completes the solution of the problem c if it is provided with the necessary information from the c qr factorization, with column pivoting, of a. that is, if c a*p = q*r, where p is a permutation matrix, q has orthogonal c columns, and r is an upper triangular matrix with diagonal c elements of nonincreasing magnitude, then lmpar expects c the full upper triangle of r, the permutation matrix p, c and the first n components of (q transpose)*b. on output c lmpar also provides an upper triangular matrix s such that c c t t t c p *(a *a + par*d*d)*p = s *s . c c s is employed within lmpar and may be of separate interest. c c only a few iterations are generally needed for convergence c of the algorithm. if, however, the limit of 10 iterations c is reached, then the output par will contain the best c value obtained so far. c c the subroutine statement is c c subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag, c wa1,wa2) c c where c c n is a positive integer input variable set to the order of r. c c r is an n by n array. on input the full upper triangle c must contain the full upper triangle of the matrix r. c on output the full upper triangle is unaltered, and the c strict lower triangle contains the strict upper triangle c (transposed) of the upper triangular matrix s. c c ldr is a positive integer input variable not less than n c which specifies the leading dimension of the array r. c c ipvt is an integer input array of length n which defines the c permutation matrix p such that a*p = q*r. column j of p c is column ipvt(j) of the identity matrix. c c diag is an input array of length n which must contain the c diagonal elements of the matrix d. c c qtb is an input array of length n which must contain the first c n elements of the vector (q transpose)*b. c c delta is a positive input variable which specifies an upper c bound on the euclidean norm of d*x. c c par is a nonnegative variable. on input par contains an c initial estimate of the levenberg-marquardt parameter. c on output par contains the final estimate. c c x is an output array of length n which contains the least c squares solution of the system a*x = b, sqrt(par)*d*x = 0, c for the output par. c c sdiag is an output array of length n which contains the c diagonal elements of the upper triangular matrix s. c c wa1 and wa2 are work arrays of length n. c c subprograms called c c minpack-supplied ... dpmpar,enorm,qrsolv c c fortran-supplied ... dabs,dmax1,dmin1,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iter,j,jm1,jp1,k,l,nsing double precision dxnorm,dwarf,fp,gnorm,parc,parl,paru,p1,p001, * sum,temp,zero double precision dpmpar,enorm data p1,p001,zero /1.0d-1,1.0d-3,0.0d0/ c c dwarf is the smallest positive magnitude. c dwarf = dpmpar(2) c c compute and store in x the gauss-newton direction. if the c jacobian is rank-deficient, obtain a least squares solution. c nsing = n do 10 j = 1, n wa1(j) = qtb(j) if (r(j,j) .eq. zero .and. nsing .eq. n) nsing = j - 1 if (nsing .lt. n) wa1(j) = zero 10 continue if (nsing .lt. 1) go to 50 do 40 k = 1, nsing j = nsing - k + 1 wa1(j) = wa1(j)/r(j,j) temp = wa1(j) jm1 = j - 1 if (jm1 .lt. 1) go to 30 do 20 i = 1, jm1 wa1(i) = wa1(i) - r(i,j)*temp 20 continue 30 continue 40 continue 50 continue do 60 j = 1, n l = ipvt(j) x(l) = wa1(j) 60 continue c c initialize the iteration counter. c evaluate the function at the origin, and test c for acceptance of the gauss-newton direction. c iter = 0 do 70 j = 1, n wa2(j) = diag(j)*x(j) 70 continue dxnorm = enorm(n,wa2) fp = dxnorm - delta if (fp .le. p1*delta) go to 220 c c if the jacobian is not rank deficient, the newton c step provides a lower bound, parl, for the zero of c the function. otherwise set this bound to zero. c parl = zero if (nsing .lt. n) go to 120 do 80 j = 1, n l = ipvt(j) wa1(j) = diag(l)*(wa2(l)/dxnorm) 80 continue do 110 j = 1, n sum = zero jm1 = j - 1 if (jm1 .lt. 1) go to 100 do 90 i = 1, jm1 sum = sum + r(i,j)*wa1(i) 90 continue 100 continue wa1(j) = (wa1(j) - sum)/r(j,j) 110 continue temp = enorm(n,wa1) parl = ((fp/delta)/temp)/temp 120 continue c c calculate an upper bound, paru, for the zero of the function. c do 140 j = 1, n sum = zero do 130 i = 1, j sum = sum + r(i,j)*qtb(i) 130 continue l = ipvt(j) wa1(j) = sum/diag(l) 140 continue gnorm = enorm(n,wa1) paru = gnorm/delta if (paru .eq. zero) paru = dwarf/dmin1(delta,p1) c c if the input par lies outside of the interval (parl,paru), c set par to the closer endpoint. c par = dmax1(par,parl) par = dmin1(par,paru) if (par .eq. zero) par = gnorm/dxnorm c c beginning of an iteration. c 150 continue iter = iter + 1 c c evaluate the function at the current value of par. c if (par .eq. zero) par = dmax1(dwarf,p001*paru) temp = dsqrt(par) do 160 j = 1, n wa1(j) = temp*diag(j) 160 continue call qrsolv(n,r,ldr,ipvt,wa1,qtb,x,sdiag,wa2) do 170 j = 1, n wa2(j) = diag(j)*x(j) 170 continue dxnorm = enorm(n,wa2) temp = fp fp = dxnorm - delta c c if the function is small enough, accept the current value c of par. also test for the exceptional cases where parl c is zero or the number of iterations has reached 10. c if (dabs(fp) .le. p1*delta * .or. parl .eq. zero .and. fp .le. temp * .and. temp .lt. zero .or. iter .eq. 10) go to 220 c c compute the newton correction. c do 180 j = 1, n l = ipvt(j) wa1(j) = diag(l)*(wa2(l)/dxnorm) 180 continue do 210 j = 1, n wa1(j) = wa1(j)/sdiag(j) temp = wa1(j) jp1 = j + 1 if (n .lt. jp1) go to 200 do 190 i = jp1, n wa1(i) = wa1(i) - r(i,j)*temp 190 continue 200 continue 210 continue temp = enorm(n,wa1) parc = ((fp/delta)/temp)/temp c c depending on the sign of the function, update parl or paru. c if (fp .gt. zero) parl = dmax1(parl,par) if (fp .lt. zero) paru = dmin1(paru,par) c c compute an improved estimate for par. c par = dmax1(parl,par+parc) c c end of an iteration. c go to 150 220 continue c c termination. c if (iter .eq. 0) par = zero return c c last card of subroutine lmpar. c end cminpack-1.3.4/fortran/lmstr.f000644 000765 000765 00000037022 12225167750 016252 0ustar00devernay000000 000000 subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, * maxfev,diag,mode,factor,nprint,info,nfev,njev, * ipvt,qtf,wa1,wa2,wa3,wa4) integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev integer ipvt(n) logical sing double precision ftol,xtol,gtol,factor double precision x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), * wa1(n),wa2(n),wa3(n),wa4(m) c ********** c c subroutine lmstr c c the purpose of lmstr is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of c the levenberg-marquardt algorithm which uses minimal storage. c the user must provide a subroutine which calculates the c functions and the rows of the jacobian. c c the subroutine statement is c c subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, c maxfev,diag,mode,factor,nprint,info,nfev, c njev,ipvt,qtf,wa1,wa2,wa3,wa4) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the rows of the jacobian. c fcn must be declared in an external statement in the c user calling program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,fjrow,iflag) c integer m,n,iflag c double precision x(n),fvec(m),fjrow(n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. c if iflag = i calculate the (i-1)-st row of the c jacobian at x and return this vector in fjrow. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmstr. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c fjac is an output n by n array. the upper triangle of fjac c contains an upper triangular matrix r such that c c t t t c p *(jac *jac)*p = r *r, c c where p is a permutation matrix and jac is the final c calculated jacobian. column j of p is column ipvt(j) c (see below) of the identity matrix. the lower triangular c part of fjac contains information generated during c the computation of r. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c ftol is a nonnegative input variable. termination c occurs when both the actual and predicted relative c reductions in the sum of squares are at most ftol. c therefore, ftol measures the relative error desired c in the sum of squares. c c xtol is a nonnegative input variable. termination c occurs when the relative error between two consecutive c iterates is at most xtol. therefore, xtol measures the c relative error desired in the approximate solution. c c gtol is a nonnegative input variable. termination c occurs when the cosine of the angle between fvec and c any column of the jacobian is at most gtol in absolute c value. therefore, gtol measures the orthogonality c desired between the function vector and the columns c of the jacobian. c c maxfev is a positive integer input variable. termination c occurs when the number of calls to fcn with iflag = 1 c has reached maxfev. c c diag is an array of length n. if mode = 1 (see c below), diag is internally set. if mode = 2, diag c must contain positive entries that serve as c multiplicative scale factors for the variables. c c mode is an integer input variable. if mode = 1, the c variables will be scaled internally. if mode = 2, c the scaling is specified by the input diag. other c values of mode are equivalent to mode = 1. c c factor is a positive input variable used in determining the c initial step bound. this bound is set to the product of c factor and the euclidean norm of diag*x if nonzero, or else c to factor itself. in most cases factor should lie in the c interval (.1,100.). 100. is a generally recommended value. c c nprint is an integer input variable that enables controlled c printing of iterates if it is positive. in this case, c fcn is called with iflag = 0 at the beginning of the first c iteration and every nprint iterations thereafter and c immediately prior to return, with x and fvec available c for printing. if nprint is not positive, no special calls c of fcn with iflag = 0 are made. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 both actual and predicted relative reductions c in the sum of squares are at most ftol. c c info = 2 relative error between two consecutive iterates c is at most xtol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 the cosine of the angle between fvec and any c column of the jacobian is at most gtol in c absolute value. c c info = 5 number of calls to fcn with iflag = 1 has c reached maxfev. c c info = 6 ftol is too small. no further reduction in c the sum of squares is possible. c c info = 7 xtol is too small. no further improvement in c the approximate solution x is possible. c c info = 8 gtol is too small. fvec is orthogonal to the c columns of the jacobian to machine precision. c c nfev is an integer output variable set to the number of c calls to fcn with iflag = 1. c c njev is an integer output variable set to the number of c calls to fcn with iflag = 2. c c ipvt is an integer output array of length n. ipvt c defines a permutation matrix p such that jac*p = q*r, c where jac is the final calculated jacobian, q is c orthogonal (not stored), and r is upper triangular. c column j of p is column ipvt(j) of the identity matrix. c c qtf is an output array of length n which contains c the first n elements of the vector (q transpose)*fvec. c c wa1, wa2, and wa3 are work arrays of length n. c c wa4 is a work array of length m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt c c fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, c jorge j. more c c ********** integer i,iflag,iter,j,l double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm, * one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio, * sum,temp,temp1,temp2,xnorm,zero double precision dpmpar,enorm data one,p1,p5,p25,p75,p0001,zero * /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c info = 0 iflag = 0 nfev = 0 njev = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. n * .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero * .or. maxfev .le. 0 .or. factor .le. zero) go to 340 if (mode .ne. 2) go to 20 do 10 j = 1, n if (diag(j) .le. zero) go to 340 10 continue 20 continue c c evaluate the function at the starting point c and calculate its norm. c iflag = 1 call fcn(m,n,x,fvec,wa3,iflag) nfev = 1 if (iflag .lt. 0) go to 340 fnorm = enorm(m,fvec) c c initialize levenberg-marquardt parameter and iteration counter. c par = zero iter = 1 c c beginning of the outer loop. c 30 continue c c if requested, call fcn to enable printing of iterates. c if (nprint .le. 0) go to 40 iflag = 0 if (mod(iter-1,nprint) .eq. 0) call fcn(m,n,x,fvec,wa3,iflag) if (iflag .lt. 0) go to 340 40 continue c c compute the qr factorization of the jacobian matrix c calculated one row at a time, while simultaneously c forming (q transpose)*fvec and storing the first c n components in qtf. c do 60 j = 1, n qtf(j) = zero do 50 i = 1, n fjac(i,j) = zero 50 continue 60 continue iflag = 2 do 70 i = 1, m call fcn(m,n,x,fvec,wa3,iflag) if (iflag .lt. 0) go to 340 temp = fvec(i) call rwupdt(n,fjac,ldfjac,wa3,qtf,temp,wa1,wa2) iflag = iflag + 1 70 continue njev = njev + 1 c c if the jacobian is rank deficient, call qrfac to c reorder its columns and update the components of qtf. c sing = .false. do 80 j = 1, n if (fjac(j,j) .eq. zero) sing = .true. ipvt(j) = j wa2(j) = enorm(j,fjac(1,j)) 80 continue if (.not.sing) go to 130 call qrfac(n,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3) do 120 j = 1, n if (fjac(j,j) .eq. zero) go to 110 sum = zero do 90 i = j, n sum = sum + fjac(i,j)*qtf(i) 90 continue temp = -sum/fjac(j,j) do 100 i = j, n qtf(i) = qtf(i) + fjac(i,j)*temp 100 continue 110 continue fjac(j,j) = wa1(j) 120 continue 130 continue c c on the first iteration and if mode is 1, scale according c to the norms of the columns of the initial jacobian. c if (iter .ne. 1) go to 170 if (mode .eq. 2) go to 150 do 140 j = 1, n diag(j) = wa2(j) if (wa2(j) .eq. zero) diag(j) = one 140 continue 150 continue c c on the first iteration, calculate the norm of the scaled x c and initialize the step bound delta. c do 160 j = 1, n wa3(j) = diag(j)*x(j) 160 continue xnorm = enorm(n,wa3) delta = factor*xnorm if (delta .eq. zero) delta = factor 170 continue c c compute the norm of the scaled gradient. c gnorm = zero if (fnorm .eq. zero) go to 210 do 200 j = 1, n l = ipvt(j) if (wa2(l) .eq. zero) go to 190 sum = zero do 180 i = 1, j sum = sum + fjac(i,j)*(qtf(i)/fnorm) 180 continue gnorm = dmax1(gnorm,dabs(sum/wa2(l))) 190 continue 200 continue 210 continue c c test for convergence of the gradient norm. c if (gnorm .le. gtol) info = 4 if (info .ne. 0) go to 340 c c rescale if necessary. c if (mode .eq. 2) go to 230 do 220 j = 1, n diag(j) = dmax1(diag(j),wa2(j)) 220 continue 230 continue c c beginning of the inner loop. c 240 continue c c determine the levenberg-marquardt parameter. c call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2, * wa3,wa4) c c store the direction p and x + p. calculate the norm of p. c do 250 j = 1, n wa1(j) = -wa1(j) wa2(j) = x(j) + wa1(j) wa3(j) = diag(j)*wa1(j) 250 continue pnorm = enorm(n,wa3) c c on the first iteration, adjust the initial step bound. c if (iter .eq. 1) delta = dmin1(delta,pnorm) c c evaluate the function at x + p and calculate its norm. c iflag = 1 call fcn(m,n,wa2,wa4,wa3,iflag) nfev = nfev + 1 if (iflag .lt. 0) go to 340 fnorm1 = enorm(m,wa4) c c compute the scaled actual reduction. c actred = -one if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2 c c compute the scaled predicted reduction and c the scaled directional derivative. c do 270 j = 1, n wa3(j) = zero l = ipvt(j) temp = wa1(l) do 260 i = 1, j wa3(i) = wa3(i) + fjac(i,j)*temp 260 continue 270 continue temp1 = enorm(n,wa3)/fnorm temp2 = (dsqrt(par)*pnorm)/fnorm prered = temp1**2 + temp2**2/p5 dirder = -(temp1**2 + temp2**2) c c compute the ratio of the actual to the predicted c reduction. c ratio = zero if (prered .ne. zero) ratio = actred/prered c c update the step bound. c if (ratio .gt. p25) go to 280 if (actred .ge. zero) temp = p5 if (actred .lt. zero) * temp = p5*dirder/(dirder + p5*actred) if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1 delta = temp*dmin1(delta,pnorm/p1) par = par/temp go to 300 280 continue if (par .ne. zero .and. ratio .lt. p75) go to 290 delta = pnorm/p5 par = p5*par 290 continue 300 continue c c test for successful iteration. c if (ratio .lt. p0001) go to 330 c c successful iteration. update x, fvec, and their norms. c do 310 j = 1, n x(j) = wa2(j) wa2(j) = diag(j)*x(j) 310 continue do 320 i = 1, m fvec(i) = wa4(i) 320 continue xnorm = enorm(n,wa2) fnorm = fnorm1 iter = iter + 1 330 continue c c tests for convergence. c if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one) info = 1 if (delta .le. xtol*xnorm) info = 2 if (dabs(actred) .le. ftol .and. prered .le. ftol * .and. p5*ratio .le. one .and. info .eq. 2) info = 3 if (info .ne. 0) go to 340 c c tests for termination and stringent tolerances. c if (nfev .ge. maxfev) info = 5 if (dabs(actred) .le. epsmch .and. prered .le. epsmch * .and. p5*ratio .le. one) info = 6 if (delta .le. epsmch*xnorm) info = 7 if (gnorm .le. epsmch) info = 8 if (info .ne. 0) go to 340 c c end of the inner loop. repeat if iteration unsuccessful. c if (ratio .lt. p0001) go to 240 c c end of the outer loop. c go to 30 340 continue c c termination, either normal or user imposed. c if (iflag .lt. 0) info = iflag iflag = 0 if (nprint .gt. 0) call fcn(m,n,x,fvec,wa3,iflag) return c c last card of subroutine lmstr. c end cminpack-1.3.4/fortran/lmstr1.f000644 000765 000765 00000012731 12225167750 016333 0ustar00devernay000000 000000 subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, * lwa) integer m,n,ldfjac,info,lwa integer ipvt(n) double precision tol double precision x(n),fvec(m),fjac(ldfjac,n),wa(lwa) external fcn c ********** c c subroutine lmstr1 c c the purpose of lmstr1 is to minimize the sum of the squares of c m nonlinear functions in n variables by a modification of c the levenberg-marquardt algorithm which uses minimal storage. c this is done by using the more general least-squares solver c lmstr. the user must provide a subroutine which calculates c the functions and the rows of the jacobian. c c the subroutine statement is c c subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, c ipvt,wa,lwa) c c where c c fcn is the name of the user-supplied subroutine which c calculates the functions and the rows of the jacobian. c fcn must be declared in an external statement in the c user calling program, and should be written as follows. c c subroutine fcn(m,n,x,fvec,fjrow,iflag) c integer m,n,iflag c double precision x(n),fvec(m),fjrow(n) c ---------- c if iflag = 1 calculate the functions at x and c return this vector in fvec. c if iflag = i calculate the (i-1)-st row of the c jacobian at x and return this vector in fjrow. c ---------- c return c end c c the value of iflag should not be changed by fcn unless c the user wants to terminate execution of lmstr1. c in this case set iflag to a negative integer. c c m is a positive integer input variable set to the number c of functions. c c n is a positive integer input variable set to the number c of variables. n must not exceed m. c c x is an array of length n. on input x must contain c an initial estimate of the solution vector. on output x c contains the final estimate of the solution vector. c c fvec is an output array of length m which contains c the functions evaluated at the output x. c c fjac is an output n by n array. the upper triangle of fjac c contains an upper triangular matrix r such that c c t t t c p *(jac *jac)*p = r *r, c c where p is a permutation matrix and jac is the final c calculated jacobian. column j of p is column ipvt(j) c (see below) of the identity matrix. the lower triangular c part of fjac contains information generated during c the computation of r. c c ldfjac is a positive integer input variable not less than n c which specifies the leading dimension of the array fjac. c c tol is a nonnegative input variable. termination occurs c when the algorithm estimates either that the relative c error in the sum of squares is at most tol or that c the relative error between x and the solution is at c most tol. c c info is an integer output variable. if the user has c terminated execution, info is set to the (negative) c value of iflag. see description of fcn. otherwise, c info is set as follows. c c info = 0 improper input parameters. c c info = 1 algorithm estimates that the relative error c in the sum of squares is at most tol. c c info = 2 algorithm estimates that the relative error c between x and the solution is at most tol. c c info = 3 conditions for info = 1 and info = 2 both hold. c c info = 4 fvec is orthogonal to the columns of the c jacobian to machine precision. c c info = 5 number of calls to fcn with iflag = 1 has c reached 100*(n+1). c c info = 6 tol is too small. no further reduction in c the sum of squares is possible. c c info = 7 tol is too small. no further improvement in c the approximate solution x is possible. c c ipvt is an integer output array of length n. ipvt c defines a permutation matrix p such that jac*p = q*r, c where jac is the final calculated jacobian, q is c orthogonal (not stored), and r is upper triangular. c column j of p is column ipvt(j) of the identity matrix. c c wa is a work array of length lwa. c c lwa is a positive integer input variable not less than 5*n+m. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... lmstr c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, c jorge j. more c c ********** integer maxfev,mode,nfev,njev,nprint double precision factor,ftol,gtol,xtol,zero data factor,zero /1.0d2,0.0d0/ info = 0 c c check the input parameters for errors. c if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. n .or. tol .lt. zero * .or. lwa .lt. 5*n + m) go to 10 c c call lmstr. c maxfev = 100*(n + 1) ftol = tol xtol = tol gtol = zero mode = 1 nprint = 0 call lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,maxfev, * wa(1),mode,factor,nprint,info,nfev,njev,ipvt,wa(n+1), * wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1)) if (info .eq. 8) info = 4 10 continue return c c last card of subroutine lmstr1. c end cminpack-1.3.4/fortran/Makefile000644 000765 000765 00000001562 12303616324 016373 0ustar00devernay000000 000000 #!/usr/bin/make # pick up your FORTRAN compiler #F77=g77 F77=gfortran FFLAGS=-O3 # uncomment the following for FORTRAN MINPACK #MINPACK=-lminpack #F77C=$(F77) #F77CFLAGS=-g OBJS = \ chkder.o enorm.o hybrd1.o hybrj.o lmdif1.o lmstr1.o qrfac.o r1updt.o \ dogleg.o fdjac1.o hybrd.o lmder1.o lmdif.o lmstr.o qrsolv.o rwupdt.o \ dpmpar.o fdjac2.o hybrj1.o lmder.o lmpar.o qform.o r1mpyq.o covar.o # target dir for install DESTDIR=/usr/local # # Static library target # .PHONY: all clean veryclean install all: libminpack.a libminpack.a: $(OBJS) ar r $@ $(OBJS); ranlib $@ %.o: %.f ${F77} ${FFLAGS} -c -o $@ $< install: libminpack.a cp libminpack.a ${DESTDIR}/lib chmod 644 ${DESTDIR}/lib/libminpack.a ranlib -t ${DESTDIR}/lib/libminpack.a # might be unnecessary clean: rm -f $(OBJS) libminpack.a veryclean: rm -f *.o *.gcno *.gcda *~ #*# cminpack-1.3.4/fortran/minpack.f90000644 000765 000765 00000034626 12225167750 016713 0ustar00devernay000000 000000 module minpack ! F90 interface to minpack implicit none ! set to .true. for debug prints logical, parameter, private :: dbg = .true. ! precision for double real integer, parameter, private :: r8 = selected_real_kind(15) interface subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) integer, parameter :: r8 = selected_real_kind(15) integer, intent(in) :: m,n,ldfjac,mode real(r8) :: x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m),err(m) end subroutine chkder subroutine covar(n,r,ldr,ipvt,tol,wa) integer, parameter :: r8 = selected_real_kind(15) integer, intent(in) :: n,ldr integer:: ipvt(n) real(r8) :: tol real(r8) :: r(ldr,n),wa(n) end subroutine covar subroutine dmchar(ibeta,it,irnd,ngrd,machep,negep,iexp,minexp, & maxexp,eps,epsneg,xmin,xmax) integer, parameter :: r8 = selected_real_kind(15) integer :: i,ibeta,iexp,irnd,it,iz,j,k,machep,maxexp,minexp, & mx,negep,ngrd real(r8) :: a,b,beta,betain,betam1,eps,epsneg,one,xmax, & xmin,y,z,zero end subroutine dmchar subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) integer, parameter :: r8 = selected_real_kind(15) integer :: n,lr real(r8) :: delta real(r8) :: r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n) end subroutine dogleg function dpmpar(i) integer, parameter :: r8 = selected_real_kind(15) real(r8) :: dpmpar integer, intent(in) :: i end function dpmpar function enorm(n,x) integer, parameter :: r8 = selected_real_kind(15) integer, intent(in) :: n real(r8) :: enorm,x(n) end function enorm subroutine errjac(n,x,fjac,ldfjac,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,nprob real(r8) :: x(n),fjac(ldfjac,n) end subroutine errjac subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,wa1,wa2) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,iflag,ml,mu real(r8) :: epsfcn real(r8) :: x(n),fvec(n),fjac(ldfjac,n),wa1(n),wa2(n) interface subroutine fcn(n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: n,iflag real(r8) :: x(n),fvec(n) end subroutine fcn end interface end subroutine fdjac1 subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,iflag real(r8) :: epsfcn real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(m) interface subroutine fcn(m,n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,iflag real(r8) :: x(n),fvec(m) end subroutine fcn end interface end subroutine fdjac2 subroutine grdfcn(n,x,g,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,nprob real(r8) :: x(n),g(n) end subroutine grdfcn subroutine hesfcn(n,x,h,ldh,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldh,nprob real(r8) :: x(n),h(ldh,n) end subroutine hesfcn subroutine initpt(n,x,nprob,factor) integer, parameter :: r8 = selected_real_kind(15) integer :: n,nprob real(r8) :: factor real(r8) :: x(n) end subroutine initpt subroutine 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) integer, parameter :: r8 = selected_real_kind(15) integer :: n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr real(r8) :: xtol,epsfcn,factor real(r8) :: x(n),fvec(n),diag(n),fjac(ldfjac,n),r(lr), & qtf(n),wa1(n),wa2(n),wa3(n),wa4(n) interface subroutine fcn(n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: n,iflag real(r8) :: x(n),fvec(n) end subroutine fcn end interface end subroutine hybrd subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) integer, parameter :: r8 = selected_real_kind(15) integer :: n,info,lwa real(r8) :: tol real(r8) :: x(n),fvec(n),wa(lwa) interface subroutine fcn(n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: n,iflag real(r8) :: x(n),fvec(n) end subroutine fcn end interface end subroutine hybrd1 subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode, & factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2, & wa3,wa4) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr real(r8) :: xtol,factor real(r8) :: x(n),fvec(n),fjac(ldfjac,n),diag(n),r(lr), & qtf(n),wa1(n),wa2(n),wa3(n),wa4(n) interface subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,iflag real(r8) :: x(n),fvec(n),fjac(ldfjac,n) end subroutine fcn end interface end subroutine hybrj subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,info,lwa real(r8) :: tol real(r8) :: x(n),fvec(n),fjac(ldfjac,n),wa(lwa) interface subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,iflag real(r8) :: x(n),fvec(n),fjac(ldfjac,n) end subroutine fcn end interface end subroutine hybrj1 subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, & maxfev,diag,mode,factor,nprint,info,nfev,njev, & ipvt,qtf,wa1,wa2,wa3,wa4) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev integer :: ipvt(n) real(r8) :: ftol,xtol,gtol,factor real(r8) :: x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), & wa1(n),wa2(n),wa3(n),wa4(m) interface subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,iflag real(r8) :: x(n),fvec(m),fjac(ldfjac,n) end subroutine fcn end interface end subroutine lmder subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,lwa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,info,lwa integer :: ipvt(n) real(r8) :: tol real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(lwa) interface subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,iflag real(r8) :: x(n),fvec(m),fjac(ldfjac,n) end subroutine fcn end interface end subroutine lmder1 subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, & diag,mode,factor,nprint,info,nfev,fjac,ldfjac, & ipvt,qtf,wa1,wa2,wa3,wa4) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,maxfev,mode,nprint,info,nfev,ldfjac integer :: ipvt(n) real(r8) :: ftol,xtol,gtol,epsfcn,factor real(r8) :: x(n),fvec(m),diag(n),fjac(ldfjac,n),qtf(n), & wa1(n),wa2(n),wa3(n),wa4(m) interface subroutine fcn(m,n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,iflag real(r8) :: x(n),fvec(m) end subroutine fcn end interface end subroutine lmdif subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,info,lwa integer :: iwa(n) real(r8) :: tol real(r8) :: x(n),fvec(m),wa(lwa) interface subroutine fcn(m,n,x,fvec,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,iflag real(r8) :: x(n),fvec(m) end subroutine fcn end interface end subroutine lmdif1 subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1,wa2) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldr integer :: ipvt(n) real(r8) :: delta,par real(r8) :: r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa1(n),wa2(n) end subroutine lmpar subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, & maxfev,diag,mode,factor,nprint,info,nfev,njev, & ipvt,qtf,wa1,wa2,wa3,wa4) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev integer :: ipvt(n) logical :: sing real(r8) :: ftol,xtol,gtol,factor real(r8) :: x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), & wa1(n),wa2(n),wa3(n),wa4(m) interface subroutine fcn(m,n,x,fvec,fjrow,iflag) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,iflag real(r8) :: x(n),fvec(m),fjrow(n) end subroutine fcn end interface end subroutine lmstr subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,lwa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,info,lwa integer :: ipvt(n) real(r8) :: tol real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(lwa) interface subroutine fcn(m,n,x,fvec,fjrow,iflag) integer, parameter :: r8 = selected_real_kind(15) integer m,n,iflag real(r8) x(n),fvec(m),fjrow(n) end subroutine fcn end interface end subroutine lmstr1 subroutine objfcn(n,x,f,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,nprob real(r8) :: f real(r8) :: x(n) end subroutine objfcn subroutine qform(m,n,q,ldq,wa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldq real(r8) :: q(ldq,m),wa(m) end subroutine qform subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,lda,lipvt integer :: ipvt(lipvt) logical :: pivot real(r8) :: a(lda,n),rdiag(n),acnorm(n),wa(n) end subroutine qrfac subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldr integer :: ipvt(n) real(r8) :: r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n) end subroutine qrsolv subroutine r1mpyq(m,n,a,lda,v,w) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,lda real(r8) :: a(lda,n),v(n),w(n) end subroutine r1mpyq subroutine r1updt(m,n,s,ls,u,v,w,sing) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ls logical :: sing real(r8) :: s(ls),u(m),v(n),w(m) end subroutine r1updt subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldr real(r8) :: alpha real(r8) :: r(ldr,n),w(n),b(n),cos(n),sin(n) end subroutine rwupdt subroutine ssqfcn(m,n,x,fvec,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,nprob real(r8) :: x(n),fvec(m) end subroutine ssqfcn subroutine ssqjac(m,n,x,fjac,ldfjac,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: m,n,ldfjac,nprob real(r8) :: x(n),fjac(ldfjac,n) end subroutine ssqjac subroutine vecfcn(n,x,fvec,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,nprob real(r8) :: x(n),fvec(n) end subroutine vecfcn subroutine vecjac(n,x,fjac,ldfjac,nprob) integer, parameter :: r8 = selected_real_kind(15) integer :: n,ldfjac,nprob real(r8) :: x(n),fjac(ldfjac,n) end subroutine vecjac end interface contains !---------------------------------------------------------------------- ! ! add-ons ! !---------------------------------------------------------------------- subroutine qrinv(m,n,a,a1,lda,diag) ! compute inverse matrix in least-quare sense by the use ! of the QR factorisation ! implementation is reference, no effective, test for different ! m and n are sparse implicit none integer :: m,n,lda real(r8) :: a(lda,n),a1(lda,n), diag(n) real(r8) :: r(m,n), q(m,n), qtb(m,n) integer :: i,ipvt(n) real(r8) :: rdiag(n),acnorm(n),wa(n),x(n),b(n),sdiag(n) character(len=10) :: fmt = '(xxf17.7)' if(dbg) then write(*,*) 'qrinv:' write(fmt(2:3),'(i2.2)') n write(*,fmt) a endif ! form the r matrix, r is upper trinagle (without diagonal) ! of the factorized a, diagonal is presented in rdiag call qrfac(m,n,a,lda,.true.,ipvt,n,rdiag,acnorm,wa) if(dbg) then write(*,*) 'qrfac:' write(*,fmt) a,rdiag,acnorm end if r = a do i = 1, n r(i,i) = rdiag(i) end do if(dbg) then write(*,*) 'r:' write(*,fmt) r endif ! form the q matrix call qform(m,n,a,lda,wa) if(dbg) then write(*,*) 'qform:' write(*,fmt) a,rdiag,acnorm write(*,*) 'ipvt:' write(*,*) ipvt end if q = a qtb = transpose(q) do i = 1, n b = 0 b(i) = 1.0 b = matmul(qtb,b) call qrsolv(n,r,m,ipvt,diag,b,x,sdiag,wa) a1(i,:) = x enddo end subroutine qrinv !--------------------------------------------------------------------- ! ! Fortran 90 interfaces ! !--------------------------------------------------------------------- ! subroutine chkder_8(x,fvec,fjac,xp,fvecp,mode,err) ! integer, intent(in) :: mode ! real(r8) :: x(:),fvec(:),fjac(:,:),xp(:),fvecp(:),err(:) ! integer :: m,n,ldfjac ! ! m = size(fvec) ! n = size(x) ! ldfjac = size(fjac,1) ! ! call chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) ! end subroutine chkder_8 end module minpack cminpack-1.3.4/fortran/qform.f000644 000765 000765 00000004676 12225167750 016246 0ustar00devernay000000 000000 subroutine qform(m,n,q,ldq,wa) integer m,n,ldq double precision q(ldq,m),wa(m) c ********** c c subroutine qform c c this subroutine proceeds from the computed qr factorization of c an m by n matrix a to accumulate the m by m orthogonal matrix c q from its factored form. c c the subroutine statement is c c subroutine qform(m,n,q,ldq,wa) c c where c c m is a positive integer input variable set to the number c of rows of a and the order of q. c c n is a positive integer input variable set to the number c of columns of a. c c q is an m by m array. on input the full lower trapezoid in c the first min(m,n) columns of q contains the factored form. c on output q has been accumulated into a square matrix. c c ldq is a positive integer input variable not less than m c which specifies the leading dimension of the array q. c c wa is a work array of length m. c c subprograms called c c fortran-supplied ... min0 c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,jm1,k,l,minmn,np1 double precision one,sum,temp,zero data one,zero /1.0d0,0.0d0/ c c zero out upper triangle of q in the first min(m,n) columns. c minmn = min0(m,n) if (minmn .lt. 2) go to 30 do 20 j = 2, minmn jm1 = j - 1 do 10 i = 1, jm1 q(i,j) = zero 10 continue 20 continue 30 continue c c initialize remaining columns to those of the identity matrix. c np1 = n + 1 if (m .lt. np1) go to 60 do 50 j = np1, m do 40 i = 1, m q(i,j) = zero 40 continue q(j,j) = one 50 continue 60 continue c c accumulate q from its factored form. c do 120 l = 1, minmn k = minmn - l + 1 do 70 i = k, m wa(i) = q(i,k) q(i,k) = zero 70 continue q(k,k) = one if (wa(k) .eq. zero) go to 110 do 100 j = k, m sum = zero do 80 i = k, m sum = sum + q(i,j)*wa(i) 80 continue temp = sum/wa(k) do 90 i = k, m q(i,j) = q(i,j) - temp*wa(i) 90 continue 100 continue 110 continue 120 continue return c c last card of subroutine qform. c end cminpack-1.3.4/fortran/qrfac.f000644 000765 000765 00000012451 12225167750 016204 0ustar00devernay000000 000000 subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) integer m,n,lda,lipvt integer ipvt(lipvt) logical pivot double precision a(lda,n),rdiag(n),acnorm(n),wa(n) c ********** c c subroutine qrfac c c this subroutine uses householder transformations with column c pivoting (optional) to compute a qr factorization of the c m by n matrix a. that is, qrfac determines an orthogonal c matrix q, a permutation matrix p, and an upper trapezoidal c matrix r with diagonal elements of nonincreasing magnitude, c such that a*p = q*r. the householder transformation for c column k, k = 1,2,...,min(m,n), is of the form c c t c i - (1/u(k))*u*u c c where u has zeros in the first k-1 positions. the form of c this transformation and the method of pivoting first c appeared in the corresponding linpack subroutine. c c the subroutine statement is c c subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) c c where c c m is a positive integer input variable set to the number c of rows of a. c c n is a positive integer input variable set to the number c of columns of a. c c a is an m by n array. on input a contains the matrix for c which the qr factorization is to be computed. on output c the strict upper trapezoidal part of a contains the strict c upper trapezoidal part of r, and the lower trapezoidal c part of a contains a factored form of q (the non-trivial c elements of the u vectors described above). c c lda is a positive integer input variable not less than m c which specifies the leading dimension of the array a. c c pivot is a logical input variable. if pivot is set true, c then column pivoting is enforced. if pivot is set false, c then no column pivoting is done. c c ipvt is an integer output array of length lipvt. ipvt c defines the permutation matrix p such that a*p = q*r. c column j of p is column ipvt(j) of the identity matrix. c if pivot is false, ipvt is not referenced. c c lipvt is a positive integer input variable. if pivot is false, c then lipvt may be as small as 1. if pivot is true, then c lipvt must be at least n. c c rdiag is an output array of length n which contains the c diagonal elements of r. c c acnorm is an output array of length n which contains the c norms of the corresponding columns of the input matrix a. c if this information is not needed, then acnorm can coincide c with rdiag. c c wa is a work array of length n. if pivot is false, then wa c can coincide with rdiag. c c subprograms called c c minpack-supplied ... dpmpar,enorm c c fortran-supplied ... dmax1,dsqrt,min0 c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,jp1,k,kmax,minmn double precision ajnorm,epsmch,one,p05,sum,temp,zero double precision dpmpar,enorm data one,p05,zero /1.0d0,5.0d-2,0.0d0/ c c epsmch is the machine precision. c epsmch = dpmpar(1) c c compute the initial column norms and initialize several arrays. c do 10 j = 1, n acnorm(j) = enorm(m,a(1,j)) rdiag(j) = acnorm(j) wa(j) = rdiag(j) if (pivot) ipvt(j) = j 10 continue c c reduce a to r with householder transformations. c minmn = min0(m,n) do 110 j = 1, minmn if (.not.pivot) go to 40 c c bring the column of largest norm into the pivot position. c kmax = j do 20 k = j, n if (rdiag(k) .gt. rdiag(kmax)) kmax = k 20 continue if (kmax .eq. j) go to 40 do 30 i = 1, m temp = a(i,j) a(i,j) = a(i,kmax) a(i,kmax) = temp 30 continue rdiag(kmax) = rdiag(j) wa(kmax) = wa(j) k = ipvt(j) ipvt(j) = ipvt(kmax) ipvt(kmax) = k 40 continue c c compute the householder transformation to reduce the c j-th column of a to a multiple of the j-th unit vector. c ajnorm = enorm(m-j+1,a(j,j)) if (ajnorm .eq. zero) go to 100 if (a(j,j) .lt. zero) ajnorm = -ajnorm do 50 i = j, m a(i,j) = a(i,j)/ajnorm 50 continue a(j,j) = a(j,j) + one c c apply the transformation to the remaining columns c and update the norms. c jp1 = j + 1 if (n .lt. jp1) go to 100 do 90 k = jp1, n sum = zero do 60 i = j, m sum = sum + a(i,j)*a(i,k) 60 continue temp = sum/a(j,j) do 70 i = j, m a(i,k) = a(i,k) - temp*a(i,j) 70 continue if (.not.pivot .or. rdiag(k) .eq. zero) go to 80 temp = a(j,k)/rdiag(k) rdiag(k) = rdiag(k)*dsqrt(dmax1(zero,one-temp**2)) if (p05*(rdiag(k)/wa(k))**2 .gt. epsmch) go to 80 rdiag(k) = enorm(m-j,a(jp1,k)) wa(k) = rdiag(k) 80 continue 90 continue 100 continue rdiag(j) = -ajnorm 110 continue return c c last card of subroutine qrfac. c end cminpack-1.3.4/fortran/qrsolv.f000644 000765 000765 00000014042 12225167750 016434 0ustar00devernay000000 000000 subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) integer n,ldr integer ipvt(n) double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n) c ********** c c subroutine qrsolv c c given an m by n matrix a, an n by n diagonal matrix d, c and an m-vector b, the problem is to determine an x which c solves the system c c a*x = b , d*x = 0 , c c in the least squares sense. c c this subroutine completes the solution of the problem c if it is provided with the necessary information from the c qr factorization, with column pivoting, of a. that is, if c a*p = q*r, where p is a permutation matrix, q has orthogonal c columns, and r is an upper triangular matrix with diagonal c elements of nonincreasing magnitude, then qrsolv expects c the full upper triangle of r, the permutation matrix p, c and the first n components of (q transpose)*b. the system c a*x = b, d*x = 0, is then equivalent to c c t t c r*z = q *b , p *d*p*z = 0 , c c where x = p*z. if this system does not have full rank, c then a least squares solution is obtained. on output qrsolv c also provides an upper triangular matrix s such that c c t t t c p *(a *a + d*d)*p = s *s . c c s is computed within qrsolv and may be of separate interest. c c the subroutine statement is c c subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) c c where c c n is a positive integer input variable set to the order of r. c c r is an n by n array. on input the full upper triangle c must contain the full upper triangle of the matrix r. c on output the full upper triangle is unaltered, and the c strict lower triangle contains the strict upper triangle c (transposed) of the upper triangular matrix s. c c ldr is a positive integer input variable not less than n c which specifies the leading dimension of the array r. c c ipvt is an integer input array of length n which defines the c permutation matrix p such that a*p = q*r. column j of p c is column ipvt(j) of the identity matrix. c c diag is an input array of length n which must contain the c diagonal elements of the matrix d. c c qtb is an input array of length n which must contain the first c n elements of the vector (q transpose)*b. c c x is an output array of length n which contains the least c squares solution of the system a*x = b, d*x = 0. c c sdiag is an output array of length n which contains the c diagonal elements of the upper triangular matrix s. c c wa is a work array of length n. c c subprograms called c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,jp1,k,kp1,l,nsing double precision cos,cotan,p5,p25,qtbpj,sin,sum,tan,temp,zero data p5,p25,zero /5.0d-1,2.5d-1,0.0d0/ c c copy r and (q transpose)*b to preserve input and initialize s. c in particular, save the diagonal elements of r in x. c do 20 j = 1, n do 10 i = j, n r(i,j) = r(j,i) 10 continue x(j) = r(j,j) wa(j) = qtb(j) 20 continue c c eliminate the diagonal matrix d using a givens rotation. c do 100 j = 1, n c c prepare the row of d to be eliminated, locating the c diagonal element using p from the qr factorization. c l = ipvt(j) if (diag(l) .eq. zero) go to 90 do 30 k = j, n sdiag(k) = zero 30 continue sdiag(j) = diag(l) c c the transformations to eliminate the row of d c modify only a single element of (q transpose)*b c beyond the first n, which is initially zero. c qtbpj = zero do 80 k = j, n c c determine a givens rotation which eliminates the c appropriate element in the current row of d. c if (sdiag(k) .eq. zero) go to 70 if (dabs(r(k,k)) .ge. dabs(sdiag(k))) go to 40 cotan = r(k,k)/sdiag(k) sin = p5/dsqrt(p25+p25*cotan**2) cos = sin*cotan go to 50 40 continue tan = sdiag(k)/r(k,k) cos = p5/dsqrt(p25+p25*tan**2) sin = cos*tan 50 continue c c compute the modified diagonal element of r and c the modified element of ((q transpose)*b,0). c r(k,k) = cos*r(k,k) + sin*sdiag(k) temp = cos*wa(k) + sin*qtbpj qtbpj = -sin*wa(k) + cos*qtbpj wa(k) = temp c c accumulate the tranformation in the row of s. c kp1 = k + 1 if (n .lt. kp1) go to 70 do 60 i = kp1, n temp = cos*r(i,k) + sin*sdiag(i) sdiag(i) = -sin*r(i,k) + cos*sdiag(i) r(i,k) = temp 60 continue 70 continue 80 continue 90 continue c c store the diagonal element of s and restore c the corresponding diagonal element of r. c sdiag(j) = r(j,j) r(j,j) = x(j) 100 continue c c solve the triangular system for z. if the system is c singular, then obtain a least squares solution. c nsing = n do 110 j = 1, n if (sdiag(j) .eq. zero .and. nsing .eq. n) nsing = j - 1 if (nsing .lt. n) wa(j) = zero 110 continue if (nsing .lt. 1) go to 150 do 140 k = 1, nsing j = nsing - k + 1 sum = zero jp1 = j + 1 if (nsing .lt. jp1) go to 130 do 120 i = jp1, nsing sum = sum + r(i,j)*wa(i) 120 continue 130 continue wa(j) = (wa(j) - sum)/sdiag(j) 140 continue 150 continue c c permute the components of z back to components of x. c do 160 j = 1, n l = ipvt(j) x(l) = wa(j) 160 continue return c c last card of subroutine qrsolv. c end cminpack-1.3.4/fortran/r1mpyq.f000644 000765 000765 00000005455 12225167750 016347 0ustar00devernay000000 000000 subroutine r1mpyq(m,n,a,lda,v,w) integer m,n,lda double precision a(lda,n),v(n),w(n) c ********** c c subroutine r1mpyq c c given an m by n matrix a, this subroutine computes a*q where c q is the product of 2*(n - 1) transformations c c gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) c c and gv(i), gw(i) are givens rotations in the (i,n) plane which c eliminate elements in the i-th and n-th planes, respectively. c q itself is not given, rather the information to recover the c gv, gw rotations is supplied. c c the subroutine statement is c c subroutine r1mpyq(m,n,a,lda,v,w) c c where c c m is a positive integer input variable set to the number c of rows of a. c c n is a positive integer input variable set to the number c of columns of a. c c a is an m by n array. on input a must contain the matrix c to be postmultiplied by the orthogonal matrix q c described above. on output a*q has replaced a. c c lda is a positive integer input variable not less than m c which specifies the leading dimension of the array a. c c v is an input array of length n. v(i) must contain the c information necessary to recover the givens rotation gv(i) c described above. c c w is an input array of length n. w(i) must contain the c information necessary to recover the givens rotation gw(i) c described above. c c subroutines called c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,nmj,nm1 double precision cos,one,sin,temp data one /1.0d0/ c c apply the first set of givens rotations to a. c nm1 = n - 1 if (nm1 .lt. 1) go to 50 do 20 nmj = 1, nm1 j = n - nmj if (dabs(v(j)) .gt. one) cos = one/v(j) if (dabs(v(j)) .gt. one) sin = dsqrt(one-cos**2) if (dabs(v(j)) .le. one) sin = v(j) if (dabs(v(j)) .le. one) cos = dsqrt(one-sin**2) do 10 i = 1, m temp = cos*a(i,j) - sin*a(i,n) a(i,n) = sin*a(i,j) + cos*a(i,n) a(i,j) = temp 10 continue 20 continue c c apply the second set of givens rotations to a. c do 40 j = 1, nm1 if (dabs(w(j)) .gt. one) cos = one/w(j) if (dabs(w(j)) .gt. one) sin = dsqrt(one-cos**2) if (dabs(w(j)) .le. one) sin = w(j) if (dabs(w(j)) .le. one) cos = dsqrt(one-sin**2) do 30 i = 1, m temp = cos*a(i,j) + sin*a(i,n) a(i,n) = -sin*a(i,j) + cos*a(i,n) a(i,j) = temp 30 continue 40 continue 50 continue return c c last card of subroutine r1mpyq. c end cminpack-1.3.4/fortran/r1updt.f000644 000765 000765 00000013106 12225167750 016325 0ustar00devernay000000 000000 subroutine r1updt(m,n,s,ls,u,v,w,sing) integer m,n,ls logical sing double precision s(ls),u(m),v(n),w(m) c ********** c c subroutine r1updt c c given an m by n lower trapezoidal matrix s, an m-vector u, c and an n-vector v, the problem is to determine an c orthogonal matrix q such that c c t c (s + u*v )*q c c is again lower trapezoidal. c c this subroutine determines q as the product of 2*(n - 1) c transformations c c gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) c c where gv(i), gw(i) are givens rotations in the (i,n) plane c which eliminate elements in the i-th and n-th planes, c respectively. q itself is not accumulated, rather the c information to recover the gv, gw rotations is returned. c c the subroutine statement is c c subroutine r1updt(m,n,s,ls,u,v,w,sing) c c where c c m is a positive integer input variable set to the number c of rows of s. c c n is a positive integer input variable set to the number c of columns of s. n must not exceed m. c c s is an array of length ls. on input s must contain the lower c trapezoidal matrix s stored by columns. on output s contains c the lower trapezoidal matrix produced as described above. c c ls is a positive integer input variable not less than c (n*(2*m-n+1))/2. c c u is an input array of length m which must contain the c vector u. c c v is an array of length n. on input v must contain the vector c v. on output v(i) contains the information necessary to c recover the givens rotation gv(i) described above. c c w is an output array of length m. w(i) contains information c necessary to recover the givens rotation gw(i) described c above. c c sing is a logical output variable. sing is set true if any c of the diagonal elements of the output s are zero. otherwise c sing is set false. c c subprograms called c c minpack-supplied ... dpmpar c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more, c john l. nazareth c c ********** integer i,j,jj,l,nmj,nm1 double precision cos,cotan,giant,one,p5,p25,sin,tan,tau,temp, * zero double precision dpmpar data one,p5,p25,zero /1.0d0,5.0d-1,2.5d-1,0.0d0/ c c giant is the largest magnitude. c giant = dpmpar(3) c c initialize the diagonal element pointer. c jj = (n*(2*m - n + 1))/2 - (m - n) c c move the nontrivial part of the last column of s into w. c l = jj do 10 i = n, m w(i) = s(l) l = l + 1 10 continue c c rotate the vector v into a multiple of the n-th unit vector c in such a way that a spike is introduced into w. c nm1 = n - 1 if (nm1 .lt. 1) go to 70 do 60 nmj = 1, nm1 j = n - nmj jj = jj - (m - j + 1) w(j) = zero if (v(j) .eq. zero) go to 50 c c determine a givens rotation which eliminates the c j-th element of v. c if (dabs(v(n)) .ge. dabs(v(j))) go to 20 cotan = v(n)/v(j) sin = p5/dsqrt(p25+p25*cotan**2) cos = sin*cotan tau = one if (dabs(cos)*giant .gt. one) tau = one/cos go to 30 20 continue tan = v(j)/v(n) cos = p5/dsqrt(p25+p25*tan**2) sin = cos*tan tau = sin 30 continue c c apply the transformation to v and store the information c necessary to recover the givens rotation. c v(n) = sin*v(j) + cos*v(n) v(j) = tau c c apply the transformation to s and extend the spike in w. c l = jj do 40 i = j, m temp = cos*s(l) - sin*w(i) w(i) = sin*s(l) + cos*w(i) s(l) = temp l = l + 1 40 continue 50 continue 60 continue 70 continue c c add the spike from the rank 1 update to w. c do 80 i = 1, m w(i) = w(i) + v(n)*u(i) 80 continue c c eliminate the spike. c sing = .false. if (nm1 .lt. 1) go to 140 do 130 j = 1, nm1 if (w(j) .eq. zero) go to 120 c c determine a givens rotation which eliminates the c j-th element of the spike. c if (dabs(s(jj)) .ge. dabs(w(j))) go to 90 cotan = s(jj)/w(j) sin = p5/dsqrt(p25+p25*cotan**2) cos = sin*cotan tau = one if (dabs(cos)*giant .gt. one) tau = one/cos go to 100 90 continue tan = w(j)/s(jj) cos = p5/dsqrt(p25+p25*tan**2) sin = cos*tan tau = sin 100 continue c c apply the transformation to s and reduce the spike in w. c l = jj do 110 i = j, m temp = cos*s(l) + sin*w(i) w(i) = -sin*s(l) + cos*w(i) s(l) = temp l = l + 1 110 continue c c store the information necessary to recover the c givens rotation. c w(j) = tau 120 continue c c test for zero diagonal elements in the output s. c if (s(jj) .eq. zero) sing = .true. jj = jj + (m - j + 1) 130 continue 140 continue c c move w back into the last column of the output s. c l = jj do 150 i = n, m s(l) = w(i) l = l + 1 150 continue if (s(jj) .eq. zero) sing = .true. return c c last card of subroutine r1updt. c end cminpack-1.3.4/fortran/README.txt000644 000765 000765 00000000343 12225167750 016434 0ustar00devernay000000 000000 This is non-modified version of Minpack library. Downloaded from ftp://ftp.netlib.org/minpack/. For Copyright see CopyrightMINPACK.txt. Other resources: http://en.wikipedia.org/wiki/MINPACK http://www.netlib.org/minpack/ cminpack-1.3.4/fortran/rwupdt.f000644 000765 000765 00000007335 12225167750 016442 0ustar00devernay000000 000000 subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) integer n,ldr double precision alpha double precision r(ldr,n),w(n),b(n),cos(n),sin(n) c ********** c c subroutine rwupdt c c given an n by n upper triangular matrix r, this subroutine c computes the qr decomposition of the matrix formed when a row c is added to r. if the row is specified by the vector w, then c rwupdt determines an orthogonal matrix q such that when the c n+1 by n matrix composed of r augmented by w is premultiplied c by (q transpose), the resulting matrix is upper trapezoidal. c the matrix (q transpose) is the product of n transformations c c g(n)*g(n-1)* ... *g(1) c c where g(i) is a givens rotation in the (i,n+1) plane which c eliminates elements in the (n+1)-st plane. rwupdt also c computes the product (q transpose)*c where c is the c (n+1)-vector (b,alpha). q itself is not accumulated, rather c the information to recover the g rotations is supplied. c c the subroutine statement is c c subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) c c where c c n is a positive integer input variable set to the order of r. c c r is an n by n array. on input the upper triangular part of c r must contain the matrix to be updated. on output r c contains the updated triangular matrix. c c ldr is a positive integer input variable not less than n c which specifies the leading dimension of the array r. c c w is an input array of length n which must contain the row c vector to be added to r. c c b is an array of length n. on input b must contain the c first n elements of the vector c. on output b contains c the first n elements of the vector (q transpose)*c. c c alpha is a variable. on input alpha must contain the c (n+1)-st element of the vector c. on output alpha contains c the (n+1)-st element of the vector (q transpose)*c. c c cos is an output array of length n which contains the c cosines of the transforming givens rotations. c c sin is an output array of length n which contains the c sines of the transforming givens rotations. c c subprograms called c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, c jorge j. more c c ********** integer i,j,jm1 double precision cotan,one,p5,p25,rowj,tan,temp,zero data one,p5,p25,zero /1.0d0,5.0d-1,2.5d-1,0.0d0/ c do 60 j = 1, n rowj = w(j) jm1 = j - 1 c c apply the previous transformations to c r(i,j), i=1,2,...,j-1, and to w(j). c if (jm1 .lt. 1) go to 20 do 10 i = 1, jm1 temp = cos(i)*r(i,j) + sin(i)*rowj rowj = -sin(i)*r(i,j) + cos(i)*rowj r(i,j) = temp 10 continue 20 continue c c determine a givens rotation which eliminates w(j). c cos(j) = one sin(j) = zero if (rowj .eq. zero) go to 50 if (dabs(r(j,j)) .ge. dabs(rowj)) go to 30 cotan = r(j,j)/rowj sin(j) = p5/dsqrt(p25+p25*cotan**2) cos(j) = sin(j)*cotan go to 40 30 continue tan = rowj/r(j,j) cos(j) = p5/dsqrt(p25+p25*tan**2) sin(j) = cos(j)*tan 40 continue c c apply the current transformation to r(j,j), b(j), and alpha. c r(j,j) = cos(j)*r(j,j) + sin(j)*rowj temp = cos(j)*b(j) + sin(j)*alpha alpha = -sin(j)*b(j) + cos(j)*alpha b(j) = temp 50 continue 60 continue return c c last card of subroutine rwupdt. c end cminpack-1.3.4/examples/chkdrv.c000644 000765 000765 00000007613 12274450254 016533 0ustar00devernay000000 000000 /* Usage: chkdrv < chkder.data */ #include #include #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ /* ********** */ /* this program tests the ability of chkder to detect */ /* inconsistencies between functions and their first derivatives. */ /* fourteen test function vectors and jacobians are used. eleven of */ /* the tests are false(f), i.e. there are inconsistencies between */ /* the function vectors and the corresponding jacobians. three of */ /* the tests are true(t), i.e. there are no inconsistencies. the */ /* driver reads in data, calls chkder and prints out information */ /* required by and received from chkder. */ /* subprograms called */ /* minpack supplied ... chkder,errjac,initpt,vecfcn */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { /* Initialized data */ const int a[14] = { 0,0,0,1,0,0,0,1,0,0,0,0,1,0 }; real cp = .123; /* Local variables */ int i, n; real x1[10], x2[10]; int na[14], np[14]; real err[10]; int lnp = 0; real fjac[10*10]; const int ldfjac = 10; real diff[10]; real fvec1[10], fvec2[10]; int nprob; real errmin[14], errmax[14]; (void)argc; (void)argv; for (;;) { scanf("%5d%5d\n", &nprob, &n); if (nprob <= 0) { break; } hybipt(n,x1,nprob,1.); for(i=0; i err[i]) errmin[nprob-1] = err[i]; if (errmax[nprob-1] < err[i]) errmax[nprob-1] = err[i]; } np[nprob-1] = nprob; lnp = nprob; na[nprob-1] = n; printf("\n first function vector \n\n"); printvec(n, fvec1); printf("\n\n function difference vector\n\n"); printvec(n, diff); printf("\n\n error vector\n\n"); printvec(n, err); } printf("\f summary of %3d tests of chkder\n", lnp); printf("\n nprob n status errmin errmax\n\n"); for (i = 0; i < lnp; ++i) { printf("%4d%6d %c %15.7e%15.7e\n", np[i], na[i], a[i]?'T':'F', (double)errmin[i], (double)errmax[i]); } exit(0); } cminpack-1.3.4/examples/chkdrv.f000644 000765 000765 00000006257 12225167750 016543 0ustar00devernay000000 000000 c ********** c c this program tests the ability of chkder to detect c inconsistencies between functions and their first derivatives. c fourteen test function vectors and jacobians are used. eleven of c the tests are false(f), i.e. there are inconsistencies between c the function vectors and the corresponding jacobians. three of c the tests are true(t), i.e. there are no inconsistencies. the c driver reads in data, calls chkder and prints out information c required by and received from chkder. c c subprograms called c c minpack supplied ... chkder,errjac,initpt,vecfcn c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ldfjac,lnp,mode,n,nprob,nread,nwrite integer na(14),np(14) logical a(14) double precision cp,one double precision diff(10),err(10),errmax(14),errmin(14), * fjac(10,10),fvec1(10),fvec2(10),x1(10),x2(10) c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8),a(9),a(10),a(11), * a(12),a(13),a(14) * /.false.,.false.,.false.,.true.,.false.,.false.,.false., * .true.,.false.,.false.,.false.,.false.,.true.,.false./ data cp,one /1.23d-1,1.0d0/ ldfjac = 10 10 continue read (nread,60) nprob,n if (nprob .le. 0) go to 40 call initpt(n,x1,nprob,one) do 20 i = 1, n x1(i) = x1(i) + cp cp = -cp 20 continue write (nwrite,70) nprob,n,a(nprob) mode = 1 call chkder(n,n,x1,fvec1,fjac,ldfjac,x2,fvec2,mode,err) mode = 2 call vecfcn(n,x1,fvec1,nprob) call errjac(n,x1,fjac,ldfjac,nprob) call vecfcn(n,x2,fvec2,nprob) call chkder(n,n,x1,fvec1,fjac,ldfjac,x2,fvec2,mode,err) errmin(nprob) = err(1) errmax(nprob) = err(1) do 30 i = 1, n diff(i) = fvec2(i) - fvec1(i) if (errmin(nprob) .gt. err(i)) errmin(nprob) = err(i) if (errmax(nprob) .lt. err(i)) errmax(nprob) = err(i) 30 continue np(nprob) = nprob lnp = nprob na(nprob) = n write (nwrite,80) (fvec1(i), i = 1, n) write (nwrite,90) (diff(i), i = 1, n) write (nwrite,100) (err(i), i = 1, n) go to 10 40 continue write (nwrite,110) lnp write (nwrite,120) do 50 i = 1, lnp write (nwrite,130) np(i),na(i),a(i),errmin(i),errmax(i) 50 continue stop 60 format (2i5) 70 format ( /// 5x, 8h problem, i5, 5x, 15h with dimension, i5, 2x, * 5h is , l1) 80 format ( // 5x, 25h first function vector // (5x, 5d15.7)) 90 format ( // 5x, 27h function difference vector // (5x, 5d15.7)) 100 format ( // 5x, 13h error vector // (5x, 5d15.7)) 110 format (12h1summary of , i3, 16h tests of chkder /) 120 format (46h nprob n status errmin errmax /) 130 format (i4, i6, 6x, l1, 3x, 2d15.7) c c last card of derivative check test driver. c end cminpack-1.3.4/examples/chkdrv_.c000644 000765 000765 00000007653 12274450514 016675 0ustar00devernay000000 000000 /* Usage: chkdrv < chkder.data */ #include #include #include #include "minpack.h" #include "vec.h" #define real __minpack_real__ /* ********** */ /* this program tests the ability of chkder to detect */ /* inconsistencies between functions and their first derivatives. */ /* fourteen test function vectors and jacobians are used. eleven of */ /* the tests are false(f), i.e. there are inconsistencies between */ /* the function vectors and the corresponding jacobians. three of */ /* the tests are true(t), i.e. there are no inconsistencies. the */ /* driver reads in data, calls chkder and prints out information */ /* required by and received from chkder. */ /* subprograms called */ /* minpack supplied ... chkder,errjac,initpt,vecfcn */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { /* Initialized data */ const int a[14] = { 0,0,0,1,0,0,0,1,0,0,0,0,1,0 }; real cp = .123; /* Local variables */ int i, n; real x1[10], x2[10]; int na[14], np[14]; real err[10]; int lnp; real fjac[10*10]; const int ldfjac = 10; real diff[10]; real fvec1[10], fvec2[10]; int nprob; real errmin[14], errmax[14]; const int i1 = 1, i2 = 2; (void)argc; (void)argv; for (;;) { scanf("%5d%5d\n", &nprob, &n); if (nprob <= 0) { break; } hybipt(n,x1,nprob,1.); for(i=0; i err[i]) errmin[nprob-1] = err[i]; if (errmax[nprob-1] < err[i]) errmax[nprob-1] = err[i]; } np[nprob-1] = nprob; lnp = nprob; na[nprob-1] = n; printf("\n first function vector \n\n"); printvec(n, fvec1); printf("\n\n function difference vector\n\n"); printvec(n, diff); printf("\n\n error vector\n\n"); printvec(n, err); } printf("\f summary of %3d tests of chkder\n", lnp); printf("\n nprob n status errmin errmax\n\n"); for (i = 0; i < lnp; ++i) { printf("%4d%6d %c %15.7e%15.7e\n", np[i], na[i], a[i]?'T':'F', (double)errmin[i], (double)errmax[i]); } exit(0); } cminpack-1.3.4/examples/CMakeLists.txt000644 000765 000765 00000005334 12225167750 017646 0ustar00devernay000000 000000 option (BUILD_EXAMPLES "Build the examples and tests." ON) option (BUILD_EXAMPLES_FORTRAN "Build the FORTRAN examples and tests." OFF) if (BUILD_EXAMPLES) # Make sure the compiler can find include files from our cminpack library. include_directories (${CMINPACK_SOURCE_DIR}) # Make sure the linker can find the cminpack library once it is built. link_directories (${CMINPACK_BINARY_DIR}) set (FPGM tchkder thybrd thybrd1 thybrj thybrj1 tlmder tlmder1 tlmdif tlmdif1 tlmstr tlmstr1) set (CPGM ${FPGM} tfdjac2) # cmpfiles could be used by runtest.cmake... for now it's unused add_executable (cmpfiles cmpfiles.c) # inspired by http://www.netlib.org/clapack/clapack-3.2.1-CMAKE/TESTING/CMakeLists.txt # except that here we have to compare the output to a reference macro(add_minpack_test testname reference) set(TEST_OUTPUT "${CMINPACK_BINARY_DIR}/examples/${testname}.out") set(TEST_REFERENCE "${CMINPACK_SOURCE_DIR}/examples/ref/${reference}.ref") get_target_property(TEST_LOC ${testname} LOCATION) add_test(${testname} "${CMAKE_COMMAND}" -DTEST=${TEST_LOC} -DOUTPUT=${TEST_OUTPUT} -DREFERENCE=${TEST_REFERENCE} -DINTDIR=${CMAKE_CFG_INTDIR} -P "${CMINPACK_SOURCE_DIR}/examples/runtest.cmake") endmacro(add_minpack_test) foreach (source ${CPGM}) add_executable (${source}_ ${source}_.c) target_link_libraries (${source}_ cminpack) if (OS_LINUX) target_link_libraries (${source}_ m) endif (OS_LINUX) add_minpack_test(${source}_ ${source}c) add_executable (${source}c ${source}c.c) target_link_libraries (${source}c cminpack) if (OS_LINUX) target_link_libraries (${source}c m) endif (OS_LINUX) add_minpack_test(${source}c ${source}c) endforeach(source) endif (BUILD_EXAMPLES) if (BUILD_EXAMPLES_FORTRAN) enable_language (Fortran OPTIONAL) if (CMAKE_Fortran_COMPILER_WORKS) foreach (FPGM_item ${FPGM}) list (APPEND FPGM_SRCS ${CMINPACK_SOURCE_DIR}/examples/${FPGM_item}.f) endforeach (FPGM_item ${FPGM}) # add the executable that will do the generation add_executable (genf77tests genf77tests.c) get_target_property (GENF77TESTS_EXE genf77tests LOCATION) add_custom_command ( OUTPUT ${FPGM_SRCS} COMMAND ${GENF77TESTS_EXE} ${CMINPACK_SOURCE_DIR}/doc/minpack-documentation.txt WORKING_DIRECTORY ${CMINPACK_SOURCE_DIR}/examples DEPENDS genf77tests MAIN_DEPENDENCY ${CMINPACK_SOURCE_DIR}/doc/minpack-documentation.txt ) foreach (source ${FPGM}) add_executable (${source} ${source}.f) target_link_libraries (${source} cminpack) add_minpack_test(${source} ${source}) endforeach (source) endif (CMAKE_Fortran_COMPILER_WORKS) endif (BUILD_EXAMPLES_FORTRAN) cminpack-1.3.4/examples/cmpfiles.c000644 000765 000765 00000002554 12225167750 017055 0ustar00devernay000000 000000 /* Compare two files line by line, output differences to stderr. Exit status is 0 if files are the same, 1 if different. Author: Frederic.Devernay@m4x.org */ #include #include #include int main(int argc, char **argv) { FILE *fp1, *fp2; char buf1[1024], buf2[1024]; int differences = 0; if (argc != 3) { fprintf(stderr,"Usage: %s filename1 filename2\n", argv[0]); exit(2); } fp1 = fopen(argv[1],"r"); if (fp1 == NULL) { perror("Error: cannot open input file"); exit(1); } fp2 = fopen(argv[2], "r"); if (fp2 == NULL) { perror("Error: cannot open input file"); exit(1); } while (fgets(buf1, sizeof(buf1), fp1) != NULL) { if(fgets(buf2, sizeof(buf2), fp2) == NULL) { fprintf(stderr, "<%s", buf1); ++differences; } else if(strcmp(buf1, buf2) != 0) { fprintf(stderr, "<%s", buf1); fprintf(stderr, ">%s", buf2); ++differences; } } while(fgets(buf2, sizeof(buf2), fp2) != NULL) { fprintf(stderr, ">%s", buf2); ++differences; } if (differences != 0) { fprintf(stderr,"Total differences between files '%s' and '%s': %d lines\n", argv[1], argv[2], differences); } exit(differences != 0); } cminpack-1.3.4/examples/errjac.c000644 000765 000765 00000024046 12225167750 016521 0ustar00devernay000000 000000 #include #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ static inline int max(int a, int b) { return (a > b) ? a : b; } static inline int min(int a, int b) { return (a < b) ? a : b; } void errjac(int n, const real *x, real *fjac, int ldfjac, int nprob) { /* System generated locals */ int fjac_offset; real d__1, d__2; /* Local variables */ static real h__; static int i__, j, k, k1, k2, ml; static real ti, tj, tk; static int mu; static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2, temp3, temp4; /* ********** */ /* subroutine errjac */ /* this subroutine is derived from vecjac which defines the */ /* jacobian matrices of fourteen test functions. the problem */ /* dimensions are as described in the prologue comments of vecfcn. */ /* various errors are deliberately introduced to provide a test */ /* for chkder. */ /* the subroutine statement is */ /* subroutine errjac(n,x,fjac,ldfjac,nprob) */ /* where */ /* n is a positive integer variable. */ /* x is an array of length n. */ /* fjac is an n by n array. on output fjac contains the */ /* jacobian matrix, with various errors deliberately */ /* introduced, of the nprob function evaluated at x. */ /* ldfjac is a positive integer variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* nprob is a positive integer variable which defines the */ /* number of the problem. nprob must not exceed 14. */ /* subprograms called */ /* fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, */ /* max0,min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; fjac_offset = 1 + ldfjac; fjac -= fjac_offset; /* Function Body */ /* jacobian routine selector. */ assert(nprob >= 1 && nprob <=14); switch (nprob) { case 1: goto L10; case 2: goto L20; case 3: goto L50; case 4: goto L60; case 5: goto L90; case 6: goto L100; case 7: goto L200; case 8: goto L230; case 9: goto L290; case 10: goto L320; case 11: goto L350; case 12: goto L380; case 13: goto L420; case 14: goto L450; } /* rosenbrock function with sign reversal affecting element (1,1). */ L10: fjac[1 * ldfjac + 1] = 1.; fjac[2 * ldfjac + 1] = 0.; fjac[1 * ldfjac + 2] = -20. * x[1]; fjac[2 * ldfjac + 2] = 10.; goto L490; /* powell singular function with sign reversal affecting element */ /* (3,3). */ L20: for (k = 1; k <= 4; ++k) { for (j = 1; j <= 4; ++j) { fjac[k + j * ldfjac] = 0.; /* L30: */ } /* L40: */ } fjac[1 * ldfjac + 1] = 1.; fjac[2 * ldfjac + 1] = 10.; fjac[3 * ldfjac + 2] = sqrt(5.); fjac[4 * ldfjac + 2] = -fjac[3 * ldfjac + 2]; fjac[2 * ldfjac + 3] = 2. * (x[2] - 2. * x[3]); fjac[3 * ldfjac + 3] = 2. * fjac[2 * ldfjac + 3]; fjac[1 * ldfjac + 4] = 2. * sqrt(10.) * (x[1] - x[4]); fjac[4 * ldfjac + 4] = -fjac[1 * ldfjac + 4]; goto L490; /* powell badly scaled function with the sign of the jacobian */ /* reversed. */ L50: fjac[1 * ldfjac + 1] = -1e4 * x[2]; fjac[2 * ldfjac + 1] = -1e4 * x[1]; fjac[1 * ldfjac + 2] = exp(-x[1]); fjac[2 * ldfjac + 2] = exp(-x[2]); goto L490; /* wood function without error. */ L60: for (k = 1; k <= 4; ++k) { for (j = 1; j <= 4; ++j) { fjac[k + j * ldfjac] = 0.; /* L70: */ } /* L80: */ } /* Computing 2nd power */ d__1 = x[1]; temp1 = x[2] - 3. * (d__1 * d__1); /* Computing 2nd power */ d__1 = x[3]; temp2 = x[4] - 3. * (d__1 * d__1); fjac[1 * ldfjac + 1] = -200. * temp1 + 1.; fjac[2 * ldfjac + 1] = -200. * x[1]; fjac[1 * ldfjac + 2] = -2. * 200. * x[1]; fjac[2 * ldfjac + 2] = 200. + 20.2; fjac[4 * ldfjac + 2] = 19.8; fjac[3 * ldfjac + 3] = -180. * temp2 + 1.; fjac[4 * ldfjac + 3] = -180. * x[3]; fjac[2 * ldfjac + 4] = 19.8; fjac[3 * ldfjac + 4] = -2. * 180. * x[3]; fjac[4 * ldfjac + 4] = 180. + 20.2; goto L490; /* helical valley function with multiplicative error affecting */ /* elements (2,1) and (2,2). */ L90: tpi = 8. * atan(1.); /* Computing 2nd power */ d__1 = x[1]; /* Computing 2nd power */ d__2 = x[2]; temp = d__1 * d__1 + d__2 * d__2; temp1 = tpi * temp; temp2 = sqrt(temp); fjac[1 * ldfjac + 1] = 100. * x[2] / temp1; fjac[2 * ldfjac + 1] = -100. * x[1] / temp1; fjac[3 * ldfjac + 1] = 10.; fjac[1 * ldfjac + 2] = 5. * x[1] / temp2; fjac[2 * ldfjac + 2] = 5. * x[2] / temp2; fjac[3 * ldfjac + 2] = 0.; fjac[1 * ldfjac + 3] = 0.; fjac[2 * ldfjac + 3] = 0.; fjac[3 * ldfjac + 3] = 1.; goto L490; /* watson function with sign reversals affecting the computation of */ /* temp1. */ L100: for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L110: */ } /* L120: */ } for (i__ = 1; i__ <= 29; ++i__) { ti = (real) i__ / 29.; sum1 = 0.; temp = 1.; for (j = 2; j <= n; ++j) { sum1 += (real) (j-1) * temp * x[j]; temp = ti * temp; /* L130: */ } sum2 = 0.; temp = 1.; for (j = 1; j <= n; ++j) { sum2 += temp * x[j]; temp = ti * temp; /* L140: */ } /* Computing 2nd power */ d__1 = sum2; temp1 = 2. * (sum1 - d__1 * d__1 + 1.); temp2 = 2. * sum2; /* Computing 2nd power */ d__1 = ti; temp = d__1 * d__1; tk = 1.; for (k = 1; k <= n; ++k) { tj = tk; for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] += tj * (((real) (k-1) / ti - temp2) * ((real) (j-1) / ti - temp2) - temp1); tj = ti * tj; /* L150: */ } tk = temp * tk; /* L160: */ } /* L170: */ } /* Computing 2nd power */ d__1 = x[1]; fjac[1 * ldfjac + 1] = fjac[1 * ldfjac + 1] + 6. * (d__1 * d__1) - 2. * x[2] + 3.; fjac[2 * ldfjac + 1] -= 2. * x[1]; fjac[2 * ldfjac + 2] += 1.; for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[j + k * ldfjac] = fjac[k + j * ldfjac]; /* L180: */ } /* L190: */ } goto L490; /* chebyquad function with jacobian twice correct size. */ L200: tk = 1. / (real) (n); for (j = 1; j <= n; ++j) { temp1 = 1.; temp2 = 2. * x[j] - 1.; temp = 2. * temp2; temp3 = 0.; temp4 = 2.; for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = 2. * tk * temp4; ti = 4. * temp2 + temp * temp4 - temp3; temp3 = temp4; temp4 = ti; ti = temp * temp2 - temp1; temp1 = temp2; temp2 = ti; /* L210: */ } /* L220: */ } goto L490; /* brown almost-linear function without error. */ L230: prod = 1.; for (j = 1; j <= n; ++j) { prod = x[j] * prod; for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = 1.; /* L240: */ } fjac[j + j * ldfjac] = 2.; /* L250: */ } for (j = 1; j <= n; ++j) { temp = x[j]; if (temp != 0.) { goto L270; } temp = 1.; prod = 1.; for (k = 1; k <= n; ++k) { if (k != j) { prod = x[k] * prod; } /* L260: */ } L270: fjac[n + j * ldfjac] = prod / temp; /* L280: */ } goto L490; /* discrete boundary value function with multiplicative error */ /* affecting the jacobian diagonal. */ L290: h__ = 1. / (real) (n+1); for (k = 1; k <= n; ++k) { /* Computing 2nd power */ d__1 = x[k] + (real) k * h__ + 1.; temp = 3. * (d__1 * d__1); for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L300: */ } /* Computing 2nd power */ d__1 = h__; fjac[k + k * ldfjac] = 4. + temp * (d__1 * d__1); if (k != 1) { fjac[k + (k - 1) * ldfjac] = -1.; } if (k != n) { fjac[k + (k + 1) * ldfjac] = -1.; } /* L310: */ } goto L490; /* discrete integral equation function with sign error affecting */ /* the jacobian diagonal. */ L320: h__ = 1. / (real) (n+1); for (k = 1; k <= n; ++k) { tk = (real) k * h__; for (j = 1; j <= n; ++j) { tj = (real) j * h__; /* Computing 2nd power */ d__1 = x[j] + tj + 1.; temp = 3. * (d__1 * d__1); /* Computing MIN */ d__1 = tj * (1. - tk), d__2 = tk * (1. - tj); fjac[k + j * ldfjac] = h__ * min(d__1,d__2) * temp / 2.; /* L330: */ } fjac[k + k * ldfjac] -= 1.; /* L340: */ } goto L490; /* trigonometric function with sign errors affecting the */ /* offdiagonal elements of the jacobian. */ L350: for (j = 1; j <= n; ++j) { temp = sin(x[j]); for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = -temp; /* L360: */ } fjac[j + j * ldfjac] = (real) (j+1) * temp - cos(x[j]); /* L370: */ } goto L490; /* variably dimensioned function with operation error affecting */ /* the upper triangular elements of the jacobian. */ L380: sum = 0.; for (j = 1; j <= n; ++j) { sum += (real) j * (x[j] - 1.); /* L390: */ } /* Computing 2nd power */ d__1 = sum; temp = 1. + 6. * (d__1 * d__1); for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] = (real) (k*j) / temp; fjac[j + k * ldfjac] = fjac[k + j * ldfjac]; /* L400: */ } fjac[k + k * ldfjac] += 1.; /* L410: */ } goto L490; /* broyden tridiagonal function without error. */ L420: for (k = 1; k <= n; ++k) { for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L430: */ } fjac[k + k * ldfjac] = 3. - 4. * x[k]; if (k != 1) { fjac[k + (k - 1) * ldfjac] = -1.; } if (k != n) { fjac[k + (k + 1) * ldfjac] = -2.; } /* L440: */ } goto L490; /* broyden banded function with sign error affecting the jacobian */ /* diagonal. */ L450: ml = 5; mu = 1; for (k = 1; k <= n; ++k) { for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L460: */ } /* Computing MAX */ k1 = max(1,k-ml); /* Computing MIN */ k2 = min(k+mu,n); for (j = k1; j <= k2; ++j) { if (j != k) { fjac[k + j * ldfjac] = -(1. + 2. * x[j]); } /* L470: */ } /* Computing 2nd power */ d__1 = x[k]; fjac[k + k * ldfjac] = 2. - 15. * (d__1 * d__1); /* L480: */ } L490: return; /* last card of subroutine errjac. */ } /* errjac_ */ cminpack-1.3.4/examples/errjac.f000644 000765 000765 00000021430 12225167750 016516 0ustar00devernay000000 000000 subroutine errjac(n,x,fjac,ldfjac,nprob) integer n,ldfjac,nprob double precision x(n),fjac(ldfjac,n) c ********** c c subroutine errjac c c this subroutine is derived from vecjac which defines the c jacobian matrices of fourteen test functions. the problem c dimensions are as described in the prologue comments of vecfcn. c various errors are deliberately introduced to provide a test c for chkder. c c the subroutine statement is c c subroutine errjac(n,x,fjac,ldfjac,nprob) c c where c c n is a positive integer variable. c c x is an array of length n. c c fjac is an n by n array. on output fjac contains the c jacobian matrix, with various errors deliberately c introduced, of the nprob function evaluated at x. c c ldfjac is a positive integer variable not less than n c which specifies the leading dimension of the array fjac. c c nprob is a positive integer variable which defines the c number of the problem. nprob must not exceed 14. c c subprograms called c c fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, c max0,min0 c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ivar,j,k,k1,k2,ml,mu double precision c1,c3,c4,c5,c6,c9,eight,fiftn,five,four,h, * hundrd,one,prod,six,sum,sum1,sum2,temp,temp1, * temp2,temp3,temp4,ten,three,ti,tj,tk,tpi, * twenty,two,zero double precision dfloat data zero,one,two,three,four,five,six,eight,ten,fiftn,twenty, * hundrd * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,6.0d0,8.0d0,1.0d1, * 1.5d1,2.0d1,1.0d2/ data c1,c3,c4,c5,c6,c9 /1.0d4,2.0d2,2.02d1,1.98d1,1.8d2,2.9d1/ dfloat(ivar) = ivar c c jacobian routine selector. c go to (10,20,50,60,90,100,200,230,290,320,350,380,420,450), * nprob c c rosenbrock function with sign reversal affecting element (1,1). c 10 continue fjac(1,1) = one fjac(1,2) = zero fjac(2,1) = -twenty*x(1) fjac(2,2) = ten go to 490 c c powell singular function with sign reversal affecting element c (3,3). c 20 continue do 40 k = 1, 4 do 30 j = 1, 4 fjac(k,j) = zero 30 continue 40 continue fjac(1,1) = one fjac(1,2) = ten fjac(2,3) = dsqrt(five) fjac(2,4) = -fjac(2,3) fjac(3,2) = two*(x(2) - two*x(3)) fjac(3,3) = two*fjac(3,2) fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4)) fjac(4,4) = -fjac(4,1) go to 490 c c powell badly scaled function with the sign of the jacobian c reversed. c 50 continue fjac(1,1) = -c1*x(2) fjac(1,2) = -c1*x(1) fjac(2,1) = dexp(-x(1)) fjac(2,2) = dexp(-x(2)) go to 490 c c wood function without error. c 60 continue do 80 k = 1, 4 do 70 j = 1, 4 fjac(k,j) = zero 70 continue 80 continue temp1 = x(2) - three*x(1)**2 temp2 = x(4) - three*x(3)**2 fjac(1,1) = -c3*temp1 + one fjac(1,2) = -c3*x(1) fjac(2,1) = -two*c3*x(1) fjac(2,2) = c3 + c4 fjac(2,4) = c5 fjac(3,3) = -c6*temp2 + one fjac(3,4) = -c6*x(3) fjac(4,2) = c5 fjac(4,3) = -two*c6*x(3) fjac(4,4) = c6 + c4 go to 490 c c helical valley function with multiplicative error affecting c elements (2,1) and (2,2). c 90 continue tpi = eight*datan(one) temp = x(1)**2 + x(2)**2 temp1 = tpi*temp temp2 = dsqrt(temp) fjac(1,1) = hundrd*x(2)/temp1 fjac(1,2) = -hundrd*x(1)/temp1 fjac(1,3) = ten fjac(2,1) = five*x(1)/temp2 fjac(2,2) = five*x(2)/temp2 fjac(2,3) = zero fjac(3,1) = zero fjac(3,2) = zero fjac(3,3) = one go to 490 c c watson function with sign reversals affecting the computation of c temp1. c 100 continue do 120 k = 1, n do 110 j = k, n fjac(k,j) = zero 110 continue 120 continue do 170 i = 1, 29 ti = dfloat(i)/c9 sum1 = zero temp = one do 130 j = 2, n sum1 = sum1 + dfloat(j-1)*temp*x(j) temp = ti*temp 130 continue sum2 = zero temp = one do 140 j = 1, n sum2 = sum2 + temp*x(j) temp = ti*temp 140 continue temp1 = two*(sum1 + sum2**2 + one) temp2 = two*sum2 temp = ti**2 tk = one do 160 k = 1, n tj = tk do 150 j = k, n fjac(k,j) = fjac(k,j) * + tj * *((dfloat(k-1)/ti - temp2) * *(dfloat(j-1)/ti - temp2) - temp1) tj = ti*tj 150 continue tk = temp*tk 160 continue 170 continue fjac(1,1) = fjac(1,1) + six*x(1)**2 - two*x(2) + three fjac(1,2) = fjac(1,2) - two*x(1) fjac(2,2) = fjac(2,2) + one do 190 k = 1, n do 180 j = k, n fjac(j,k) = fjac(k,j) 180 continue 190 continue go to 490 c c chebyquad function with jacobian twice correct size. c 200 continue tk = one/dfloat(n) do 220 j = 1, n temp1 = one temp2 = two*x(j) - one temp = two*temp2 temp3 = zero temp4 = two do 210 k = 1, n fjac(k,j) = two*tk*temp4 ti = four*temp2 + temp*temp4 - temp3 temp3 = temp4 temp4 = ti ti = temp*temp2 - temp1 temp1 = temp2 temp2 = ti 210 continue 220 continue go to 490 c c brown almost-linear function without error. c 230 continue prod = one do 250 j = 1, n prod = x(j)*prod do 240 k = 1, n fjac(k,j) = one 240 continue fjac(j,j) = two 250 continue do 280 j = 1, n temp = x(j) if (temp .ne. zero) go to 270 temp = one prod = one do 260 k = 1, n if (k .ne. j) prod = x(k)*prod 260 continue 270 continue fjac(n,j) = prod/temp 280 continue go to 490 c c discrete boundary value function with multiplicative error c affecting the jacobian diagonal. c 290 continue h = one/dfloat(n+1) do 310 k = 1, n temp = three*(x(k) + dfloat(k)*h + one)**2 do 300 j = 1, n fjac(k,j) = zero 300 continue fjac(k,k) = four + temp*h**2 if (k .ne. 1) fjac(k,k-1) = -one if (k .ne. n) fjac(k,k+1) = -one 310 continue go to 490 c c discrete integral equation function with sign error affecting c the jacobian diagonal. c 320 continue h = one/dfloat(n+1) do 340 k = 1, n tk = dfloat(k)*h do 330 j = 1, n tj = dfloat(j)*h temp = three*(x(j) + tj + one)**2 fjac(k,j) = h*dmin1(tj*(one-tk),tk*(one-tj))*temp/two 330 continue fjac(k,k) = fjac(k,k) - one 340 continue go to 490 c c trigonometric function with sign errors affecting the c offdiagonal elements of the jacobian. c 350 continue do 370 j = 1, n temp = dsin(x(j)) do 360 k = 1, n fjac(k,j) = -temp 360 continue fjac(j,j) = dfloat(j+1)*temp - dcos(x(j)) 370 continue go to 490 c c variably dimensioned function with operation error affecting c the upper triangular elements of the jacobian. c 380 continue sum = zero do 390 j = 1, n sum = sum + dfloat(j)*(x(j) - one) 390 continue temp = one + six*sum**2 do 410 k = 1, n do 400 j = k, n fjac(k,j) = dfloat(k*j)/temp fjac(j,k) = fjac(k,j) 400 continue fjac(k,k) = fjac(k,k) + one 410 continue go to 490 c c broyden tridiagonal function without error. c 420 continue do 440 k = 1, n do 430 j = 1, n fjac(k,j) = zero 430 continue fjac(k,k) = three - four*x(k) if (k .ne. 1) fjac(k,k-1) = -one if (k .ne. n) fjac(k,k+1) = -two 440 continue go to 490 c c broyden banded function with sign error affecting the jacobian c diagonal. c 450 continue ml = 5 mu = 1 do 480 k = 1, n do 460 j = 1, n fjac(k,j) = zero 460 continue k1 = max0(1,k-ml) k2 = min0(k+mu,n) do 470 j = k1, k2 if (j .ne. k) fjac(k,j) = -(one + two*x(j)) 470 continue fjac(k,k) = two - fiftn*x(k)**2 480 continue 490 continue return c c last card of subroutine errjac. c end cminpack-1.3.4/examples/fcn.mpl000644 000765 000765 00000000666 12274173735 016375 0ustar00devernay000000 000000 with(VectorCalculus): fvec := Vector(15); y := Vector([.14, .18, .22, .25, .29, .32, .35, .39, .37, .58, .73, .96, 1.34, 2.1, 4.39]); for i to 15 do tmp1 := (i -1)+ 1: tmp2 := 15 - (i-1): if (i-1) > 7 then tmp3 := tmp2 else tmp3 := tmp1 fi: fvec[i] := y[i] - (x[1] + tmp1/(x[2]*tmp2 + x[3]*tmp3)): od: Jacobian(fvec,[x[1],x[2],x[3]]); # now, with the second variable, x[2] bounded between a=0.1 and b=0.9 a:=0.1: b:=cminpack-1.3.4/examples/genf77tests.c000644 000765 000765 00000006025 12225167750 017430 0ustar00devernay000000 000000 /* generate F77 test sources for MINPACK from the documentation author: Frederic.Devernay@m4x.org */ /* Original awk program was: /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; } */ #include #include #include #include int main(int argc, char **argv) { FILE *f_doc; char buf[256]; if (argc != 2) { fprintf(stderr,"Usage: %s path/to/minpack-documentation.txt\n", argv[0]); exit(2); } f_doc = fopen(argv[1], "r"); if (f_doc == NULL) { perror("Error: cannot open input file"); exit(1); } while (fgets(buf, sizeof(buf), f_doc) != NULL) { const char *head = "DRIVER FOR"; char *pos; pos = strstr(buf, head); /* fgets() always returns a NUL-terminated buffer, so there's no buffer over-read risk */ if (pos != NULL) { FILE *f_src; /* we found a test source */ char *name, *line; int i; int finished = 0; pos = pos + strlen(head); name = strdup(pos); assert(name[0] == ' '); name[0] = 't'; i = 1; while(name[i] != 0 && name[i] != ' ') { if (name[i] >= 'A' && name[i] <= 'Z') name[i] = name[i] - 'A' + 'a'; i++; } assert(name[i] == ' ' && name[i+1] != 0); name[i] = '.'; name[i+1] = 'f'; name[i+2] = 0; f_src = fopen(name, "w"); if (f_src == NULL) { perror("Error: cannot open output file"); exit(1); } fputs(buf+2, f_src); while (!finished && fgets(buf, sizeof(buf), f_doc) != NULL) { /* test for page skip */ const char *buf1 = buf; while(*buf1 != 0 && *buf1 == ' ') buf1++; if (*buf1 == 0) { /* blank line (happens before page skip) */ } else if(strcmp(buf1, "Page\n") == 0) { /* page skip */ /* fputs("\n",f_src); */ } else { /* test for end of function */ finished = (strstr(buf, "LAST CARD OF SUBROUTINE FCN") != NULL); fputs(buf+2, f_src); } } assert(finished); /* two more lines */ line = fgets(buf, sizeof(buf), f_doc); assert(line != NULL); fputs(buf+2, f_src); line = fgets(buf, sizeof(buf), f_doc); assert(line != NULL); fputs(buf+2, f_src); fclose(f_src); } } fclose(f_doc); } cminpack-1.3.4/examples/grdfcn.f000644 000765 000765 00000025317 12225167750 016523 0ustar00devernay000000 000000 subroutine grdfcn(n,x,g,nprob) integer n,nprob double precision x(n),g(n) c ********** c c subroutine grdfcn c c this subroutine defines the gradient vectors of eighteen c nonlinear unconstrained minimization problems. the problem c dimensions are as described in the prologue comments of objfcn. c c the subroutine statement is c c subroutine grdfcn(n,x,g,nprob) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c g is an output array of length n which contains the components c of the gradient vector of the nprob objective function c evaluated at x. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin, c dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j double precision ap,arg,c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5, * c2p25,c2p625,c3p5,c19p8,c20p2,c25,c29,c100, * c180,c200,c10000,c1pd6,d1,d2,eight,fifty,five, * four,one,r,s1,s2,s3,t,t1,t2,t3,ten,th,three, * tpi,twenty,two,zero double precision fvec(50),y(15) double precision dfloat data zero,one,two,three,four,five,eight,ten,twenty,fifty * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1, * 5.0d1/ data c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,c2p25,c2p625,c3p5, * c19p8,c20p2,c25,c29,c100,c180,c200,c10000,c1pd6 * /2.0d-6,1.0d-4,1.0d-1,2.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0, * 2.625d0,3.5d0,1.98d1,2.02d1,2.5d1,2.9d1,1.0d2,1.8d2,2.0d2, * 1.0d4,1.0d6/ data ap /1.0d-5/ data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11), * y(12),y(13),y(14),y(15) * /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1, * 3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3, * 9.0d-4/ dfloat(ivar) = ivar c c gradient routine selector. c go to (10,20,50,70,80,100,130,190,220,260,270,290,310,350,370, * 390,400,410), nprob c c helical valley function. c 10 continue tpi = eight*datan(one) th = dsign(cp25,x(2)) if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5 arg = x(1)**2 + x(2)**2 r = dsqrt(arg) t = x(3) - ten*th s1 = ten*t/(tpi*arg) g(1) = c200*(x(1) - x(1)/r + x(2)*s1) g(2) = c200*(x(2) - x(2)/r - x(1)*s1) g(3) = two*(c100*t + x(3)) go to 490 c c biggs exp6 function. c 20 continue do 30 j = 1, 6 g(j) = zero 30 continue do 40 i = 1, 13 d1 = dfloat(i)/ten d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1) s1 = dexp(-d1*x(1)) s2 = dexp(-d1*x(2)) s3 = dexp(-d1*x(5)) t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2 th = d1*t g(1) = g(1) - s1*th g(2) = g(2) + s2*th g(3) = g(3) + s1*t g(4) = g(4) - s2*t g(5) = g(5) - s3*th g(6) = g(6) + s3*t 40 continue g(1) = two*x(3)*g(1) g(2) = two*x(4)*g(2) g(3) = two*g(3) g(4) = two*g(4) g(5) = two*x(6)*g(5) g(6) = two*g(6) go to 490 c c gaussian function. c 50 continue g(1) = zero g(2) = zero g(3) = zero do 60 i = 1, 15 d1 = cp5*dfloat(i-1) d2 = c3p5 - d1 - x(3) arg = -cp5*x(2)*d2**2 r = dexp(arg) t = x(1)*r - y(i) s1 = r*t s2 = d2*s1 g(1) = g(1) + s1 g(2) = g(2) - d2*s2 g(3) = g(3) + s2 60 continue g(1) = two*g(1) g(2) = x(1)*g(2) g(3) = two*x(1)*x(2)*g(3) go to 490 c c powell badly scaled function. c 70 continue t1 = c10000*x(1)*x(2) - one s1 = dexp(-x(1)) s2 = dexp(-x(2)) t2 = s1 + s2 - one - cp0001 g(1) = two*(c10000*x(2)*t1 - s1*t2) g(2) = two*(c10000*x(1)*t1 - s2*t2) go to 490 c c box 3-dimensional function. c 80 continue g(1) = zero g(2) = zero g(3) = zero do 90 i = 1, 10 d1 = dfloat(i) d2 = d1/ten s1 = dexp(-d2*x(1)) s2 = dexp(-d2*x(2)) s3 = dexp(-d2) - dexp(-d1) t = s1 - s2 - s3*x(3) th = d2*t g(1) = g(1) - s1*th g(2) = g(2) + s2*th g(3) = g(3) - s3*t 90 continue g(1) = two*g(1) g(2) = two*g(2) g(3) = two*g(3) go to 490 c c variably dimensioned function. c 100 continue t1 = zero do 110 j = 1, n t1 = t1 + dfloat(j)*(x(j) - one) 110 continue t = t1*(one + two*t1**2) do 120 j = 1, n g(j) = two*(x(j) - one + dfloat(j)*t) 120 continue go to 490 c c watson function. c 130 continue do 140 j = 1, n g(j) = zero 140 continue do 180 i = 1, 29 d1 = dfloat(i)/c29 s1 = zero d2 = one do 150 j = 2, n s1 = s1 + dfloat(j-1)*d2*x(j) d2 = d1*d2 150 continue s2 = zero d2 = one do 160 j = 1, n s2 = s2 + d2*x(j) d2 = d1*d2 160 continue t = s1 - s2**2 - one s3 = two*d1*s2 d2 = two/d1 do 170 j = 1, n g(j) = g(j) + d2*(dfloat(j-1) - s3)*t d2 = d1*d2 170 continue 180 continue t1 = x(2) - x(1)**2 - one g(1) = g(1) + x(1)*(two - four*t1) g(2) = g(2) + two*t1 go to 490 c c penalty function i. c 190 continue t1 = -cp25 do 200 j = 1, n t1 = t1 + x(j)**2 200 continue d1 = two*ap th = four*t1 do 210 j = 1, n g(j) = d1*(x(j) - one) + x(j)*th 210 continue go to 490 c c penalty function ii. c 220 continue t1 = -one do 230 j = 1, n t1 = t1 + dfloat(n-j+1)*x(j)**2 230 continue d1 = dexp(cp1) d2 = one th = four*t1 do 250 j = 1, n g(j) = dfloat(n-j+1)*x(j)*th s1 = dexp(x(j)/ten) if (j .eq. 1) go to 240 s3 = s1 + s2 - d2*(d1 + one) g(j) = g(j) + ap*s1*(s3 + s1 - one/d1)/five g(j-1) = g(j-1) + ap*s2*s3/five 240 continue s2 = s1 d2 = d1*d2 250 continue g(1) = g(1) + two*(x(1) - cp2) go to 490 c c brown badly scaled function. c 260 continue t1 = x(1) - c1pd6 t2 = x(2) - c2pdm6 t3 = x(1)*x(2) - two g(1) = two*(t1 + x(2)*t3) g(2) = two*(t2 + x(1)*t3) go to 490 c c brown and dennis function. c 270 continue g(1) = zero g(2) = zero g(3) = zero g(4) = zero do 280 i = 1, 20 d1 = dfloat(i)/five d2 = dsin(d1) t1 = x(1) + d1*x(2) - dexp(d1) t2 = x(3) + d2*x(4) - dcos(d1) t = t1**2 + t2**2 s1 = t1*t s2 = t2*t g(1) = g(1) + s1 g(2) = g(2) + d1*s1 g(3) = g(3) + s2 g(4) = g(4) + d2*s2 280 continue g(1) = four*g(1) g(2) = four*g(2) g(3) = four*g(3) g(4) = four*g(4) go to 490 c c gulf research and development function. c 290 continue g(1) = zero g(2) = zero g(3) = zero d1 = two/three do 300 i = 1, 99 arg = dfloat(i)/c100 r = (-fifty*dlog(arg))**d1 + c25 - x(2) t1 = dabs(r)**x(3)/x(1) t2 = dexp(-t1) t = t2 - arg s1 = t1*t2*t g(1) = g(1) + s1 g(2) = g(2) + s1/r g(3) = g(3) - s1*dlog(dabs(r)) 300 continue g(1) = two*g(1)/x(1) g(2) = two*x(3)*g(2) g(3) = two*g(3) go to 490 c c trigonometric function. c 310 continue s1 = zero do 320 j = 1, n g(j) = dcos(x(j)) s1 = s1 + g(j) 320 continue s2 = zero do 330 j = 1, n th = dsin(x(j)) t = dfloat(n+j) - th - s1 - dfloat(j)*g(j) s2 = s2 + t g(j) = (dfloat(j)*th - g(j))*t 330 continue do 340 j = 1, n g(j) = two*(g(j) + dsin(x(j))*s2) 340 continue go to 490 c c extended rosenbrock function. c 350 continue do 360 j = 1, n, 2 t1 = one - x(j) g(j+1) = c200*(x(j+1) - x(j)**2) g(j) = -two*(x(j)*g(j+1) + t1) 360 continue go to 490 c c extended powell function. c 370 continue do 380 j = 1, n, 4 t = x(j) + ten*x(j+1) t1 = x(j+2) - x(j+3) s1 = five*t1 t2 = x(j+1) - two*x(j+2) s2 = four*t2**3 t3 = x(j) - x(j+3) s3 = twenty*t3**3 g(j) = two*(t + s3) g(j+1) = twenty*t + s2 g(j+2) = two*(s1 - s2) g(j+3) = -two*(s1 + s3) 380 continue go to 490 c c beale function. c 390 continue s1 = one - x(2) t1 = c1p5 - x(1)*s1 s2 = one - x(2)**2 t2 = c2p25 - x(1)*s2 s3 = one - x(2)**3 t3 = c2p625 - x(1)*s3 g(1) = -two*(s1*t1 + s2*t2 + s3*t3) g(2) = two*x(1)*(t1 + x(2)*(two*t2 + three*x(2)*t3)) go to 490 c c wood function. c 400 continue s1 = x(2) - x(1)**2 s2 = one - x(1) s3 = x(2) - one t1 = x(4) - x(3)**2 t2 = one - x(3) t3 = x(4) - one g(1) = -two*(c200*x(1)*s1 + s2) g(2) = c200*s1 + c20p2*s3 + c19p8*t3 g(3) = -two*(c180*x(3)*t1 + t2) g(4) = c180*t1 + c20p2*t3 + c19p8*s3 go to 490 c c chebyquad function. c 410 continue do 420 i = 1, n fvec(i) = zero 420 continue do 440 j = 1, n t1 = one t2 = two*x(j) - one t = two*t2 do 430 i = 1, n fvec(i) = fvec(i) + t2 th = t*t2 - t1 t1 = t2 t2 = th 430 continue 440 continue d1 = one/dfloat(n) iev = -1 do 450 i = 1, n fvec(i) = d1*fvec(i) if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one) iev = -iev 450 continue do 470 j = 1, n g(j) = zero t1 = one t2 = two*x(j) - one t = two*t2 s1 = zero s2 = two do 460 i = 1, n g(j) = g(j) + fvec(i)*s2 th = four*t2 + t*s2 - s1 s1 = s2 s2 = th th = t*t2 - t1 t1 = t2 t2 = th 460 continue 470 continue d2 = two*d1 do 480 j = 1, n g(j) = d2*g(j) 480 continue 490 continue return c c last card of subroutine grdfcn. c end cminpack-1.3.4/examples/hesfcn.f000644 000765 000765 00000042456 12225167750 016531 0ustar00devernay000000 000000 subroutine hesfcn(n,x,h,ldh,nprob) integer n,ldh,nprob double precision x(n),h(ldh,n) c ********** c c subroutine hesfcn c c this subroutine defines the hessian matrices of eighteen c nonlinear unconstrained minimization problems. the problem c dimensions are as described in the prologue comments of objfcn. c the upper triangle of the (symmetric) hessian matrix is c computed columnwise. storage locations below the diagonal c are not disturbed until the final step, which reflects the c upper triangle to fill the square matrix. c c the subroutine statement is c c subroutine hesfcn(n,x,h,ldh,nprob) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c h is an n by n array. on output h contains the hessian c matrix of the nprob objective function evaluated at x. c c ldh is a positive integer input variable not less than n c which specifies the leading dimension of the array h. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin, c dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j,k,n2 double precision ap,arg,cp0001,cp1,cp25,cp5,c1p5,c2p25, * c2p625,c3p5,c19p8,c25,c29,c100,c200,c10000,d1, * d2,eight,fifty,five,four,one,r,s1,s2,s3,t,t1, * t2,t3,ten,th,three,tpi,twenty,two,zero double precision d3,r1,r2,r3,u1,u2,v,v1,v2 double precision fvec(50),fvec1(50),y(15) double precision dfloat double precision six,xnine,twelve,c120,c200p2,c202,c220p2,c360, * c400,c1200 data six,xnine,twelve,c120,c200p2,c202,c220p2,c360,c400,c1200 * /6.0d0,9.0d0,1.2d1,1.2d2,2.002d2,2.02d2,2.202d2,3.6d2, * 4.0d2,1.2d3/ data zero,one,two,three,four,five,eight,ten,twenty,fifty * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1, * 5.0d1/ data cp0001,cp1,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c19p8,c25,c29, * c100,c200,c10000 * /1.0d-4,1.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,2.625d0,3.5d0, * 1.98d1,2.5d1,2.9d1,1.0d2,2.0d2,1.0d4/ data ap /1.0d-5/ data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11), * y(12),y(13),y(14),y(15) * /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1, * 3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3, * 9.0d-4/ dfloat(ivar) = ivar c c hessian routine selector. c go to (10,20,60,100,110,170,210,290,330,380,390,450,490,580,620, * 660,670,680), nprob c c helical valley function. c 10 continue tpi = eight*datan(one) th = dsign(cp25,x(2)) if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5 arg = x(1)**2 + x(2)**2 r = dsqrt(arg) t = x(3) - ten*th s1 = ten*t/(tpi*arg) t1 = ten/tpi t2 = t1/arg t3 = (x(1)/r - t1*t2*x(1) - two*x(2)*s1)/arg h(1,1) = c200 * *(one - x(2)/arg*(x(2)/r - t1*t2*x(2) + two*x(1)*s1)) h(1,2) = c200*(s1 + x(2)*t3) h(2,2) = c200*(one - x(1)*t3) h(1,3) = c200*t2*x(2) h(2,3) = -c200*t2*x(1) h(3,3) = c202 go to 800 c c biggs exp6 function. c 20 continue do 40 j = 1, 6 do 30 i = 1, j h(i,j) = zero 30 continue 40 continue do 50 i = 1, 13 d1 = dfloat(i)/ten d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1) s1 = dexp(-d1*x(1)) s2 = dexp(-d1*x(2)) s3 = dexp(-d1*x(5)) t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2 th = d1*t r1 = d1*s1 r2 = d1*s2 r3 = d1*s3 h(1,1) = h(1,1) + r1*(th + x(3)*r1) h(1,2) = h(1,2) - r1*r2 h(2,2) = h(2,2) - r2*(th - x(4)*r2) h(1,3) = h(1,3) - s1*(th + x(3)*r1) h(3,3) = h(3,3) + s1**2 h(1,4) = h(1,4) + r1*s2 h(2,4) = h(2,4) + s2*(th - x(4)*r2) h(3,4) = h(3,4) - s1*s2 h(4,4) = h(4,4) + s2**2 h(1,5) = h(1,5) + r1*r3 h(2,5) = h(2,5) - r2*r3 h(5,5) = h(5,5) + r3*(th + x(6)*r3) h(1,6) = h(1,6) - r1*s3 h(2,6) = h(2,6) + r2*s3 h(3,6) = h(3,6) + s1*s3 h(4,6) = h(4,6) - s2*s3 h(5,6) = h(5,6) - s3*(th + x(6)*r3) h(6,6) = h(6,6) + s3**2 50 continue h(1,1) = two*x(3)*h(1,1) h(1,2) = two*x(3)*x(4)*h(1,2) h(2,2) = two*x(4)*h(2,2) h(1,3) = two*h(1,3) h(2,3) = two*x(4)*h(1,4) h(3,3) = two*h(3,3) h(1,4) = two*x(3)*h(1,4) h(2,4) = two*h(2,4) h(3,4) = two*h(3,4) h(4,4) = two*h(4,4) h(1,5) = two*x(3)*x(6)*h(1,5) h(2,5) = two*x(4)*x(6)*h(2,5) h(3,5) = two*x(6)*h(1,6) h(4,5) = two*x(6)*h(2,6) h(5,5) = two*x(6)*h(5,5) h(1,6) = two*x(3)*h(1,6) h(2,6) = two*x(4)*h(2,6) h(3,6) = two*h(3,6) h(4,6) = two*h(4,6) h(5,6) = two*h(5,6) h(6,6) = two*h(6,6) go to 800 c c gaussian function. c 60 continue do 80 j = 1, 3 do 70 i = 1, j h(i,j) = zero 70 continue 80 continue do 90 i = 1, 15 d1 = cp5*dfloat(i-1) d2 = c3p5 - d1 - x(3) arg = -cp5*x(2)*d2**2 r = dexp(arg) t = x(1)*r - y(i) s1 = r*t s2 = d2*s1 t1 = s2 + d2*x(1)*r**2 t2 = d2*t1 h(1,1) = h(1,1) + r**2 h(1,2) = h(1,2) - t2 h(2,2) = h(2,2) + d2**2*t2 h(1,3) = h(1,3) + t1 h(2,3) = h(2,3) + two*s2 - d2*x(2)*t2 h(3,3) = h(3,3) + x(2)*t2 - s1 90 continue h(1,1) = two*h(1,1) h(1,2) = h(1,2) h(2,2) = cp5*x(1)*h(2,2) h(1,3) = two*x(2)*h(1,3) h(2,3) = x(1)*h(2,3) h(3,3) = two*x(1)*x(2)*h(3,3) go to 800 c c powell badly scaled function. c 100 continue t1 = c10000*x(1)*x(2) - one s1 = dexp(-x(1)) s2 = dexp(-x(2)) t2 = s1 + s2 - one - cp0001 h(1,1) = two*((c10000*x(2))**2 + s1*(s1 + t2)) h(1,2) = two*(c10000*(one + two*t1) + s1*s2) h(2,2) = two*((c10000*x(1))**2 + s2*(s2 + t2)) go to 800 c c box 3-dimensional function. c 110 continue do 130 j = 1, 3 do 120 i = 1, j h(i,j) = zero 120 continue 130 continue do 140 i = 1, 10 d1 = dfloat(i) d2 = d1/ten s1 = dexp(-d2*x(1)) s2 = dexp(-d2*x(2)) s3 = dexp(-d2) - dexp(-d1) t = s1 - s2 - s3*x(3) th = d2*t r1 = d2*s1 r2 = d2*s2 h(1,1) = h(1,1) + r1*(th + r1) h(1,2) = h(1,2) - r1*r2 h(2,2) = h(2,2) - r2*(th - r2) h(1,3) = h(1,3) + r1*s3 h(2,3) = h(2,3) - r2*s3 h(3,3) = h(3,3) + s3**2 140 continue do 160 j = 1, 3 do 150 i = 1, j h(i,j) = two*h(i,j) 150 continue 160 continue go to 800 c c variably dimensioned function. c 170 continue t1 = zero do 180 j = 1, n t1 = t1 + dfloat(j)*(x(j) - one) 180 continue c t = t1*(one + two*t1**2) t2 = two + twelve*t1**2 do 200 j = 1, n do 190 i = 1, j h(i,j) = dfloat(i*j)*t2 190 continue h(j,j) = h(j,j) + two 200 continue go to 800 c c watson function. c 210 continue do 230 j = 1, n do 220 k = 1, j h(k,j) = zero 220 continue 230 continue do 280 i = 1, 29 d1 = dfloat(i)/c29 s1 = zero d2 = one do 240 j = 2, n s1 = s1 + dfloat(j-1)*d2*x(j) d2 = d1*d2 240 continue s2 = zero d2 = one do 250 j = 1, n s2 = s2 + d2*x(j) d2 = d1*d2 250 continue t = s1 - s2**2 - one s3 = two*d1*s2 d2 = two/d1 th = two*d1**2*t do 270 j = 1, n v = dfloat(j-1) - s3 d3 = one/d1 do 260 k = 1, j h(k,j) = h(k,j) + d2*d3*(v*(dfloat(k-1) - s3) - th) d3 = d1*d3 260 continue d2 = d1*d2 270 continue 280 continue t1 = x(2) - x(1)**2 - one h(1,1) = h(1,1) + eight*x(1)**2 + two - four*t1 h(1,2) = h(1,2) - four*x(1) h(2,2) = h(2,2) + two go to 800 c c penalty function i. c 290 continue t1 = -cp25 do 300 j = 1, n t1 = t1 + x(j)**2 300 continue d1 = two*ap th = four*t1 do 320 j = 1, n t2 = eight*x(j) do 310 i = 1, j h(i,j) = x(i)*t2 310 continue h(j,j) = h(j,j) + d1 + th 320 continue go to 800 c c penalty function ii. c 330 continue t1 = -one do 340 j = 1, n t1 = t1 + dfloat(n-j+1)*x(j)**2 340 continue d1 = dexp(cp1) d2 = one th = four*t1 do 370 j = 1, n t2 = eight*dfloat(n-j+1)*x(j) do 350 i = 1, j h(i,j) = dfloat(n-i+1)*x(i)*t2 350 continue h(j,j) = h(j,j) + dfloat(n-j+1)*th s1 = dexp(x(j)/ten) if (j .eq. 1) go to 360 s3 = s1 + s2 - d2*(d1 + one) h(j,j) = h(j,j) + ap*s1*(s3 + three*s1 - one/d1)/fifty h(j-1,j) = h(j-1,j) + ap*s1*s2/fifty h(j-1,j-1) = h(j-1,j-1) + ap*s2*(s2 + s3)/fifty 360 continue s2 = s1 d2 = d1*d2 370 continue h(1,1) = h(1,1) + two go to 800 c c brown badly scaled function. c 380 continue c t1 = x(1) - c1pd6 c t2 = x(2) - c2pdm6 t3 = x(1)*x(2) - two h(1,1) = two*(one + x(2)**2) h(1,2) = four*(one + t3) h(2,2) = two*(one + x(1)**2) go to 800 c c brown and dennis function. c 390 continue do 410 j = 1, 4 do 400 i = 1, j h(i,j) = zero 400 continue 410 continue do 420 i = 1, 20 d1 = dfloat(i)/five d2 = dsin(d1) t1 = x(1) + d1*x(2) - dexp(d1) t2 = x(3) + d2*x(4) - dcos(d1) t = t1**2 + t2**2 c s1 = t1*t c s2 = t2*t s3 = two*t1*t2 r1 = t + two*t1**2 r2 = t + two*t2**2 h(1,1) = h(1,1) + r1 h(1,2) = h(1,2) + d1*r1 h(2,2) = h(2,2) + d1**2*r1 h(1,3) = h(1,3) + s3 h(2,3) = h(2,3) + d1*s3 h(3,3) = h(3,3) + r2 h(1,4) = h(1,4) + d2*s3 h(2,4) = h(2,4) + d1*d2*s3 h(3,4) = h(3,4) + d2*r2 h(4,4) = h(4,4) + d2**2*r2 420 continue do 440 j = 1, 4 do 430 i = 1, j h(i,j) = four*h(i,j) 430 continue 440 continue go to 800 c c gulf research and development function. c 450 continue do 470 j = 1, 3 do 460 i = 1, j h(i,j) = zero 460 continue 470 continue d1 = two/three do 480 i = 1, 99 arg = dfloat(i)/c100 r = (-fifty*dlog(arg))**d1 + c25 - x(2) t1 = dabs(r)**x(3)/x(1) t2 = dexp(-t1) t = t2 - arg s1 = t1*t2*t s2 = t1*(s1 + t2*(t1*t2 - t)) r1 = dlog(dabs(r)) r2 = r1*s2 h(1,1) = h(1,1) + s2 - s1 h(1,2) = h(1,2) + s2/r h(2,2) = h(2,2) + (s1 + x(3)*s2)/r**2 h(1,3) = h(1,3) - r2 h(2,3) = h(2,3) + (s1 - x(3)*r2)/r h(3,3) = h(3,3) + r1*r2 480 continue h(1,1) = two*h(1,1)/x(1)**2 h(1,2) = two*x(3)*h(1,2)/x(1) h(2,2) = two*x(3)*h(2,2) h(1,3) = two*h(1,3)/x(1) h(2,3) = two*h(2,3) h(3,3) = two*h(3,3) go to 800 c c trigonometric function. c 490 continue u2 = dcos(x(n)) s1 = u2 if (n .eq. 1) go to 510 u1 = dcos(x(n-1)) s1 = s1 + u1 if (n .eq. 2) go to 510 n2 = n - 2 do 500 j = 1, n2 h(j,n-1) = dcos(x(j)) s1 = s1 + h(j,n-1) 500 continue 510 continue v2 = dsin(x(n)) s2 = dfloat(2*n) - v2 - s1 - dfloat(n)*u2 r2 = dfloat(2*n)*v2 - u2 if (n .eq. 1) go to 570 v1 = dsin(x(n-1)) s2 = s2 + dfloat(2*n-1) - v1 - s1 - dfloat(n-1)*u1 r1 = dfloat(2*n-1)*v1 - u1 if (n .eq. 2) go to 560 do 520 j = 1, n2 h(j,n) = dsin(x(j)) t = dfloat(n+j) - h(j,n) - s1 - dfloat(j)*h(j,n-1) s2 = s2 + t 520 continue do 540 j = 1, n2 v = dfloat(j)*h(j,n-1) + h(j,n) t = dfloat(n+j) - s1 - v t1 = dfloat(n+j)*h(j,n) - h(j,n-1) do 530 i = 1, j th = dfloat(i)*h(i,n) - h(i,n-1) h(i,j) = two*(h(i,n)*t1 + h(j,n)*th) 530 continue h(j,j) = h(j,j) + two*(h(j,n-1)*s2 + v*t + th**2) 540 continue do 550 i = 1, n2 th = dfloat(i)*h(i,n) - h(i,n-1) h(i,n-1) = two*(h(i,n)*r1 + v1*th) h(i,n) = two*(h(i,n)*r2 + v2*th) 550 continue 560 continue v = dfloat(n-1)*u1 + v1 t = dfloat(2*n-1) - s1 - v th = dfloat(n-1)*v1 - u1 h(n-1,n-1) = two*(v1*(r1 + th) + u1*s2 + v*t + th**2) h(n-1,n) = two*(v1*r2 + v2*th) 570 continue v = dfloat(n)*u2 + v2 t = dfloat(2*n) - s1 - v th = dfloat(n)*v2 - u2 h(n,n) = two*(v2*(r2 + th) + u2*s2 + v*t + th**2) go to 800 c c extended rosenbrock function. c 580 continue do 600 j = 1, n do 590 i = 1, j h(i,j) = zero 590 continue 600 continue do 610 j = 1, n, 2 c t1 = one - x(j) h(j,j) = c1200*x(j)**2 - c400*x(j+1) + two h(j,j+1) = -c400*x(j) h(j+1,j+1) = c200 610 continue go to 800 c c extended powell function. c 620 continue do 640 j = 1, n do 630 i = 1, j h(i,j) = zero 630 continue 640 continue do 650 j = 1, n, 4 c t = x(j) + ten*x(j+1) c t1 = x(j+2) - x(j+3) c s1 = five*t1 t2 = x(j+1) - two*x(j+2) c s2 = four*t2**3 t3 = x(j) - x(j+3) c s3 = twenty*t3**3 r2 = twelve*t2**2 r3 = c120*t3**2 h(j,j) = two + r3 h(j,j+1) = twenty h(j+1,j+1) = c200 + r2 h(j+1,j+2) = -two*r2 h(j+2,j+2) = ten + four*r2 h(j,j+3) = -r3 h(j+2,j+3) = -ten h(j+3,j+3) = ten + r3 650 continue go to 800 c c beale function. c 660 continue s1 = one - x(2) t1 = c1p5 - x(1)*s1 s2 = one - x(2)**2 t2 = c2p25 - x(1)*s2 s3 = one - x(2)**3 t3 = c2p625 - x(1)*s3 h(1,1) = two*(s1**2 + s2**2 + s3**2) h(1,2) = two * *(t1 + x(2)*(two*t2 + three*x(2)*t3) * - x(1)*(s1 + x(2)*(two*s2 + three*x(2)*s3))) h(2,2) = two*x(1) * *(x(1) + two*t2 * + x(2)*(six*t3 + x(1)*x(2)*(four + xnine*x(2)**2))) go to 800 c c wood function. c 670 continue s1 = x(2) - x(1)**2 c s2 = one - x(1) c s3 = x(2) - one t1 = x(4) - x(3)**2 c t2 = one - x(3) c t3 = x(4) - one h(1,1) = c400*(two*x(1)**2 - s1) + two h(1,2) = -c400*x(1) h(2,2) = c220p2 h(1,3) = zero h(2,3) = zero h(3,3) = c360*(two*x(3)**2 - t1) + two h(1,4) = zero h(2,4) = c19p8 h(3,4) = -c360*x(3) h(4,4) = c200p2 go to 800 c c chebyquad function. c 680 continue do 690 i = 1, n fvec(i) = zero 690 continue do 710 j = 1, n t1 = one t2 = two*x(j) - one t = two*t2 do 700 i = 1, n fvec(i) = fvec(i) + t2 th = t*t2 - t1 t1 = t2 t2 = th 700 continue 710 continue d1 = one/dfloat(n) iev = -1 do 720 i = 1, n fvec(i) = d1*fvec(i) if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one) iev = -iev 720 continue do 770 j = 1, n do 730 k = 1, j h(k,j) = zero 730 continue t1 = one t2 = two*x(j) - one t = two*t2 s1 = zero s2 = two r1 = zero r2 = zero do 740 i = 1, n h(j,j) = h(j,j) + fvec(i)*r2 th = eight*s2 + t*r2 - r1 r1 = r2 r2 = th fvec1(i) = d1*s2 th = four*t2 + t*s2 - s1 s1 = s2 s2 = th th = t*t2 - t1 t1 = t2 t2 = th 740 continue do 760 k = 1, j v1 = one v2 = two*x(k) - one v = two*v2 u1 = zero u2 = two do 750 i = 1, n h(k,j) = h(k,j) + fvec1(i)*u2 th = four*v2 + v*u2 - u1 u1 = u2 u2 = th th = v*v2 - v1 v1 = v2 v2 = th 750 continue 760 continue 770 continue d2 = two*d1 do 790 j = 1, n do 780 k = 1, j h(k,j) = d2*h(k,j) 780 continue 790 continue c c reflect the upper triangle to fill the square matrix. c 800 continue do 820 j = 1, n do 810 i = j, n h(i,j) = h(j,i) 810 continue 820 continue return c c last card of subroutine hesfcn. c end cminpack-1.3.4/examples/hybdrv.c000644 000765 000765 00000012125 12274450242 016537 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ /* ********** */ /* this program tests codes for the solution of n nonlinear */ /* equations in n variables. it consists of a driver and an */ /* interface subroutine fcn. the driver reads in data, calls the */ /* nonlinear equation solver, and finally prints out information */ /* on the performance of the solver. this is only a sample driver, */ /* many other drivers are possible. the interface subroutine fcn */ /* is necessary to take into account the forms of calling */ /* sequences used by the function subroutines in the various */ /* nonlinear equation solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ int fcn(void *p, int n, const real *x, real *fvec, int iflag); struct refnum { int nprob, nfev, njev; }; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,n,ntries; struct refnum hybrdtest; int info; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fnm[60]; real fvec[40]; real x[40]; real wa[2660]; const int lwa = 2660; (void)argc; (void)argv; tol = sqrt(__cminpack_func__(dpmpar)(1)); ic = 0; for (;;) { scanf("%5d%5d%5d\n", &hybrdtest.nprob, &n, &ntries); if (hybrdtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { hybipt(n,x,hybrdtest.nprob,factor); vecfcn(n,x,fvec,hybrdtest.nprob); fnorm1 = __cminpack_func__(enorm)(n,fvec); printf("\n\n\n\n problem%5d dimension%5d\n\n", hybrdtest.nprob, n); hybrdtest.nfev = 0; hybrdtest.njev = 0; info = __cminpack_func__(hybrd1)(fcn,&hybrdtest,n,x,fvec,tol,wa,lwa); fnorm2 = __cminpack_func__(enorm)(n,fvec); np[ic] = hybrdtest.nprob; na[ic] = n; nf[ic] = hybrdtest.nfev; hybrdtest.njev /= n; nj[ic] = hybrdtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of Jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, hybrdtest.nfev, hybrdtest.njev, info); printvec(n, x); factor *= 10.; } } printf("\f summary of %d calls to hybrd1\n", ic); printf("\n nprob n nfev njev info final l2 norm\n\n"); for (i = 0; i < ic; ++i) { printf("%4d%6d%7d%7d%6d%16.7e\n", np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]); } exit(0); } int fcn(void *p, int n, const real *x, real *fvec, int iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* equation solver. fcn should only call the testing function */ /* subroutine vecfcn with the appropriate value of problem */ /* number (nprob). */ /* subprograms called */ /* minpack-supplied ... vecfcn */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ struct refnum *hybrdtest = (struct refnum *)p; vecfcn(n, x, fvec, hybrdtest->nprob); if (iflag == 1) { hybrdtest->nfev++; } if (iflag == 2) { hybrdtest->njev++; } return 0; } /* fcn_ */ cminpack-1.3.4/examples/hybdrv.f000644 000765 000765 00000007151 12225167750 016552 0ustar00devernay000000 000000 c ********** c c this program tests codes for the solution of n nonlinear c equations in n variables. it consists of a driver and an c interface subroutine fcn. the driver reads in data, calls the c nonlinear equation solver, and finally prints out information c on the performance of the solver. this is only a sample driver, c many other drivers are possible. the interface subroutine fcn c is necessary to take into account the forms of calling c sequences used by the function subroutines in the various c nonlinear equation solvers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,lwa,n,nfev,nprob,nread,ntries,nwrite integer na(60),nf(60),np(60),nx(60) double precision factor,fnorm1,fnorm2,one,ten,tol double precision fnm(60),fvec(40),wa(2660),x(40) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) lwa = 2660 ic = 0 10 continue read (nread,50) nprob,n,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call vecfcn(n,x,fvec,nprob) fnorm1 = enorm(n,fvec) write (nwrite,60) nprob,n nfev = 0 call hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) fnorm2 = enorm(n,fvec) np(ic) = nprob na(ic) = n nf(ic) = nfev nx(ic) = info fnm(ic) = fnorm2 write (nwrite,70) fnorm1,fnorm2,nfev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),nf(i),nx(i),fnm(i) 40 continue stop 50 format (3i5) 60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to hybrd1 /) 90 format (39h nprob n nfev info final l2 norm /) 100 format (i4, i6, i7, i6, 1x, d15.7) c c last card of driver. c end subroutine fcn(n,x,fvec,iflag) integer n,iflag double precision x(n),fvec(n) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the nonlinear c equation solver. fcn should only call the testing function c subroutine vecfcn with the appropriate value of problem c number (nprob). c c subprograms called c c minpack-supplied ... vecfcn c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev common /refnum/ nprob,nfev call vecfcn(n,x,fvec,nprob) nfev = nfev + 1 return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/hybdrv_.c000644 000765 000765 00000012033 12274450502 016673 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "minpack.h" #include "vec.h" #define real __minpack_real__ /* ********** */ /* this program tests codes for the solution of n nonlinear */ /* equations in n variables. it consists of a driver and an */ /* interface subroutine fcn. the driver reads in data, calls the */ /* nonlinear equation solver, and finally prints out information */ /* on the performance of the solver. this is only a sample driver, */ /* many other drivers are possible. the interface subroutine fcn */ /* is necessary to take into account the forms of calling */ /* sequences used by the function subroutines in the various */ /* nonlinear equation solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ void fcn(const int *n, const real *x, real *fvec, int *iflag); struct refnum { int nprob, nfev, njev; }; struct refnum hybrdtest; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,n,ntries; int info; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fnm[60]; real fvec[40]; real x[40]; real wa[2660]; const int lwa = 2660; const int i1 = 1; (void)argc; (void)argv; tol = sqrt(__minpack_func__(dpmpar)(&i1)); ic = 0; for (;;) { scanf("%5d%5d%5d\n", &hybrdtest.nprob, &n, &ntries); if (hybrdtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { hybipt(n,x,hybrdtest.nprob,factor); vecfcn(n,x,fvec,hybrdtest.nprob); fnorm1 = __minpack_func__(enorm)(&n,fvec); printf("\n\n\n\n problem%5d dimension%5d\n\n", hybrdtest.nprob, n); hybrdtest.nfev = 0; hybrdtest.njev = 0; __minpack_func__(hybrd1)(fcn,&n,x,fvec,&tol,&info,wa,&lwa); fnorm2 = __minpack_func__(enorm)(&n,fvec); np[ic] = hybrdtest.nprob; na[ic] = n; nf[ic] = hybrdtest.nfev; hybrdtest.njev /= n; nj[ic] = hybrdtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of Jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, hybrdtest.nfev, hybrdtest.njev, info); printvec(n, x); factor *= 10.; } } printf("\f summary of %d calls to hybrd1\n", ic); printf("\n nprob n nfev njev info final l2 norm\n\n"); for (i = 0; i < ic; ++i) { printf("%4d%6d%7d%7d%6d%16.7e\n", np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]); } exit(0); } void fcn(const int *n, const real *x, real *fvec, int *iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* equation solver. fcn should only call the testing function */ /* subroutine vecfcn with the appropriate value of problem */ /* number (nprob). */ /* subprograms called */ /* minpack-supplied ... vecfcn */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ vecfcn(*n, x, fvec, hybrdtest.nprob); if (*iflag == 1) { hybrdtest.nfev++; } if (*iflag == 2) { hybrdtest.njev++; } } /* fcn_ */ cminpack-1.3.4/examples/hybipt.c000644 000765 000765 00000007646 12225167750 016561 0ustar00devernay000000 000000 #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ void hybipt(int n, real *x, int nprob, real factor) { /* Local variables */ static real h__; static int j; static real tj; /* ********** */ /* subroutine initpt */ /* this subroutine specifies the standard starting points for */ /* the functions defined by subroutine vecfcn. the subroutine */ /* returns in x a multiple (factor) of the standard starting */ /* point. for the sixth function the standard starting point is */ /* zero, so in this case, if factor is not unity, then the */ /* subroutine returns the vector x(j) = factor, j=1,...,n. */ /* the subroutine statement is */ /* subroutine initpt(n,x,nprob,factor) */ /* where */ /* n is a positive integer input variable. */ /* x is an output array of length n which contains the standard */ /* starting point for problem nprob multiplied by factor. */ /* nprob is a positive integer input variable which defines the */ /* number of the problem. nprob must not exceed 14. */ /* factor is an input variable which specifies the multiple of */ /* the standard starting point. if factor is unity, no */ /* multiplication is performed. */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; /* Function Body */ /* selection of initial point. */ switch (nprob) { case 1: /* rosenbrock function. */ x[1] = -1.2; x[2] = 1.; break; case 2: /* powell singular function. */ x[1] = 3.; x[2] = -1.; x[3] = 0.; x[4] = 1.; break; case 3: /* powell badly scaled function. */ x[1] = 0.; x[2] = 1.; break; case 4: /* wood function. */ x[1] = -3.; x[2] = -1.; x[3] = -3.; x[4] = -1.; break; case 5: /* helical valley function. */ x[1] = -1.; x[2] = 0.; x[3] = 0.; break; case 6: /* watson function. */ for (j = 1; j <= n; ++j) { x[j] = 0.; } break; case 7: /* chebyquad function. */ h__ = 1. / (real) (n+1); for (j = 1; j <= n; ++j) { x[j] = (real) j * h__; } break; case 8: /* brown almost-linear function. */ for (j = 1; j <= n; ++j) { x[j] = .5; } break; case 9: case 10: /* discrete boundary value and integral equation functions. */ h__ = 1. / (real) (n+1); for (j = 1; j <= n; ++j) { tj = (real) j * h__; x[j] = tj * (tj - 1.); } break; case 11: /* trigonometric function. */ h__ = 1. / (real) (n); for (j = 1; j <= n; ++j) { x[j] = h__; } break; case 12: /* variably dimensioned function. */ h__ = 1. / (real) (n); for (j = 1; j <= n; ++j) { x[j] = 1. - (real) j * h__; } break; case 13: case 14: /* broyden tridiagonal and banded functions. */ for (j = 1; j <= n; ++j) { x[j] = -1.; } break; } /* compute multiple of initial point. */ if (factor == 1.) { return; } if (nprob == 6) { for (j = 1; j <= n; ++j) { x[j] = factor; } } else { for (j = 1; j <= n; ++j) { x[j] = factor * x[j]; } } } /* initpt_ */ cminpack-1.3.4/examples/hybipt.f000644 000765 000765 00000007107 12225167750 016554 0ustar00devernay000000 000000 subroutine initpt(n,x,nprob,factor) integer n,nprob double precision factor double precision x(n) c ********** c c subroutine initpt c c this subroutine specifies the standard starting points for c the functions defined by subroutine vecfcn. the subroutine c returns in x a multiple (factor) of the standard starting c point. for the sixth function the standard starting point is c zero, so in this case, if factor is not unity, then the c subroutine returns the vector x(j) = factor, j=1,...,n. c c the subroutine statement is c c subroutine initpt(n,x,nprob,factor) c c where c c n is a positive integer input variable. c c x is an output array of length n which contains the standard c starting point for problem nprob multiplied by factor. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 14. c c factor is an input variable which specifies the multiple of c the standard starting point. if factor is unity, no c multiplication is performed. c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer ivar,j double precision c1,h,half,one,three,tj,zero double precision dfloat data zero,half,one,three,c1 /0.0d0,5.0d-1,1.0d0,3.0d0,1.2d0/ dfloat(ivar) = ivar c c selection of initial point. c go to (10,20,30,40,50,60,80,100,120,120,140,160,180,180), nprob c c rosenbrock function. c 10 continue x(1) = -c1 x(2) = one go to 200 c c powell singular function. c 20 continue x(1) = three x(2) = -one x(3) = zero x(4) = one go to 200 c c powell badly scaled function. c 30 continue x(1) = zero x(2) = one go to 200 c c wood function. c 40 continue x(1) = -three x(2) = -one x(3) = -three x(4) = -one go to 200 c c helical valley function. c 50 continue x(1) = -one x(2) = zero x(3) = zero go to 200 c c watson function. c 60 continue do 70 j = 1, n x(j) = zero 70 continue go to 200 c c chebyquad function. c 80 continue h = one/dfloat(n+1) do 90 j = 1, n x(j) = dfloat(j)*h 90 continue go to 200 c c brown almost-linear function. c 100 continue do 110 j = 1, n x(j) = half 110 continue go to 200 c c discrete boundary value and integral equation functions. c 120 continue h = one/dfloat(n+1) do 130 j = 1, n tj = dfloat(j)*h x(j) = tj*(tj - one) 130 continue go to 200 c c trigonometric function. c 140 continue h = one/dfloat(n) do 150 j = 1, n x(j) = h 150 continue go to 200 c c variably dimensioned function. c 160 continue h = one/dfloat(n) do 170 j = 1, n x(j) = one - dfloat(j)*h 170 continue go to 200 c c broyden tridiagonal and banded functions. c 180 continue do 190 j = 1, n x(j) = -one 190 continue 200 continue c c compute multiple of initial point. c if (factor .eq. one) go to 250 if (nprob .eq. 6) go to 220 do 210 j = 1, n x(j) = factor*x(j) 210 continue go to 240 220 continue do 230 j = 1, n x(j) = factor 230 continue 240 continue 250 continue return c c last card of subroutine initpt. c end cminpack-1.3.4/examples/hyjdrv.c000644 000765 000765 00000012427 12274450224 016554 0ustar00devernay000000 000000 /* Usage: hyjdrv < hybrd.data */ #include #include #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ /* ********** */ /* this program tests codes for the solution of n nonlinear */ /* equations in n variables. it consists of a driver and an */ /* interface subroutine fcn. the driver reads in data, calls the */ /* nonlinear equation solver, and finally prints out information */ /* on the performance of the solver. this is only a sample driver, */ /* many other drivers are possible. the interface subroutine fcn */ /* is necessary to take into account the forms of calling */ /* sequences used by the function and jacobian subroutines in */ /* the various nonlinear equation solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); struct refnum { int nprob, nfev, njev; }; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,n,ntries; struct refnum hybrjtest; int info; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[40*40]; const int ldfjac = 40; real fnm[60]; real fvec[40]; real x[40]; real wa[1060]; const int lwa = 1060; (void)argc; (void)argv; tol = sqrt(__cminpack_func__(dpmpar)(1)); ic = 0; for (;;) { scanf("%5d%5d%5d\n", &hybrjtest.nprob, &n, &ntries); if (hybrjtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { hybipt(n,x,hybrjtest.nprob,factor); vecfcn(n,x,fvec,hybrjtest.nprob); fnorm1 = __cminpack_func__(enorm)(n,fvec); printf("\n\n\n\n problem%5d dimension%5d\n\n", hybrjtest.nprob, n); hybrjtest.nfev = 0; hybrjtest.njev = 0; info = __cminpack_func__(hybrj1)(fcn,&hybrjtest,n,x,fvec,fjac,ldfjac,tol,wa,lwa); fnorm2 = __cminpack_func__(enorm)(n,fvec); np[ic] = hybrjtest.nprob; na[ic] = n; nf[ic] = hybrjtest.nfev; nj[ic] = hybrjtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, hybrjtest.nfev, hybrjtest.njev, info); printvec(n, x); factor *= 10.; } } printf("\f summary of %d calls to hybrj1\n", ic); printf("\n nprob n nfev njev info final l2 norm\n\n"); for (i = 0; i < ic; ++i) { printf("%4d%6d%7d%7d%6d%16.7e\n", np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]); } exit(0); } int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* equation solver. fcn should only call the testing function */ /* and jacobian subroutines vecfcn and vecjac with the */ /* appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... vecfcn,vecjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ struct refnum *hybrjtest = (struct refnum *)p; if (iflag == 1) { vecfcn(n, x, fvec, hybrjtest->nprob); hybrjtest->nfev++; } if (iflag == 2) { vecjac(n, x, fjac, ldfjac, hybrjtest->nprob); hybrjtest->njev++; } return 0; } /* fcn_ */ cminpack-1.3.4/examples/hyjdrv.f000644 000765 000765 00000010055 12225167750 016557 0ustar00devernay000000 000000 c ********** c c this program tests codes for the solution of n nonlinear c equations in n variables. it consists of a driver and an c interface subroutine fcn. the driver reads in data, calls the c nonlinear equation solver, and finally prints out information c on the performance of the solver. this is only a sample driver, c many other drivers are possible. the interface subroutine fcn c is necessary to take into account the forms of calling c sequences used by the function and jacobian subroutines in c the various nonlinear equation solvers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,ldfjac,lwa,n,nfev,njev,nprob,nread,ntries, 1 nwrite integer na(60),nf(60),nj(60),np(60),nx(60) double precision factor,fnorm1,fnorm2,one,ten,tol double precision fnm(60),fjac(40,40),fvec(40),wa(1060),x(40) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev,njev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) ldfjac = 40 lwa = 1060 ic = 0 10 continue read (nread,50) nprob,n,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call vecfcn(n,x,fvec,nprob) fnorm1 = enorm(n,fvec) write (nwrite,60) nprob,n nfev = 0 njev = 0 call hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) fnorm2 = enorm(n,fvec) np(ic) = nprob na(ic) = n nf(ic) = nfev nj(ic) = njev nx(ic) = info fnm(ic) = fnorm2 write (nwrite,70) 1 fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),nf(i),nj(i),nx(i),fnm(i) 40 continue stop 50 format (3i5) 60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, 1 33h final l2 norm of the residuals , d15.7 // 5x, 2 33h number of function evaluations , i10 // 5x, 3 33h number of jacobian evaluations , i10 // 5x, 4 15h exit parameter, 18x, i10 // 5x, 5 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to hybrj1 /) 90 format (46h nprob n nfev njev info final l2 norm /) 100 format (i4, i6, 2i7, i6, 1x, d15.7) c c last card of driver. c end subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) integer n,ldfjac,iflag double precision x(n),fvec(n),fjac(ldfjac,n) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the nonlinear c equation solver. fcn should only call the testing function c and jacobian subroutines vecfcn and vecjac with the c appropriate value of problem number (nprob). c c subprograms called c c minpack-supplied ... vecfcn,vecjac c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev,njev common /refnum/ nprob,nfev,njev if (iflag .eq. 1) call vecfcn(n,x,fvec,nprob) if (iflag .eq. 2) call vecjac(n,x,fjac,ldfjac,nprob) if (iflag .eq. 1) nfev = nfev + 1 if (iflag .eq. 2) njev = njev + 1 return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/hyjdrv_.c000644 000765 000765 00000012365 12274450463 016721 0ustar00devernay000000 000000 /* Usage: hyjdrv < hybrd.data */ #include #include #include #include "minpack.h" #include "vec.h" #define real __minpack_real__ /* ********** */ /* this program tests codes for the solution of n nonlinear */ /* equations in n variables. it consists of a driver and an */ /* interface subroutine fcn. the driver reads in data, calls the */ /* nonlinear equation solver, and finally prints out information */ /* on the performance of the solver. this is only a sample driver, */ /* many other drivers are possible. the interface subroutine fcn */ /* is necessary to take into account the forms of calling */ /* sequences used by the function and jacobian subroutines in */ /* the various nonlinear equation solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); struct refnum { int nprob, nfev, njev; }; struct refnum hybrjtest; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,n,ntries; int info; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[40*40]; const int ldfjac = 40; real fnm[60]; real fvec[40]; real x[40]; real wa[1060]; const int lwa = 1060; const int i1 = 1; (void)argc; (void)argv; tol = sqrt(__minpack_func__(dpmpar)(&i1)); ic = 0; for (;;) { scanf("%5d%5d%5d\n", &hybrjtest.nprob, &n, &ntries); if (hybrjtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { hybipt(n,x,hybrjtest.nprob,factor); vecfcn(n,x,fvec,hybrjtest.nprob); fnorm1 = __minpack_func__(enorm)(&n,fvec); printf("\n\n\n\n problem%5d dimension%5d\n\n", hybrjtest.nprob, n); hybrjtest.nfev = 0; hybrjtest.njev = 0; __minpack_func__(hybrj1)(fcn,&n,x,fvec,fjac,&ldfjac,&tol,&info,wa,&lwa); fnorm2 = __minpack_func__(enorm)(&n,fvec); np[ic] = hybrjtest.nprob; na[ic] = n; nf[ic] = hybrjtest.nfev; nj[ic] = hybrjtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, hybrjtest.nfev, hybrjtest.njev, info); printvec(n, x); factor *= 10.; } } printf("\f summary of %d calls to hybrj1\n", ic); printf("\n nprob n nfev njev info final l2 norm\n\n"); for (i = 0; i < ic; ++i) { printf("%4d%6d%7d%7d%6d%16.7e\n", np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]); } exit(0); } void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* equation solver. fcn should only call the testing function */ /* and jacobian subroutines vecfcn and vecjac with the */ /* appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... vecfcn,vecjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ if (*iflag == 1) { vecfcn(*n, x, fvec, hybrjtest.nprob); hybrjtest.nfev++; } if (*iflag == 2) { vecjac(*n, x, fjac, *ldfjac, hybrjtest.nprob); hybrjtest.njev++; } } /* fcn_ */ cminpack-1.3.4/examples/ibmdpdr.c000644 000765 000765 00000006223 12274444374 016675 0ustar00devernay000000 000000 #include #include #include "cminpack.h" #define real __cminpack_real__ extern void machar_(int *ibeta, int *it, int *irnd, int *ngrd, int *machep, int *negep, int *iexp, int *minexp, int *maxexp, real *eps, real *epsneg, real *xmin, real *xmax); /* ********** */ /* this program checks the constants of machine precision and */ /* smallest and largest machine representable numbers specified in */ /* function dpmpar, against the corresponding hardware-determined */ /* machine constants obtained by machar, a subroutine due to */ /* w. j. cody. */ /* data statements in dpmpar corresponding to the machine used must */ /* be activated by removing c in column 1. */ /* the printed output consists of the machine constants obtained by */ /* machar and comparisons of the dpmpar constants with their */ /* machar counterparts. descriptions of the machine constants are */ /* given in the prologue comments of machar. */ /* subprograms called */ /* minpack-supplied ... machar,dpmpar */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Main program */ int main(int argc, char **argv) { /* Local variables */ int it; real eps; int ngrd, irnd, iexp; real rerr[3], xmin, xmax; int ibeta, negep; real giant, dwarf; int machep; real epsmch, epsneg; int minexp, maxexp; (void)argc; (void)argv; /* determine the machine constants dynamically from machar. */ machar_(&ibeta, &it, &irnd, &ngrd, &machep, &negep, &iexp, &minexp, & maxexp, &eps, &epsneg, &xmin, &xmax); /* compare the dpmpar constants with their machar counterparts and */ /* store the relative differences in rerr. */ epsmch = __cminpack_func__(dpmpar)(1); dwarf = __cminpack_func__(dpmpar)(2); giant = __cminpack_func__(dpmpar)(3); rerr[0] = (epsmch - eps) / epsmch; rerr[1] = (dwarf - xmin) / dwarf; rerr[2] = (xmax - giant) / giant; /* write the MACHAR constants. */ printf("\f MACHAR constants\n\n\n"); printf(" ibeta =%6i\n\n", ibeta); printf(" it =%6i\n\n", it); printf(" irnd =%6i\n\n", irnd); printf(" ngrd =%6i\n\n", ngrd); printf(" machep =%6i\n\n", machep); printf(" negep =%6i\n\n", negep); printf(" iexp =%6i\n\n", iexp); printf(" minexp =%6i\n\n", minexp); printf(" maxexp =%6i\n\n", maxexp); printf(" eps =%15.7e\n\n", (double)eps); printf(" epsneg =%15.7e\n\n", (double)epsneg); printf(" xmin =%15.7e\n\n", (double)xmin); printf(" xmax =%15.7e\n\n", (double)xmax); /* write the DPMPAR constants and the relative differences. */ printf("\n\n DPMPAR constants and relative differences\n\n\n"); printf(" epsmch =%15.7e\n", (double)epsmch); printf(" rerr(1) =%15.7e\n\n", (double)rerr[0]); printf(" dwarf =%15.7e\n", (double)dwarf); printf(" rerr(2) =%15.7e\n\n", (double)rerr[1]); printf(" giant =%15.7e\n", (double)giant); printf(" rerr(3) =%15.7e\n", (double)rerr[2]); return 0; } /* MAIN__ */ cminpack-1.3.4/examples/ibmdpdr.f000644 000765 000765 00000005043 12225167750 016673 0ustar00devernay000000 000000 c ********** c c this program checks the constants of machine precision and c smallest and largest machine representable numbers specified in c function dpmpar, against the corresponding hardware-determined c machine constants obtained by machar, a subroutine due to c w. j. cody. c c data statements in dpmpar corresponding to the machine used must c be activated by removing c in column 1. c c the printed output consists of the machine constants obtained by c machar and comparisons of the dpmpar constants with their c machar counterparts. descriptions of the machine constants are c given in the prologue comments of machar. c c subprograms called c c minpack-supplied ... machar,dpmpar c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer ibeta,iexp,irnd,it,machep,maxexp,minexp,negep,ngrd, * nwrite double precision dwarf,eps,epsmch,epsneg,giant,xmax,xmin double precision rerr(3) double precision dpmpar c c logical output unit is assumed to be number 6. c data nwrite /6/ c c determine the machine constants dynamically from machar. c call machar(ibeta,it,irnd,ngrd,machep,negep,iexp,minexp,maxexp, * eps,epsneg,xmin,xmax) c c compare the dpmpar constants with their machar counterparts and c store the relative differences in rerr. c epsmch = dpmpar(1) dwarf = dpmpar(2) giant = dpmpar(3) rerr(1) = (epsmch - eps)/epsmch rerr(2) = (dwarf - xmin)/dwarf rerr(3) = (xmax - giant)/giant c c write the machar constants. c write (nwrite,10) * ibeta,it,irnd,ngrd,machep,negep,iexp,minexp,maxexp,eps, * epsneg,xmin,xmax c c write the dpmpar constants and the relative differences. c write (nwrite,20) epsmch,rerr(1),dwarf,rerr(2),giant,rerr(3) stop 10 format (17h1MACHAR constants /// 8h ibeta =, i6 // 8h it =, * i6 // 8h irnd =, i6 // 8h ngrd =, i6 // 9h machep =, * i6 // 8h negep =, i6 // 7h iexp =, i6 // 9h minexp =, * i6 // 9h maxexp =, i6 // 6h eps =, d15.7 // 9h epsneg =, * d15.7 // 7h xmin =, d15.7 // 7h xmax =, d15.7) 20 format ( /// 42h dpmpar constants and relative differences /// * 9h epsmch =, d15.7 / 10h rerr(1) =, d15.7 // * 8h dwarf =, d15.7 / 10h rerr(2) =, d15.7 // 8h giant =, * d15.7 / 10h rerr(3) =, d15.7) c c last card of driver. c end cminpack-1.3.4/examples/ibmdpdr_.c000644 000765 000765 00000006272 12274446573 017043 0ustar00devernay000000 000000 #include #include #include "minpack.h" #define real __minpack_real__ extern void machar_(int *ibeta, int *it, int *irnd, int *ngrd, int *machep, int *negep, int *iexp, int *minexp, int *maxexp, real *eps, real *epsneg, real *xmin, real *xmax); /* ********** */ /* this program checks the constants of machine precision and */ /* smallest and largest machine representable numbers specified in */ /* function dpmpar, against the corresponding hardware-determined */ /* machine constants obtained by machar, a subroutine due to */ /* w. j. cody. */ /* data statements in dpmpar corresponding to the machine used must */ /* be activated by removing c in column 1. */ /* the printed output consists of the machine constants obtained by */ /* machar and comparisons of the dpmpar constants with their */ /* machar counterparts. descriptions of the machine constants are */ /* given in the prologue comments of machar. */ /* subprograms called */ /* minpack-supplied ... machar,dpmpar */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Main program */ int main(int argc, char **argv) { /* Local variables */ int it; real eps; int ngrd, irnd, iexp; real rerr[3], xmin, xmax; int ibeta, negep; real giant, dwarf; int machep; real epsmch, epsneg; int minexp, maxexp; const int i1 = 1, i2 = 2, i3 = 3; (void)argc; (void)argv; /* determine the machine constants dynamically from machar. */ machar_(&ibeta, &it, &irnd, &ngrd, &machep, &negep, &iexp, &minexp, & maxexp, &eps, &epsneg, &xmin, &xmax); /* compare the dpmpar constants with their machar counterparts and */ /* store the relative differences in rerr. */ epsmch = __minpack_func__(dpmpar)(&i1); dwarf = __minpack_func__(dpmpar)(&i2); giant = __minpack_func__(dpmpar)(&i3); rerr[0] = (epsmch - eps) / epsmch; rerr[1] = (dwarf - xmin) / dwarf; rerr[2] = (xmax - giant) / giant; /* write the MACHAR constants. */ printf("\f MACHAR constants\n\n\n"); printf(" ibeta =%6i\n\n", ibeta); printf(" it =%6i\n\n", it); printf(" irnd =%6i\n\n", irnd); printf(" ngrd =%6i\n\n", ngrd); printf(" machep =%6i\n\n", machep); printf(" negep =%6i\n\n", negep); printf(" iexp =%6i\n\n", iexp); printf(" minexp =%6i\n\n", minexp); printf(" maxexp =%6i\n\n", maxexp); printf(" eps =%15.7e\n\n", (double)eps); printf(" epsneg =%15.7e\n\n", (double)epsneg); printf(" xmin =%15.7e\n\n", (double)xmin); printf(" xmax =%15.7e\n\n", (double)xmax); /* write the DPMPAR constants and the relative differences. */ printf("\n\n DPMPAR constants and relative differences\n\n\n"); printf(" epsmch =%15.7e\n", (double)epsmch); printf(" rerr(1) =%15.7e\n\n", (double)rerr[0]); printf(" dwarf =%15.7e\n", (double)dwarf); printf(" rerr(2) =%15.7e\n\n", (double)rerr[1]); printf(" giant =%15.7e\n", (double)giant); printf(" rerr(3) =%15.7e\n", (double)rerr[2]); return 0; } /* MAIN__ */ cminpack-1.3.4/examples/lhesfcn.f000644 000765 000765 00000042123 12225167750 016674 0ustar00devernay000000 000000 subroutine hesfcn(n,x,h,ldh,nprob) integer n,ldh,nprob double precision x(n),h(ldh) c ********** c c subroutine hesfcn c c this subroutine defines the hessian matrices of eighteen c nonlinear unconstrained minimization problems. the problem c dimensions are as described in the prologue comments of objfcn. c the upper triangle of the (symmetric) hessian matrix is c computed columnwise and stored as a one-dimensional array. c c the subroutine statement is c c subroutine hesfcn(n,x,h,ldh,nprob) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c h is an array of length ldh. on output h contains the hessian c matrix of the nprob objective function evaluated at x. c c ldh is a positive integer input variable not less than c (n*(n+1))/2 which specifies the dimension of the array h. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin, c dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j,k,n2 integer ij,ijm1,ijp1,ijp2,ijp3,ki,kip1,kj,kjp1,ntr double precision ap,arg,cp0001,cp1,cp25,cp5,c1p5,c2p25, * c2p625,c3p5,c19p8,c25,c29,c100,c200,c10000,d1, * d2,eight,fifty,five,four,one,r,s1,s2,s3,t,t1, * t2,t3,ten,th,three,tpi,twenty,two,zero double precision d3,r1,r2,r3,u1,u2,v,v1,v2 double precision fvec(50),fvec1(50),y(15) double precision dfloat double precision six,xnine,twelve,c120,c200p2,c202,c220p2,c360, * c400,c1200 data six,xnine,twelve,c120,c200p2,c202,c220p2,c360,c400,c1200 * /6.0d0,9.0d0,1.2d1,1.2d2,2.002d2,2.02d2,2.202d2,3.6d2, * 4.0d2,1.2d3/ data zero,one,two,three,four,five,eight,ten,twenty,fifty * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1, * 5.0d1/ data cp0001,cp1,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c19p8,c25,c29, * c100,c200,c10000 * /1.0d-4,1.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,2.625d0,3.5d0, * 1.98d1,2.5d1,2.9d1,1.0d2,2.0d2,1.0d4/ data ap /1.0d-5/ data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11), * y(12),y(13),y(14),y(15) * /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1, * 3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3, * 9.0d-4/ dfloat(ivar) = ivar c c hessian routine selector. c go to (10,20,60,100,110,170,210,290,330,380,390,450,490,580,620, * 660,670,680), nprob c c helical valley function. c 10 continue tpi = eight*datan(one) th = dsign(cp25,x(2)) if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5 arg = x(1)**2 + x(2)**2 r = dsqrt(arg) t = x(3) - ten*th s1 = ten*t/(tpi*arg) t1 = ten/tpi t2 = t1/arg t3 = (x(1)/r - t1*t2*x(1) - two*x(2)*s1)/arg h(1) = c200 * *(one - x(2)/arg*(x(2)/r - t1*t2*x(2) + two*x(1)*s1)) h(2) = c200*(s1 + x(2)*t3) h(3) = c200*(one - x(1)*t3) h(4) = c200*t2*x(2) h(5) = -c200*t2*x(1) h(6) = c202 go to 800 c c biggs exp6 function. c 20 continue do 40 ij = 1, 21 h(ij) = zero 40 continue do 50 i = 1, 13 d1 = dfloat(i)/ten d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1) s1 = dexp(-d1*x(1)) s2 = dexp(-d1*x(2)) s3 = dexp(-d1*x(5)) t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2 th = d1*t r1 = d1*s1 r2 = d1*s2 r3 = d1*s3 h(1) = h(1) + r1*(th + x(3)*r1) h(2) = h(2) - r1*r2 h(3) = h(3) - r2*(th - x(4)*r2) h(4) = h(4) - s1*(th + x(3)*r1) h(6) = h(6) + s1**2 h(7) = h(7) + r1*s2 h(8) = h(8) + s2*(th - x(4)*r2) h(9) = h(9) - s1*s2 h(10) = h(10) + s2**2 h(11) = h(11) + r1*r3 h(12) = h(12) - r2*r3 h(15) = h(15) + r3*(th + x(6)*r3) h(16) = h(16) - r1*s3 h(17) = h(17) + r2*s3 h(18) = h(18) + s1*s3 h(19) = h(19) - s2*s3 h(20) = h(20) - s3*(th + x(6)*r3) h(21) = h(21) + s3**2 50 continue h(1) = two*x(3)*h(1) h(2) = two*x(3)*x(4)*h(2) h(3) = two*x(4)*h(3) h(4) = two*h(4) h(5) = two*x(4)*h(7) h(6) = two*h(6) h(7) = two*x(3)*h(7) h(8) = two*h(8) h(9) = two*h(9) h(10) = two*h(10) h(11) = two*x(3)*x(6)*h(11) h(12) = two*x(4)*x(6)*h(12) h(13) = two*x(6)*h(16) h(14) = two*x(6)*h(17) h(15) = two*x(6)*h(15) h(16) = two*x(3)*h(16) h(17) = two*x(4)*h(17) h(18) = two*h(18) h(19) = two*h(19) h(20) = two*h(20) h(21) = two*h(21) go to 800 c c gaussian function. c 60 continue do 80 ij = 1, 6 h(ij) = zero 80 continue do 90 i = 1, 15 d1 = cp5*dfloat(i-1) d2 = c3p5 - d1 - x(3) arg = -cp5*x(2)*d2**2 r = dexp(arg) t = x(1)*r - y(i) s1 = r*t s2 = d2*s1 t1 = s2 + d2*x(1)*r**2 t2 = d2*t1 h(1) = h(1) + r**2 h(2) = h(2) - t2 h(3) = h(3) + d2**2*t2 h(4) = h(4) + t1 h(5) = h(5) + two*s2 - d2*x(2)*t2 h(6) = h(6) + x(2)*t2 - s1 90 continue h(1) = two*h(1) h(2) = h(2) h(3) = cp5*x(1)*h(3) h(4) = two*x(2)*h(4) h(5) = x(1)*h(5) h(6) = two*x(1)*x(2)*h(6) go to 800 c c powell badly scaled function. c 100 continue t1 = c10000*x(1)*x(2) - one s1 = dexp(-x(1)) s2 = dexp(-x(2)) t2 = s1 + s2 - one - cp0001 h(1) = two*((c10000*x(2))**2 + s1*(s1 + t2)) h(2) = two*(c10000*(one + two*t1) + s1*s2) h(3) = two*((c10000*x(1))**2 + s2*(s2 + t2)) go to 800 c c box 3-dimensional function. c 110 continue do 130 ij = 1, 6 h(ij) = zero 130 continue do 140 i = 1, 10 d1 = dfloat(i) d2 = d1/ten s1 = dexp(-d2*x(1)) s2 = dexp(-d2*x(2)) s3 = dexp(-d2) - dexp(-d1) t = s1 - s2 - s3*x(3) th = d2*t r1 = d2*s1 r2 = d2*s2 h(1) = h(1) + r1*(th + r1) h(2) = h(2) - r1*r2 h(3) = h(3) - r2*(th - r2) h(4) = h(4) + r1*s3 h(5) = h(5) - r2*s3 h(6) = h(6) + s3**2 140 continue do 160 ij = 1, 6 h(ij) = two*h(ij) 160 continue go to 800 c c variably dimensioned function. c 170 continue t1 = zero do 180 j = 1, n t1 = t1 + dfloat(j)*(x(j) - one) 180 continue c t = t1*(one + two*t1**2) t2 = two + twelve*t1**2 ij = 0 do 200 j = 1, n do 190 i = 1, j ij = ij + 1 h(ij) = dfloat(i*j)*t2 190 continue h(ij) = h(ij) + two 200 continue go to 800 c c watson function. c 210 continue ntr = (n*(n + 1))/2 do 230 kj = 1, ntr h(kj) = zero 230 continue do 280 i = 1, 29 d1 = dfloat(i)/c29 s1 = zero d2 = one do 240 j = 2, n s1 = s1 + dfloat(j-1)*d2*x(j) d2 = d1*d2 240 continue s2 = zero d2 = one do 250 j = 1, n s2 = s2 + d2*x(j) d2 = d1*d2 250 continue t = s1 - s2**2 - one s3 = two*d1*s2 d2 = two/d1 th = two*d1**2*t kj = 0 do 270 j = 1, n v = dfloat(j-1) - s3 d3 = one/d1 do 260 k = 1, j kj = kj + 1 h(kj) = h(kj) + d2*d3*(v*(dfloat(k-1) - s3) - th) d3 = d1*d3 260 continue d2 = d1*d2 270 continue 280 continue t1 = x(2) - x(1)**2 - one h(1) = h(1) + eight*x(1)**2 + two - four*t1 h(2) = h(2) - four*x(1) h(3) = h(3) + two go to 800 c c penalty function i. c 290 continue t1 = -cp25 do 300 j = 1, n t1 = t1 + x(j)**2 300 continue d1 = two*ap th = four*t1 ij = 0 do 320 j = 1, n t2 = eight*x(j) do 310 i = 1, j ij = ij + 1 h(ij) = x(i)*t2 310 continue h(ij) = h(ij) + d1 + th 320 continue go to 800 c c penalty function ii. c 330 continue t1 = -one do 340 j = 1, n t1 = t1 + dfloat(n-j+1)*x(j)**2 340 continue d1 = dexp(cp1) d2 = one th = four*t1 ij = 0 do 370 j = 1, n t2 = eight*dfloat(n-j+1)*x(j) do 350 i = 1, j ij = ij + 1 h(ij) = dfloat(n-i+1)*x(i)*t2 350 continue h(ij) = h(ij) + dfloat(n-j+1)*th s1 = dexp(x(j)/ten) if (j .eq. 1) go to 360 s3 = s1 + s2 - d2*(d1 + one) h(ij) = h(ij) + ap*s1*(s3 + three*s1 - one/d1)/fifty h(ij-1) = h(ij-1) + ap*s1*s2/fifty h(ijm1) = h(ijm1) + ap*s2*(s2 + s3)/fifty 360 continue s2 = s1 d2 = d1*d2 ijm1 = ij 370 continue h(1) = h(1) + two go to 800 c c brown badly scaled function. c 380 continue c t1 = x(1) - c1pd6 c t2 = x(2) - c2pdm6 t3 = x(1)*x(2) - two h(1) = two*(one + x(2)**2) h(2) = four*(one + t3) h(3) = two*(one + x(1)**2) go to 800 c c brown and dennis function. c 390 continue do 410 ij = 1, 10 h(ij) = zero 410 continue do 420 i = 1, 20 d1 = dfloat(i)/five d2 = dsin(d1) t1 = x(1) + d1*x(2) - dexp(d1) t2 = x(3) + d2*x(4) - dcos(d1) t = t1**2 + t2**2 c s1 = t1*t c s2 = t2*t s3 = two*t1*t2 r1 = t + two*t1**2 r2 = t + two*t2**2 h(1) = h(1) + r1 h(2) = h(2) + d1*r1 h(3) = h(3) + d1**2*r1 h(4) = h(4) + s3 h(5) = h(5) + d1*s3 h(6) = h(6) + r2 h(7) = h(7) + d2*s3 h(8) = h(8) + d1*d2*s3 h(9) = h(9) + d2*r2 h(10) = h(10) + d2**2*r2 420 continue do 440 ij = 1, 10 h(ij) = four*h(ij) 440 continue go to 800 c c gulf research and development function. c 450 continue do 470 ij = 1, 6 h(ij) = zero 470 continue d1 = two/three do 480 i = 1, 99 arg = dfloat(i)/c100 r = (-fifty*dlog(arg))**d1 + c25 - x(2) t1 = dabs(r)**x(3)/x(1) t2 = dexp(-t1) t = t2 - arg s1 = t1*t2*t s2 = t1*(s1 + t2*(t1*t2 - t)) r1 = dlog(dabs(r)) r2 = r1*s2 h(1) = h(1) + s2 - s1 h(2) = h(2) + s2/r h(3) = h(3) + (s1 + x(3)*s2)/r**2 h(4) = h(4) - r2 h(5) = h(5) + (s1 - x(3)*r2)/r h(6) = h(6) + r1*r2 480 continue h(1) = two*h(1)/x(1)**2 h(2) = two*x(3)*h(2)/x(1) h(3) = two*x(3)*h(3) h(4) = two*h(4)/x(1) h(5) = two*h(5) h(6) = two*h(6) go to 800 c c trigonometric function. c 490 continue u2 = dcos(x(n)) s1 = u2 if (n .eq. 1) go to 510 u1 = dcos(x(n-1)) s1 = s1 + u1 if (n .eq. 2) go to 510 n2 = n - 2 ntr = (n2*(n - 1))/2 kj = ntr do 500 j = 1, n2 kj = kj + 1 h(kj) = dcos(x(j)) s1 = s1 + h(kj) 500 continue 510 continue v2 = dsin(x(n)) s2 = dfloat(2*n) - v2 - s1 - dfloat(n)*u2 r2 = dfloat(2*n)*v2 - u2 ij = 0 if (n .eq. 1) go to 570 v1 = dsin(x(n-1)) s2 = s2 + dfloat(2*n-1) - v1 - s1 - dfloat(n-1)*u1 r1 = dfloat(2*n-1)*v1 - u1 if (n .eq. 2) go to 560 kj = ntr do 520 j = 1, n2 kjp1 = kj + n kj = kj + 1 h(kjp1) = dsin(x(j)) t = dfloat(n+j) - h(kjp1) - s1 - dfloat(j)*h(kj) s2 = s2 + t 520 continue kj = ntr do 540 j = 1, n2 kjp1 = kj + n kj = kj + 1 v = dfloat(j)*h(kj) + h(kjp1) t = dfloat(n+j) - s1 - v t1 = dfloat(n+j)*h(kjp1) - h(kj) ki = ntr do 530 i = 1, j ij = ij + 1 kip1 = ki + n ki = ki + 1 th = dfloat(i)*h(kip1) - h(ki) h(ij) = two*(h(kip1)*t1 + h(kjp1)*th) 530 continue h(ij) = h(ij) + two*(h(kj)*s2 + v*t + th**2) 540 continue do 550 i = 1, n2 ijp1 = ij + n ij = ij + 1 th = dfloat(i)*h(ijp1) - h(ij) h(ij) = two*(h(ijp1)*r1 + v1*th) h(ijp1) = two*(h(ijp1)*r2 + v2*th) 550 continue 560 continue v = dfloat(n-1)*u1 + v1 t = dfloat(2*n-1) - s1 - v th = dfloat(n-1)*v1 - u1 ijp1 = ij + n ij = ij + 1 h(ij) = two*(v1*(r1 + th) + u1*s2 + v*t + th**2) h(ijp1) = two*(v1*r2 + v2*th) 570 continue v = dfloat(n)*u2 + v2 t = dfloat(2*n) - s1 - v th = dfloat(n)*v2 - u2 ijp1 = ij + n h(ijp1) = two*(v2*(r2 + th) + u2*s2 + v*t + th**2) go to 800 c c extended rosenbrock function. c 580 continue ntr = (n*(n + 1))/2 do 600 ij = 1, ntr h(ij) = zero 600 continue ijp1 = 0 do 610 j = 1, n, 2 c t1 = one - x(j) ij = ijp1 + j ijp1 = ij + j + 1 h(ij) = c1200*x(j)**2 - c400*x(j+1) + two h(ijp1-1) = -c400*x(j) h(ijp1) = c200 610 continue go to 800 c c extended powell function. c 620 continue ntr = (n*(n + 1))/2 do 640 ij = 1, ntr h(ij) = zero 640 continue ijp3 = 0 do 650 j = 1, n, 4 c t = x(j) + ten*x(j+1) c t1 = x(j+2) - x(j+3) c s1 = five*t1 t2 = x(j+1) - two*x(j+2) c s2 = four*t2**3 t3 = x(j) - x(j+3) c s3 = twenty*t3**3 r2 = twelve*t2**2 r3 = c120*t3**2 ij = ijp3 + j ijp1 = ij + j + 1 ijp2 = ijp1 + j + 2 ijp3 = ijp2 + j + 3 h(ij) = two + r3 h(ijp1-1) = twenty h(ijp1) = c200 + r2 h(ijp2-1) = -two*r2 h(ijp2) = ten + four*r2 h(ijp3-3) = -r3 h(ijp3-1) = -ten h(ijp3) = ten + r3 650 continue go to 800 c c beale function. c 660 continue s1 = one - x(2) t1 = c1p5 - x(1)*s1 s2 = one - x(2)**2 t2 = c2p25 - x(1)*s2 s3 = one - x(2)**3 t3 = c2p625 - x(1)*s3 h(1) = two*(s1**2 + s2**2 + s3**2) h(2) = two * *(t1 + x(2)*(two*t2 + three*x(2)*t3) * - x(1)*(s1 + x(2)*(two*s2 + three*x(2)*s3))) h(3) = two*x(1) * *(x(1) + two*t2 * + x(2)*(six*t3 + x(1)*x(2)*(four + xnine*x(2)**2))) go to 800 c c wood function. c 670 continue s1 = x(2) - x(1)**2 c s2 = one - x(1) c s3 = x(2) - one t1 = x(4) - x(3)**2 c t2 = one - x(3) c t3 = x(4) - one h(1) = c400*(two*x(1)**2 - s1) + two h(2) = -c400*x(1) h(3) = c220p2 h(4) = zero h(5) = zero h(6) = c360*(two*x(3)**2 - t1) + two h(7) = zero h(8) = c19p8 h(9) = -c360*x(3) h(10) = c200p2 go to 800 c c chebyquad function. c 680 continue do 690 i = 1, n fvec(i) = zero 690 continue do 710 j = 1, n t1 = one t2 = two*x(j) - one t = two*t2 do 700 i = 1, n fvec(i) = fvec(i) + t2 th = t*t2 - t1 t1 = t2 t2 = th 700 continue 710 continue d1 = one/dfloat(n) iev = -1 do 720 i = 1, n fvec(i) = d1*fvec(i) if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one) iev = -iev 720 continue kj = 0 do 770 j = 1, n do 730 k = 1, j kj = kj + 1 h(kj) = zero 730 continue t1 = one t2 = two*x(j) - one t = two*t2 s1 = zero s2 = two r1 = zero r2 = zero do 740 i = 1, n h(kj) = h(kj) + fvec(i)*r2 th = eight*s2 + t*r2 - r1 r1 = r2 r2 = th fvec1(i) = d1*s2 th = four*t2 + t*s2 - s1 s1 = s2 s2 = th th = t*t2 - t1 t1 = t2 t2 = th 740 continue kj = kj - j do 760 k = 1, j kj = kj + 1 v1 = one v2 = two*x(k) - one v = two*v2 u1 = zero u2 = two do 750 i = 1, n h(kj) = h(kj) + fvec1(i)*u2 th = four*v2 + v*u2 - u1 u1 = u2 u2 = th th = v*v2 - v1 v1 = v2 v2 = th 750 continue 760 continue 770 continue d2 = two*d1 ntr = (n*(n + 1))/2 do 790 kj = 1, ntr h(kj) = d2*h(kj) 790 continue 800 continue return c c last card of subroutine hesfcn. c end cminpack-1.3.4/examples/lmddrv.c000644 000765 000765 00000014613 12274450161 016535 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); struct refnum { int nprob, nfev, njev; }; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; struct refnum lmdertest; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[65*40]; real fnm[60]; real fvec[65]; real x[40]; int ipvt[40]; real wa[5*40+65]; const int lwa = 5*40+65; (void)argc; (void)argv; tol = sqrt(__cminpack_func__(dpmpar)(1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmdertest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmdertest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmdertest.nprob,factor); ssqfcn(m,n,x,fvec,lmdertest.nprob); fnorm1 = __cminpack_func__(enorm)(m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmdertest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmdertest.nfev = 0; lmdertest.njev = 0; info = __cminpack_func__(lmder1)(fcn,&lmdertest,m,n,x,fvec,fjac,m,tol,ipvt,wa,lwa); ssqfcn(m,n,x,fvec,lmdertest.nprob); fnorm2 = __cminpack_func__(enorm)(m,fvec); np[ic] = lmdertest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmdertest.nfev; nj[ic] = lmdertest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmdertest.nfev, lmdertest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmder1: \n\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmder1 /) */ printf("\n\n nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least-squares solver. fcn should only call the testing */ /* function and jacobian subroutines ssqfcn and ssqjac with */ /* the appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ struct refnum *lmdertest = (struct refnum *)p; if (iflag == 1) { ssqfcn(m,n,x,fvec,lmdertest->nprob); lmdertest->nfev++; } if (iflag == 2) { ssqjac(m,n,x,fjac,ldfjac,lmdertest->nprob); lmdertest->njev++; } return 0; } /* fcn_ */ cminpack-1.3.4/examples/lmddrv.f000644 000765 000765 00000010333 12225167750 016540 0ustar00devernay000000 000000 c ********** c c this program tests codes for the least-squares solution of c m nonlinear equations in n variables. it consists of a driver c and an interface subroutine fcn. the driver reads in data, c calls the nonlinear least-squares solver, and finally prints c out information on the performance of the solver. this is c only a sample driver, many other drivers are possible. the c interface subroutine fcn is necessary to take into account the c forms of calling sequences used by the function and jacobian c subroutines in the various nonlinear least-squares solvers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,ldfjac,lwa,m,n,nfev,njev,nprob,nread,ntries, * nwrite integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60) double precision factor,fnorm1,fnorm2,one,ten,tol double precision fjac(65,40),fnm(60),fvec(65),wa(265),x(40) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev,njev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) ldfjac = 65 lwa = 265 ic = 0 10 continue read (nread,50) nprob,n,m,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call ssqfcn(m,n,x,fvec,nprob) fnorm1 = enorm(m,fvec) write (nwrite,60) nprob,n,m nfev = 0 njev = 0 call lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,iwa,wa, * lwa) call ssqfcn(m,n,x,fvec,nprob) fnorm2 = enorm(m,fvec) np(ic) = nprob na(ic) = n ma(ic) = m nf(ic) = nfev nj(ic) = njev nx(ic) = info fnm(ic) = fnorm2 write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 40 continue stop 50 format (4i5) 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to lmder1 /) 90 format (49h nprob n m nfev njev info final l2 norm /) 100 format (3i5, 3i6, 1x, d15.7) c c last card of driver. c end subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) integer m,n,ldfjac,iflag double precision x(n),fvec(m),fjac(ldfjac,n) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the nonlinear c least-squares solver. fcn should only call the testing c function and jacobian subroutines ssqfcn and ssqjac with c the appropriate value of problem number (nprob). c c subprograms called c c minpack-supplied ... ssqfcn,ssqjac c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev,njev common /refnum/ nprob,nfev,njev if (iflag .eq. 1) call ssqfcn(m,n,x,fvec,nprob) if (iflag .eq. 2) call ssqjac(m,n,x,fjac,ldfjac,nprob) if (iflag .eq. 1) nfev = nfev + 1 if (iflag .eq. 2) njev = njev + 1 return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/lmddrv_.c000644 000765 000765 00000014572 12274450427 016705 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "minpack.h" #include "ssq.h" #define real __minpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); struct refnum { int nprob, nfev, njev; }; struct refnum lmdertest; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[65*40]; real fnm[60]; real fvec[65]; real x[40]; int ipvt[40]; real wa[5*40+65]; const int lwa = 5*40+65; const int i1 = 1; (void)argc; (void)argv; tol = sqrt(__minpack_func__(dpmpar)(&i1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmdertest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmdertest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmdertest.nprob,factor); ssqfcn(m,n,x,fvec,lmdertest.nprob); fnorm1 = __minpack_func__(enorm)(&m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmdertest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmdertest.nfev = 0; lmdertest.njev = 0; __minpack_func__(lmder1)(fcn,&m,&n,x,fvec,fjac,&m,&tol,&info,ipvt,wa,&lwa); ssqfcn(m,n,x,fvec,lmdertest.nprob); fnorm2 = __minpack_func__(enorm)(&m,fvec); np[ic] = lmdertest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmdertest.nfev; nj[ic] = lmdertest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmdertest.nfev, lmdertest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmder1: \n\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmder1 /) */ printf("\n\n nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least-squares solver. fcn should only call the testing */ /* function and jacobian subroutines ssqfcn and ssqjac with */ /* the appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ if (*iflag == 1) { ssqfcn(*m,*n,x,fvec,lmdertest.nprob); lmdertest.nfev++; } if (*iflag == 2) { ssqjac(*m,*n,x,fjac,*ldfjac,lmdertest.nprob); lmdertest.njev++; } } /* fcn_ */ cminpack-1.3.4/examples/lmdipt.c000644 000765 000765 00000010746 12225167750 016546 0ustar00devernay000000 000000 #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ void lmdipt(int n, real *x, int nprob, real factor) { /* Local variables */ static real h; static int j; /* ********** */ /* subroutine initpt */ /* this subroutine specifies the standard starting points for the */ /* functions defined by subroutine ssqfcn. the subroutine returns */ /* in x a multiple (factor) of the standard starting point. for */ /* the 11th function the standard starting point is zero, so in */ /* this case, if factor is not unity, then the subroutine returns */ /* the vector x(j) = factor, j=1,...,n. */ /* the subroutine statement is */ /* subroutine initpt(n,x,nprob,factor) */ /* where */ /* n is a positive integer input variable. */ /* x is an output array of length n which contains the standard */ /* starting point for problem nprob multiplied by factor. */ /* nprob is a positive integer input variable which defines the */ /* number of the problem. nprob must not exceed 18. */ /* factor is an input variable which specifies the multiple of */ /* the standard starting point. if factor is unity, no */ /* multiplication is performed. */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; /* Function Body */ /* selection of initial point. */ switch (nprob) { /* linear function - full rank or rank 1. */ case 1: case 2: case 3: for (j = 1; j <= n; ++j) { x[j] = 1.; } break; /* rosenbrock function. */ case 4: x[1] = -1.2; x[2] = 1.; break; /* helical valley function. */ case 5: x[1] = -1.; x[2] = 0.; x[3] = 0.; break; /* powell singular function. */ case 6: x[1] = 3.; x[2] = -1.; x[3] = 0.; x[4] = 1.; break; /* freudenstein and roth function. */ case 7: x[1] = .5; x[2] = -2.; break; /* bard function. */ case 8: x[1] = 1.; x[2] = 1.; x[3] = 1.; break; /* kowalik and osborne function. */ case 9: x[1] = .25; x[2] = .39; x[3] = .415; x[4] = .39; break; /* meyer function. */ case 10: x[1] = .02; x[2] = 4e3; x[3] = 250.; break; /* watson function. */ case 11: for (j = 1; j <= n; ++j) { x[j] = 0.; } break; /* box 3-dimensional function. */ case 12: x[1] = 0.; x[2] = 10.; x[3] = 20.; break; /* jennrich and sampson function. */ case 13: x[1] = .3; x[2] = .4; break; /* brown and dennis function. */ case 14: x[1] = 25.; x[2] = 5.; x[3] = -5.; x[4] = -1.; break; /* chebyquad function. */ case 15: h = 1. / (real) (n + 1); for (j = 1; j <= n; ++j) { x[j] = (real) j * h; } break; /* brown almost-linear function. */ case 16: for (j = 1; j <= n; ++j) { x[j] = .5; } break; /* osborne 1 function. */ case 17: x[1] = .5; x[2] = 1.5; x[3] = -1.; x[4] = .01; x[5] = .02; break; /* osborne 2 function. */ case 18: x[1] = 1.3; x[2] = .65; x[3] = .65; x[4] = .7; x[5] = .6; x[6] = 3.; x[7] = 5.; x[8] = 7.; x[9] = 2.; x[10] = 4.5; x[11] = 5.5; break; } /* compute multiple of initial point. */ if (factor != 1.) { if (nprob != 11) { for (j = 1; j <= n; ++j) { x[j] *= factor; } } else { for (j = 1; j <= n; ++j) { x[j] = factor; } } } /* last card of subroutine initpt. */ } /* initpt_ */ cminpack-1.3.4/examples/lmdipt.f000644 000765 000765 00000010732 12225167750 016544 0ustar00devernay000000 000000 subroutine initpt(n,x,nprob,factor) integer n,nprob double precision factor double precision x(n) c ********** c c subroutine initpt c c this subroutine specifies the standard starting points for the c functions defined by subroutine ssqfcn. the subroutine returns c in x a multiple (factor) of the standard starting point. for c the 11th function the standard starting point is zero, so in c this case, if factor is not unity, then the subroutine returns c the vector x(j) = factor, j=1,...,n. c c the subroutine statement is c c subroutine initpt(n,x,nprob,factor) c c where c c n is a positive integer input variable. c c x is an output array of length n which contains the standard c starting point for problem nprob multiplied by factor. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c factor is an input variable which specifies the multiple of c the standard starting point. if factor is unity, no c multiplication is performed. c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer ivar,j double precision c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14, * c15,c16,c17,five,h,half,one,seven,ten,three, * twenty,twntf,two,zero double precision dfloat data zero,half,one,two,three,five,seven,ten,twenty,twntf * /0.0d0,5.0d-1,1.0d0,2.0d0,3.0d0,5.0d0,7.0d0,1.0d1,2.0d1, * 2.5d1/ data c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17 * /1.2d0,2.5d-1,3.9d-1,4.15d-1,2.0d-2,4.0d3,2.5d2,3.0d-1, * 4.0d-1,1.5d0,1.0d-2,1.3d0,6.5d-1,7.0d-1,6.0d-1,4.5d0, * 5.5d0/ dfloat(ivar) = ivar c c selection of initial point. c go to (10,10,10,30,40,50,60,70,80,90,100,120,130,140,150,170, * 190,200), nprob c c linear function - full rank or rank 1. c 10 continue do 20 j = 1, n x(j) = one 20 continue go to 210 c c rosenbrock function. c 30 continue x(1) = -c1 x(2) = one go to 210 c c helical valley function. c 40 continue x(1) = -one x(2) = zero x(3) = zero go to 210 c c powell singular function. c 50 continue x(1) = three x(2) = -one x(3) = zero x(4) = one go to 210 c c freudenstein and roth function. c 60 continue x(1) = half x(2) = -two go to 210 c c bard function. c 70 continue x(1) = one x(2) = one x(3) = one go to 210 c c kowalik and osborne function. c 80 continue x(1) = c2 x(2) = c3 x(3) = c4 x(4) = c3 go to 210 c c meyer function. c 90 continue x(1) = c5 x(2) = c6 x(3) = c7 go to 210 c c watson function. c 100 continue do 110 j = 1, n x(j) = zero 110 continue go to 210 c c box 3-dimensional function. c 120 continue x(1) = zero x(2) = ten x(3) = twenty go to 210 c c jennrich and sampson function. c 130 continue x(1) = c8 x(2) = c9 go to 210 c c brown and dennis function. c 140 continue x(1) = twntf x(2) = five x(3) = -five x(4) = -one go to 210 c c chebyquad function. c 150 continue h = one/dfloat(n+1) do 160 j = 1, n x(j) = dfloat(j)*h 160 continue go to 210 c c brown almost-linear function. c 170 continue do 180 j = 1, n x(j) = half 180 continue go to 210 c c osborne 1 function. c 190 continue x(1) = half x(2) = c10 x(3) = -one x(4) = c11 x(5) = c5 go to 210 c c osborne 2 function. c 200 continue x(1) = c12 x(2) = c13 x(3) = c13 x(4) = c14 x(5) = c15 x(6) = three x(7) = five x(8) = seven x(9) = two x(10) = c16 x(11) = c17 210 continue c c compute multiple of initial point. c if (factor .eq. one) go to 260 if (nprob .eq. 11) go to 230 do 220 j = 1, n x(j) = factor*x(j) 220 continue go to 250 230 continue do 240 j = 1, n x(j) = factor 240 continue 250 continue 260 continue return c c last card of subroutine initpt. c end cminpack-1.3.4/examples/lmfdrv.c000644 000765 000765 00000014445 12274450176 016550 0ustar00devernay000000 000000 /* Usage: lmfdrv < lm.data */ #include #include #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag); struct refnum { int nprob, nfev, njev; }; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; struct refnum lmdiftest; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fnm[60]; real fvec[65]; real x[40]; int iwa[40]; real wa[65*40+5*40+65]; const int lwa = 65*40+5*40+65; (void)argc; (void)argv; tol = sqrt(__cminpack_func__(dpmpar)(1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmdiftest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmdiftest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmdiftest.nprob,factor); ssqfcn(m,n,x,fvec,lmdiftest.nprob); fnorm1 = __cminpack_func__(enorm)(m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmdiftest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmdiftest.nfev = 0; lmdiftest.njev = 0; info = __cminpack_func__(lmdif1)(fcn,&lmdiftest,m,n,x,fvec,tol,iwa,wa,lwa); ssqfcn(m,n,x,fvec,lmdiftest.nprob); fnorm2 = __cminpack_func__(enorm)(m,fvec); np[ic] = lmdiftest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmdiftest.nfev; lmdiftest.njev /= n; nj[ic] = lmdiftest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of Jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmdiftest.nfev, lmdiftest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmdif1: \n\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmdif1 /) */ printf("\n\n nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least-squares solver. fcn should only call the testing */ /* function and jacobian subroutines ssqfcn and ssqjac with */ /* the appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ struct refnum *lmdiftest = (struct refnum *)p; ssqfcn(m,n,x,fvec,lmdiftest->nprob); if (iflag == 1) { lmdiftest->nfev++; } if (iflag == 2) { lmdiftest->njev++; } return 0; } /* fcn_ */ cminpack-1.3.4/examples/lmfdrv.f000644 000765 000765 00000010015 12225167750 016537 0ustar00devernay000000 000000 c ********** c c this program tests codes for the least-squares solution of c m nonlinear equations in n variables. it consists of a driver c and an interface subroutine fcn. the driver reads in data, c calls the nonlinear least-squares solver, and finally prints c out information on the performance of the solver. this is c only a sample driver, many other drivers are possible. the c interface subroutine fcn is necessary to take into account the c forms of calling sequences used by the function and jacobian c subroutines in the various nonlinear least-squares solvers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,lwa,m,n,nfev,njev,nprob,nread,ntries,nwrite integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60) double precision factor,fnorm1,fnorm2,one,ten,tol double precision fnm(60),fvec(65),wa(2865),x(40) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev,njev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) lwa = 2865 ic = 0 10 continue read (nread,50) nprob,n,m,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call ssqfcn(m,n,x,fvec,nprob) fnorm1 = enorm(m,fvec) write (nwrite,60) nprob,n,m nfev = 0 njev = 0 call lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) call ssqfcn(m,n,x,fvec,nprob) fnorm2 = enorm(m,fvec) np(ic) = nprob na(ic) = n ma(ic) = m nf(ic) = nfev njev = njev/n nj(ic) = njev nx(ic) = info fnm(ic) = fnorm2 write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 40 continue stop 50 format (4i5) 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to lmdif1 /) 90 format (49h nprob n m nfev njev info final l2 norm /) 100 format (3i5, 3i6, 1x, d15.7) c c last card of driver. c end subroutine fcn(m,n,x,fvec,iflag) integer m,n,iflag double precision x(n),fvec(m) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the nonlinear c least-squares solver. fcn should only call the testing c function subroutine ssqfcn with the appropriate value of c problem number (nprob). c c subprograms called c c minpack-supplied ... ssqfcn c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev,njev common /refnum/ nprob,nfev,njev call ssqfcn(m,n,x,fvec,nprob) if (iflag .eq. 1) nfev = nfev + 1 if (iflag .eq. 2) njev = njev + 1 return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/lmfdrv_.c000644 000765 000765 00000014373 12274450442 016703 0ustar00devernay000000 000000 /* Usage: lmfdrv < lm.data */ #include #include #include #include "minpack.h" #include "ssq.h" #define real __minpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag); struct refnum { int nprob, nfev, njev; }; struct refnum lmdiftest; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fnm[60]; real fvec[65]; real x[40]; int iwa[40]; real wa[65*40+5*40+65]; const int lwa = 65*40+5*40+65; const int i1 = 1; (void)argc; (void)argv; tol = sqrt(__minpack_func__(dpmpar)(&i1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmdiftest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmdiftest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmdiftest.nprob,factor); ssqfcn(m,n,x,fvec,lmdiftest.nprob); fnorm1 = __minpack_func__(enorm)(&m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmdiftest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmdiftest.nfev = 0; lmdiftest.njev = 0; __minpack_func__(lmdif1)(fcn,&m,&n,x,fvec,&tol,&info,iwa,wa,&lwa); ssqfcn(m,n,x,fvec,lmdiftest.nprob); fnorm2 = __minpack_func__(enorm)(&m,fvec); np[ic] = lmdiftest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmdiftest.nfev; lmdiftest.njev /= n; nj[ic] = lmdiftest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of Jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmdiftest.nfev, lmdiftest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmdif1: \n\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmdif1 /) */ printf("\n\n nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag) { /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least-squares solver. fcn should only call the testing */ /* function and jacobian subroutines ssqfcn and ssqjac with */ /* the appropriate value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ ssqfcn(*m,*n,x,fvec,lmdiftest.nprob); if (*iflag == 1) { lmdiftest.nfev++; } if (*iflag == 2) { lmdiftest.njev++; } } /* fcn_ */ cminpack-1.3.4/examples/lmsdrv.c000644 000765 000765 00000015615 12274450210 016552 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag); struct refnum { int nprob, nfev, njev; }; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; struct refnum lmstrtest; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[40*40]; const int ldfjac = 40; real fnm[60]; real fvec[65]; real x[40]; int ipvt[40]; real wa[5*40+65]; const int lwa = 5*40+65; (void)argc; (void)argv; tol = sqrt(__cminpack_func__(dpmpar)(1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmstrtest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmstrtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmstrtest.nprob,factor); ssqfcn(m,n,x,fvec,lmstrtest.nprob); fnorm1 = __cminpack_func__(enorm)(m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmstrtest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmstrtest.nfev = 0; lmstrtest.njev = 0; info = __cminpack_func__(lmstr1)(fcn,&lmstrtest,m,n,x,fvec,fjac,ldfjac,tol,ipvt,wa,lwa); ssqfcn(m,n,x,fvec,lmstrtest.nprob); fnorm2 = __cminpack_func__(enorm)(m,fvec); np[ic] = lmstrtest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmstrtest.nfev; nj[ic] = lmstrtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmstrtest.nfev, lmstrtest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmstr1\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmstr1 /) */ printf(" nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } real temp[65*40]; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag) { /* Local variables */ int j; /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least squares solver. if iflag = 1, fcn should only call the */ /* testing function subroutine ssqfcn. if iflag = i, i .ge. 2, */ /* fcn should only call subroutine ssqjac to calculate the */ /* (i-1)-st row of the jacobian. (the ssqjac subroutine provided */ /* here for testing purposes calculates the entire jacobian */ /* matrix and is therefore called only when iflag = 2.) each */ /* call to ssqfcn or ssqjac should specify the appropriate */ /* value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ struct refnum *lmstrtest = (struct refnum *)p; if (iflag == 1) { ssqfcn(m,n,x,fvec,lmstrtest->nprob); lmstrtest->nfev++; } if (iflag >= 2) { if (iflag == 2) { ssqjac(m,n,x,temp,65,lmstrtest->nprob); lmstrtest->njev++; } for (j = 0; j < n; ++j) { fjrow[j] = temp[(iflag - 2) + j * 65]; } } return 0; } /* fcn_ */ cminpack-1.3.4/examples/lmsdrv.f000644 000765 000765 00000011236 12225167750 016562 0ustar00devernay000000 000000 c ********** c c this program tests codes for the least-squares solution of c m nonlinear equations in n variables. it consists of a driver c and an interface subroutine fcn. the driver reads in data, c calls the nonlinear least-squares solver, and finally prints c out information on the performance of the solver. this is c only a sample driver, many other drivers are possible. the c interface subroutine fcn is necessary to take into account the c forms of calling sequences used by the function and jacobian c subroutines in the various nonlinear least-squares solvers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,ldfjac,lwa,m,n,nfev,njev,nprob,nread,ntries, * nwrite integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60) double precision factor,fnorm1,fnorm2,one,ten,tol double precision fjac(40,40),fnm(60),fvec(65),wa(265),x(40) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev,njev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) ldfjac = 40 lwa = 265 ic = 0 10 continue read (nread,50) nprob,n,m,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call ssqfcn(m,n,x,fvec,nprob) fnorm1 = enorm(m,fvec) write (nwrite,60) nprob,n,m nfev = 0 njev = 0 call lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,iwa,wa, * lwa) call ssqfcn(m,n,x,fvec,nprob) fnorm2 = enorm(m,fvec) np(ic) = nprob na(ic) = n ma(ic) = m nf(ic) = nfev nj(ic) = njev nx(ic) = info fnm(ic) = fnorm2 write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 40 continue stop 50 format (4i5) 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to lmstr1 /) 90 format (49h nprob n m nfev njev info final l2 norm /) 100 format (3i5, 3i6, 1x, d15.7) c c last card of driver. c end subroutine fcn(m,n,x,fvec,fjrow,iflag) integer m,n,iflag double precision x(n),fvec(m),fjrow(n) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the nonlinear c least squares solver. if iflag = 1, fcn should only call the c testing function subroutine ssqfcn. if iflag = i, i .ge. 2, c fcn should only call subroutine ssqjac to calculate the c (i-1)-st row of the jacobian. (the ssqjac subroutine provided c here for testing purposes calculates the entire jacobian c matrix and is therefore called only when iflag = 2.) each c call to ssqfcn or ssqjac should specify the appropriate c value of problem number (nprob). c c subprograms called c c minpack-supplied ... ssqfcn,ssqjac c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev,njev,j double precision temp(65,40) common /refnum/ nprob,nfev,njev if (iflag .eq. 1) call ssqfcn(m,n,x,fvec,nprob) if (iflag .eq. 2) call ssqjac(m,n,x,temp,65,nprob) if (iflag .eq. 1) nfev = nfev + 1 if (iflag .eq. 2) njev = njev + 1 if (iflag .eq. 1) go to 120 do 110 j = 1, n fjrow(j) = temp(iflag-1,j) 110 continue 120 continue return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/lmsdrv_.c000644 000765 000765 00000015551 12274450454 016722 0ustar00devernay000000 000000 /* Usage: lmddrv < lm.data */ #include #include #include #include "minpack.h" #include "ssq.h" #define real __minpack_real__ /* ********** */ /* this program tests codes for the least-squares solution of */ /* m nonlinear equations in n variables. it consists of a driver */ /* and an interface subroutine fcn. the driver reads in data, */ /* calls the nonlinear least-squares solver, and finally prints */ /* out information on the performance of the solver. this is */ /* only a sample driver, many other drivers are possible. the */ /* interface subroutine fcn is necessary to take into account the */ /* forms of calling sequences used by the function and jacobian */ /* subroutines in the various nonlinear least-squares solvers. */ /* subprograms called */ /* user-supplied ...... fcn */ /* minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn */ /* fortran-supplied ... dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag); struct refnum { int nprob, nfev, njev; }; struct refnum lmstrtest; static void printvec(int n, const real *x) { int i, num5, ilow, numleft; num5 = n/5; for (i = 0; i < num5; ++i) { ilow = i*5; printf(" %15.7e%15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]); } numleft = n%5; ilow = n - numleft; switch (numleft) { case 1: printf(" %15.7e\n", (double)x[ilow+0]); break; case 2: printf(" %15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1]); break; case 3: printf(" %15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]); break; case 4: printf(" %15.7e%15.7e%15.7e%15.7e\n", (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]); break; } } /* Main program */ int main(int argc, char **argv) { int i,ic,k,m,n,ntries; int info; int ma[60]; int na[60]; int nf[60]; int nj[60]; int np[60]; int nx[60]; real factor,fnorm1,fnorm2,tol; real fjac[40*40]; const int ldfjac = 40; real fnm[60]; real fvec[65]; real x[40]; int ipvt[40]; real wa[5*40+65]; const int lwa = 5*40+65; const int i1 = 1; (void)argc; (void)argv; tol = sqrt(__minpack_func__(dpmpar)(&i1)); ic = 0; for (;;) { scanf("%5d%5d%5d%5d\n", &lmstrtest.nprob, &n, &m, &ntries); /* read (nread,50) nprob,n,m,ntries 50 format (4i5) */ if (lmstrtest.nprob <= 0.) break; factor = 1.; for (k = 0; k < ntries; ++k, ++ic) { lmdipt(n,x,lmstrtest.nprob,factor); ssqfcn(m,n,x,fvec,lmstrtest.nprob); fnorm1 = __minpack_func__(enorm)(&m,fvec); printf("\n\n\n\n problem%5d dimensions%5d%5d\n\n", lmstrtest.nprob, n, m); /* write (nwrite,60) nprob,n,m 60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x // * ) */ lmstrtest.nfev = 0; lmstrtest.njev = 0; __minpack_func__(lmstr1)(fcn,&m,&n,x,fvec,fjac,&ldfjac,&tol,&info,ipvt,wa,&lwa); ssqfcn(m,n,x,fvec,lmstrtest.nprob); fnorm2 = __minpack_func__(enorm)(&m,fvec); np[ic] = lmstrtest.nprob; na[ic] = n; ma[ic] = m; nf[ic] = lmstrtest.nfev; nj[ic] = lmstrtest.njev; nx[ic] = info; fnm[ic] = fnorm2; printf("\n initial l2 norm of the residuals%15.7e\n" "\n final l2 norm of the residuals %15.7e\n" "\n number of function evaluations %10d\n" "\n number of jacobian evaluations %10d\n" "\n exit parameter %10d\n" "\n final approximate solution\n\n", (double)fnorm1, (double)fnorm2, lmstrtest.nfev, lmstrtest.njev, info); printvec(n, x); /* write (nwrite,70) * fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n) 70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x, * 33h final l2 norm of the residuals , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 33h number of jacobian evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) */ factor *= 10.; } } printf("\f summary of %d calls to lmstr1\n", ic); /* write (nwrite,80) ic 80 format (12h1summary of , i3, 16h calls to lmstr1 /) */ printf(" nprob n m nfev njev info final L2 norm \n\n"); /* write (nwrite,90) 90 format (49h nprob n m nfev njev info final l2 norm /) */ for (i = 0; i < ic; ++i) { printf("%5d%5d%5d%6d%6d%6d%16.7e\n", np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]); /* write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i) 100 format (3i5, 3i6, 1x, d15.7) */ } exit(0); } real temp[65*40]; void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag) { /* Local variables */ int j; /* ********** */ /* the calling sequence of fcn should be identical to the */ /* calling sequence of the function subroutine in the nonlinear */ /* least squares solver. if iflag = 1, fcn should only call the */ /* testing function subroutine ssqfcn. if iflag = i, i .ge. 2, */ /* fcn should only call subroutine ssqjac to calculate the */ /* (i-1)-st row of the jacobian. (the ssqjac subroutine provided */ /* here for testing purposes calculates the entire jacobian */ /* matrix and is therefore called only when iflag = 2.) each */ /* call to ssqfcn or ssqjac should specify the appropriate */ /* value of problem number (nprob). */ /* subprograms called */ /* minpack-supplied ... ssqfcn,ssqjac */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ if (*iflag == 1) { ssqfcn(*m,*n,x,fvec,lmstrtest.nprob); lmstrtest.nfev++; } if (*iflag >= 2) { if (*iflag == 2) { ssqjac(*m,*n,x,temp,65,lmstrtest.nprob); lmstrtest.njev++; } for (j = 0; j < *n; ++j) { fjrow[j] = temp[(*iflag - 2) + j * 65]; } } } /* fcn_ */ cminpack-1.3.4/examples/machar.c000644 000765 000765 00000022174 12225167750 016506 0ustar00devernay000000 000000 #include #include #include "cminpack.h" #define real __cminpack_real__ #define ABS(xxx) ((xxx>(real)0.)?(xxx):(-xxx)) extern void machar_(int *ibeta, int *it, int *irnd, int *ngrd, int *machep, int *negep, int *iexp, int *minexp, int *maxexp, real *eps, real *epsneg, real *xmin, real *xmax); void machar_(int *ibeta, int *it, int *irnd, int *ngrd, int *machep, int *negep, int *iexp, int *minexp, int *maxexp, real *eps, real *epsneg, real *xmin, real *xmax) /* This subroutine is intended to determine the parameters of the floating-point arithmetic system specified below. The determination of the first three uses an extension of an algorithm due to M. Malcolm, CACM 15 (1972), pp. 949-951, incorporating some, but not all, of the improvements suggested by M. Gentleman and S. Marovich, CACM 17 (1974), pp. 276-277. An earlier version of this program was published in the book Software Manual for the Elementary Functions by W. J. Cody and W. Waite, Prentice-Hall, Englewood Cliffs, NJ, 1980. The present program is a translation of the Fortran 77 program in W. J. Cody, "MACHAR: A subroutine to dynamically determine machine parameters". TOMS (14), 1988. Parameter values reported are as follows: ibeta - the radix for the floating-point representation it - the number of base ibeta digits in the floating-point significand irnd - 0 if floating-point addition chops 1 if floating-point addition rounds, but not in the IEEE style 2 if floating-point addition rounds in the IEEE style 3 if floating-point addition chops, and there is partial underflow 4 if floating-point addition rounds, but not in the IEEE style, and there is partial underflow 5 if floating-point addition rounds in the IEEE style, and there is partial underflow ngrd - the number of guard digits for multiplication with truncating arithmetic. It is 0 if floating-point arithmetic rounds, or if it truncates and only it base ibeta digits participate in the post-normalization shift of the floating-point significand in multiplication; 1 if floating-point arithmetic truncates and more than it base ibeta digits participate in the post-normalization shift of the floating-point significand in multiplication. machep - the largest negative integer such that 1.0+FLOAT(ibeta)**machep .NE. 1.0, except that machep is bounded below by -(it+3) negeps - the largest negative integer such that 1.0-FLOAT(ibeta)**negeps .NE. 1.0, except that negeps is bounded below by -(it+3) iexp - the number of bits (decimal places if ibeta = 10) reserved for the representation of the exponent (including the bias or sign) of a floating-point number minexp - the largest in magnitude negative integer such that FLOAT(ibeta)**minexp is positive and normalized maxexp - the smallest positive power of BETA that overflows eps - the smallest positive floating-point number such that 1.0+eps .NE. 1.0. In particular, if either ibeta = 2 or IRND = 0, eps = FLOAT(ibeta)**machep. Otherwise, eps = (FLOAT(ibeta)**machep)/2 epsneg - A small positive floating-point number such that 1.0-epsneg .NE. 1.0. In particular, if ibeta = 2 or IRND = 0, epsneg = FLOAT(ibeta)**negeps. Otherwise, epsneg = (ibeta**negeps)/2. Because negeps is bounded below by -(it+3), epsneg may not be the smallest number that can alter 1.0 by subtraction. xmin - the smallest non-vanishing normalized floating-point power of the radix, i.e., xmin = FLOAT(ibeta)**minexp xmax - the largest finite floating-point number. In particular xmax = (1.0-epsneg)*FLOAT(ibeta)**maxexp Note - on some machines xmax will be only the second, or perhaps third, largest number, being too small by 1 or 2 units in the last digit of the significand. Latest revision - August 4, 1988 Author - W. J. Cody Argonne National Laboratory */ { int i,iz,j,k; int mx,itmp,nxres; real a,b,beta,betain,one,y,z,zero; real betah,t,tmp,tmpa,tmp1,two; (*irnd) = 1; one = (real)(*irnd); two = one + one; a = two; b = a; zero = 0.0e0; /* determine ibeta,beta ala malcolm */ tmp = ((a+one)-a)-one; while (tmp == zero) { a = a+a; tmp = a+one; tmp1 = tmp-a; tmp = tmp1-one; } tmp = a+b; itmp = (int)(tmp-a); while (itmp == 0) { b = b+b; tmp = a+b; itmp = (int)(tmp-a); } *ibeta = itmp; beta = (real)(*ibeta); /* determine irnd, it */ (*it) = 0; b = one; tmp = ((b+one)-b)-one; while (tmp == zero) { *it = *it+1; b = b*beta; tmp = b+one; tmp1 = tmp-b; tmp = tmp1-one; } *irnd = 0; betah = beta/two; tmp = a+betah; tmp1 = tmp-a; if (tmp1 != zero) *irnd = 1; tmpa = a+beta; tmp = tmpa+betah; if ((*irnd == 0) && (tmp-tmpa != zero)) *irnd = 2; /* determine negep, epsneg */ (*negep) = (*it) + 3; betain = one / beta; a = one; for (i = 1; i<=(*negep); i++) { a = a * betain; } b = a; tmp = (one-a); tmp = tmp-one; while (tmp == zero) { a = a*beta; *negep = *negep-1; tmp1 = one-a; tmp = tmp1-one; } (*negep) = -(*negep); (*epsneg) = a; /* determine machep, eps */ (*machep) = -(*it) - 3; a = b; tmp = one+a; while (tmp-one == zero) { a = a*beta; *machep = *machep+1; tmp = one+a; } *eps = a; /* determine ngrd */ (*ngrd) = 0; tmp = one+*eps; tmp = tmp*one; if (((*irnd) == 0) && (tmp-one) != zero) (*ngrd) = 1; /* determine iexp, minexp, xmin loop to determine largest i such that (1/beta) ** (2**(i)) does not underflow. exit from loop is signaled by an underflow. */ i = 0; k = 1; z = betain; t = one+*eps; nxres = 0; for (;;) { y = z; z = y * y; /* check for underflow */ a = z * one; tmp = z*t; if ((a+a == zero) || (ABS(z) > y)) break; tmp1 = tmp*betain; if (tmp1*beta == z) break; i = i + 1; k = k+k; } /* determine k such that (1/beta)**k does not underflow first set k = 2 ** i */ (*iexp) = i + 1; mx = k + k; if (*ibeta == 10) { /* for decimal machines only */ (*iexp) = 2; iz = *ibeta; while (k >= iz) { iz = iz * (*ibeta); (*iexp) = (*iexp) + 1; } mx = iz + iz - 1; } /* loop to determine minexp, xmin. exit from loop is signaled by an underflow. */ for (;;) { (*xmin) = y; y = y * betain; a = y * one; tmp = y*t; tmp1 = a+a; if ((tmp1 == zero) || (ABS(y) >= (*xmin))) break; k = k + 1; tmp1 = tmp*betain; tmp1 = tmp1*beta; if ((tmp1 == y) && (tmp != y)) { nxres = 3; *xmin = y; break; } } (*minexp) = -k; /* determine maxexp, xmax */ if ((mx <= k+k-3) && ((*ibeta) != 10)) { mx = mx + mx; (*iexp) = (*iexp) + 1; } (*maxexp) = mx + (*minexp); /* Adjust *irnd to reflect partial underflow. */ (*irnd) = (*irnd)+nxres; /* Adjust for IEEE style machines. */ if ((*irnd) >= 2) (*maxexp) = (*maxexp)-2; /* adjust for machines with implicit leading bit in binary significand and machines with radix point at extreme right of significand. */ i = (*maxexp) + (*minexp); if (((*ibeta) == 2) && (i == 0)) (*maxexp) = (*maxexp) - 1; if (i > 20) (*maxexp) = (*maxexp) - 1; if (a != y) (*maxexp) = (*maxexp) - 2; (*xmax) = one - (*epsneg); tmp = (*xmax)*one; if (tmp != (*xmax)) (*xmax) = one - beta * (*epsneg); (*xmax) = (*xmax) / (beta * beta * beta * (*xmin)); i = (*maxexp) + (*minexp) + 3; if (i > 0) { for (j = 1; j<=i; j++ ) { if ((*ibeta) == 2) (*xmax) = (*xmax) + (*xmax); if ((*ibeta) != 2) (*xmax) = (*xmax) * beta; } } return; } cminpack-1.3.4/examples/machar.f000644 000765 000765 00000025171 12225167750 016511 0ustar00devernay000000 000000 SUBROUTINE MACHAR(IBETA,IT,IRND,NGRD,MACHEP,NEGEP,IEXP,MINEXP, 1 MAXEXP,EPS,EPSNEG,XMIN,XMAX) C----------------------------------------------------------------------- C This Fortran 77 subroutine is intended to determine the parameters C of the floating-point arithmetic system specified below. The C determination of the first three uses an extension of an algorithm C due to M. Malcolm, CACM 15 (1972), pp. 949-951, incorporating some, C but not all, of the improvements suggested by M. Gentleman and S. C Marovich, CACM 17 (1974), pp. 276-277. An earlier version of this C program was published in the book Software Manual for the C Elementary Functions by W. J. Cody and W. Waite, Prentice-Hall, C Englewood Cliffs, NJ, 1980. The present version is documented in C W. J. Cody, "MACHAR: A subroutine to dynamically determine machine C parameters," TOMS 14, December, 1988. C C The program as given here must be modified before compiling. If C a single (double) precision version is desired, change all C occurrences of CS (CD) in columns 1 and 2 to blanks. C C Parameter values reported are as follows: C C IBETA - the radix for the floating-point representation C IT - the number of base IBETA digits in the floating-point C significand C IRND - 0 if floating-point addition chops C 1 if floating-point addition rounds, but not in the C IEEE style C 2 if floating-point addition rounds in the IEEE style C 3 if floating-point addition chops, and there is C partial underflow C 4 if floating-point addition rounds, but not in the C IEEE style, and there is partial underflow C 5 if floating-point addition rounds in the IEEE style, C and there is partial underflow C NGRD - the number of guard digits for multiplication with C truncating arithmetic. It is C 0 if floating-point arithmetic rounds, or if it C truncates and only IT base IBETA digits C participate in the post-normalization shift of the C floating-point significand in multiplication; C 1 if floating-point arithmetic truncates and more C than IT base IBETA digits participate in the C post-normalization shift of the floating-point C significand in multiplication. C MACHEP - the largest negative integer such that C 1.0+FLOAT(IBETA)**MACHEP .NE. 1.0, except that C MACHEP is bounded below by -(IT+3) C NEGEPS - the largest negative integer such that C 1.0-FLOAT(IBETA)**NEGEPS .NE. 1.0, except that C NEGEPS is bounded below by -(IT+3) C IEXP - the number of bits (decimal places if IBETA = 10) C reserved for the representation of the exponent C (including the bias or sign) of a floating-point C number C MINEXP - the largest in magnitude negative integer such that C FLOAT(IBETA)**MINEXP is positive and normalized C MAXEXP - the smallest positive power of BETA that overflows C EPS - the smallest positive floating-point number such C that 1.0+EPS .NE. 1.0. In particular, if either C IBETA = 2 or IRND = 0, EPS = FLOAT(IBETA)**MACHEP. C Otherwise, EPS = (FLOAT(IBETA)**MACHEP)/2 C EPSNEG - A small positive floating-point number such that C 1.0-EPSNEG .NE. 1.0. In particular, if IBETA = 2 C or IRND = 0, EPSNEG = FLOAT(IBETA)**NEGEPS. C Otherwise, EPSNEG = (IBETA**NEGEPS)/2. Because C NEGEPS is bounded below by -(IT+3), EPSNEG may not C be the smallest number that can alter 1.0 by C subtraction. C XMIN - the smallest non-vanishing normalized floating-point C power of the radix, i.e., XMIN = FLOAT(IBETA)**MINEXP C XMAX - the largest finite floating-point number. In C particular XMAX = (1.0-EPSNEG)*FLOAT(IBETA)**MAXEXP C Note - on some machines XMAX will be only the C second, or perhaps third, largest number, being C too small by 1 or 2 units in the last digit of C the significand. C C Latest revision - December 4, 1987 C C Author - W. J. Cody C Argonne National Laboratory C C----------------------------------------------------------------------- INTEGER I,IBETA,IEXP,IRND,IT,ITEMP,IZ,J,K,MACHEP,MAXEXP, 1 MINEXP,MX,NEGEP,NGRD,NXRES CS REAL DOUBLE PRECISION 1 A,B,BETA,BETAIN,BETAH,CONV,EPS,EPSNEG,ONE,T,TEMP,TEMPA, 2 TEMP1,TWO,XMAX,XMIN,Y,Z,ZERO C----------------------------------------------------------------------- CS CONV(I) = REAL(I) CONV(I) = DBLE(I) ONE = CONV(1) TWO = ONE + ONE ZERO = ONE - ONE C----------------------------------------------------------------------- C Determine IBETA, BETA ala Malcolm. C----------------------------------------------------------------------- A = ONE 10 A = A + A TEMP = A+ONE TEMP1 = TEMP-A IF (TEMP1-ONE .EQ. ZERO) GO TO 10 B = ONE 20 B = B + B TEMP = A+B ITEMP = INT(TEMP-A) IF (ITEMP .EQ. 0) GO TO 20 IBETA = ITEMP BETA = CONV(IBETA) C----------------------------------------------------------------------- C Determine IT, IRND. C----------------------------------------------------------------------- IT = 0 B = ONE 100 IT = IT + 1 B = B * BETA TEMP = B+ONE TEMP1 = TEMP-B IF (TEMP1-ONE .EQ. ZERO) GO TO 100 IRND = 0 BETAH = BETA / TWO TEMP = A+BETAH IF (TEMP-A .NE. ZERO) IRND = 1 TEMPA = A + BETA TEMP = TEMPA+BETAH IF ((IRND .EQ. 0) .AND. (TEMP-TEMPA .NE. ZERO)) IRND = 2 C----------------------------------------------------------------------- C Determine NEGEP, EPSNEG. C----------------------------------------------------------------------- NEGEP = IT + 3 BETAIN = ONE / BETA A = ONE DO 200 I = 1, NEGEP A = A * BETAIN 200 CONTINUE B = A 210 TEMP = ONE-A IF (TEMP-ONE .NE. ZERO) GO TO 220 A = A * BETA NEGEP = NEGEP - 1 GO TO 210 220 NEGEP = -NEGEP EPSNEG = A C----------------------------------------------------------------------- C Determine MACHEP, EPS. C----------------------------------------------------------------------- MACHEP = -IT - 3 A = B 300 TEMP = ONE+A IF (TEMP-ONE .NE. ZERO) GO TO 320 A = A * BETA MACHEP = MACHEP + 1 GO TO 300 320 EPS = A C----------------------------------------------------------------------- C Determine NGRD. C----------------------------------------------------------------------- NGRD = 0 TEMP = ONE+EPS IF ((IRND .EQ. 0) .AND. (TEMP*ONE-ONE .NE. ZERO)) NGRD = 1 C----------------------------------------------------------------------- C Determine IEXP, MINEXP, XMIN. C C Loop to determine largest I and K = 2**I such that C (1/BETA) ** (2**(I)) C does not underflow. C Exit from loop is signaled by an underflow. C----------------------------------------------------------------------- I = 0 K = 1 Z = BETAIN T = ONE + EPS NXRES = 0 400 Y = Z Z = Y * Y C----------------------------------------------------------------------- C Check for underflow here. C----------------------------------------------------------------------- A = Z * ONE TEMP = Z * T IF ((A+A .EQ. ZERO) .OR. (ABS(Z) .GE. Y)) GO TO 410 TEMP1 = TEMP * BETAIN IF (TEMP1*BETA .EQ. Z) GO TO 410 I = I + 1 K = K + K GO TO 400 410 IF (IBETA .EQ. 10) GO TO 420 IEXP = I + 1 MX = K + K GO TO 450 C----------------------------------------------------------------------- C This segment is for decimal machines only. C----------------------------------------------------------------------- 420 IEXP = 2 IZ = IBETA 430 IF (K .LT. IZ) GO TO 440 IZ = IZ * IBETA IEXP = IEXP + 1 GO TO 430 440 MX = IZ + IZ - 1 C----------------------------------------------------------------------- C Loop to determine MINEXP, XMIN. C Exit from loop is signaled by an underflow. C----------------------------------------------------------------------- 450 XMIN = Y Y = Y * BETAIN C----------------------------------------------------------------------- C Check for underflow here. C----------------------------------------------------------------------- A = Y * ONE TEMP = Y * T IF (((A+A) .EQ. ZERO) .OR. (ABS(Y) .GE. XMIN)) GO TO 460 K = K + 1 TEMP1 = TEMP * BETAIN IF ((TEMP1*BETA .NE. Y) .OR. (TEMP .EQ. Y)) THEN GO TO 450 ELSE NXRES = 3 XMIN = Y END IF 460 MINEXP = -K C----------------------------------------------------------------------- C Determine MAXEXP, XMAX. C----------------------------------------------------------------------- IF ((MX .GT. K+K-3) .OR. (IBETA .EQ. 10)) GO TO 500 MX = MX + MX IEXP = IEXP + 1 500 MAXEXP = MX + MINEXP C----------------------------------------------------------------- C Adjust IRND to reflect partial underflow. C----------------------------------------------------------------- IRND = IRND + NXRES C----------------------------------------------------------------- C Adjust for IEEE-style machines. C----------------------------------------------------------------- IF (IRND .GE. 2) MAXEXP = MAXEXP - 2 C----------------------------------------------------------------- C Adjust for machines with implicit leading bit in binary C significand, and machines with radix point at extreme C right of significand. C----------------------------------------------------------------- I = MAXEXP + MINEXP IF ((IBETA .EQ. 2) .AND. (I .EQ. 0)) MAXEXP = MAXEXP - 1 IF (I .GT. 20) MAXEXP = MAXEXP - 1 IF (A .NE. Y) MAXEXP = MAXEXP - 2 XMAX = ONE - EPSNEG IF (XMAX*ONE .NE. XMAX) XMAX = ONE - BETA * EPSNEG XMAX = XMAX / (BETA * BETA * BETA * XMIN) I = MAXEXP + MINEXP + 3 IF (I .LE. 0) GO TO 520 DO 510 J = 1, I IF (IBETA .EQ. 2) XMAX = XMAX + XMAX IF (IBETA .NE. 2) XMAX = XMAX * BETA 510 CONTINUE 520 RETURN C---------- LAST CARD OF MACHAR ---------- END cminpack-1.3.4/examples/Makefile000644 000765 000765 00000034600 12303616324 016535 0ustar00devernay000000 000000 #!/usr/bin/make # pick up your FORTRAN compiler #F77=g77 F77=gfortran # uncomment the following for FORTRAN MINPACK #MINPACK=-lminpack #F77C=$(F77) #F77CFLAGS=-g # uncomment the following for C MINPACK MINPACK=../libcminpack$(LIBSUFFIX).a CC=gcc CFLAGS=-g -Wall CPPFLAGS=-I.. FMINPACK=../fortran/libminpack.a # uncomment the following to debug using valgrind #VALGRIND=valgrind --tool=memcheck ### The default configuration is to compile the double precision version ### configuration for the LAPACK/BLAS (double precision) version: ## make LIBSUFFIX= CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" #LIBSUFFIX=s #CFLAGS="-O3 -g -Wall -Wextra -DUSE_CBLAS -DUSE_LAPACK" CFLAGS_L=$(CFLAGS) -DUSE_CBLAS -DUSE_LAPACK LDADD_L=-framework vecLib ### configuration for the float (single precision) version: ## make LIBSUFFIX=s CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" #LIBSUFFIX=s #CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__" CFLAGS_F=$(CFLAGS) -D__cminpack_float__ ### configuration for the half (half precision) version: ## make LIBSUFFIX=h CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" LDADD="-L/opt/local/lib -lHalf" CC=g++ #LIBSUFFIX=h #CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" #LDADD="-L/opt/local/lib -lHalf" #CC=g++ CFLAGS_H=$(CFLAGS) -I/opt/local/include -D__cminpack_half__ LDADD_H=-L/opt/local/lib -lHalf CC_H=$(CXX) FPGM=\ $(LIBSUFFIX)tchkder \ $(LIBSUFFIX)thybrd \ $(LIBSUFFIX)thybrd1 \ $(LIBSUFFIX)thybrj \ $(LIBSUFFIX)thybrj1 \ $(LIBSUFFIX)tlmder \ $(LIBSUFFIX)tlmder1 \ $(LIBSUFFIX)tlmdif \ $(LIBSUFFIX)tlmdif1 \ $(LIBSUFFIX)tlmstr \ $(LIBSUFFIX)tlmstr1 \ $(LIBSUFFIX)ibmdpdr PGM=\ $(LIBSUFFIX)tenorm_ \ $(LIBSUFFIX)tchkder_ \ $(LIBSUFFIX)thybrd_ \ $(LIBSUFFIX)thybrd1_ \ $(LIBSUFFIX)thybrj_ \ $(LIBSUFFIX)thybrj1_ \ $(LIBSUFFIX)tlmder_ \ $(LIBSUFFIX)tlmder1_ \ $(LIBSUFFIX)tlmdif_ \ $(LIBSUFFIX)tlmdif1_ \ $(LIBSUFFIX)tlmstr_ \ $(LIBSUFFIX)tlmstr1_ \ $(LIBSUFFIX)tfdjac2_ \ $(LIBSUFFIX)ibmdpdr_ CPGM=\ $(LIBSUFFIX)tenormc \ $(LIBSUFFIX)tchkderc \ $(LIBSUFFIX)thybrdc \ $(LIBSUFFIX)thybrd1c \ $(LIBSUFFIX)thybrjc \ $(LIBSUFFIX)thybrj1c \ $(LIBSUFFIX)tlmderc \ $(LIBSUFFIX)tlmder1c \ $(LIBSUFFIX)tlmdifc \ $(LIBSUFFIX)tlmdif1c \ $(LIBSUFFIX)tlmstrc \ $(LIBSUFFIX)tlmstr1c \ $(LIBSUFFIX)tfdjac2c \ $(LIBSUFFIX)ibmdpdrc \ $(LIBSUFFIX)tchkderc_box \ $(LIBSUFFIX)tlmderc_box \ $(LIBSUFFIX)thybrjc_box FDRVPGM=\ $(LIBSUFFIX)lmddrv_ \ $(LIBSUFFIX)lmfdrv_ \ $(LIBSUFFIX)lmsdrv_ \ $(LIBSUFFIX)hyjdrv_ \ $(LIBSUFFIX)hybdrv_ \ $(LIBSUFFIX)chkdrv_ DRVPGM=\ $(LIBSUFFIX)lmddrv \ $(LIBSUFFIX)lmfdrv \ $(LIBSUFFIX)lmsdrv \ $(LIBSUFFIX)hyjdrv \ $(LIBSUFFIX)hybdrv \ $(LIBSUFFIX)chkdrv CDRVPGM=\ $(LIBSUFFIX)lmddrvc \ $(LIBSUFFIX)lmfdrvc \ $(LIBSUFFIX)lmsdrvc \ $(LIBSUFFIX)hyjdrvc \ $(LIBSUFFIX)hybdrvc \ $(LIBSUFFIX)chkdrvc FSRCGEN=tchkder.f thybrd.f thybrd1.f thybrj.f thybrj1.f tlmder.f tlmder1.f \ tlmdif.f tlmdif1.f tlmstr.f tlmstr1.f FSRC=$(FSRCGEN) \ lmddrv.f lmdipt.f ssqfcn.f ssqjac.f lmfdrv.f lmsdrv.f \ hyjdrv.f hybipt.f vecfcn.f vecjac.f hybdrv.f \ errjac.f chkdrv.f ibmdpdr.f machar.f SRC=tchkder_.c thybrd_.c thybrd1_.c thybrj_.c thybrj1_.c tlmder_.c tlmder1_.c \ tlmdif_.c tlmdif1_.c tlmstr_.c tlmstr1_.c tfdjac2_.c \ lmddrv_.c lmfdrv_.c lmsdrv_.c \ hyjdrv_.c hybdrv_.c \ chkdrv_.c ibmdpdr_.c CSRC=tchkderc.c thybrdc.c thybrd1c.c thybrjc.c thybrj1c.c tlmderc.c tlmder1c.c \ tlmdifc.c tlmdif1c.c tlmstrc.c tlmstr1c.c tfdjac2c.c \ lmddrv.c lmdipt.c ssqfcn.c ssqjac.c lmfdrv.c lmsdrv.c \ hyjdrv.c hybipt.c vecfcn.c vecjac.c hybdrv.c \ errjac.c chkdrv.c ibmdpdr.c machar.c CDRVSRC=lmddrv.c lmfdrv.c lmsdrv.c hyjdrv.c hybdrv.c REF=test.ref ctest.ref ftest.ref all: @echo "*****************************************************" @echo "Please type 'make check' to run all tests at once, or:" @echo "*****************************************************" @echo "make test: calling FORTRAN CMINPACK from C" @echo "make test MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from C" @echo "make ctest: calling CMINPACK from C" @echo "make ftest: calling FORTRAN CMINPACK from FORTRAN" @echo "make ftest MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from FORTRAN" @echo "Intensive (driver) tests:" @echo "make testdrv: calling FORTRAN CMINPACK from C" @echo "make testdrv MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from C" @echo "make ctestdrv: calling CMINPACK from C" @echo "make ftestdrv: calling FORTRAN CMINPACK from FORTRAN" @echo "make ftestdrv MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from FORTRAN" .PHONY: test ctest ctestdrv ctestlmdrv ctesthydrv ctestchkdrv ftest ftestdrv ftestlmdrv ftesthydrv ftestchkdrv check checkdoublec checkdouble checkfloatc checkfloat checkhalfc checkhalf checkfail clean veryclean test: $(MINPACK) $(PGM) @echo "*** Running standard tests (calling MINPACK from C using $(MINPACK))" for x in $(PGM); do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/`echo $$x.ref|sed -e s/_.ref/c.ref/` $$x.out ; done testdrv: $(MINPACK) $(FDRVPGM) testlmdrv testhydrv testchkdrv testlmdrv: $(LIBSUFFIX)lmddrv_ $(LIBSUFFIX)lmfdrv_ $(LIBSUFFIX)lmsdrv_ @echo "*** Running LM tests (calling MINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/`echo $$x |sed -e s/_/c/`.ref $$x.out ; done testhydrv: $(LIBSUFFIX)hyjdrv_ $(LIBSUFFIX)hybdrv_ @echo "*** Running HY tests (calling MINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/`echo $$x |sed -e s/_/c/`.ref $$x.out ; done testchkdrv: $(LIBSUFFIX)chkdrv_ @echo "*** Running CHK tests (calling MINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/`echo $$x |sed -e s/_/c/`.ref $$x.out ; done ctest: $(MINPACK) $(CPGM) @echo "*** Running standard tests (calling CMINPACK from C using $(MINPACK))" for x in $(CPGM); do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/$$x.ref $$x.out ; done ctestdrv: $(MINPACK) $(CDRVPGM) ctestlmdrv ctesthydrv ctestchkdrv ctestlmdrv: $(LIBSUFFIX)lmddrvc $(LIBSUFFIX)lmfdrvc $(LIBSUFFIX)lmsdrvc @echo "*** Running LM tests (calling CMINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done ctesthydrv: $(LIBSUFFIX)hyjdrvc $(LIBSUFFIX)hybdrvc @echo "*** Running HY tests (calling CMINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done ctestchkdrv: $(LIBSUFFIX)chkdrvc @echo "*** Running CHK tests (calling CMINPACK from C using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done ftest: $(MINPACK) $(FPGM) @echo "*** Running standard tests (calling MINPACK from FORTRAN using $(MINPACK))" for x in ${FPGM}; do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/$$x.ref $$x.out ; done ftestdrv: $(MINPACK) $(DRVPGM) ftestlmdrv ftesthydrv ftestchkdrv ftestlmdrv: $(LIBSUFFIX)lmddrv $(LIBSUFFIX)lmfdrv $(LIBSUFFIX)lmsdrv @echo "*** Running LM tests (calling MINPACK from FORTRAN using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done ftesthydrv: $(LIBSUFFIX)hyjdrv $(LIBSUFFIX)hybdrv @echo "*** Running HY tests (calling MINPACK from FORTRAN using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done ftestchkdrv: $(LIBSUFFIX)chkdrv @echo "*** Running CHK tests (calling MINPACK from FORTRAN using $(MINPACK))" for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/$$x.ref $$x.out ; done check: checkdouble checkfloat checkdoublec: $(MAKE) -C .. double 2>&1 > /dev/null $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) ctest LIBSUFFIX= $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) -k ctestdrv LIBSUFFIX= $(MAKE) clean 2>&1 > /dev/null checkdouble: checkdoublec ../fortran/libminpack.a $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) test LIBSUFFIX= $(MAKE) clean LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null -$(MAKE) test LIBSUFFIX= MINPACK=../fortran/libminpack.a $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) ftest LIBSUFFIX= $(MAKE) clean LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null -$(MAKE) ftest LIBSUFFIX= MINPACK=../fortran/libminpack.a $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) -k testdrv LIBSUFFIX= $(MAKE) clean 2>&1 > /dev/null checkfloatc: $(MAKE) -C .. float 2>&1 > /dev/null $(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null -$(MAKE) ctest LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" $(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null -$(MAKE) -k ctestdrv LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" $(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null checkfloat: checkfloatc $(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null -$(MAKE) test LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" $(MAKE) clean LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 2>&1 > /dev/null -$(MAKE) -k testdrv LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" $(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null checklapack: $(MAKE) -C .. lapack 2>&1 > /dev/null $(MAKE) clean LIBSUFFIX=l 2>&1 > /dev/null -$(MAKE) ctest LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)" $(MAKE) clean LIBSUFFIX=l 2>&1 > /dev/null -$(MAKE) -k ctestdrv LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)" $(MAKE) clean LIBSUFFIX=l 2>&1 > /dev/null checkhalfc: $(MAKE) -C .. half 2>&1 > /dev/null $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null -$(MAKE) ctest LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null -$(MAKE) -k ctestdrv LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null checkhalf: checkhalfc $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null -$(MAKE) test LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null -$(MAKE) -k testdrv LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" $(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null checkfail: ../fortran/libminpack.a check $(MAKE) clean LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null -$(MAKE) -k testdrv LIBSUFFIX= MINPACK=../fortran/libminpack.a $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null -$(MAKE) -k ftestdrv LIBSUFFIX= $(MAKE) clean LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null -$(MAKE) -k ftestdrv LIBSUFFIX= MINPACK=../fortran/libminpack.a $(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null ../libcminpack$(LIBSUFFIX).a: $(MAKE) -C .. ../fortran/libminpack.a: $(MAKE) -C ../fortran clean: -rm -f $(PGM) $(FDRVPGM) $(DRVPGM) $(CPGM) $(CDRVPGM) $(FPGM) veryclean: clean -rm -f *.o *.gcno *.gcda *.out *~ #*# -rm -rf $(PGM:=.dSYM) $(CPGM:=.dSYM) $(CDRVPGM:=.dSYM) $(FPGM:=.dSYM) ${FSRCGEN}: ../doc/minpack-documentation.txt cat $< | 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; \ }' $(LIBSUFFIX)%: %.f $(MINPACK) $(F77) $(FFLAGS) -o $@ $< $(MINPACK) $(LIBSUFFIX)%: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)%.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(LIBSUFFIX)lmddrv_: $(MINPACK) $(LIBSUFFIX)lmddrv_.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(LIBSUFFIX)ssqjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmfdrv_: $(MINPACK) $(LIBSUFFIX)lmfdrv_.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmsdrv_: $(MINPACK) $(LIBSUFFIX)lmsdrv_.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(LIBSUFFIX)ssqjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)hyjdrv_: $(MINPACK) $(LIBSUFFIX)hyjdrv_.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(LIBSUFFIX)vecjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)hybdrv_: $(MINPACK) $(LIBSUFFIX)hybdrv_.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)chkdrv_: $(MINPACK) $(LIBSUFFIX)chkdrv_.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(LIBSUFFIX)errjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)ibmdpdr_: $(MINPACK) $(LIBSUFFIX)ibmdpdr_.o $(LIBSUFFIX)machar.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmddrvc: $(MINPACK) $(LIBSUFFIX)lmddrv.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(LIBSUFFIX)ssqjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmfdrvc: $(MINPACK) $(LIBSUFFIX)lmfdrv.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmsdrvc: $(MINPACK) $(LIBSUFFIX)lmsdrv.o $(LIBSUFFIX)lmdipt.o $(LIBSUFFIX)ssqfcn.o $(LIBSUFFIX)ssqjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)hyjdrvc: $(MINPACK) $(LIBSUFFIX)hyjdrv.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(LIBSUFFIX)vecjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)hybdrvc: $(MINPACK) $(LIBSUFFIX)hybdrv.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)chkdrvc: $(MINPACK) $(LIBSUFFIX)chkdrv.o $(LIBSUFFIX)hybipt.o $(LIBSUFFIX)vecfcn.o $(LIBSUFFIX)errjac.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)ibmdpdrc: $(MINPACK) $(LIBSUFFIX)ibmdpdr.o $(LIBSUFFIX)machar.o $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm $(LIBSUFFIX)lmddrv: $(MINPACK) lmddrv.f lmdipt.f ssqfcn.f ssqjac.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)lmfdrv: $(MINPACK) lmfdrv.f lmdipt.f ssqfcn.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)lmsdrv: $(MINPACK) lmsdrv.f lmdipt.f ssqfcn.f ssqjac.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)hyjdrv: $(MINPACK) hyjdrv.f hybipt.f vecfcn.f vecjac.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)hybdrv: $(MINPACK) hybdrv.f hybipt.f vecfcn.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)chkdrv: $(MINPACK) chkdrv.f hybipt.f vecfcn.f errjac.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) $(LIBSUFFIX)ibmdpdr: $(MINPACK) ibmdpdr.f machar.f $(F77) $(FFLAGS) -o $@ $^ $(MINPACK) cminpack-1.3.4/examples/objfcn.f000644 000765 000765 00000020405 12225167750 016512 0ustar00devernay000000 000000 subroutine objfcn(n,x,f,nprob) integer n,nprob double precision f double precision x(n) c ********** c c subroutine objfcn c c this subroutine defines the objective functions of eighteen c nonlinear unconstrained minimization problems. the values c of n for functions 1,2,3,4,5,10,11,12,16 and 17 are c 3,6,3,2,3,2,4,3,2 and 4, respectively. c for function 7, n may be 2 or greater but is usually 6 or 9. c for functions 6,8,9,13,14,15 and 18 n may be variable, c however it must be even for function 14, a multiple of 4 for c function 15, and not greater than 50 for function 18. c c the subroutine statement is c c subroutine objfcn(n,x,f,nprob) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c f is an output variable which contains the value of c the nprob objective function evaluated at x. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin, c dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j double precision ap,arg,c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5, * c2p25,c2p625,c3p5,c25,c29,c90,c100,c10000, * c1pd6,d1,d2,eight,fifty,five,four,one,r,s1,s2, * s3,t,t1,t2,t3,ten,th,three,tpi,two,zero double precision fvec(50),y(15) double precision dfloat data zero,one,two,three,four,five,eight,ten,fifty * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,5.0d1/ data c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c25, * c29,c90,c100,c10000,c1pd6 * /2.0d-6,1.0d-4,1.0d-1,2.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0, * 2.625d0,3.5d0,2.5d1,2.9d1,9.0d1,1.0d2,1.0d4,1.0d6/ data ap /1.0d-5/ data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11), * y(12),y(13),y(14),y(15) * /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1, * 3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3, * 9.0d-4/ dfloat(ivar) = ivar c c function routine selector. c go to (10,20,40,60,70,90,110,150,170,200,210,230,250,280,300, * 320,330,340), nprob c c helical valley function. c 10 continue tpi = eight*datan(one) th = dsign(cp25,x(2)) if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5 arg = x(1)**2 + x(2)**2 r = dsqrt(arg) t = x(3) - ten*th f = c100*(t**2 + (r - one)**2) + x(3)**2 go to 390 c c biggs exp6 function. c 20 continue f = zero do 30 i = 1, 13 d1 = dfloat(i)/ten d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1) s1 = dexp(-d1*x(1)) s2 = dexp(-d1*x(2)) s3 = dexp(-d1*x(5)) t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2 f = f + t**2 30 continue go to 390 c c gaussian function. c 40 continue f = zero do 50 i = 1, 15 d1 = cp5*dfloat(i-1) d2 = c3p5 - d1 - x(3) arg = -cp5*x(2)*d2**2 r = dexp(arg) t = x(1)*r - y(i) f = f + t**2 50 continue go to 390 c c powell badly scaled function. c 60 continue t1 = c10000*x(1)*x(2) - one s1 = dexp(-x(1)) s2 = dexp(-x(2)) t2 = s1 + s2 - one - cp0001 f = t1**2 + t2**2 go to 390 c c box 3-dimensional function. c 70 continue f = zero do 80 i = 1, 10 d1 = dfloat(i) d2 = d1/ten s1 = dexp(-d2*x(1)) s2 = dexp(-d2*x(2)) s3 = dexp(-d2) - dexp(-d1) t = s1 - s2 - s3*x(3) f = f + t**2 80 continue go to 390 c c variably dimensioned function. c 90 continue t1 = zero t2 = zero do 100 j = 1, n t1 = t1 + dfloat(j)*(x(j) - one) t2 = t2 + (x(j) - one)**2 100 continue f = t2 + t1**2*(one + t1**2) go to 390 c c watson function. c 110 continue f = zero do 140 i = 1, 29 d1 = dfloat(i)/c29 s1 = zero d2 = one do 120 j = 2, n s1 = s1 + dfloat(j-1)*d2*x(j) d2 = d1*d2 120 continue s2 = zero d2 = one do 130 j = 1, n s2 = s2 + d2*x(j) d2 = d1*d2 130 continue t = s1 - s2**2 - one f = f + t**2 140 continue t1 = x(2) - x(1)**2 - one f = f + x(1)**2 + t1**2 go to 390 c c penalty function i. c 150 continue t1 = -cp25 t2 = zero do 160 j = 1, n t1 = t1 + x(j)**2 t2 = t2 + (x(j) - one)**2 160 continue f = ap*t2 + t1**2 go to 390 c c penalty function ii. c 170 continue t1 = -one t2 = zero t3 = zero d1 = dexp(cp1) d2 = one do 190 j = 1, n t1 = t1 + dfloat(n-j+1)*x(j)**2 s1 = dexp(x(j)/ten) if (j .eq. 1) go to 180 s3 = s1 + s2 - d2*(d1 + one) t2 = t2 + s3**2 t3 = t3 + (s1 - one/d1)**2 180 continue s2 = s1 d2 = d1*d2 190 continue f = ap*(t2 + t3) + t1**2 + (x(1) - cp2)**2 go to 390 c c brown badly scaled function. c 200 continue t1 = x(1) - c1pd6 t2 = x(2) - c2pdm6 t3 = x(1)*x(2) - two f = t1**2 + t2**2 + t3**2 go to 390 c c brown and dennis function. c 210 continue f = zero do 220 i = 1, 20 d1 = dfloat(i)/five d2 = dsin(d1) t1 = x(1) + d1*x(2) - dexp(d1) t2 = x(3) + d2*x(4) - dcos(d1) t = t1**2 + t2**2 f = f + t**2 220 continue go to 390 c c gulf research and development function. c 230 continue f = zero d1 = two/three do 240 i = 1, 99 arg = dfloat(i)/c100 r = (-fifty*dlog(arg))**d1 + c25 - x(2) t1 = dabs(r)**x(3)/x(1) t2 = dexp(-t1) t = t2 - arg f = f + t**2 240 continue go to 390 c c trigonometric function. c 250 continue s1 = zero do 260 j = 1, n s1 = s1 + dcos(x(j)) 260 continue f = zero do 270 j = 1, n t = dfloat(n+j) - dsin(x(j)) - s1 - dfloat(j)*dcos(x(j)) f = f + t**2 270 continue go to 390 c c extended rosenbrock function. c 280 continue f = zero do 290 j = 1, n, 2 t1 = one - x(j) t2 = ten*(x(j+1) - x(j)**2) f = f + t1**2 + t2**2 290 continue go to 390 c c extended powell function. c 300 continue f = zero do 310 j = 1, n, 4 t = x(j) + ten*x(j+1) t1 = x(j+2) - x(j+3) s1 = five*t1 t2 = x(j+1) - two*x(j+2) s2 = t2**3 t3 = x(j) - x(j+3) s3 = ten*t3**3 f = f + t**2 + s1*t1 + s2*t2 + s3*t3 310 continue go to 390 c c beale function. c 320 continue s1 = one - x(2) t1 = c1p5 - x(1)*s1 s2 = one - x(2)**2 t2 = c2p25 - x(1)*s2 s3 = one - x(2)**3 t3 = c2p625 - x(1)*s3 f = t1**2 + t2**2 + t3**2 go to 390 c c wood function. c 330 continue s1 = x(2) - x(1)**2 s2 = one - x(1) s3 = x(2) - one t1 = x(4) - x(3)**2 t2 = one - x(3) t3 = x(4) - one f = c100*s1**2 + s2**2 + c90*t1**2 + t2**2 + ten*(s3 + t3)**2 * + (s3 - t3)**2/ten go to 390 c c chebyquad function. c 340 continue do 350 i = 1, n fvec(i) = zero 350 continue do 370 j = 1, n t1 = one t2 = two*x(j) - one t = two*t2 do 360 i = 1, n fvec(i) = fvec(i) + t2 th = t*t2 - t1 t1 = t2 t2 = th 360 continue 370 continue f = zero d1 = one/dfloat(n) iev = -1 do 380 i = 1, n t = d1*fvec(i) if (iev .gt. 0) t = t + one/(dfloat(i)**2 - one) f = f + t**2 iev = -iev 380 continue 390 continue return c c last card of subroutine objfcn. c end cminpack-1.3.4/examples/ocpipt.f000644 000765 000765 00000010772 12225167750 016555 0ustar00devernay000000 000000 subroutine initpt(n,x,nprob,factor) integer n,nprob double precision factor double precision x(n) c ********** c c subroutine initpt c c this subroutine specifies the standard starting points for the c functions defined by subroutine objfcn. the subroutine returns c in x a multiple (factor) of the standard starting point. for c the seventh function the standard starting point is zero, so in c this case, if factor is not unity, then the subroutine returns c the vector x(j) = factor, j=1,...,n. c c the subroutine statement is c c subroutine initpt(n,x,nprob,factor) c c where c c n is a positive integer input variable. c c x is an output array of length n which contains the standard c starting point for problem nprob multiplied by factor. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c factor is an input variable which specifies the multiple of c the standard starting point. if factor is unity, no c multiplication is performed. c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer ivar,j double precision c1,c2,c3,c4,five,h,half,one,ten,three,twenty, * twntf,two,zero double precision dfloat data zero,half,one,two,three,five,ten,twenty,twntf * /0.0d0,0.5d0,1.0d0,2.0d0,3.0d0,5.0d0,1.0d1,2.0d1,2.5d1/ data c1,c2,c3,c4 /4.0d-1,2.5d0,1.5d-1,1.2d0/ dfloat(ivar) = ivar c c selection of initial point. c go to (10,20,30,40,50,60,80,100,120,140,150,160,170,190,210,230, * 240,250), nprob c c helical valley function. c 10 continue x(1) = -one x(2) = zero x(3) = zero go to 270 c c biggs exp6 function. c 20 continue x(1) = one x(2) = two x(3) = one x(4) = one x(5) = one x(6) = one go to 270 c c gaussian function. c 30 continue x(1) = c1 x(2) = one x(3) = zero go to 270 c c powell badly scaled function. c 40 continue x(1) = zero x(2) = one go to 270 c c box 3-dimensional function. c 50 continue x(1) = zero x(2) = ten x(3) = twenty go to 270 c c variably dimensioned function. c 60 continue h = one/dfloat(n) do 70 j = 1, n x(j) = one - dfloat(j)*h 70 continue go to 270 c c watson function. c 80 continue do 90 j = 1, n x(j) = zero 90 continue go to 270 c c penalty function i. c 100 continue do 110 j = 1, n x(j) = dfloat(j) 110 continue go to 270 c c penalty function ii. c 120 continue do 130 j = 1, n x(j) = half 130 continue go to 270 c c brown badly scaled function. c 140 continue x(1) = one x(2) = one go to 270 c c brown and dennis function. c 150 continue x(1) = twntf x(2) = five x(3) = -five x(4) = -one go to 270 c c gulf research and development function. c 160 continue x(1) = five x(2) = c2 x(3) = c3 go to 270 c c trigonometric function. c 170 continue h = one/dfloat(n) do 180 j = 1, n x(j) = h 180 continue go to 270 c c extended rosenbrock function. c 190 continue do 200 j = 1, n, 2 x(j) = -c4 x(j+1) = one 200 continue go to 270 c c extended powell singular function. c 210 continue do 220 j = 1, n, 4 x(j) = three x(j+1) = -one x(j+2) = zero x(j+3) = one 220 continue go to 270 c c beale function. c 230 continue x(1) = one x(2) = one go to 270 c c wood function. c 240 continue x(1) = -three x(2) = -one x(3) = -three x(4) = -one go to 270 c c chebyquad function. c 250 continue h = one/dfloat(n+1) do 260 j = 1, n x(j) = dfloat(j)*h 260 continue 270 continue c c compute multiple of initial point. c if (factor .eq. one) go to 320 if (nprob .eq. 7) go to 290 do 280 j = 1, n x(j) = factor*x(j) 280 continue go to 310 290 continue do 300 j = 1, n x(j) = factor 300 continue 310 continue 320 continue return c c last card of subroutine initpt. c end cminpack-1.3.4/examples/ref/000755 000765 000765 00000000000 12305351633 015647 5ustar00devernay000000 000000 cminpack-1.3.4/examples/runtest.cmake000644 000765 000765 00000002464 12225167750 017615 0ustar00devernay000000 000000 # Replace INTDIR with the value of $ENV{CMAKE_CONFIG_TYPE} that is set # by ctest when -C Debug|Releaes|etc is given, and INDIR is passed # in from the main cmake run and is the variable that is used # by the build system to specify the build directory if(NOT "${INTDIR}" STREQUAL ".") set(TEST_ORIG "${TEST}") string(REPLACE "${INTDIR}" "$ENV{CMAKE_CONFIG_TYPE}" TEST "${TEST}") if("$ENV{CMAKE_CONFIG_TYPE}" STREQUAL "") if(NOT EXISTS "${TEST}") message("Warning: CMAKE_CONFIG_TYPE not defined did you forget the -C option for ctest?") message(FATAL_ERROR "Could not find test executable: ${TEST_ORIG}") endif() endif() endif() set(ARGS ) set(ARGS OUTPUT_FILE "${OUTPUT}" ERROR_FILE "${OUTPUT}.err") message("Running: ${TEST}") message("ARGS= ${ARGS}") execute_process(COMMAND "${TEST}" ${ARGS} RESULT_VARIABLE RET) # if the test does not return 0, then fail it if(NOT ${RET} EQUAL 0) message(FATAL_ERROR "Test ${TEST} returned ${RET}") endif() # result with reference execute_process(COMMAND "${CMAKE_COMMAND}" -E compare_files "${OUTPUT}" "${REFERENCE}" RESULT_VARIABLE RET) # if the test does not return 0, then fail it if(NOT ${RET} EQUAL 0) message(FATAL_ERROR "Test ${TEST} produced a result which is different from the reference}") endif() message( "Test ${TEST} returned ${RET}") cminpack-1.3.4/examples/ssq.h000644 000765 000765 00000000725 12225167750 016064 0ustar00devernay000000 000000 #ifndef __CMINPACK_SSQ_H__ #define __CMINPACK_SSQ_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ void lmdipt(int n, __cminpack_real__ *x, int nprob, __cminpack_real__ factor); void ssqfcn(int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int nprob); void ssqjac(int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __CMINPACK_SSQ_H__ */ cminpack-1.3.4/examples/ssqfcn.c000644 000765 000765 00000024163 12225167750 016550 0ustar00devernay000000 000000 #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ void ssqfcn(int m, int n, const real *x, real *fvec, int nprob) { /* Initialized data */ const real v[11] = { 4.,2.,1.,.5,.25,.167,.125,.1,.0833,.0714, .0625 }; const real y1[15] = { .14,.18,.22,.25,.29,.32,.35,.39,.37,.58,.73, .96,1.34,2.1,4.39 }; const real y2[11] = { .1957,.1947,.1735,.16,.0844,.0627,.0456, .0342,.0323,.0235,.0246 }; const real y3[16] = { 34780.,28610.,23650.,19630.,16370.,13720., 11540.,9744.,8261.,7030.,6005.,5147.,4427.,3820.,3307.,2872. }; const real y4[33] = { .844,.908,.932,.936,.925,.908,.881,.85,.818, .784,.751,.718,.685,.658,.628,.603,.58,.558,.538,.522,.506,.49, .478,.467,.457,.448,.438,.431,.424,.42,.414,.411,.406 }; const real y5[65] = { 1.366,1.191,1.112,1.013,.991,.885,.831,.847, .786,.725,.746,.679,.608,.655,.616,.606,.602,.626,.651,.724,.649, .649,.694,.644,.624,.661,.612,.558,.533,.495,.5,.423,.395,.375, .372,.391,.396,.405,.428,.429,.523,.562,.607,.653,.672,.708,.633, .668,.645,.632,.591,.559,.597,.625,.739,.71,.729,.72,.636,.581, .428,.292,.162,.098,.054 }; /* System generated locals */ real d__1; /* Local variables */ static int i, j; static real s1, s2, dx, ti; static int nm1; static real div; static int iev; static real tpi, sum, tmp1, tmp2, tmp3, tmp4, prod, temp; /* ********** */ /* subroutine ssqfcn */ /* this subroutine defines the functions of eighteen nonlinear */ /* least squares problems. the allowable values of (m,n) for */ /* functions 1,2 and 3 are variable but with m .ge. n. */ /* for functions 4,5,6,7,8,9 and 10 the values of (m,n) are */ /* (2,2),(3,3),(4,4),(2,2),(15,3),(11,4) and (16,3), respectively. */ /* function 11 (watson) has m = 31 with n usually 6 or 9. */ /* however, any n, n = 2,...,31, is permitted. */ /* functions 12,13 and 14 have n = 3,2 and 4, respectively, but */ /* allow any m .ge. n, with the usual choices being 10,10 and 20. */ /* function 15 (chebyquad) allows m and n variable with m .ge. n. */ /* function 16 (brown) allows n variable with m = n. */ /* for functions 17 and 18, the values of (m,n) are */ /* (33,5) and (65,11), respectively. */ /* the subroutine statement is */ /* subroutine ssqfcn(m,n,x,fvec,nprob) */ /* where */ /* m and n are positive integer input variables. n must not */ /* exceed m. */ /* x is an input array of length n. */ /* fvec is an output array of length m which contains the nprob */ /* function evaluated at x. */ /* nprob is a positive integer input variable which defines the */ /* number of the problem. nprob must not exceed 18. */ /* subprograms called */ /* fortran-supplied ... datan,dcos,dexp,dsin,dsqrt,dsign */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; /* Function Body */ /* function routine selector. */ switch (nprob) { /* linear function - full rank. */ case 1: sum = 0.; for (j = 1; j <= n; ++j) { sum += x[j]; } temp = 2. * sum / (real) (m) + 1.; for (i = 1; i <= m; ++i) { fvec[i] = -temp; if (i <= n) { fvec[i] += x[i]; } } break; /* linear function - rank 1. */ case 2: sum = 0.; for (j = 1; j <= n; ++j) { sum += (real) j * x[j]; } for (i = 1; i <= m; ++i) { fvec[i] = (real) i * sum - 1.; } break; /* linear function - rank 1 with zero columns and rows. */ case 3: sum = 0.; nm1 = n - 1; if (nm1 >= 2) { for (j = 2; j <= nm1; ++j) { sum += (real) j * x[j]; } } for (i = 1; i <= m; ++i) { fvec[i] = (real) (i - 1) * sum - 1.; } fvec[m] = -1.; break; /* rosenbrock function. */ case 4: fvec[1] = 10. * (x[2] - x[1] * x[1]); fvec[2] = 1. - x[1]; break; /* helical valley function. */ case 5: tpi = 8. * atan(1.); tmp1 = x[2] < 0. ? -.25 : .25; if (x[1] > 0.) { tmp1 = atan(x[2] / x[1]) / tpi; } if (x[1] < 0.) { tmp1 = atan(x[2] / x[1]) / tpi + .5; } tmp2 = sqrt(x[1] * x[1] + x[2] * x[2]); fvec[1] = 10. * (x[3] - 10. * tmp1); fvec[2] = 10. * (tmp2 - 1.); fvec[3] = x[3]; break; /* powell singular function. */ case 6: fvec[1] = x[1] + 10. * x[2]; fvec[2] = sqrt(5.) * (x[3] - x[4]); /* Computing 2nd power */ d__1 = x[2] - 2. * x[3]; fvec[3] = d__1 * d__1; /* Computing 2nd power */ d__1 = x[1] - x[4]; fvec[4] = sqrt(10.) * (d__1 * d__1); break; /* freudenstein and roth function. */ case 7: fvec[1] = -13. + x[1] + ((5. - x[2]) * x[2] - 2.) * x[2]; fvec[2] = -29. + x[1] + ((1. + x[2]) * x[2] - 14.) * x[2]; break; /* bard function. */ case 8: for (i = 1; i <= 15; ++i) { tmp1 = (real) i; tmp2 = (real) (16 - i); tmp3 = tmp1; if (i > 8) { tmp3 = tmp2; } fvec[i] = y1[i - 1] - (x[1] + tmp1 / (x[2] * tmp2 + x[3] * tmp3)); } break; /* kowalik and osborne function. */ case 9: for (i = 1; i <= 11; ++i) { tmp1 = v[i - 1] * (v[i - 1] + x[2]); tmp2 = v[i - 1] * (v[i - 1] + x[3]) + x[4]; fvec[i] = y2[i - 1] - x[1] * tmp1 / tmp2; } break; /* meyer function. */ case 10: for (i = 1; i <= 16; ++i) { temp = 5. * (real) i + 45. + x[3]; tmp1 = x[2] / temp; tmp2 = exp(tmp1); fvec[i] = x[1] * tmp2 - y3[i - 1]; } break; /* watson function. */ case 11: for (i = 1; i <= 29; ++i) { div = (real) i / 29.; s1 = 0.; dx = 1.; for (j = 2; j <= n; ++j) { s1 += (real) (j - 1) * dx * x[j]; dx = div * dx; } s2 = 0.; dx = 1.; for (j = 1; j <= n; ++j) { s2 += dx * x[j]; dx = div * dx; } fvec[i] = s1 - s2 * s2 - 1.; } fvec[30] = x[1]; fvec[31] = x[2] - x[1] * x[1] - 1.; break; /* box 3-dimensional function. */ case 12: for (i = 1; i <= m; ++i) { temp = (real) i; tmp1 = temp / 10.; fvec[i] = exp(-tmp1 * x[1]) - exp(-tmp1 * x[2]) + (exp(-temp) - exp(-tmp1)) * x[3]; } break; /* jennrich and sampson function. */ case 13: for (i = 1; i <= m; ++i) { temp = (real) i; fvec[i] = 2. + 2. * temp - exp(temp * x[1]) - exp(temp * x[2]); } break; /* brown and dennis function. */ case 14: for (i = 1; i <= m; ++i) { temp = (real) i / 5.; tmp1 = x[1] + temp * x[2] - exp(temp); tmp2 = x[3] + sin(temp) * x[4] - cos(temp); fvec[i] = tmp1 * tmp1 + tmp2 * tmp2; } break; /* chebyquad function. */ case 15: for (i = 1; i <= m; ++i) { fvec[i] = 0.; } for (j = 1; j <= n; ++j) { tmp1 = 1.; tmp2 = 2. * x[j] - 1.; temp = 2. * tmp2; for (i = 1; i <= m; ++i) { fvec[i] += tmp2; ti = temp * tmp2 - tmp1; tmp1 = tmp2; tmp2 = ti; } } dx = 1. / (real) (n); iev = -1; for (i = 1; i <= m; ++i) { fvec[i] = dx * fvec[i]; if (iev > 0) { fvec[i] += 1. / (i * i - 1.); } iev = -iev; } break; /* brown almost-linear function. */ case 16: sum = -((real) (n + 1)); prod = 1.; for (j = 1; j <= n; ++j) { sum += x[j]; prod = x[j] * prod; } for (i = 1; i <= n; ++i) { fvec[i] = x[i] + sum; } fvec[n] = prod - 1.; break; /* osborne 1 function. */ case 17: for (i = 1; i <= 33; ++i) { temp = 10. * (real) (i - 1); tmp1 = exp(-x[4] * temp); tmp2 = exp(-x[5] * temp); fvec[i] = y4[i - 1] - (x[1] + x[2] * tmp1 + x[3] * tmp2); } break; /* osborne 2 function. */ case 18: for (i = 1; i <= 65; ++i) { temp = (real) (i - 1) / 10.; tmp1 = exp(-x[5] * temp); /* Computing 2nd power */ d__1 = temp - x[9]; tmp2 = exp(-x[6] * (d__1 * d__1)); /* Computing 2nd power */ d__1 = temp - x[10]; tmp3 = exp(-x[7] * (d__1 * d__1)); /* Computing 2nd power */ d__1 = temp - x[11]; tmp4 = exp(-x[8] * (d__1 * d__1)); fvec[i] = y5[i - 1] - (x[1] * tmp1 + x[2] * tmp2 + x[3] * tmp3 + x[4] * tmp4); } break; } /* last card of subroutine ssqfcn. */ } /* ssqfcn_ */ cminpack-1.3.4/examples/ssqfcn.f000644 000765 000765 00000024223 12225167750 016550 0ustar00devernay000000 000000 subroutine ssqfcn(m,n,x,fvec,nprob) integer m,n,nprob double precision x(n),fvec(m) c ********** c c subroutine ssqfcn c c this subroutine defines the functions of eighteen nonlinear c least squares problems. the allowable values of (m,n) for c functions 1,2 and 3 are variable but with m .ge. n. c for functions 4,5,6,7,8,9 and 10 the values of (m,n) are c (2,2),(3,3),(4,4),(2,2),(15,3),(11,4) and (16,3), respectively. c function 11 (watson) has m = 31 with n usually 6 or 9. c however, any n, n = 2,...,31, is permitted. c functions 12,13 and 14 have n = 3,2 and 4, respectively, but c allow any m .ge. n, with the usual choices being 10,10 and 20. c function 15 (chebyquad) allows m and n variable with m .ge. n. c function 16 (brown) allows n variable with m = n. c for functions 17 and 18, the values of (m,n) are c (33,5) and (65,11), respectively. c c the subroutine statement is c c subroutine ssqfcn(m,n,x,fvec,nprob) c c where c c m and n are positive integer input variables. n must not c exceed m. c c x is an input array of length n. c c fvec is an output array of length m which contains the nprob c function evaluated at x. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... datan,dcos,dexp,dsin,dsqrt,dsign c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j,nm1 double precision c13,c14,c29,c45,div,dx,eight,five,one,prod,sum, * s1,s2,temp,ten,ti,tmp1,tmp2,tmp3,tmp4,tpi,two, * zero,zp25,zp5 double precision v(11),y1(15),y2(11),y3(16),y4(33),y5(65) double precision dfloat data zero,zp25,zp5,one,two,five,eight,ten,c13,c14,c29,c45 * /0.0d0,2.5d-1,5.0d-1,1.0d0,2.0d0,5.0d0,8.0d0,1.0d1,1.3d1, * 1.4d1,2.9d1,4.5d1/ data v(1),v(2),v(3),v(4),v(5),v(6),v(7),v(8),v(9),v(10),v(11) * /4.0d0,2.0d0,1.0d0,5.0d-1,2.5d-1,1.67d-1,1.25d-1,1.0d-1, * 8.33d-2,7.14d-2,6.25d-2/ data y1(1),y1(2),y1(3),y1(4),y1(5),y1(6),y1(7),y1(8),y1(9), * y1(10),y1(11),y1(12),y1(13),y1(14),y1(15) * /1.4d-1,1.8d-1,2.2d-1,2.5d-1,2.9d-1,3.2d-1,3.5d-1,3.9d-1, * 3.7d-1,5.8d-1,7.3d-1,9.6d-1,1.34d0,2.1d0,4.39d0/ data y2(1),y2(2),y2(3),y2(4),y2(5),y2(6),y2(7),y2(8),y2(9), * y2(10),y2(11) * /1.957d-1,1.947d-1,1.735d-1,1.6d-1,8.44d-2,6.27d-2,4.56d-2, * 3.42d-2,3.23d-2,2.35d-2,2.46d-2/ data y3(1),y3(2),y3(3),y3(4),y3(5),y3(6),y3(7),y3(8),y3(9), * y3(10),y3(11),y3(12),y3(13),y3(14),y3(15),y3(16) * /3.478d4,2.861d4,2.365d4,1.963d4,1.637d4,1.372d4,1.154d4, * 9.744d3,8.261d3,7.03d3,6.005d3,5.147d3,4.427d3,3.82d3, * 3.307d3,2.872d3/ data y4(1),y4(2),y4(3),y4(4),y4(5),y4(6),y4(7),y4(8),y4(9), * y4(10),y4(11),y4(12),y4(13),y4(14),y4(15),y4(16),y4(17), * y4(18),y4(19),y4(20),y4(21),y4(22),y4(23),y4(24),y4(25), * y4(26),y4(27),y4(28),y4(29),y4(30),y4(31),y4(32),y4(33) * /8.44d-1,9.08d-1,9.32d-1,9.36d-1,9.25d-1,9.08d-1,8.81d-1, * 8.5d-1,8.18d-1,7.84d-1,7.51d-1,7.18d-1,6.85d-1,6.58d-1, * 6.28d-1,6.03d-1,5.8d-1,5.58d-1,5.38d-1,5.22d-1,5.06d-1, * 4.9d-1,4.78d-1,4.67d-1,4.57d-1,4.48d-1,4.38d-1,4.31d-1, * 4.24d-1,4.2d-1,4.14d-1,4.11d-1,4.06d-1/ data y5(1),y5(2),y5(3),y5(4),y5(5),y5(6),y5(7),y5(8),y5(9), * y5(10),y5(11),y5(12),y5(13),y5(14),y5(15),y5(16),y5(17), * y5(18),y5(19),y5(20),y5(21),y5(22),y5(23),y5(24),y5(25), * y5(26),y5(27),y5(28),y5(29),y5(30),y5(31),y5(32),y5(33), * y5(34),y5(35),y5(36),y5(37),y5(38),y5(39),y5(40),y5(41), * y5(42),y5(43),y5(44),y5(45),y5(46),y5(47),y5(48),y5(49), * y5(50),y5(51),y5(52),y5(53),y5(54),y5(55),y5(56),y5(57), * y5(58),y5(59),y5(60),y5(61),y5(62),y5(63),y5(64),y5(65) * /1.366d0,1.191d0,1.112d0,1.013d0,9.91d-1,8.85d-1,8.31d-1, * 8.47d-1,7.86d-1,7.25d-1,7.46d-1,6.79d-1,6.08d-1,6.55d-1, * 6.16d-1,6.06d-1,6.02d-1,6.26d-1,6.51d-1,7.24d-1,6.49d-1, * 6.49d-1,6.94d-1,6.44d-1,6.24d-1,6.61d-1,6.12d-1,5.58d-1, * 5.33d-1,4.95d-1,5.0d-1,4.23d-1,3.95d-1,3.75d-1,3.72d-1, * 3.91d-1,3.96d-1,4.05d-1,4.28d-1,4.29d-1,5.23d-1,5.62d-1, * 6.07d-1,6.53d-1,6.72d-1,7.08d-1,6.33d-1,6.68d-1,6.45d-1, * 6.32d-1,5.91d-1,5.59d-1,5.97d-1,6.25d-1,7.39d-1,7.1d-1, * 7.29d-1,7.2d-1,6.36d-1,5.81d-1,4.28d-1,2.92d-1,1.62d-1, * 9.8d-2,5.4d-2/ dfloat(ivar) = ivar c c function routine selector. c go to (10,40,70,110,120,130,140,150,170,190,210,250,270,290,310, * 360,390,410), nprob c c linear function - full rank. c 10 continue sum = zero do 20 j = 1, n sum = sum + x(j) 20 continue temp = two*sum/dfloat(m) + one do 30 i = 1, m fvec(i) = -temp if (i .le. n) fvec(i) = fvec(i) + x(i) 30 continue go to 430 c c linear function - rank 1. c 40 continue sum = zero do 50 j = 1, n sum = sum + dfloat(j)*x(j) 50 continue do 60 i = 1, m fvec(i) = dfloat(i)*sum - one 60 continue go to 430 c c linear function - rank 1 with zero columns and rows. c 70 continue sum = zero nm1 = n - 1 if (nm1 .lt. 2) go to 90 do 80 j = 2, nm1 sum = sum + dfloat(j)*x(j) 80 continue 90 continue do 100 i = 1, m fvec(i) = dfloat(i-1)*sum - one 100 continue fvec(m) = -one go to 430 c c rosenbrock function. c 110 continue fvec(1) = ten*(x(2) - x(1)**2) fvec(2) = one - x(1) go to 430 c c helical valley function. c 120 continue tpi = eight*datan(one) tmp1 = dsign(zp25,x(2)) if (x(1) .gt. zero) tmp1 = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) tmp1 = datan(x(2)/x(1))/tpi + zp5 tmp2 = dsqrt(x(1)**2+x(2)**2) fvec(1) = ten*(x(3) - ten*tmp1) fvec(2) = ten*(tmp2 - one) fvec(3) = x(3) go to 430 c c powell singular function. c 130 continue fvec(1) = x(1) + ten*x(2) fvec(2) = dsqrt(five)*(x(3) - x(4)) fvec(3) = (x(2) - two*x(3))**2 fvec(4) = dsqrt(ten)*(x(1) - x(4))**2 go to 430 c c freudenstein and roth function. c 140 continue fvec(1) = -c13 + x(1) + ((five - x(2))*x(2) - two)*x(2) fvec(2) = -c29 + x(1) + ((one + x(2))*x(2) - c14)*x(2) go to 430 c c bard function. c 150 continue do 160 i = 1, 15 tmp1 = dfloat(i) tmp2 = dfloat(16-i) tmp3 = tmp1 if (i .gt. 8) tmp3 = tmp2 fvec(i) = y1(i) - (x(1) + tmp1/(x(2)*tmp2 + x(3)*tmp3)) 160 continue go to 430 c c kowalik and osborne function. c 170 continue do 180 i = 1, 11 tmp1 = v(i)*(v(i) + x(2)) tmp2 = v(i)*(v(i) + x(3)) + x(4) fvec(i) = y2(i) - x(1)*tmp1/tmp2 180 continue go to 430 c c meyer function. c 190 continue do 200 i = 1, 16 temp = five*dfloat(i) + c45 + x(3) tmp1 = x(2)/temp tmp2 = dexp(tmp1) fvec(i) = x(1)*tmp2 - y3(i) 200 continue go to 430 c c watson function. c 210 continue do 240 i = 1, 29 div = dfloat(i)/c29 s1 = zero dx = one do 220 j = 2, n s1 = s1 + dfloat(j-1)*dx*x(j) dx = div*dx 220 continue s2 = zero dx = one do 230 j = 1, n s2 = s2 + dx*x(j) dx = div*dx 230 continue fvec(i) = s1 - s2**2 - one 240 continue fvec(30) = x(1) fvec(31) = x(2) - x(1)**2 - one go to 430 c c box 3-dimensional function. c 250 continue do 260 i = 1, m temp = dfloat(i) tmp1 = temp/ten fvec(i) = dexp(-tmp1*x(1)) - dexp(-tmp1*x(2)) * + (dexp(-temp) - dexp(-tmp1))*x(3) 260 continue go to 430 c c jennrich and sampson function. c 270 continue do 280 i = 1, m temp = dfloat(i) fvec(i) = two + two*temp - dexp(temp*x(1)) - dexp(temp*x(2)) 280 continue go to 430 c c brown and dennis function. c 290 continue do 300 i = 1, m temp = dfloat(i)/five tmp1 = x(1) + temp*x(2) - dexp(temp) tmp2 = x(3) + dsin(temp)*x(4) - dcos(temp) fvec(i) = tmp1**2 + tmp2**2 300 continue go to 430 c c chebyquad function. c 310 continue do 320 i = 1, m fvec(i) = zero 320 continue do 340 j = 1, n tmp1 = one tmp2 = two*x(j) - one temp = two*tmp2 do 330 i = 1, m fvec(i) = fvec(i) + tmp2 ti = temp*tmp2 - tmp1 tmp1 = tmp2 tmp2 = ti 330 continue 340 continue dx = one/dfloat(n) iev = -1 do 350 i = 1, m fvec(i) = dx*fvec(i) if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one) iev = -iev 350 continue go to 430 c c brown almost-linear function. c 360 continue sum = -dfloat(n+1) prod = one do 370 j = 1, n sum = sum + x(j) prod = x(j)*prod 370 continue do 380 i = 1, n fvec(i) = x(i) + sum 380 continue fvec(n) = prod - one go to 430 c c osborne 1 function. c 390 continue do 400 i = 1, 33 temp = ten*dfloat(i-1) tmp1 = dexp(-x(4)*temp) tmp2 = dexp(-x(5)*temp) fvec(i) = y4(i) - (x(1) + x(2)*tmp1 + x(3)*tmp2) 400 continue go to 430 c c osborne 2 function. c 410 continue do 420 i = 1, 65 temp = dfloat(i-1)/ten tmp1 = dexp(-x(5)*temp) tmp2 = dexp(-x(6)*(temp-x(9))**2) tmp3 = dexp(-x(7)*(temp-x(10))**2) tmp4 = dexp(-x(8)*(temp-x(11))**2) fvec(i) = y5(i) * - (x(1)*tmp1 + x(2)*tmp2 + x(3)*tmp3 + x(4)*tmp4) 420 continue 430 continue return c c last card of subroutine ssqfcn. c end cminpack-1.3.4/examples/ssqjac.c000644 000765 000765 00000027505 12225167750 016542 0ustar00devernay000000 000000 #include #include "cminpack.h" #include "ssq.h" #define real __cminpack_real__ void ssqjac(int m, int n, const real *x, real *fjac, int ldfjac, int nprob) { /* Initialized data */ const real v[11] = { 4.,2.,1.,.5,.25,.167,.125,.1,.0833,.0714, .0625 }; /* System generated locals */ real d__1; /* Local variables */ int i, j, k; real s2, dx, ti; int mm1, nm1; real div, tpi, tmp1, tmp2, tmp3, tmp4, prod, temp; /* ********** */ /* subroutine ssqjac */ /* this subroutine defines the jacobian matrices of eighteen */ /* nonlinear least squares problems. the problem dimensions are */ /* as described in the prologue comments of ssqfcn. */ /* the subroutine statement is */ /* subroutine ssqjac(m,n,x,fjac,ldfjac,nprob) */ /* where */ /* m and n are positive int input variables. n must not */ /* exceed m. */ /* x is an input array of length n. */ /* fjac is an m by n output array which contains the jacobian */ /* matrix of the nprob function evaluated at x. */ /* ldfjac is a positive int input variable not less than m */ /* which specifies the leading dimension of the array fjac. */ /* nprob is a positive int variable which defines the */ /* number of the problem. nprob must not exceed 18. */ /* subprograms called */ /* fortran-supplied ... datan,dcos,dexp,dsin,dsqrt */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; fjac -= 1 + ldfjac; /* Function Body */ /* jacobian routine selector. */ switch (nprob) { /* linear function - full rank. */ case 1: temp = 2. / (real) m; for (j = 1; j <= n; ++j) { for (i = 1; i <= m; ++i) { fjac[i + j * ldfjac] = -temp; } fjac[j + j * ldfjac] += 1.; } break; /* linear function - rank 1. */ case 2: for (j = 1; j <= n; ++j) { for (i = 1; i <= m; ++i) { fjac[i + j * ldfjac] = (real) i * (real) j; } } break; /* linear function - rank 1 with zero columns and rows. */ case 3: for (j = 1; j <= n; ++j) { for (i = 1; i <= m; ++i) { fjac[i + j * ldfjac] = 0.; } } #if 0 if (nm1 < 2) { goto L120; } for (j = 2; j <= nm1; ++j) { i__2 = mm1; for (i__ = 2; i__ <= mm1; ++i__) { i__3 = i__ - 1; fjac[i__ + j * fjac_dim1] = (doublereal) i__3 * (doublereal) j; /* L100: */ } /* L110: */ } L120: #else nm1 = n - 1; mm1 = m - 1; if (nm1 >= 2) { for (j = 2; j <= nm1; ++j) { for (i = 2; i <= mm1; ++i) { fjac[i + j * ldfjac] = (real) (i - 1) * (real) j; } } } #endif break; /* rosenbrock function. */ case 4: fjac[1 + 1 * ldfjac] = -20. * x[1]; fjac[1 + 2 * ldfjac] = 10.; fjac[2 + 1 * ldfjac] = -1.; fjac[2 + 2 * ldfjac] = 0.; break; /* helical valley function. */ case 5: tpi = 8. * atan(1.); temp = x[1] * x[1] + x[2] * x[2]; tmp1 = tpi * temp; tmp2 = sqrt(temp); fjac[1 + 1 * ldfjac] = 100. * x[2] / tmp1; fjac[1 + 2 * ldfjac] = -100. * x[1] / tmp1; fjac[1 + 3 * ldfjac] = 10.; fjac[2 + 1 * ldfjac] = 10. * x[1] / tmp2; fjac[2 + 2 * ldfjac] = 10. * x[2] / tmp2; fjac[2 + 3 * ldfjac] = 0.; fjac[3 + 1 * ldfjac] = 0.; fjac[3 + 2 * ldfjac] = 0.; fjac[3 + 3 * ldfjac] = 1.; break; /* powell singular function. */ case 6: for (j = 1; j <= 4; ++j) { for (i = 1; i <= 4; ++i) { fjac[i + j * ldfjac] = 0.; } } fjac[1 + 1 * ldfjac] = 1.; fjac[1 + 2 * ldfjac] = 10.; fjac[2 + 3 * ldfjac] = sqrt(5.); fjac[2 + 4 * ldfjac] = -fjac[2 + 3 * ldfjac]; fjac[3 + 2 * ldfjac] = 2. * (x[2] - 2. * x[3]); fjac[3 + 3 * ldfjac] = -2. * fjac[3 + 2 * ldfjac]; fjac[4 + 1 * ldfjac] = 2. * sqrt(10.) * (x[1] - x[4]); fjac[4 + 4 * ldfjac] = -fjac[4 + 1 * ldfjac]; break; /* freudenstein and roth function. */ case 7: fjac[1 + 1 * ldfjac] = 1.; fjac[1 + 2 * ldfjac] = x[2] * (10. - 3. * x[2]) - 2.; fjac[2 + 1 * ldfjac] = 1.; fjac[2 + 2 * ldfjac] = x[2] * (2. + 3. * x[2]) - 14.; break; /* bard function. */ case 8: for (i = 1; i <= 15; ++i) { tmp1 = (real) i; tmp2 = (real) (16 - i); tmp3 = tmp1; if (i > 8) { tmp3 = tmp2; } /* Computing 2nd power */ d__1 = x[2] * tmp2 + x[3] * tmp3; tmp4 = d__1 * d__1; fjac[i + 1 * ldfjac] = -1.; fjac[i + 2 * ldfjac] = tmp1 * tmp2 / tmp4; fjac[i + 3 * ldfjac] = tmp1 * tmp3 / tmp4; } break; /* kowalik and osborne function. */ case 9: for (i = 1; i <= 11; ++i) { tmp1 = v[i - 1] * (v[i - 1] + x[2]); tmp2 = v[i - 1] * (v[i - 1] + x[3]) + x[4]; fjac[i + 1 * ldfjac] = -tmp1 / tmp2; fjac[i + 2 * ldfjac] = -v[i - 1] * x[1] / tmp2; fjac[i + 3 * ldfjac] = fjac[i + 1 * ldfjac] * fjac[i + 2 * ldfjac]; fjac[i + 4 * ldfjac] = fjac[i + 3 * ldfjac] / v[i - 1]; } break; /* meyer function. */ case 10: for (i = 1; i <= 16; ++i) { temp = 5. * (real) i + 45. + x[3]; tmp1 = x[2] / temp; tmp2 = exp(tmp1); fjac[i + 1 * ldfjac] = tmp2; fjac[i + 2 * ldfjac] = x[1] * tmp2 / temp; fjac[i + 3 * ldfjac] = -tmp1 * fjac[i + 2 * ldfjac]; } break; /* watson function. */ case 11: for (i = 1; i <= 29; ++i) { div = (real) i / 29.; s2 = 0.; dx = 1.; for (j = 1; j <= n; ++j) { s2 += dx * x[j]; dx = div * dx; } temp = 2. * div * s2; dx = 1. / div; for (j = 1; j <= n; ++j) { fjac[i + j * ldfjac] = dx * ((real) (j - 1) - temp); dx = div * dx; } } for (j = 1; j <= n; ++j) { for (i = 30; i <= 31; ++i) { fjac[i + j * ldfjac] = 0.; } } fjac[30 + 1 * ldfjac] = 1.; fjac[31 + 1 * ldfjac] = -2. * x[1]; fjac[31 + 2 * ldfjac] = 1.; break; /* box 3-dimensional function. */ case 12: for (i = 1; i <= m; ++i) { temp = (real) i; tmp1 = temp / 10.; fjac[i + 1 * ldfjac] = -tmp1 * exp(-tmp1 * x[1]); fjac[i + 2 * ldfjac] = tmp1 * exp(-tmp1 * x[2]); fjac[i + 3 * ldfjac] = exp(-temp) - exp(-tmp1); } break; /* jennrich and sampson function. */ case 13: for (i = 1; i <= m; ++i) { temp = (real) i; fjac[i + 1 * ldfjac] = -temp * exp(temp * x[1]); fjac[i + 2 * ldfjac] = -temp * exp(temp * x[2]); } break; /* brown and dennis function. */ case 14: for (i = 1; i <= m; ++i) { temp = (real) i / 5.; ti = sin(temp); tmp1 = x[1] + temp * x[2] - exp(temp); tmp2 = x[3] + ti * x[4] - cos(temp); fjac[i + 1 * ldfjac] = 2. * tmp1; fjac[i + 2 * ldfjac] = temp * fjac[i + 1 * ldfjac]; fjac[i + 3 * ldfjac] = 2. * tmp2; fjac[i + 4 * ldfjac] = ti * fjac[i + 3 * ldfjac]; } break; /* chebyquad function. */ case 15: dx = 1. / (real) (n); for (j = 1; j <= n; ++j) { tmp1 = 1.; tmp2 = 2. * x[j] - 1.; temp = 2. * tmp2; tmp3 = 0.; tmp4 = 2.; for (i = 1; i <= m; ++i) { fjac[i + j * ldfjac] = dx * tmp4; ti = 4. * tmp2 + temp * tmp4 - tmp3; tmp3 = tmp4; tmp4 = ti; ti = temp * tmp2 - tmp1; tmp1 = tmp2; tmp2 = ti; } } break; /* brown almost-linear function. */ case 16: prod = 1.; for (j = 1; j <= n; ++j) { prod = x[j] * prod; for (i = 1; i <= n; ++i) { fjac[i + j * ldfjac] = 1.; } fjac[j + j * ldfjac] = 2.; } for (j = 1; j <= n; ++j) { temp = x[j]; if (temp == 0.) { temp = 1.; prod = 1.; for (k = 1; k <= n; ++k) { if (k != j) { prod = x[k] * prod; } } } fjac[n + j * ldfjac] = prod / temp; } break; /* osborne 1 function. */ case 17: for (i = 1; i <= 33; ++i) { temp = 10. * (real) (i - 1); tmp1 = exp(-x[4] * temp); tmp2 = exp(-x[5] * temp); fjac[i + 1 * ldfjac] = -1.; fjac[i + 2 * ldfjac] = -tmp1; fjac[i + 3 * ldfjac] = -tmp2; fjac[i + 4 * ldfjac] = temp * x[2] * tmp1; fjac[i + 5 * ldfjac] = temp * x[3] * tmp2; } break; /* osborne 2 function. */ case 18: for (i = 1; i <= 65; ++i) { temp = (real) (i - 1) / 10.; tmp1 = exp(-x[5] * temp); /* Computing 2nd power */ d__1 = temp - x[9]; tmp2 = exp(-x[6] * (d__1 * d__1)); /* Computing 2nd power */ d__1 = temp - x[10]; tmp3 = exp(-x[7] * (d__1 * d__1)); /* Computing 2nd power */ d__1 = temp - x[11]; tmp4 = exp(-x[8] * (d__1 * d__1)); fjac[i + 1 * ldfjac] = -tmp1; fjac[i + 2 * ldfjac] = -tmp2; fjac[i + 3 * ldfjac] = -tmp3; fjac[i + 4 * ldfjac] = -tmp4; fjac[i + 5 * ldfjac] = temp * x[1] * tmp1; /* Computing 2nd power */ d__1 = temp - x[9]; fjac[i + 6 * ldfjac] = x[2] * (d__1 * d__1) * tmp2; /* Computing 2nd power */ d__1 = temp - x[10]; fjac[i + 7 * ldfjac] = x[3] * (d__1 * d__1) * tmp3; /* Computing 2nd power */ d__1 = temp - x[11]; fjac[i + 8 * ldfjac] = x[4] * (d__1 * d__1) * tmp4; fjac[i + 9 * ldfjac] = -2. * x[2] * x[6] * (temp - x[9]) * tmp2; fjac[i + 10 * ldfjac] = -2. * x[3] * x[7] * (temp - x[10]) * tmp3; fjac[i + 11 * ldfjac] = -2. * x[4] * x[8] * (temp - x[11]) * tmp4; } break; } /* last card of subroutine ssqjac. */ } /* ssqjac_ */ cminpack-1.3.4/examples/ssqjac.f000644 000765 000765 00000021113 12225167750 016532 0ustar00devernay000000 000000 subroutine ssqjac(m,n,x,fjac,ldfjac,nprob) integer m,n,ldfjac,nprob double precision x(n),fjac(ldfjac,n) c ********** c c subroutine ssqjac c c this subroutine defines the jacobian matrices of eighteen c nonlinear least squares problems. the problem dimensions are c as described in the prologue comments of ssqfcn. c c the subroutine statement is c c subroutine ssqjac(m,n,x,fjac,ldfjac,nprob) c c where c c m and n are positive integer input variables. n must not c exceed m. c c x is an input array of length n. c c fjac is an m by n output array which contains the jacobian c matrix of the nprob function evaluated at x. c c ldfjac is a positive integer input variable not less than m c which specifies the leading dimension of the array fjac. c c nprob is a positive integer variable which defines the c number of the problem. nprob must not exceed 18. c c subprograms called c c fortran-supplied ... datan,dcos,dexp,dsin,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ivar,j,k,mm1,nm1 double precision c14,c20,c29,c45,c100,div,dx,eight,five,four, * one,prod,s2,temp,ten,three,ti,tmp1,tmp2,tmp3, * tmp4,tpi,two,zero double precision v(11) double precision dfloat data zero,one,two,three,four,five,eight,ten,c14,c20,c29,c45,c100 * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,1.4d1, * 2.0d1,2.9d1,4.5d1,1.0d2/ data v(1),v(2),v(3),v(4),v(5),v(6),v(7),v(8),v(9),v(10),v(11) * /4.0d0,2.0d0,1.0d0,5.0d-1,2.5d-1,1.67d-1,1.25d-1,1.0d-1, * 8.33d-2,7.14d-2,6.25d-2/ dfloat(ivar) = ivar c c jacobian routine selector. c go to (10,40,70,130,140,150,180,190,210,230,250,310,330,350,370, * 400,460,480), nprob c c linear function - full rank. c 10 continue temp = two/dfloat(m) do 30 j = 1, n do 20 i = 1, m fjac(i,j) = -temp 20 continue fjac(j,j) = fjac(j,j) + one 30 continue go to 500 c c linear function - rank 1. c 40 continue do 60 j = 1, n do 50 i = 1, m fjac(i,j) = dfloat(i)*dfloat(j) 50 continue 60 continue go to 500 c c linear function - rank 1 with zero columns and rows. c 70 continue do 90 j = 1, n do 80 i = 1, m fjac(i,j) = zero 80 continue 90 continue nm1 = n - 1 mm1 = m - 1 if (nm1 .lt. 2) go to 120 do 110 j = 2, nm1 do 100 i = 2, mm1 fjac(i,j) = dfloat(i-1)*dfloat(j) 100 continue 110 continue 120 continue go to 500 c c rosenbrock function. c 130 continue fjac(1,1) = -c20*x(1) fjac(1,2) = ten fjac(2,1) = -one fjac(2,2) = zero go to 500 c c helical valley function. c 140 continue tpi = eight*datan(one) temp = x(1)**2 + x(2)**2 tmp1 = tpi*temp tmp2 = dsqrt(temp) fjac(1,1) = c100*x(2)/tmp1 fjac(1,2) = -c100*x(1)/tmp1 fjac(1,3) = ten fjac(2,1) = ten*x(1)/tmp2 fjac(2,2) = ten*x(2)/tmp2 fjac(2,3) = zero fjac(3,1) = zero fjac(3,2) = zero fjac(3,3) = one go to 500 c c powell singular function. c 150 continue do 170 j = 1, 4 do 160 i = 1, 4 fjac(i,j) = zero 160 continue 170 continue fjac(1,1) = one fjac(1,2) = ten fjac(2,3) = dsqrt(five) fjac(2,4) = -fjac(2,3) fjac(3,2) = two*(x(2) - two*x(3)) fjac(3,3) = -two*fjac(3,2) fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4)) fjac(4,4) = -fjac(4,1) go to 500 c c freudenstein and roth function. c 180 continue fjac(1,1) = one fjac(1,2) = x(2)*(ten - three*x(2)) - two fjac(2,1) = one fjac(2,2) = x(2)*(two + three*x(2)) - c14 go to 500 c c bard function. c 190 continue do 200 i = 1, 15 tmp1 = dfloat(i) tmp2 = dfloat(16-i) tmp3 = tmp1 if (i .gt. 8) tmp3 = tmp2 tmp4 = (x(2)*tmp2 + x(3)*tmp3)**2 fjac(i,1) = -one fjac(i,2) = tmp1*tmp2/tmp4 fjac(i,3) = tmp1*tmp3/tmp4 200 continue go to 500 c c kowalik and osborne function. c 210 continue do 220 i = 1, 11 tmp1 = v(i)*(v(i) + x(2)) tmp2 = v(i)*(v(i) + x(3)) + x(4) fjac(i,1) = -tmp1/tmp2 fjac(i,2) = -v(i)*x(1)/tmp2 fjac(i,3) = fjac(i,1)*fjac(i,2) fjac(i,4) = fjac(i,3)/v(i) 220 continue go to 500 c c meyer function. c 230 continue do 240 i = 1, 16 temp = five*dfloat(i) + c45 + x(3) tmp1 = x(2)/temp tmp2 = dexp(tmp1) fjac(i,1) = tmp2 fjac(i,2) = x(1)*tmp2/temp fjac(i,3) = -tmp1*fjac(i,2) 240 continue go to 500 c c watson function. c 250 continue do 280 i = 1, 29 div = dfloat(i)/c29 s2 = zero dx = one do 260 j = 1, n s2 = s2 + dx*x(j) dx = div*dx 260 continue temp = two*div*s2 dx = one/div do 270 j = 1, n fjac(i,j) = dx*(dfloat(j-1) - temp) dx = div*dx 270 continue 280 continue do 300 j = 1, n do 290 i = 30, 31 fjac(i,j) = zero 290 continue 300 continue fjac(30,1) = one fjac(31,1) = -two*x(1) fjac(31,2) = one go to 500 c c box 3-dimensional function. c 310 continue do 320 i = 1, m temp = dfloat(i) tmp1 = temp/ten fjac(i,1) = -tmp1*dexp(-tmp1*x(1)) fjac(i,2) = tmp1*dexp(-tmp1*x(2)) fjac(i,3) = dexp(-temp) - dexp(-tmp1) 320 continue go to 500 c c jennrich and sampson function. c 330 continue do 340 i = 1, m temp = dfloat(i) fjac(i,1) = -temp*dexp(temp*x(1)) fjac(i,2) = -temp*dexp(temp*x(2)) 340 continue go to 500 c c brown and dennis function. c 350 continue do 360 i = 1, m temp = dfloat(i)/five ti = dsin(temp) tmp1 = x(1) + temp*x(2) - dexp(temp) tmp2 = x(3) + ti*x(4) - dcos(temp) fjac(i,1) = two*tmp1 fjac(i,2) = temp*fjac(i,1) fjac(i,3) = two*tmp2 fjac(i,4) = ti*fjac(i,3) 360 continue go to 500 c c chebyquad function. c 370 continue dx = one/dfloat(n) do 390 j = 1, n tmp1 = one tmp2 = two*x(j) - one temp = two*tmp2 tmp3 = zero tmp4 = two do 380 i = 1, m fjac(i,j) = dx*tmp4 ti = four*tmp2 + temp*tmp4 - tmp3 tmp3 = tmp4 tmp4 = ti ti = temp*tmp2 - tmp1 tmp1 = tmp2 tmp2 = ti 380 continue 390 continue go to 500 c c brown almost-linear function. c 400 continue prod = one do 420 j = 1, n prod = x(j)*prod do 410 i = 1, n fjac(i,j) = one 410 continue fjac(j,j) = two 420 continue do 450 j = 1, n temp = x(j) if (temp .ne. zero) go to 440 temp = one prod = one do 430 k = 1, n if (k .ne. j) prod = x(k)*prod 430 continue 440 continue fjac(n,j) = prod/temp 450 continue go to 500 c c osborne 1 function. c 460 continue do 470 i = 1, 33 temp = ten*dfloat(i-1) tmp1 = dexp(-x(4)*temp) tmp2 = dexp(-x(5)*temp) fjac(i,1) = -one fjac(i,2) = -tmp1 fjac(i,3) = -tmp2 fjac(i,4) = temp*x(2)*tmp1 fjac(i,5) = temp*x(3)*tmp2 470 continue go to 500 c c osborne 2 function. c 480 continue do 490 i = 1, 65 temp = dfloat(i-1)/ten tmp1 = dexp(-x(5)*temp) tmp2 = dexp(-x(6)*(temp-x(9))**2) tmp3 = dexp(-x(7)*(temp-x(10))**2) tmp4 = dexp(-x(8)*(temp-x(11))**2) fjac(i,1) = -tmp1 fjac(i,2) = -tmp2 fjac(i,3) = -tmp3 fjac(i,4) = -tmp4 fjac(i,5) = temp*x(1)*tmp1 fjac(i,6) = x(2)*(temp - x(9))**2*tmp2 fjac(i,7) = x(3)*(temp - x(10))**2*tmp3 fjac(i,8) = x(4)*(temp - x(11))**2*tmp4 fjac(i,9) = -two*x(2)*x(6)*(temp - x(9))*tmp2 fjac(i,10) = -two*x(3)*x(7)*(temp - x(10))*tmp3 fjac(i,11) = -two*x(4)*x(8)*(temp - x(11))*tmp4 490 continue 500 continue return c c last card of subroutine ssqjac. c end cminpack-1.3.4/examples/tchkder.f000644 000765 000765 00000004577 12275012134 016677 0ustar00devernay000000 000000 C DRIVER FOR CHKDER EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER I,M,N,LDFJAC,MODE,NWRITE DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),XP(3),FVECP(15), * ERR(15) C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING VALUES SHOULD BE SUITABLE FOR C CHECKING THE JACOBIAN MATRIX. C X(1) = 9.2D-1 X(2) = 1.3D-1 X(3) = 5.4D-1 C LDFJAC = 15 C MODE = 1 CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR) MODE = 2 CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,1) CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,2) CALL FCN(M,N,XP,FVECP,FJAC,LDFJAC,1) CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR) C DO 10 I = 1, M FVECP(I) = FVECP(I) - FVEC(I) 10 CONTINUE WRITE (NWRITE,1000) (FVEC(I),I=1,M) WRITE (NWRITE,2000) (FVECP(I),I=1,M) WRITE (NWRITE,3000) (ERR(I),I=1,M) STOP 1000 FORMAT (/5X,5H FVEC // (5X,3D15.7)) 2000 FORMAT (/5X,13H FVECP - FVEC // (5X,3D15.7)) 3000 FORMAT (/5X,4H ERR // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR CHKDER EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR CHKDER EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I C C ERROR INTRODUCED INTO NEXT STATEMENT FOR ILLUSTRATION. C CORRECTED STATEMENT SHOULD READ TMP3 = TMP1 . C TMP3 = TMP2 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tchkder_.c000644 000765 000765 00000004515 12274447654 017045 0ustar00devernay000000 000000 /* driver for chkder example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); int main() { int i, m, n, ldfjac, mode; real 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; __minpack_func__(chkder)(&m, &n, x, NULL, NULL, &ldfjac, xp, NULL, &mode, NULL); mode = 2; fcn(&m, &n, x, fvec, NULL, &ldfjac, &one); fcn(&m, &n, x, NULL, fjac, &ldfjac, &two); fcn(&m, &n, xp, fvecp, NULL, &ldfjac, &one); __minpack_func__(chkder)(&m, &n, x, fvec, fjac, &ldfjac, NULL, 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 ":"", (double)fvec[i-1]); printf("\n fvecp - fvec\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", (double)fvecp[i-1]); printf("\n err\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", (double)err[i-1]); printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* subroutine fcn for chkder example. */ int i; real tmp1, tmp2, tmp3, tmp4; real 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}; assert(*m == 15 && *n == 3); 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; } cminpack-1.3.4/examples/tchkderc.c000644 000765 000765 00000007501 12274444374 017043 0ustar00devernay000000 000000 /* driver for chkder example. */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; #ifdef BOX_CONSTRAINTS real *xmin; real *xmax; #endif } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); int main() { int i, ldfjac; real x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], err[15]; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; #ifdef BOX_CONSTRAINTS real xmin[3] = {0., 0.1, 0.5}; real xmax[3] = {2., 1.5, 2.3}; #endif fcndata_t data; data.m = m; data.y = y; #ifdef BOX_CONSTRAINTS data.xmin = xmin; data.xmax = xmax; #endif /* the following values should be suitable for */ /* checking the jacobian matrix. */ x[0] = 9.2e-1; x[1] = 1.3e-1; x[2] = 5.4e-1; ldfjac = 15; /* compute xp from x */ __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL); /* compute fvec at x (all components of fvec should be != 0).*/ fcn(&data, m, n, x, fvec, NULL, ldfjac, 1); /* compute fjac at x */ fcn(&data, m, n, x, NULL, fjac, ldfjac, 2); /* compute fvecp at xp (all components of fvecp should be != 0)*/ fcn(&data, m, n, xp, fvecp, NULL, ldfjac, 1); /* check Jacobian, put the result in err */ __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err); /* Output values: err[i] = 1.: i-th gradient is correct err[i] = 0.: i-th gradient is incorrect err[I] > 0.5: i-th gradient is probably correct */ for (i=0; iy; #ifdef BOX_CONSTRAINTS const real *xmin = ((fcndata_t*)p)->xmin; const real *xmax = ((fcndata_t*)p)->xmax; int j; real xb[3]; real jacfac[3]; for (j = 0; j < 3; ++j) { real xmiddle = (xmin[j]+xmax[j])/2.; real xwidth = (xmax[j]-xmin[j])/2.; real th = tanh((x[j]-xmiddle)/xwidth); xb[j] = xmiddle + th * xwidth; jacfac[j] = 1. - th * th; } x = xb; #endif if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 0; } if (iflag != 2) { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } else { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; # ifdef TCHKDER_FIXED tmp3 = (i > 7) ? tmp2 : tmp1; # else /* error introduced into next statement for illustration. */ /* corrected statement should read tmp3 = (i > 7) ? tmp2 : tmp1 . */ tmp3 = (i > 7) ? tmp2 : tmp2; # endif tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; fjac[i + ldfjac*0] = -1.; fjac[i + ldfjac*1] = tmp1*tmp2/tmp4; fjac[i + ldfjac*2] = tmp1*tmp3/tmp4; } # ifdef BOX_CONSTRAINTS for (j = 0; j < 3; ++j) { for (i=0; i < 15; ++i) { fjac[i + ldfjac*j] *= jacfac[j]; } } # endif } return 0; } cminpack-1.3.4/examples/tchkderc_box.c000644 000765 000765 00000000056 12275011461 017675 0ustar00devernay000000 000000 #define BOX_CONSTRAINTS #include "tchkderc.c" cminpack-1.3.4/examples/tenorm_.c000644 000765 000765 00000003370 12275246511 016711 0ustar00devernay000000 000000 /* driver for enorm example. */ #include #include #include #include #include #define real __minpack_real__ #ifdef __cminpack_double__ #define N1 3 #define N2 367 #define SQRTFAC 1.5 #define FAC 10. #endif #ifdef __cminpack_float__ #define N1 3 #define N2 367 #define SQRTFAC 1.5 #define FAC 10. #endif #ifdef __cminpack_half__ #define N1 2 #define N2 2 #define SQRTFAC 1. #define FAC 2. #endif int main() { int i; int n; real* x; real norm; real agiant; real rdwarf = sqrt(__cminpack_func__(dpmpar)(2)*SQRTFAC) * FAC; real rgiant = sqrt(__cminpack_func__(dpmpar)(3)) / FAC; printf ("dpmpar(2) = %15.7g, dpmpar(3) = %15.7g\n", (double)__cminpack_func__(dpmpar)(2), (double)__cminpack_func__(dpmpar)(3)); printf ("rdwarf = %.16g, rgiant = %.16g\n", (double)rdwarf, (double)rgiant); n = N1*N1*N2*N2*2+2; x = (real*)malloc(n*sizeof(real)); for (i = 0; i < n; ++i) { if (i < 2) { x[i] = rdwarf * N1; } else { x[i] = rdwarf / N2; } } norm = 0; for (i = 0; i < n; ++i) { norm += x[i]*x[i]; } norm = sqrt(norm) / rdwarf / N1 / 2; printf( "norm/rdwarf (naive) = %.15g\n", norm); norm = __minpack_func__(enorm)(&n, x); norm = norm / rdwarf / N1 / 2; printf( "norm/rdwarf (enorm) = %.15g\n", norm); agiant = rgiant / (real)n; for (i = 0; i < n; ++i) { if (i < 2) { x[i] = agiant * N1; } else { x[i] = agiant / N2; } } norm = 0; for (i = 0; i < n; ++i) { norm += x[i]*x[i]; } norm = sqrt(norm) / agiant / N1 / 2; printf( "norm/agiant (naive) = %.15g\n", norm); norm = __minpack_func__(enorm)(&n, x); norm = norm / agiant / N1 / 2; printf( "norm/agiant (enorm) = %.15g\n", norm); free (x); return 0; } cminpack-1.3.4/examples/tenormc.c000644 000765 000765 00000003432 12275177135 016721 0ustar00devernay000000 000000 /* driver for enorm example. */ #include #include #include #include #include #define real __cminpack_real__ #ifdef __cminpack_double__ #define N1 3 #define N2 367 #define SQRTFAC 1.5 #define FAC 10. #endif #ifdef __cminpack_float__ #define N1 3 #define N2 367 #define SQRTFAC 1.5 #define FAC 10. #endif #ifdef __cminpack_half__ #define N1 2 #define N2 2 #define SQRTFAC 1. #define FAC 2. #endif int main() { int i; int n; real* x; real norm; real agiant; real rdwarf = sqrt(__cminpack_func__(dpmpar)(2)*SQRTFAC) * FAC; real rgiant = sqrt(__cminpack_func__(dpmpar)(3)) / FAC; printf ("dpmpar(2) = %15.7g, dpmpar(3) = %15.7g\n", (double)__cminpack_func__(dpmpar)(2), (double)__cminpack_func__(dpmpar)(3)); printf ("rdwarf = %.16g, rgiant = %.16g\n", (double)rdwarf, (double)rgiant); n = N1*N1*N2*N2*2+2; x = (real*)malloc(n*sizeof(real)); for (i = 0; i < n; ++i) { if (i < 2) { x[i] = rdwarf * N1; } else { x[i] = rdwarf / N2; } } norm = 0; for (i = 0; i < n; ++i) { norm += x[i]*x[i]; } norm = sqrt(norm) / rdwarf / N1 / 2; printf( "norm/rdwarf (naive) = %.15g\n", (double)norm); norm = __cminpack_func__(enorm)(n, x); norm = norm / rdwarf / N1 / 2; printf( "norm/rdwarf (enorm) = %.15g\n", (double)norm); agiant = rgiant / (real)n; for (i = 0; i < n; ++i) { if (i < 2) { x[i] = agiant * N1; } else { x[i] = agiant / N2; } } norm = 0; for (i = 0; i < n; ++i) { norm += x[i]*x[i]; } norm = sqrt(norm) / agiant / N1 / 2; printf( "norm/agiant (naive) = %.15g\n", (double)norm); norm = __cminpack_func__(enorm)(n, x); norm = norm / agiant / N1 / 2; printf( "norm/agiant (enorm) = %.15g\n", (double)norm); free (x); return 0; } cminpack-1.3.4/examples/testdata/000755 000765 000765 00000000000 12225167750 016712 5ustar00devernay000000 000000 cminpack-1.3.4/examples/tfdjac2_.c000644 000765 000765 00000005734 12274447421 016732 0ustar00devernay000000 000000 /* driver for fdjac2 example. */ /* The test works by running chkder both on the Jacobian computed by forward-differences and on the real Jacobian */ #include #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag); void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac); int main() { int i, m, n, ldfjac, mode; real epsfcn; real x[3], fvec[15], fjac[15*3], fdjac[15*3], xp[3], fvecp[15], err[15], errd[15], wa[15]; int one=1, iflag=1; 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; epsfcn = 0.; mode = 1; __minpack_func__(chkder)(&m, &n, x, NULL, NULL, &ldfjac, xp, NULL, &mode, NULL); mode = 2; fcn(&m, &n, x, fvec, &one); __minpack_func__(fdjac2)(fcn, &m, &n, x, fvec, fdjac, &ldfjac, &iflag, &epsfcn, wa); fcnjac(m, n, x, fjac, ldfjac); fcn(&m, &n, xp, fvecp, &one); __minpack_func__(chkder)(&m, &n, x, fvec, fdjac, &ldfjac, NULL, fvecp, &mode, errd); __minpack_func__(chkder)(&m, &n, x, fvec, fjac, &ldfjac, NULL, 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 ":"", (double)fvec[i-1]); printf("\n fvecp - fvec\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", (double)fvecp[i-1]); printf("\n errd\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", (double)errd[i-1]); printf("\n err\n"); for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n ":"", (double)err[i-1]); printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag) { /* subroutine fcn for fdjac2 example. */ int i; real tmp1, tmp2, tmp3; real 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}; assert(*m == 15 && *n == 3); 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)); } } void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac) { /* Jacobian of fcn (corrected version from tchkder). */ int i; real tmp1, tmp2, tmp3, tmp4; assert(m == 15 && n == 3); 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; } } cminpack-1.3.4/examples/tfdjac2c.c000644 000765 000765 00000007363 12274444374 016742 0ustar00devernay000000 000000 /* driver for fdjac2 example. */ /* The test works by running chkder both on the Jacobian computed by forward-differences and on the real Jacobian */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag); void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac); int main() { int i, ldfjac; real epsfcn; real x[3], fvec[15], fjac[15*3], fdjac[15*3], xp[3], fvecp[15], err[15], errd[15], wa[15]; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; fcndata_t data; data.m = m; data.y = y; /* 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; epsfcn = 0.; /* compute xp from x */ __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL); /* compute fvec at x (all components of fvec should be != 0).*/ fcn(&data, m, n, x, fvec, 1); /* compute fdjac (Jacobian using finite differences) at x */ __cminpack_func__(fdjac2)(fcn, &data, m, n, x, fvec, fdjac, ldfjac, epsfcn, wa); /* compute fjac (real Jacobian) at x */ fcnjac(m, n, x, fjac, ldfjac); /* compute fvecp at xp (all components of fvecp should be != 0)*/ fcn(&data, m, n, xp, fvecp, 1); /* check Jacobian fdjac, put the result in errd */ __cminpack_func__(chkder)(m, n, x, fvec, fdjac, ldfjac, NULL, fvecp, 2, errd); /* check Jacobian fjac, put the result in err */ __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err); /* Output values: err[i] = 1.: i-th gradient is correct err[i] = 0.: i-th gradient is incorrect err[I] > 0.5: i-th gradient is probably correct */ for (i=0; i 8) tmp3 = tmp2; fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3)); } return 0; } void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac) { /* Jacobian of fcn (corrected version from tchkder). */ int i; real tmp1, tmp2, tmp3, tmp4; assert(m == 15 && n == 3); 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; } } cminpack-1.3.4/examples/thybrd.f000644 000765 000765 00000004310 12275012134 016530 0ustar00devernay000000 000000 C DRIVER FOR HYBRD EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,MAXFEV,ML,MU,MODE,NPRINT,INFO,NFEV,LDFJAC,LR,NWRITE DOUBLE PRECISION XTOL,EPSFCN,FACTOR,FNORM DOUBLE PRECISION X(9),FVEC(9),DIAG(9),FJAC(9,9),R(45),QTF(9), * WA1(9),WA2(9),WA3(9),WA4(9) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LR = 45 C C SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C XTOL = DSQRT(DPMPAR(1)) C MAXFEV = 2000 ML = 1 MU = 1 EPSFCN = 0.D0 MODE = 2 DO 20 J = 1, 9 DIAG(J) = 1.D0 20 CONTINUE FACTOR = 1.D2 NPRINT = 0 C CALL 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) WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRD EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,IFLAG) INTEGER N,IFLAG DOUBLE PRECISION X(N),FVEC(N) C C SUBROUTINE FCN FOR HYBRD EXAMPLE. C INTEGER K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/thybrd1.f000644 000765 000765 00000003126 12275012134 016615 0ustar00devernay000000 000000 C DRIVER FOR HYBRD1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,INFO,LWA,NWRITE DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(9),FVEC(9),WA(180) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LWA = 180 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL HYBRD1(FCN,N,X,FVEC,TOL,INFO,WA,LWA) FNORM = ENORM(N,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRD1 EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,IFLAG) INTEGER N,IFLAG DOUBLE PRECISION X(N),FVEC(N) C C SUBROUTINE FCN FOR HYBRD1 EXAMPLE. C INTEGER K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/ C DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/thybrd1_.c000644 000765 000765 00000003005 12274446131 016754 0ustar00devernay000000 000000 /* driver for hybrd1 example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *n, const real *x, real *fvec, int *iflag); int main() { int j, n, info, lwa; real tol, fnorm; real 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(__minpack_func__(dpmpar)(&one)); __minpack_func__(hybrd1)(&fcn, &n, x, fvec, &tol, &info, wa, &lwa); fnorm = __minpack_func__(enorm)(&n, fvec); printf(" final L2 norm of the residuals %15.7g\n", (double)fnorm); printf(" exit parameter %10i\n", info); printf(" final approximates solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g",j%3==1?"\n ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *n, const real *x, real *fvec, int *iflag) { /* subroutine fcn for hybrd1 example. */ int k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0; assert(*n == 9); (void)iflag; 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; } cminpack-1.3.4/examples/thybrd1c.c000644 000765 000765 00000003002 12274444374 016764 0ustar00devernay000000 000000 /* driver for hybrd1 example. */ #include #include #include #include #define real __cminpack_real__ int fcn(void *p, int n, const real *x, real *fvec, int iflag); int main() { int j, n, info, lwa; real tol, fnorm; real x[9], fvec[9], wa[180]; 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(__cminpack_func__(dpmpar)(1)); info = __cminpack_func__(hybrd1)(fcn, 0, n, x, fvec, tol, wa, lwa); fnorm = __cminpack_func__(enorm)(n, fvec); printf(" final L2 norm of the residuals %15.7g\n", (double)fnorm); printf(" exit parameter %10i\n", info); printf(" final approximates solution\n"); for (j=1; j<=n; j++) printf("%s%15.7g",j%3==1?"\n ":"", (double)x[j-1]); printf("\n"); return 0; } int fcn(void *p, int n, const real *x, real *fvec, int iflag) { /* subroutine fcn for hybrd1 example. */ int k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0; (void)p; (void)iflag; assert(n == 9); 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 0; } cminpack-1.3.4/examples/thybrd_.c000644 000765 000765 00000004102 12274446103 016671 0ustar00devernay000000 000000 /* driver for hybrd example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *n, const real *x, real *fvec, int *iflag); int main() { int j, n, maxfev, ml, mu, mode, nprint, info, nfev, ldfjac, lr; real xtol, epsfcn, factor, fnorm; real 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(__minpack_func__(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; __minpack_func__(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 = __minpack_func__(enorm)(&n, fvec); printf(" final l2 norm of the residuals %15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *n, const real *x, real *fvec, int *iflag) { /* subroutine fcn for hybrd example. */ int k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0; assert(*n == 9); 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; } cminpack-1.3.4/examples/thybrdc.c000644 000765 000765 00000004071 12274444374 016712 0ustar00devernay000000 000000 /* driver for hybrd example. */ #include #include #include #include #define real __cminpack_real__ int fcn(void *p, int n, const real *x, real *fvec, int iflag); int main() { int j, n, maxfev, ml, mu, mode, nprint, info, nfev, ldfjac, lr; real xtol, epsfcn, factor, fnorm; real x[9], fvec[9], diag[9], fjac[9*9], r[45], qtf[9], wa1[9], wa2[9], wa3[9], wa4[9]; 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(__cminpack_func__(dpmpar)(1)); 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; info = __cminpack_func__(hybrd)(fcn, 0, n, x, fvec, xtol, maxfev, ml, mu, epsfcn, diag, mode, factor, nprint, &nfev, fjac, ldfjac, r, lr, qtf, wa1, wa2, wa3, wa4); fnorm = __cminpack_func__(enorm)(n, fvec); printf(" final l2 norm of the residuals %15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } int fcn(void *p, int n, const real *x, real *fvec, int iflag) { /* subroutine fcn for hybrd example. */ int k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0; (void)p; assert(n == 9); if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 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 0; } cminpack-1.3.4/examples/thybrj.f000644 000765 000765 00000005062 12275012134 016543 0ustar00devernay000000 000000 C DRIVER FOR HYBRJ EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,LR,NWRITE DOUBLE PRECISION XTOL,FACTOR,FNORM DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),DIAG(9),R(45),QTF(9), * WA1(9),WA2(9),WA3(9),WA4(9) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LR = 45 C C SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C XTOL = DSQRT(DPMPAR(1)) C MAXFEV = 1000 MODE = 2 DO 20 J = 1, 9 DIAG(J) = 1.D0 20 CONTINUE FACTOR = 1.D2 NPRINT = 0 C CALL 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) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRJ EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR HYBRJ EXAMPLE. C INTEGER J,K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .EQ. 2) GO TO 20 DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE GO TO 50 20 CONTINUE DO 40 K = 1, N DO 30 J = 1, N FJAC(K,J) = ZERO 30 CONTINUE FJAC(K,K) = THREE - FOUR*X(K) IF (K .NE. 1) FJAC(K,K-1) = -ONE IF (K .NE. N) FJAC(K,K+1) = -TWO 40 CONTINUE 50 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/thybrj1.f000644 000765 000765 00000003752 12275012134 016630 0ustar00devernay000000 000000 C DRIVER FOR HYBRJ1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,LDFJAC,INFO,LWA,NWRITE DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),WA(99) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LWA = 99 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA) FNORM = ENORM(N,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRJ1 EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR HYBRJ1 EXAMPLE. C INTEGER J,K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE GO TO 50 20 CONTINUE DO 40 K = 1, N DO 30 J = 1, N FJAC(K,J) = ZERO 30 CONTINUE FJAC(K,K) = THREE - FOUR*X(K) IF (K .NE. 1) FJAC(K,K-1) = -ONE IF (K .NE. N) FJAC(K,K+1) = -TWO 40 CONTINUE 50 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/thybrj1_.c000644 000765 000765 00000003711 12274446056 016774 0ustar00devernay000000 000000 /* driver for hybrj1 example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); int main() { int j, n, ldfjac, info, lwa; real tol, fnorm; real 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(__minpack_func__(dpmpar)(&one)); __minpack_func__(hybrj1)(&fcn, &n, x, fvec, fjac, &ldfjac, &tol, &info, wa, &lwa); fnorm = __minpack_func__(enorm)(&n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* subroutine fcn for hybrj1 example. */ int j, k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; assert(*n == 9); 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; } cminpack-1.3.4/examples/thybrj1c.c000644 000765 000765 00000003657 12274444374 017012 0ustar00devernay000000 000000 /* driver for hybrj1 example. */ #include #include #include #include #define real __cminpack_real__ int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); int main() { int j, n, ldfjac, info, lwa; real tol, fnorm; real x[9], fvec[9], fjac[9*9], wa[99]; 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(__cminpack_func__(dpmpar)(1)); info = __cminpack_func__(hybrj1)(fcn, 0, n, x, fvec, fjac, ldfjac, tol, wa, lwa); fnorm = __cminpack_func__(enorm)(n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag) { /* subroutine fcn for hybrj1 example. */ int j, k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; (void)p; assert(n == 9); 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 0; } cminpack-1.3.4/examples/thybrj_.c000644 000765 000765 00000004701 12274446026 016710 0ustar00devernay000000 000000 /* driver for hybrj example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); int main() { int j, n, ldfjac, maxfev, mode, nprint, info, nfev, njev, lr; real xtol, factor, fnorm; real 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(__minpack_func__(dpmpar)(&one)); maxfev = 1000; mode = 2; for (j=1; j<=9; j++) { diag[j-1] = 1.; } factor = 1.e2; nprint = 0; __minpack_func__(hybrj)(&fcn, &n, x, fvec, fjac, &ldfjac, &xtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, r, &lr, qtf, wa1, wa2, wa3, wa4); fnorm = __minpack_func__(enorm)(&n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* subroutine fcn for hybrj example. */ int j, k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; assert(*n == 9); 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; } cminpack-1.3.4/examples/thybrjc.c000644 000765 000765 00000007065 12274444374 016726 0ustar00devernay000000 000000 /* driver for hybrj example. */ #include #include #include #include #define real __cminpack_real__ #ifdef BOX_CONSTRAINTS typedef struct { real *xmin; real *xmax; } fcndata_t; #endif int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); int main() { int j, n, ldfjac, maxfev, mode, nprint, info, nfev, njev, lr; real xtol, factor, fnorm; real x[9], fvec[9], fjac[9*9], diag[9], r[45], qtf[9], wa1[9], wa2[9], wa3[9], wa4[9]; void *p = NULL; #ifdef BOX_CONSTRAINTS real xmin[9] = {-2.,-0.5, -2., -2., -2., -2., -2., -2., -2.}; real xmax[9] = { 2., 2., 2., 2., 2., 2., 2., 2., 2.}; fcndata_t data; data.xmin = xmin; data.xmax = xmax; p = &data; #endif 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(__cminpack_func__(dpmpar)(1)); maxfev = 1000; mode = 2; for (j=1; j<=9; j++) { diag[j-1] = 1.; } factor = 1.e2; nprint = 0; info = __cminpack_func__(hybrj)(fcn, p, n, x, fvec, fjac, ldfjac, xtol, maxfev, diag, mode, factor, nprint, &nfev, &njev, r, lr, qtf, wa1, wa2, wa3, wa4); #ifdef BOX_CONSTRAINTS /* compute the real x, using the same change of variable as in fcn */ for (j = 0; j < 3; ++j) { real xmiddle = (xmin[j]+xmax[j])/2.; real xwidth = (xmax[j]-xmin[j])/2.; real th = tanh((x[j]-xmiddle)/xwidth); x[j] = xmiddle + th * xwidth; } #endif fnorm = __cminpack_func__(enorm)(n, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag) { /* subroutine fcn for hybrj example. */ (void)p; assert(n == 9); int j, k; real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4; #ifdef BOX_CONSTRAINTS const real *xmin = ((fcndata_t*)p)->xmin; const real *xmax = ((fcndata_t*)p)->xmax; real xb[9]; real jacfac[9]; for (j = 0; j < 9; ++j) { real xmiddle = (xmin[j]+xmax[j])/2.; real xwidth = (xmax[j]-xmin[j])/2.; real th = tanh((x[j]-xmiddle)/xwidth); xb[j] = xmiddle + th * xwidth; jacfac[j] = 1. - th * th; } x = xb; #endif if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 0; } if (iflag != 2) { for (k = 0; k < n; ++k) { temp = (three - two*x[k])*x[k]; temp1 = zero; if (k != 0) temp1 = x[k-1]; temp2 = zero; if (k != n-1) temp2 = x[k+1]; fvec[k] = temp - temp1 - two*temp2 + one; } } else { for (k = 0; k < n; ++k) { for (j = 0; j < n; ++j) { fjac[k + ldfjac*j] = zero; } fjac[k + ldfjac*k] = three - four*x[k]; if (k != 0) { fjac[k + ldfjac*(k-1)] = -one; } if (k != n-1) { fjac[k + ldfjac*(k+1)] = -two; } # ifdef BOX_CONSTRAINTS for (j = 0; j < n; ++j) { fjac[k + ldfjac*j] *= jacfac[j]; } # endif } } return 0; } cminpack-1.3.4/examples/thybrjc_box.c000644 000765 000765 00000000055 12275011517 017554 0ustar00devernay000000 000000 #define BOX_CONSTRAINTS #include "thybrjc.c" cminpack-1.3.4/examples/tlmder.f000644 000765 000765 00000005417 12275012134 016534 0ustar00devernay000000 000000 C DRIVER FOR LMDER EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),DIAG(3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 400 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMDER(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDER EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR LMDER EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmder1.f000644 000765 000765 00000004324 12275012134 016611 0ustar00devernay000000 000000 C DRIVER FOR LMDER1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE INTEGER IPVT(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),WA(30) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 LWA = 30 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMDER1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDER1 EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR LMDER1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmder1_.c000644 000765 000765 00000004065 12274445614 016763 0ustar00devernay000000 000000 /* driver for lmder1 example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); int main() { int j, m, n, ldfjac, info, lwa; int ipvt[3]; real tol, fnorm; real 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(__minpack_func__(dpmpar)(&one)); __minpack_func__(lmder1)(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &tol, &info, ipvt, wa, &lwa); fnorm = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* subroutine fcn for lmder1 example. */ int i; real tmp1, tmp2, tmp3, tmp4; real 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}; assert(*m == 15 && *n == 3); 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; } } } cminpack-1.3.4/examples/tlmder1c.c000644 000765 000765 00000004335 12274444374 016771 0ustar00devernay000000 000000 /* driver for lmder1 example. */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); int main() { int j, ldfjac, info, lwa; int ipvt[3]; real tol, fnorm; real x[3], fvec[15], fjac[15*3], wa[30]; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; fcndata_t data; data.m = m; data.y = y; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__cminpack_func__(dpmpar)(1)); info = __cminpack_func__(lmder1)(fcn, &data, m, n, x, fvec, fjac, ldfjac, tol, ipvt, wa, lwa); fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=0; jy; assert(m == 15 && n == 3); if (iflag != 2) { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } else { for (i=0; i<15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; fjac[i + ldfjac*0] = -1.; fjac[i + ldfjac*1] = tmp1*tmp2/tmp4; fjac[i + ldfjac*2] = tmp1*tmp3/tmp4; }; } return 0; } cminpack-1.3.4/examples/tlmder_.c000644 000765 000765 00000005705 12274445670 016706 0ustar00devernay000000 000000 /* driver for lmder example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag); int main() { int i, j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; real ftol, xtol, gtol, factor, fnorm; real x[3], fvec[15], fjac[15*3], diag[3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int one=1; real covfac; 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(__minpack_func__(dpmpar)(&one)); xtol = sqrt(__minpack_func__(dpmpar)(&one)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; __minpack_func__(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 = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); ftol = __minpack_func__(dpmpar)(&one); covfac = fnorm*fnorm/(m-n); __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1); printf(" covariance\n"); for (i=1; i<=n; i++) { for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", (double)fjac[(i-1)*ldfjac+j-1]*covfac); } printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, int *iflag) { /* subroutine fcn for lmder example. */ int i; real tmp1, tmp2, tmp3, tmp4; real 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}; assert(*m == 15 && *n == 3); 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; } cminpack-1.3.4/examples/tlmderc.c000644 000765 000765 00000013234 12275166445 016707 0ustar00devernay000000 000000 /* driver for lmder example. */ #include #include #include #include #include #define real __cminpack_real__ #define TEST_COVAR /* define the preprocessor symbol BOX_CONSTRAINTS to enable the simulated box constraints using a change of variables. */ /* the following struct defines the data points */ typedef struct { int m; real *y; #ifdef BOX_CONSTRAINTS real *xmin; real *xmax; #endif } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag); int main() { int i, j, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; real ftol, xtol, gtol, factor, fnorm; real x[3], fvec[15], fjac[15*3], diag[3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int k; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; #ifdef TEST_COVAR real covfac; real fjac1[15*3]; #endif #ifdef BOX_CONSTRAINTS /* the minimum and maximum bounds for each variable. */ real xmin[3] = {0., 0.1, 0.5}; real xmax[3] = {2., 1.5, 2.3}; /* the Jacobian factor for each line, used to compute the covariance matrix. */ real jacfac[3]; #endif fcndata_t data; data.m = m; data.y = y; #ifdef BOX_CONSTRAINTS data.xmin = xmin; data.xmax = xmax; #endif /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__cminpack_func__(dpmpar)(1)); xtol = sqrt(__cminpack_func__(dpmpar)(1)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; info = __cminpack_func__(lmder)(fcn, &data, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, diag, mode, factor, nprint, &nfev, &njev, ipvt, qtf, wa1, wa2, wa3, wa4); #ifdef BOX_CONSTRAINTS /* compute the real x, using the same change of variable as in fcn */ for (j = 0; j < 3; ++j) { real xmiddle = (xmin[j]+xmax[j])/2.; real xwidth = (xmax[j]-xmin[j])/2.; real th = tanh((x[j]-xmiddle)/xwidth); x[j] = xmiddle + th * xwidth; jacfac[j] = 1. - th * th; } #endif fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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=0; jy; #ifdef BOX_CONSTRAINTS const real *xmin = ((fcndata_t*)p)->xmin; const real *xmax = ((fcndata_t*)p)->xmax; int j; real xb[3]; real jacfac[3]; real xmiddle, xwidth, th; for (j = 0; j < 3; ++j) { xmiddle = (xmin[j]+xmax[j])/2.; xwidth = (xmax[j]-xmin[j])/2.; th = tanh((x[j]-xmiddle)/xwidth); xb[j] = (xmin[j]+xmax[j])/2. + th * xwidth; jacfac[j] = 1. - th * th; } x = xb; #endif assert(m == 15 && n == 3); if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 0; } if (iflag != 2) { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } else { for (i=0; i<15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; fjac[i + ldfjac*0] = -1.; fjac[i + ldfjac*1] = tmp1*tmp2/tmp4; fjac[i + ldfjac*2] = tmp1*tmp3/tmp4; } # ifdef BOX_CONSTRAINTS for (j = 0; j < 3; ++j) { for (i=0; i < 15; ++i) { fjac[i + ldfjac*j] *= jacfac[j]; } } # endif } return 0; } cminpack-1.3.4/examples/tlmderc_box.c000644 000765 000765 00000000055 12275011564 017543 0ustar00devernay000000 000000 #define BOX_CONSTRAINTS #include "tlmderc.c" cminpack-1.3.4/examples/tlmdif.f000644 000765 000765 00000004533 12275012134 016522 0ustar00devernay000000 000000 C DRIVER FOR LMDIF EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,MAXFEV,MODE,NPRINT,INFO,NFEV,LDFJAC,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,EPSFCN,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),DIAG(3),FJAC(15,3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 800 EPSFCN = 0.D0 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMDIF(FCN,M,N,X,FVEC,FTOL,XTOL,GTOL,MAXFEV,EPSFCN, * DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC, * IPVT,QTF,WA1,WA2,WA3,WA4) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDIF EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M) C C SUBROUTINE FCN FOR LMDIF EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmdif1.f000644 000765 000765 00000003404 12275012134 016577 0ustar00devernay000000 000000 C DRIVER FOR LMDIF1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,INFO,LWA,NWRITE INTEGER IWA(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),WA(75) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LWA = 75 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMDIF1(FCN,M,N,X,FVEC,TOL,INFO,IWA,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDIF1 EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M) C C SUBROUTINE FCN FOR LMDIF1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmdif1_.c000644 000765 000765 00000003077 12274447402 016752 0ustar00devernay000000 000000 /* driver for lmdif1 example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag); int main() { int j, m, n, info, lwa, iwa[3], one=1; real tol, fnorm, x[3], fvec[15], wa[75]; 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(__minpack_func__(dpmpar)(&one)); __minpack_func__(lmdif1)(&fcn, &m, &n, x, fvec, &tol, &info, iwa, wa, &lwa); fnorm = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag) { /* function fcn for lmdif1 example */ int i; real tmp1,tmp2,tmp3; real 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}; assert(*m == 15 && *n == 3); (void)iflag; 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)); } } cminpack-1.3.4/examples/tlmdif1c.c000644 000765 000765 00000003425 12274444374 016760 0ustar00devernay000000 000000 /* driver for lmdif1 example. */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag); int main() { int info, lwa, iwa[3]; real tol, fnorm, x[3], fvec[15], wa[75]; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; fcndata_t data; data.m = m; data.y = y; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 1.; 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(__cminpack_func__(dpmpar)(1)); info = __cminpack_func__(lmdif1)(fcn, &data, m, n, x, fvec, tol, iwa, wa, lwa); fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n",(double)fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n\n %15.7g%15.7g%15.7g\n", (double)x[0], (double)x[1], (double)x[2]); return 0; } int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag) { /* function fcn for lmdif1 example */ int i; real tmp1,tmp2,tmp3; const real *y = ((fcndata_t*)p)->y; assert(m == 15 && n == 3); (void)iflag; for (i = 0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } return 0; } cminpack-1.3.4/examples/tlmdif_.c000644 000765 000765 00000004773 12274445654 016704 0ustar00devernay000000 000000 /* driver for lmdif example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag); int main() { int i, j, m, n, maxfev, mode, nprint, info, nfev, ldfjac; int ipvt[3]; real ftol, xtol, gtol, epsfcn, factor, fnorm; real x[3], fvec[15], diag[3], fjac[15*3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int one=1; real covfac; 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(__minpack_func__(dpmpar)(&one)); xtol = sqrt(__minpack_func__(dpmpar)(&one)); gtol = 0.; maxfev = 800; epsfcn = 0.; mode = 1; factor = 1.e2; nprint = 0; __minpack_func__(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 = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); ftol = __minpack_func__(dpmpar)(&one); covfac = fnorm*fnorm/(m-n); __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1); printf(" covariance\n"); for (i=1; i<=n; i++) { for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", (double)fjac[(i-1)*ldfjac+j-1]*covfac); } printf("\n"); return 0; } void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag) { /* subroutine fcn for lmdif example. */ int i; real tmp1, tmp2, tmp3; real 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}; assert(*m == 15 && *n == 3); 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; } cminpack-1.3.4/examples/tlmdifc.c000644 000765 000765 00000007256 12275166550 016703 0ustar00devernay000000 000000 /* driver for lmdif example. */ #include #include #include #include #include #define real __cminpack_real__ #define TEST_COVAR /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag); int main() { int i, j, maxfev, mode, nprint, info, nfev, ldfjac; int ipvt[3]; real ftol, xtol, gtol, epsfcn, factor, fnorm; real x[3], fvec[15], diag[3], fjac[15*3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int k; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; #ifdef TEST_COVAR real covfac; real fjac1[15*3]; #endif fcndata_t data; data.m = m; data.y = y; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__cminpack_func__(dpmpar)(1)); xtol = sqrt(__cminpack_func__(dpmpar)(1)); gtol = 0.; maxfev = 800; epsfcn = 0.; mode = 1; factor = 1.e2; nprint = 0; info = __cminpack_func__(lmdif)(fcn, &data, m, n, x, fvec, ftol, xtol, gtol, maxfev, epsfcn, diag, mode, factor, nprint, &nfev, fjac, ldfjac, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)fnorm); printf(" number of function evaluations%10i\n\n", nfev); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=0; jy; assert(m == 15 && n == 3); if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 0; } for (i = 0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } return 0; } cminpack-1.3.4/examples/tlmstr.f000644 000765 000765 00000005365 12275012134 016574 0ustar00devernay000000 000000 C DRIVER FOR LMSTR EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),DIAG(3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 3 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 400 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMSTR(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMSTR EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJROW(N) C C SUBROUTINE FCN FOR LMSTR EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .GE. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE I = IFLAG - 1 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJROW(1) = -1.D0 FJROW(2) = TMP1*TMP2/TMP4 FJROW(3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmstr1.f000644 000765 000765 00000004272 12275012134 016651 0ustar00devernay000000 000000 C DRIVER FOR LMSTR1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE INTEGER IPVT(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),WA(30) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 3 LWA = 30 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMSTR1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMSTR1 EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJROW(N) C C SUBROUTINE FCN FOR LMSTR1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .GE. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE I = IFLAG - 1 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJROW(1) = -1.D0 FJROW(2) = TMP1*TMP2/TMP4 FJROW(3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END cminpack-1.3.4/examples/tlmstr1_.c000644 000765 000765 00000003675 12274445646 017034 0ustar00devernay000000 000000 /* driver for lmstr1 example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag); int main() { int j, m, n, ldfjac, info, lwa, ipvt[3], one=1; real tol, fnorm; real x[3], fvec[15], fjac[9], wa[30]; m = 15; n = 3; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__minpack_func__(dpmpar)(&one)); __minpack_func__(lmstr1)(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &tol, &info, ipvt, wa, &lwa); fnorm = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=0; j 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; } } cminpack-1.3.4/examples/tlmstr1c.c000644 000765 000765 00000004240 12274444374 017022 0ustar00devernay000000 000000 /* driver for lmstr1 example. */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag); int main() { int j, ldfjac, info, lwa, ipvt[3]; real tol, fnorm; real x[3], fvec[15], fjac[9], wa[30]; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; fcndata_t data; data.m = m; data.y = y; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__cminpack_func__(dpmpar)(1)); info = __cminpack_func__(lmstr1)(fcn, &data, m, n, x, fvec, fjac, ldfjac, tol, ipvt, wa, lwa); fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)fnorm); printf(" exit parameter %10i\n\n", info); printf(" final approximate solution\n"); for (j=0; jy; assert(m == 15 && n == 3); if (iflag < 2) { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } else { i = iflag - 2; tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; fjrow[0] = -1.; fjrow[1] = tmp1*tmp2/tmp4; fjrow[2] = tmp1*tmp3/tmp4; } return 0; } cminpack-1.3.4/examples/tlmstr_.c000644 000765 000765 00000005644 12274445637 016751 0ustar00devernay000000 000000 /* driver for lmstr example. */ #include #include #include #include #define real __minpack_real__ void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag); int main() { int i, j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; real ftol, xtol, gtol, factor, fnorm; real 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(__minpack_func__(dpmpar)(&one)); xtol = sqrt(__minpack_func__(dpmpar)(&one)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; __minpack_func__(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 = __minpack_func__(enorm)(&m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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 ":"", (double)x[j-1]); printf("\n"); ftol = __minpack_func__(dpmpar)(&one); { /* test the original covar from MINPACK */ real covfac = fnorm*fnorm/(m-n); __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1); printf(" covariance\n"); for (i=0; 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; } cminpack-1.3.4/examples/tlmstrc.c000644 000765 000765 00000007152 12275161104 016732 0ustar00devernay000000 000000 /* driver for lmstr example. */ #include #include #include #include #define real __cminpack_real__ /* the following struct defines the data points */ typedef struct { int m; real *y; } fcndata_t; int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag); int main() { int i, j, ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[3]; real ftol, xtol, gtol, factor, fnorm; real x[3], fvec[15], fjac[3*3], diag[3], qtf[3], wa1[3], wa2[3], wa3[3], wa4[15]; int k; const int m = 15; const int n = 3; /* auxiliary data (e.g. measurements) */ real 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}; fcndata_t data; data.m = m; data.y = y; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 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(__cminpack_func__(dpmpar)(1)); xtol = sqrt(__cminpack_func__(dpmpar)(1)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; info = __cminpack_func__(lmstr)(fcn, &data, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, diag, mode, factor, nprint, &nfev, &njev, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = __cminpack_func__(enorm)(m, fvec); printf(" final l2 norm of the residuals%15.7g\n\n", (double)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=0; jy; assert(m == 15 && n == 3); if (iflag == 0) { /* insert print statements here when nprint is positive. */ return 0; } if (iflag < 2) { for (i=0; i < 15; ++i) { tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } } else { i = iflag - 2; tmp1 = i + 1; tmp2 = 15 - i; tmp3 = (i > 7) ? tmp2 : tmp1; tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; fjrow[0] = -1.; fjrow[1] = tmp1*tmp2/tmp4; fjrow[2] = tmp1*tmp3/tmp4; } return 0; } cminpack-1.3.4/examples/ucodrv.f000644 000765 000765 00000010064 12225167750 016553 0ustar00devernay000000 000000 c ********** c c this program tests codes for the unconstrained optimization of c a nonlinear function of n variables. it consists of a driver c and an interface subroutine fcn. the driver reads in data, c calls the unconstrained optimizer, and finally prints out c information on the performance of the optimizer. this is c only a sample driver, many other drivers are possible. the c interface subroutine fcn is necessary to take into account the c forms of calling sequences used by the function subroutines c in the various unconstrained optimizers. c c subprograms called c c user-supplied ...... fcn c c minpack-supplied ... dpmpar,drvcr1,enorm,grdfcn,initpt,objfcn c c fortran-supplied ... dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ic,info,k,lwa,n,nfev,nprob,nread,ntries,nwrite integer na(120),nf(120),np(120),nx(120) double precision factor,f1,f2,gnorm1,gnorm2,one,ten,tol double precision fval(120),gvec(100),gnm(120),wa(6130),x(100) double precision dpmpar,enorm external fcn common /refnum/ nprob,nfev c c logical input unit is assumed to be number 5. c logical output unit is assumed to be number 6. c data nread,nwrite /5,6/ c data one,ten /1.0d0,1.0d1/ tol = dsqrt(dpmpar(1)) lwa = 6130 ic = 0 10 continue read (nread,50) nprob,n,ntries if (nprob .le. 0) go to 30 factor = one do 20 k = 1, ntries ic = ic + 1 call initpt(n,x,nprob,factor) call objfcn(n,x,f1,nprob) call grdfcn(n,x,gvec,nprob) gnorm1 = enorm(n,gvec) write (nwrite,60) nprob,n nfev = 0 call drvcr1(fcn,n,x,f2,gvec,tol,info,wa,lwa) call objfcn(n,x,f2,nprob) call grdfcn(n,x,gvec,nprob) gnorm2 = enorm(n,gvec) np(ic) = nprob na(ic) = n nf(ic) = nfev nx(ic) = info fval(ic) = f2 gnm(ic) = gnorm2 write (nwrite,70) * f1,f2,gnorm1,gnorm2,nfev,info,(x(i), i = 1, n) factor = ten*factor 20 continue go to 10 30 continue write (nwrite,80) ic write (nwrite,90) do 40 i = 1, ic write (nwrite,100) np(i),na(i),nf(i),nx(i),fval(i),gnm(i) 40 continue stop 50 format (3i5) 60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //) 70 format (5x, 23h initial function value, d15.7 // 5x, * 23h final function value , d15.7 // 5x, * 23h initial gradient norm , d15.7 // 5x, * 23h final gradient norm , d15.7 // 5x, * 33h number of function evaluations , i10 // 5x, * 15h exit parameter, 18x, i10 // 5x, * 27h final approximate solution // (5x, 5d15.7)) 80 format (12h1summary of , i3, 16h calls to drvcr1 /) 90 format (25h nprob n nfev info , * 42h final function value final gradient norm /) 100 format (i4, i6, i7, i6, 5x, d15.7, 6x, d15.7) c c last card of driver. c end subroutine fcn(n,x,f,gvec,iflag) integer n,iflag double precision f double precision x(n),gvec(n) c ********** c c the calling sequence of fcn should be identical to the c calling sequence of the function subroutine in the c unconstrained optimizer. fcn should only call the testing c function and gradient subroutines objfcn and grdfcn with c the appropriate value of problem number (nprob). c c subprograms called c c minpack-supplied ... grdfcn,objfcn c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer nprob,nfev common /refnum/ nprob,nfev call objfcn(n,x,f,nprob) call grdfcn(n,x,gvec,nprob) nfev = nfev + 1 return c c last card of interface subroutine fcn. c end cminpack-1.3.4/examples/vec.h000644 000765 000765 00000001050 12225167750 016023 0ustar00devernay000000 000000 #ifndef __CMINPACK_HYB_H__ #define __CMINPACK_HYB_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ void hybipt(int n, __cminpack_real__ *x, int nprob, __cminpack_real__ factor); void vecfcn(int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int nprob); void vecjac(int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob); void errjac(int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __CMINPACK_HYB_H__ */ cminpack-1.3.4/examples/vecfcn.c000644 000765 000765 00000017467 12225167750 016530 0ustar00devernay000000 000000 #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ static inline real d_sign(real a, real b) { real x; x = (a >= 0 ? a : -a); return( b >= 0 ? x : -x); } static inline int max(int a, int b) { return (a > b) ? a : b; } static inline int min(int a, int b) { return (a < b) ? a : b; } void vecfcn(int n, const real *x, real *fvec, int nprob) { /* System generated locals */ real d__1, d__2; /* Local variables */ static real h__; static int i__, j, k, k1, k2, ml; static real ti, tj, tk; static int mu, kp1, iev; static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2; /* ********** */ /* subroutine vecfcn */ /* this subroutine defines fourteen test functions. the first */ /* five test functions are of dimensions 2,4,2,4,3, respectively, */ /* while the remaining test functions are of variable dimension */ /* n for any n greater than or equal to 1 (problem 6 is an */ /* exception to this, since it does not allow n = 1). */ /* the subroutine statement is */ /* subroutine vecfcn(n,x,fvec,nprob) */ /* where */ /* n is a positive integer input variable. */ /* x is an input array of length n. */ /* fvec is an output array of length n which contains the nprob */ /* function vector evaluated at x. */ /* nprob is a positive integer input variable which defines the */ /* number of the problem. nprob must not exceed 14. */ /* subprograms called */ /* fortran-supplied ... datan,dcos,dexp,dsign,dsin,dsqrt, */ /* max0,min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --fvec; --x; /* Function Body */ /* problem selector. */ switch (nprob) { case 1: goto L10; case 2: goto L20; case 3: goto L30; case 4: goto L40; case 5: goto L50; case 6: goto L60; case 7: goto L120; case 8: goto L170; case 9: goto L200; case 10: goto L220; case 11: goto L270; case 12: goto L300; case 13: goto L330; case 14: goto L350; } /* rosenbrock function. */ L10: fvec[1] = 1. - x[1]; /* Computing 2nd power */ d__1 = x[1]; fvec[2] = 10. * (x[2] - d__1 * d__1); goto L380; /* powell singular function. */ L20: fvec[1] = x[1] + 10. * x[2]; fvec[2] = sqrt(5.) * (x[3] - x[4]); /* Computing 2nd power */ d__1 = x[2] - 2. * x[3]; fvec[3] = d__1 * d__1; /* Computing 2nd power */ d__1 = x[1] - x[4]; fvec[4] = sqrt(10.) * (d__1 * d__1); goto L380; /* powell badly scaled function. */ L30: fvec[1] = 1e4 * x[1] * x[2] - 1.; fvec[2] = exp(-x[1]) + exp(-x[2]) - 1.0001; goto L380; /* wood function. */ L40: /* Computing 2nd power */ d__1 = x[1]; temp1 = x[2] - d__1 * d__1; /* Computing 2nd power */ d__1 = x[3]; temp2 = x[4] - d__1 * d__1; fvec[1] = -200. * x[1] * temp1 - (1. - x[1]); fvec[2] = 200. * temp1 + 20.2 * (x[2] - 1.) + 19.8 * (x[4] - 1.); fvec[3] = -180. * x[3] * temp2 - (1. - x[3]); fvec[4] = 180. * temp2 + 20.2 * (x[4] - 1.) + 19.8 * (x[2] - 1.); goto L380; /* helical valley function. */ L50: tpi = 8. * atan(1.); temp1 = d_sign(.25, x[2]); if (x[1] > 0.) { temp1 = atan(x[2] / x[1]) / tpi; } if (x[1] < 0.) { temp1 = atan(x[2] / x[1]) / tpi + .5; } /* Computing 2nd power */ d__1 = x[1]; /* Computing 2nd power */ d__2 = x[2]; temp2 = sqrt(d__1 * d__1 + d__2 * d__2); fvec[1] = 10. * (x[3] - 10. * temp1); fvec[2] = 10. * (temp2 - 1.); fvec[3] = x[3]; goto L380; /* watson function. */ L60: for (k = 1; k <= n; ++k) { fvec[k] = 0.; /* L70: */ } for (i__ = 1; i__ <= 29; ++i__) { ti = (real) i__ / 29.; sum1 = 0.; temp = 1.; for (j = 2; j <= n; ++j) { sum1 += (real) (j - 1) * temp * x[j]; temp = ti * temp; /* L80: */ } sum2 = 0.; temp = 1.; for (j = 1; j <= n; ++j) { sum2 += temp * x[j]; temp = ti * temp; /* L90: */ } /* Computing 2nd power */ d__1 = sum2; temp1 = sum1 - d__1 * d__1 - 1.; temp2 = 2. * ti * sum2; temp = 1. / ti; for (k = 1; k <= n; ++k) { fvec[k] += temp * ((real) (k - 1) - temp2) * temp1; temp = ti * temp; /* L100: */ } /* L110: */ } /* Computing 2nd power */ d__1 = x[1]; temp = x[2] - d__1 * d__1 - 1.; fvec[1] += x[1] * (1. - 2. * temp); fvec[2] += temp; goto L380; /* chebyquad function. */ L120: for (k = 1; k <= n; ++k) { fvec[k] = 0.; /* L130: */ } for (j = 1; j <= n; ++j) { temp1 = 1.; temp2 = 2. * x[j] - 1.; temp = 2. * temp2; for (i__ = 1; i__ <= n; ++i__) { fvec[i__] += temp2; ti = temp * temp2 - temp1; temp1 = temp2; temp2 = ti; /* L140: */ } /* L150: */ } tk = 1. / (real) (n); iev = -1; for (k = 1; k <= n; ++k) { fvec[k] = tk * fvec[k]; if (iev > 0) { /* Computing 2nd power */ d__1 = (real) k; fvec[k] += 1. / (d__1 * d__1 - 1.); } iev = -iev; /* L160: */ } goto L380; /* brown almost-linear function. */ L170: sum = -((real) (n + 1)); prod = 1.; for (j = 1; j <= n; ++j) { sum += x[j]; prod = x[j] * prod; /* L180: */ } for (k = 1; k <= n; ++k) { fvec[k] = x[k] + sum; /* L190: */ } fvec[n] = prod - 1.; goto L380; /* discrete boundary value function. */ L200: h__ = 1. / (real) (n + 1); for (k = 1; k <= n; ++k) { /* Computing 3rd power */ d__1 = x[k] + (real) k * h__ + 1.; temp = d__1 * (d__1 * d__1); temp1 = 0.; if (k != 1) { temp1 = x[k - 1]; } temp2 = 0.; if (k != n) { temp2 = x[k + 1]; } /* Computing 2nd power */ d__1 = h__; fvec[k] = 2. * x[k] - temp1 - temp2 + temp * (d__1 * d__1) / 2.; /* L210: */ } goto L380; /* discrete integral equation function. */ L220: h__ = 1. / (real) (n + 1); for (k = 1; k <= n; ++k) { tk = (real) k * h__; sum1 = 0.; for (j = 1; j <= k; ++j) { tj = (real) j * h__; /* Computing 3rd power */ d__1 = x[j] + tj + 1.; temp = d__1 * (d__1 * d__1); sum1 += tj * temp; /* L230: */ } sum2 = 0.; kp1 = k + 1; if (n < kp1) { goto L250; } for (j = kp1; j <= n; ++j) { tj = (real) j * h__; /* Computing 3rd power */ d__1 = x[j] + tj + 1.; temp = d__1 * (d__1 * d__1); sum2 += (1. - tj) * temp; /* L240: */ } L250: fvec[k] = x[k] + h__ * ((1. - tk) * sum1 + tk * sum2) / 2.; /* L260: */ } goto L380; /* trigonometric function. */ L270: sum = 0.; for (j = 1; j <= n; ++j) { fvec[j] = cos(x[j]); sum += fvec[j]; /* L280: */ } for (k = 1; k <= n; ++k) { fvec[k] = (real) (n + k) - sin(x[k]) - sum - (real) k * fvec[ k]; /* L290: */ } goto L380; /* variably dimensioned function. */ L300: sum = 0.; for (j = 1; j <= n; ++j) { sum += (real) j * (x[j] - 1.); /* L310: */ } /* Computing 2nd power */ d__1 = sum; temp = sum * (1. + 2. * (d__1 * d__1)); for (k = 1; k <= n; ++k) { fvec[k] = x[k] - 1. + (real) k * temp; /* L320: */ } goto L380; /* broyden tridiagonal function. */ L330: for (k = 1; k <= n; ++k) { temp = (3. - 2. * x[k]) * x[k]; temp1 = 0.; if (k != 1) { temp1 = x[k - 1]; } temp2 = 0.; if (k != n) { temp2 = x[k + 1]; } fvec[k] = temp - temp1 - 2. * temp2 + 1.; /* L340: */ } goto L380; /* broyden banded function. */ L350: ml = 5; mu = 1; for (k = 1; k <= n; ++k) { /* Computing MAX */ k1 = max(1,k-ml); /* Computing MIN */ k2 = min(k+mu,n); temp = 0.; for (j = k1; j <= k2; ++j) { if (j != k) { temp += x[j] * (1. + x[j]); } /* L360: */ } /* Computing 2nd power */ d__1 = x[k]; fvec[k] = x[k] * (2. + 5. * (d__1 * d__1)) + 1. - temp; /* L370: */ } L380: return; /* last card of subroutine vecfcn. */ } /* vecfcn_ */ cminpack-1.3.4/examples/vecfcn.f000644 000765 000765 00000015667 12225167750 016533 0ustar00devernay000000 000000 subroutine vecfcn(n,x,fvec,nprob) integer n,nprob double precision x(n),fvec(n) c ********** c c subroutine vecfcn c c this subroutine defines fourteen test functions. the first c five test functions are of dimensions 2,4,2,4,3, respectively, c while the remaining test functions are of variable dimension c n for any n greater than or equal to 1 (problem 6 is an c exception to this, since it does not allow n = 1). c c the subroutine statement is c c subroutine vecfcn(n,x,fvec,nprob) c c where c c n is a positive integer input variable. c c x is an input array of length n. c c fvec is an output array of length n which contains the nprob c function vector evaluated at x. c c nprob is a positive integer input variable which defines the c number of the problem. nprob must not exceed 14. c c subprograms called c c fortran-supplied ... datan,dcos,dexp,dsign,dsin,dsqrt, c max0,min0 c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,iev,ivar,j,k,k1,k2,kp1,ml,mu double precision c1,c2,c3,c4,c5,c6,c7,c8,c9,eight,five,h,one, * prod,sum,sum1,sum2,temp,temp1,temp2,ten,three, * ti,tj,tk,tpi,two,zero double precision dfloat data zero,one,two,three,five,eight,ten * /0.0d0,1.0d0,2.0d0,3.0d0,5.0d0,8.0d0,1.0d1/ data c1,c2,c3,c4,c5,c6,c7,c8,c9 * /1.0d4,1.0001d0,2.0d2,2.02d1,1.98d1,1.8d2,2.5d-1,5.0d-1, * 2.9d1/ dfloat(ivar) = ivar c c problem selector. c go to (10,20,30,40,50,60,120,170,200,220,270,300,330,350), nprob c c rosenbrock function. c 10 continue fvec(1) = one - x(1) fvec(2) = ten*(x(2) - x(1)**2) go to 380 c c powell singular function. c 20 continue fvec(1) = x(1) + ten*x(2) fvec(2) = dsqrt(five)*(x(3) - x(4)) fvec(3) = (x(2) - two*x(3))**2 fvec(4) = dsqrt(ten)*(x(1) - x(4))**2 go to 380 c c powell badly scaled function. c 30 continue fvec(1) = c1*x(1)*x(2) - one fvec(2) = dexp(-x(1)) + dexp(-x(2)) - c2 go to 380 c c wood function. c 40 continue temp1 = x(2) - x(1)**2 temp2 = x(4) - x(3)**2 fvec(1) = -c3*x(1)*temp1 - (one - x(1)) fvec(2) = c3*temp1 + c4*(x(2) - one) + c5*(x(4) - one) fvec(3) = -c6*x(3)*temp2 - (one - x(3)) fvec(4) = c6*temp2 + c4*(x(4) - one) + c5*(x(2) - one) go to 380 c c helical valley function. c 50 continue tpi = eight*datan(one) temp1 = dsign(c7,x(2)) if (x(1) .gt. zero) temp1 = datan(x(2)/x(1))/tpi if (x(1) .lt. zero) temp1 = datan(x(2)/x(1))/tpi + c8 temp2 = dsqrt(x(1)**2+x(2)**2) fvec(1) = ten*(x(3) - ten*temp1) fvec(2) = ten*(temp2 - one) fvec(3) = x(3) go to 380 c c watson function. c 60 continue do 70 k = 1, n fvec(k) = zero 70 continue do 110 i = 1, 29 ti = dfloat(i)/c9 sum1 = zero temp = one do 80 j = 2, n sum1 = sum1 + dfloat(j-1)*temp*x(j) temp = ti*temp 80 continue sum2 = zero temp = one do 90 j = 1, n sum2 = sum2 + temp*x(j) temp = ti*temp 90 continue temp1 = sum1 - sum2**2 - one temp2 = two*ti*sum2 temp = one/ti do 100 k = 1, n fvec(k) = fvec(k) + temp*(dfloat(k-1) - temp2)*temp1 temp = ti*temp 100 continue 110 continue temp = x(2) - x(1)**2 - one fvec(1) = fvec(1) + x(1)*(one - two*temp) fvec(2) = fvec(2) + temp go to 380 c c chebyquad function. c 120 continue do 130 k = 1, n fvec(k) = zero 130 continue do 150 j = 1, n temp1 = one temp2 = two*x(j) - one temp = two*temp2 do 140 i = 1, n fvec(i) = fvec(i) + temp2 ti = temp*temp2 - temp1 temp1 = temp2 temp2 = ti 140 continue 150 continue tk = one/dfloat(n) iev = -1 do 160 k = 1, n fvec(k) = tk*fvec(k) if (iev .gt. 0) fvec(k) = fvec(k) + one/(dfloat(k)**2 - one) iev = -iev 160 continue go to 380 c c brown almost-linear function. c 170 continue sum = -dfloat(n+1) prod = one do 180 j = 1, n sum = sum + x(j) prod = x(j)*prod 180 continue do 190 k = 1, n fvec(k) = x(k) + sum 190 continue fvec(n) = prod - one go to 380 c c discrete boundary value function. c 200 continue h = one/dfloat(n+1) do 210 k = 1, n temp = (x(k) + dfloat(k)*h + one)**3 temp1 = zero if (k .ne. 1) temp1 = x(k-1) temp2 = zero if (k .ne. n) temp2 = x(k+1) fvec(k) = two*x(k) - temp1 - temp2 + temp*h**2/two 210 continue go to 380 c c discrete integral equation function. c 220 continue h = one/dfloat(n+1) do 260 k = 1, n tk = dfloat(k)*h sum1 = zero do 230 j = 1, k tj = dfloat(j)*h temp = (x(j) + tj + one)**3 sum1 = sum1 + tj*temp 230 continue sum2 = zero kp1 = k + 1 if (n .lt. kp1) go to 250 do 240 j = kp1, n tj = dfloat(j)*h temp = (x(j) + tj + one)**3 sum2 = sum2 + (one - tj)*temp 240 continue 250 continue fvec(k) = x(k) + h*((one - tk)*sum1 + tk*sum2)/two 260 continue go to 380 c c trigonometric function. c 270 continue sum = zero do 280 j = 1, n fvec(j) = dcos(x(j)) sum = sum + fvec(j) 280 continue do 290 k = 1, n fvec(k) = dfloat(n+k) - dsin(x(k)) - sum - dfloat(k)*fvec(k) 290 continue go to 380 c c variably dimensioned function. c 300 continue sum = zero do 310 j = 1, n sum = sum + dfloat(j)*(x(j) - one) 310 continue temp = sum*(one + two*sum**2) do 320 k = 1, n fvec(k) = x(k) - one + dfloat(k)*temp 320 continue go to 380 c c broyden tridiagonal function. c 330 continue do 340 k = 1, n temp = (three - two*x(k))*x(k) temp1 = zero if (k .ne. 1) temp1 = x(k-1) temp2 = zero if (k .ne. n) temp2 = x(k+1) fvec(k) = temp - temp1 - two*temp2 + one 340 continue go to 380 c c broyden banded function. c 350 continue ml = 5 mu = 1 do 370 k = 1, n k1 = max0(1,k-ml) k2 = min0(k+mu,n) temp = zero do 360 j = k1, k2 if (j .ne. k) temp = temp + x(j)*(one + x(j)) 360 continue fvec(k) = x(k)*(two + five*x(k)**2) + one - temp 370 continue 380 continue return c c last card of subroutine vecfcn. c end cminpack-1.3.4/examples/vecjac.c000644 000765 000765 00000022262 12225167750 016504 0ustar00devernay000000 000000 #include #include #include "cminpack.h" #include "vec.h" #define real __cminpack_real__ static inline int max(int a, int b) { return (a > b) ? a : b; } static inline int min(int a, int b) { return (a < b) ? a : b; } void vecjac(int n, const real *x, real *fjac, int ldfjac, int nprob) { /* System generated locals */ int fjac_offset; real d__1, d__2; /* Local variables */ static real h__; static int i__, j, k, k1, k2, ml; static real ti, tj, tk; static int mu; static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2, temp3, temp4; /* ********** */ /* subroutine vecjac */ /* this subroutine defines the jacobian matrices of fourteen */ /* test functions. the problem dimensions are as described */ /* in the prologue comments of vecfcn. */ /* the subroutine statement is */ /* subroutine vecjac(n,x,fjac,ldfjac,nprob) */ /* where */ /* n is a positive integer variable. */ /* x is an array of length n. */ /* fjac is an n by n array. on output fjac contains the */ /* jacobian matrix of the nprob function evaluated at x. */ /* ldfjac is a positive integer variable not less than n */ /* which specifies the leading dimension of the array fjac. */ /* nprob is a positive integer variable which defines the */ /* number of the problem. nprob must not exceed 14. */ /* subprograms called */ /* fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, */ /* max0,min0 */ /* argonne national laboratory. minpack project. march 1980. */ /* burton s. garbow, kenneth e. hillstrom, jorge j. more */ /* ********** */ /* Parameter adjustments */ --x; fjac_offset = 1 + ldfjac; fjac -= fjac_offset; /* Function Body */ /* jacobian routine selector. */ assert(nprob >= 1 && nprob <=14); switch (nprob) { case 1: goto L10; case 2: goto L20; case 3: goto L50; case 4: goto L60; case 5: goto L90; case 6: goto L100; case 7: goto L200; case 8: goto L230; case 9: goto L290; case 10: goto L320; case 11: goto L350; case 12: goto L380; case 13: goto L420; case 14: goto L450; } /* rosenbrock function. */ L10: fjac[1 * ldfjac + 1] = -1.; fjac[2 * ldfjac + 1] = 0.; fjac[1 * ldfjac + 2] = -20. * x[1]; fjac[2 * ldfjac + 2] = 10.; goto L490; /* powell singular function. */ L20: for (k = 1; k <= 4; ++k) { for (j = 1; j <= 4; ++j) { fjac[k + j * ldfjac] = 0.; /* L30: */ } /* L40: */ } fjac[1 * ldfjac + 1] = 1.; fjac[2 * ldfjac + 1] = 10.; fjac[3 * ldfjac + 2] = sqrt(5.); fjac[4 * ldfjac + 2] = -fjac[3 * ldfjac + 2]; fjac[2 * ldfjac + 3] = 2. * (x[2] - 2. * x[3]); fjac[3 * ldfjac + 3] = -2. * fjac[2 * ldfjac + 3]; fjac[1 * ldfjac + 4] = 2. * sqrt(10.) * (x[1] - x[4]); fjac[4 * ldfjac + 4] = -fjac[1 * ldfjac + 4]; goto L490; /* powell badly scaled function. */ L50: fjac[1 * ldfjac + 1] = 1e4 * x[2]; fjac[2 * ldfjac + 1] = 1e4 * x[1]; fjac[1 * ldfjac + 2] = -exp(-x[1]); fjac[2 * ldfjac + 2] = -exp(-x[2]); goto L490; /* wood function. */ L60: for (k = 1; k <= 4; ++k) { for (j = 1; j <= 4; ++j) { fjac[k + j * ldfjac] = 0.; /* L70: */ } /* L80: */ } /* Computing 2nd power */ d__1 = x[1]; temp1 = x[2] - 3. * (d__1 * d__1); /* Computing 2nd power */ d__1 = x[3]; temp2 = x[4] - 3. * (d__1 * d__1); fjac[1 * ldfjac + 1] = -200. * temp1 + 1.; fjac[2 * ldfjac + 1] = -200. * x[1]; fjac[1 * ldfjac + 2] = -2. * 200. * x[1]; fjac[2 * ldfjac + 2] = 200. + 20.2; fjac[4 * ldfjac + 2] = 19.8; fjac[3 * ldfjac + 3] = -180. * temp2 + 1.; fjac[4 * ldfjac + 3] = -180. * x[3]; fjac[2 * ldfjac + 4] = 19.8; fjac[3 * ldfjac + 4] = -2. * 180. * x[3]; fjac[4 * ldfjac + 4] = 180. + 20.2; goto L490; /* helical valley function. */ L90: tpi = 8. * atan(1.); /* Computing 2nd power */ d__1 = x[1]; /* Computing 2nd power */ d__2 = x[2]; temp = d__1 * d__1 + d__2 * d__2; temp1 = tpi * temp; temp2 = sqrt(temp); fjac[1 * ldfjac + 1] = 100. * x[2] / temp1; fjac[2 * ldfjac + 1] = -100. * x[1] / temp1; fjac[3 * ldfjac + 1] = 10.; fjac[1 * ldfjac + 2] = 10. * x[1] / temp2; fjac[2 * ldfjac + 2] = 10. * x[2] / temp2; fjac[3 * ldfjac + 2] = 0.; fjac[1 * ldfjac + 3] = 0.; fjac[2 * ldfjac + 3] = 0.; fjac[3 * ldfjac + 3] = 1.; goto L490; /* watson function. */ L100: for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L110: */ } /* L120: */ } for (i__ = 1; i__ <= 29; ++i__) { ti = (real) i__ / 29.; sum1 = 0.; temp = 1.; for (j = 2; j <= n; ++j) { sum1 += (real) (j-1) * temp * x[j]; temp = ti * temp; /* L130: */ } sum2 = 0.; temp = 1.; for (j = 1; j <= n; ++j) { sum2 += temp * x[j]; temp = ti * temp; /* L140: */ } /* Computing 2nd power */ d__1 = sum2; temp1 = 2. * (sum1 - d__1 * d__1 - 1.); temp2 = 2. * sum2; /* Computing 2nd power */ d__1 = ti; temp = d__1 * d__1; tk = 1.; for (k = 1; k <= n; ++k) { tj = tk; for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] += tj * (((real) (k-1) / ti - temp2) * ((real) (j-1) / ti - temp2) - temp1); tj = ti * tj; /* L150: */ } tk = temp * tk; /* L160: */ } /* L170: */ } /* Computing 2nd power */ d__1 = x[1]; fjac[1 * ldfjac + 1] = fjac[1 * ldfjac + 1] + 6. * (d__1 * d__1) - 2. * x[2] + 3.; fjac[2 * ldfjac + 1] -= 2. * x[1]; fjac[2 * ldfjac + 2] += 1.; for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[j + k * ldfjac] = fjac[k + j * ldfjac]; /* L180: */ } /* L190: */ } goto L490; /* chebyquad function. */ L200: tk = 1. / (real) (n); for (j = 1; j <= n; ++j) { temp1 = 1.; temp2 = 2. * x[j] - 1.; temp = 2. * temp2; temp3 = 0.; temp4 = 2.; for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = tk * temp4; ti = 4. * temp2 + temp * temp4 - temp3; temp3 = temp4; temp4 = ti; ti = temp * temp2 - temp1; temp1 = temp2; temp2 = ti; /* L210: */ } /* L220: */ } goto L490; /* brown almost-linear function. */ L230: prod = 1.; for (j = 1; j <= n; ++j) { prod = x[j] * prod; for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = 1.; /* L240: */ } fjac[j + j * ldfjac] = 2.; /* L250: */ } for (j = 1; j <= n; ++j) { temp = x[j]; if (temp != 0.) { goto L270; } temp = 1.; prod = 1.; for (k = 1; k <= n; ++k) { if (k != j) { prod = x[k] * prod; } /* L260: */ } L270: fjac[n + j * ldfjac] = prod / temp; /* L280: */ } goto L490; /* discrete boundary value function. */ L290: h__ = 1. / (real) (n+1); for (k = 1; k <= n; ++k) { /* Computing 2nd power */ d__1 = x[k] + (real) k * h__ + 1.; temp = 3. * (d__1 * d__1); for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L300: */ } /* Computing 2nd power */ d__1 = h__; fjac[k + k * ldfjac] = 2. + temp * (d__1 * d__1) / 2.; if (k != 1) { fjac[k + (k - 1) * ldfjac] = -1.; } if (k != n) { fjac[k + (k + 1) * ldfjac] = -1.; } /* L310: */ } goto L490; /* discrete integral equation function. */ L320: h__ = 1. / (real) (n+1); for (k = 1; k <= n; ++k) { tk = (real) k * h__; for (j = 1; j <= n; ++j) { tj = (real) j * h__; /* Computing 2nd power */ d__1 = x[j] + tj + 1.; temp = 3. * (d__1 * d__1); /* Computing MIN */ d__1 = tj * (1. - tk), d__2 = tk * (1. - tj); fjac[k + j * ldfjac] = h__ * min(d__1,d__2) * temp / 2.; /* L330: */ } fjac[k + k * ldfjac] += 1.; /* L340: */ } goto L490; /* trigonometric function. */ L350: for (j = 1; j <= n; ++j) { temp = sin(x[j]); for (k = 1; k <= n; ++k) { fjac[k + j * ldfjac] = temp; /* L360: */ } fjac[j + j * ldfjac] = (real) (j+1) * temp - cos(x[j]); /* L370: */ } goto L490; /* variably dimensioned function. */ L380: sum = 0.; for (j = 1; j <= n; ++j) { sum += (real) j * (x[j] - 1.); /* L390: */ } /* Computing 2nd power */ d__1 = sum; temp = 1. + 6. * (d__1 * d__1); for (k = 1; k <= n; ++k) { for (j = k; j <= n; ++j) { fjac[k + j * ldfjac] = (real) (k*j) * temp; fjac[j + k * ldfjac] = fjac[k + j * ldfjac]; /* L400: */ } fjac[k + k * ldfjac] += 1.; /* L410: */ } goto L490; /* broyden tridiagonal function. */ L420: for (k = 1; k <= n; ++k) { for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L430: */ } fjac[k + k * ldfjac] = 3. - 4. * x[k]; if (k != 1) { fjac[k + (k - 1) * ldfjac] = -1.; } if (k != n) { fjac[k + (k + 1) * ldfjac] = -2.; } /* L440: */ } goto L490; /* broyden banded function. */ L450: ml = 5; mu = 1; for (k = 1; k <= n; ++k) { for (j = 1; j <= n; ++j) { fjac[k + j * ldfjac] = 0.; /* L460: */ } /* Computing MAX */ k1 = max(1,k-ml); /* Computing MIN */ k2 = min(k+mu,n); for (j = k1; j <= k2; ++j) { if (j != k) { fjac[k + j * ldfjac] = -(1. + 2. * x[j]); } /* L470: */ } /* Computing 2nd power */ d__1 = x[k]; fjac[k + k * ldfjac] = 2. + 15. * (d__1 * d__1); /* L480: */ } L490: return; /* last card of subroutine vecjac. */ } /* vecjac_ */ cminpack-1.3.4/examples/vecjac.f000644 000765 000765 00000017717 12225167750 016520 0ustar00devernay000000 000000 subroutine vecjac(n,x,fjac,ldfjac,nprob) integer n,ldfjac,nprob double precision x(n),fjac(ldfjac,n) c ********** c c subroutine vecjac c c this subroutine defines the jacobian matrices of fourteen c test functions. the problem dimensions are as described c in the prologue comments of vecfcn. c c the subroutine statement is c c subroutine vecjac(n,x,fjac,ldfjac,nprob) c c where c c n is a positive integer variable. c c x is an array of length n. c c fjac is an n by n array. on output fjac contains the c jacobian matrix of the nprob function evaluated at x. c c ldfjac is a positive integer variable not less than n c which specifies the leading dimension of the array fjac. c c nprob is a positive integer variable which defines the c number of the problem. nprob must not exceed 14. c c subprograms called c c fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, c max0,min0 c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,ivar,j,k,k1,k2,ml,mu double precision c1,c3,c4,c5,c6,c9,eight,fiftn,five,four,h, * hundrd,one,prod,six,sum,sum1,sum2,temp,temp1, * temp2,temp3,temp4,ten,three,ti,tj,tk,tpi, * twenty,two,zero double precision dfloat data zero,one,two,three,four,five,six,eight,ten,fiftn,twenty, * hundrd * /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,6.0d0,8.0d0,1.0d1, * 1.5d1,2.0d1,1.0d2/ data c1,c3,c4,c5,c6,c9 /1.0d4,2.0d2,2.02d1,1.98d1,1.8d2,2.9d1/ dfloat(ivar) = ivar c c jacobian routine selector. c go to (10,20,50,60,90,100,200,230,290,320,350,380,420,450), * nprob c c rosenbrock function. c 10 continue fjac(1,1) = -one fjac(1,2) = zero fjac(2,1) = -twenty*x(1) fjac(2,2) = ten go to 490 c c powell singular function. c 20 continue do 40 k = 1, 4 do 30 j = 1, 4 fjac(k,j) = zero 30 continue 40 continue fjac(1,1) = one fjac(1,2) = ten fjac(2,3) = dsqrt(five) fjac(2,4) = -fjac(2,3) fjac(3,2) = two*(x(2) - two*x(3)) fjac(3,3) = -two*fjac(3,2) fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4)) fjac(4,4) = -fjac(4,1) go to 490 c c powell badly scaled function. c 50 continue fjac(1,1) = c1*x(2) fjac(1,2) = c1*x(1) fjac(2,1) = -dexp(-x(1)) fjac(2,2) = -dexp(-x(2)) go to 490 c c wood function. c 60 continue do 80 k = 1, 4 do 70 j = 1, 4 fjac(k,j) = zero 70 continue 80 continue temp1 = x(2) - three*x(1)**2 temp2 = x(4) - three*x(3)**2 fjac(1,1) = -c3*temp1 + one fjac(1,2) = -c3*x(1) fjac(2,1) = -two*c3*x(1) fjac(2,2) = c3 + c4 fjac(2,4) = c5 fjac(3,3) = -c6*temp2 + one fjac(3,4) = -c6*x(3) fjac(4,2) = c5 fjac(4,3) = -two*c6*x(3) fjac(4,4) = c6 + c4 go to 490 c c helical valley function. c 90 continue tpi = eight*datan(one) temp = x(1)**2 + x(2)**2 temp1 = tpi*temp temp2 = dsqrt(temp) fjac(1,1) = hundrd*x(2)/temp1 fjac(1,2) = -hundrd*x(1)/temp1 fjac(1,3) = ten fjac(2,1) = ten*x(1)/temp2 fjac(2,2) = ten*x(2)/temp2 fjac(2,3) = zero fjac(3,1) = zero fjac(3,2) = zero fjac(3,3) = one go to 490 c c watson function. c 100 continue do 120 k = 1, n do 110 j = k, n fjac(k,j) = zero 110 continue 120 continue do 170 i = 1, 29 ti = dfloat(i)/c9 sum1 = zero temp = one do 130 j = 2, n sum1 = sum1 + dfloat(j-1)*temp*x(j) temp = ti*temp 130 continue sum2 = zero temp = one do 140 j = 1, n sum2 = sum2 + temp*x(j) temp = ti*temp 140 continue temp1 = two*(sum1 - sum2**2 - one) temp2 = two*sum2 temp = ti**2 tk = one do 160 k = 1, n tj = tk do 150 j = k, n fjac(k,j) = fjac(k,j) * + tj * *((dfloat(k-1)/ti - temp2) * *(dfloat(j-1)/ti - temp2) - temp1) tj = ti*tj 150 continue tk = temp*tk 160 continue 170 continue fjac(1,1) = fjac(1,1) + six*x(1)**2 - two*x(2) + three fjac(1,2) = fjac(1,2) - two*x(1) fjac(2,2) = fjac(2,2) + one do 190 k = 1, n do 180 j = k, n fjac(j,k) = fjac(k,j) 180 continue 190 continue go to 490 c c chebyquad function. c 200 continue tk = one/dfloat(n) do 220 j = 1, n temp1 = one temp2 = two*x(j) - one temp = two*temp2 temp3 = zero temp4 = two do 210 k = 1, n fjac(k,j) = tk*temp4 ti = four*temp2 + temp*temp4 - temp3 temp3 = temp4 temp4 = ti ti = temp*temp2 - temp1 temp1 = temp2 temp2 = ti 210 continue 220 continue go to 490 c c brown almost-linear function. c 230 continue prod = one do 250 j = 1, n prod = x(j)*prod do 240 k = 1, n fjac(k,j) = one 240 continue fjac(j,j) = two 250 continue do 280 j = 1, n temp = x(j) if (temp .ne. zero) go to 270 temp = one prod = one do 260 k = 1, n if (k .ne. j) prod = x(k)*prod 260 continue 270 continue fjac(n,j) = prod/temp 280 continue go to 490 c c discrete boundary value function. c 290 continue h = one/dfloat(n+1) do 310 k = 1, n temp = three*(x(k) + dfloat(k)*h + one)**2 do 300 j = 1, n fjac(k,j) = zero 300 continue fjac(k,k) = two + temp*h**2/two if (k .ne. 1) fjac(k,k-1) = -one if (k .ne. n) fjac(k,k+1) = -one 310 continue go to 490 c c discrete integral equation function. c 320 continue h = one/dfloat(n+1) do 340 k = 1, n tk = dfloat(k)*h do 330 j = 1, n tj = dfloat(j)*h temp = three*(x(j) + tj + one)**2 fjac(k,j) = h*dmin1(tj*(one-tk),tk*(one-tj))*temp/two 330 continue fjac(k,k) = fjac(k,k) + one 340 continue go to 490 c c trigonometric function. c 350 continue do 370 j = 1, n temp = dsin(x(j)) do 360 k = 1, n fjac(k,j) = temp 360 continue fjac(j,j) = dfloat(j+1)*temp - dcos(x(j)) 370 continue go to 490 c c variably dimensioned function. c 380 continue sum = zero do 390 j = 1, n sum = sum + dfloat(j)*(x(j) - one) 390 continue temp = one + six*sum**2 do 410 k = 1, n do 400 j = k, n fjac(k,j) = dfloat(k*j)*temp fjac(j,k) = fjac(k,j) 400 continue fjac(k,k) = fjac(k,k) + one 410 continue go to 490 c c broyden tridiagonal function. c 420 continue do 440 k = 1, n do 430 j = 1, n fjac(k,j) = zero 430 continue fjac(k,k) = three - four*x(k) if (k .ne. 1) fjac(k,k-1) = -one if (k .ne. n) fjac(k,k+1) = -two 440 continue go to 490 c c broyden banded function. c 450 continue ml = 5 mu = 1 do 480 k = 1, n do 460 j = 1, n fjac(k,j) = zero 460 continue k1 = max0(1,k-ml) k2 = min0(k+mu,n) do 470 j = k1, k2 if (j .ne. k) fjac(k,j) = -(one + two*x(j)) 470 continue fjac(k,k) = two + fiftn*x(k)**2 480 continue 490 continue return c c last card of subroutine vecjac. c end cminpack-1.3.4/examples/testdata/chkder.data000644 000765 000765 00000000245 12225167750 021006 0ustar00devernay000000 000000 1 2 2 4 3 2 4 4 5 3 6 9 7 7 8 10 9 10 10 10 11 10 12 10 13 10 14 10 0 0 cminpack-1.3.4/examples/testdata/hybrd.data000644 000765 000765 00000000560 12225167750 020656 0ustar00devernay000000 000000 1 2 3 2 4 3 3 2 2 4 4 3 5 3 3 6 6 2 6 9 2 7 5 3 7 6 3 7 7 3 7 8 1 7 9 1 8 10 3 8 30 1 8 40 1 9 10 3 10 1 3 10 10 3 11 10 3 12 10 3 13 10 3 14 10 3 0 0 0 cminpack-1.3.4/examples/testdata/lm.data000644 000765 000765 00000001141 12225167750 020152 0ustar00devernay000000 000000 1 5 10 1 1 5 50 1 2 5 10 1 2 5 50 1 3 5 10 1 3 5 50 1 4 2 2 3 5 3 3 3 6 4 4 3 7 2 2 3 8 3 15 3 9 4 11 3 10 3 16 2 11 6 31 3 11 9 31 3 11 12 31 3 12 3 10 1 13 2 10 1 14 4 20 3 15 1 8 3 15 8 8 1 15 9 9 1 15 10 10 1 16 10 10 3 16 30 30 1 16 40 40 1 17 5 33 1 18 11 65 1 0 0 0 0 cminpack-1.3.4/examples/ref/chkdrv.ref000644 000765 000765 00000017204 12225167750 017640 0ustar00devernay000000 000000 problem 1 with dimension 2 is F first function vector 0.2077000D+01 -0.2829290D+01 function difference vector -0.1604855D-07 0.4763690D-06 error vector 0.3644165D-01 0.1000000D+01 problem 2 with dimension 4 is F first function vector -0.8107000D+01 -0.1685995D+01 0.1874161D+01 0.1595216D+02 function difference vector 0.2138764D-06 -0.2512329D-07 -0.3578106D-07 0.4754114D-06 error vector 0.1000000D+01 0.1000000D+01 0.5678431D-01 0.1000000D+01 problem 3 with dimension 2 is F first function vector 0.1077710D+04 0.3001928D+00 function difference vector 0.3214806D-04 -0.7057517D-08 error vector 0.0000000D+00 0.0000000D+00 problem 4 with dimension 4 is T first function vector -0.5412711D+04 -0.1964946D+04 -0.4871828D+04 -0.1776943D+04 function difference vector 0.2322079D-03 0.5335169D-04 0.2089914D-03 0.4808346D-04 error vector 0.9831445D+00 0.1000000D+01 0.9658781D+00 0.1000000D+01 problem 5 with dimension 3 is F first function vector -0.5098770D+02 -0.1144166D+01 0.1230000D+00 function difference vector 0.1832842D-07 -0.1319622D-06 0.1832843D-08 error vector 0.1000000D+01 0.0000000D+00 0.1000000D+01 problem 6 with dimension 9 is F first function vector -0.5793063D+01 -0.3339075D+02 -0.3468318D+02 -0.3636873D+02 -0.3794767D+02 -0.3943133D+02 -0.4083424D+02 -0.4217079D+02 -0.4345330D+02 function difference vector 0.4515008D-06 0.8252608D-06 0.1047076D-05 0.1220878D-05 0.1363613D-05 0.1485300D-05 0.1592015D-05 0.1687697D-05 0.1775024D-05 error vector 0.0000000D+00 0.4428514D-01 0.5843401D-01 0.6994800D-01 0.7939773D-01 0.8744020D-01 0.9445016D-01 0.1006670D+00 0.1062543D+00 problem 7 with dimension 7 is F first function vector 0.3514286D-01 -0.4563467D-01 0.2193640D+00 0.2130282D+00 0.2586583D+00 0.2308881D+00 0.5919599D-01 function difference vector 0.1542483D-07 0.2060287D-07 0.2376946D-07 0.5349155D-07 0.9704076D-07 0.1576633D-06 0.2112184D-06 error vector 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 problem 8 with dimension 10 is T first function vector -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.9992853D+00 function difference vector 0.8012354D-07 0.8378923D-07 0.8012354D-07 0.8378923D-07 0.8012354D-07 0.8378923D-07 0.8012354D-07 0.8378923D-07 0.8012354D-07 0.1065044D-09 error vector 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 9 with dimension 10 is F first function vector -0.3826621D+00 0.4818555D+00 -0.5049706D+00 0.4836436D+00 -0.5032711D+00 0.4873159D+00 -0.4998232D+00 0.4940986D+00 -0.4932473D+00 0.3830850D+00 function difference vector 0.5774599D-08 -0.7078711D-08 0.7631400D-08 -0.7053519D-08 0.7658129D-08 -0.7038502D-08 0.7685262D-08 -0.7047090D-08 0.6495039D-08 -0.2818530D-08 error vector 0.3418948D-01 0.1620568D+00 0.2476906D-01 0.8244201D-01 0.1652737D-01 0.7483691D-01 0.1851528D-01 0.1034222D+00 0.3225956D-01 0.1235862D+00 problem 10 with dimension 10 is F first function vector -0.1679668D+00 0.4672854D-01 -0.2204317D+00 0.1737871D-01 -0.2284545D+00 0.2898338D-01 -0.2008946D+00 0.6905061D-01 -0.1551028D+00 0.1139911D+00 function difference vector 0.3294705D-08 0.8148107D-09 0.5413628D-08 0.2381044D-08 0.6401981D-08 0.2764787D-08 0.6166095D-08 0.1882141D-08 0.4645277D-08 0.9133732D-09 error vector 0.0000000D+00 0.3304434D-01 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.5761877D-01 problem 11 with dimension 10 is F first function vector 0.1483931D+00 -0.4650248D-01 0.1489220D+00 0.3020784D-02 0.1494510D+00 0.5254404D-01 0.1499800D+00 0.1020673D+00 0.1505090D+00 0.1515906D+00 function difference vector 0.3284537D-08 0.1864165D-08 0.3268773D-08 0.3333951D-08 0.3253009D-08 0.4803739D-08 0.3237243D-08 0.6273523D-08 0.3221478D-08 0.7743310D-08 error vector 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 problem 12 with dimension 10 is F first function vector -0.1087888D+06 -0.2175772D+06 -0.3263660D+06 -0.4351544D+06 -0.5439433D+06 -0.6527317D+06 -0.7615206D+06 -0.8703090D+06 -0.9790979D+06 -0.1087886D+07 function difference vector 0.2249654D-02 0.4499299D-02 0.6748936D-02 0.8998581D-02 0.1124822D-01 0.1349786D-01 0.1574750D-01 0.1799715D-01 0.2024678D-01 0.2249643D-01 error vector 0.2027917D-01 0.2027908D-01 0.2027913D-01 0.2027909D-01 0.2027912D-01 0.2027910D-01 0.2027912D-01 0.2027910D-01 0.2027912D-01 0.2027910D-01 problem 13 with dimension 10 is T first function vector -0.3137258D+01 0.1997420D+00 -0.2260258D+01 0.1997420D+00 -0.2260258D+01 0.1997420D+00 -0.2260258D+01 0.1997420D+00 -0.2260258D+01 -0.2046258D+01 function difference vector 0.9923452D-07 0.3484660D-07 0.8616620D-07 0.3484660D-07 0.8616620D-07 0.3484660D-07 0.8616620D-07 0.3484660D-07 0.8616620D-07 0.6831461D-07 error vector 0.1000000D+01 0.8322908D+00 0.1000000D+01 0.8322908D+00 0.1000000D+01 0.8322908D+00 0.1000000D+01 0.8322908D+00 0.1000000D+01 0.9578359D+00 problem 14 with dimension 10 is F first function vector -0.8219368D+01 -0.4402889D+01 -0.8249626D+01 -0.4433147D+01 -0.8279884D+01 -0.4463405D+01 -0.8172013D+01 -0.4463405D+01 -0.8172013D+01 -0.4325276D+01 function difference vector 0.3598776D-06 0.2186061D-06 0.3905817D-06 0.2493102D-06 0.4212857D-06 0.2800143D-06 0.4311393D-06 0.2800143D-06 0.4311393D-06 0.2591637D-06 error vector 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 1summary of 14 tests of chkder nprob n status errmin errmax 1 2 F 0.3644165D-01 0.1000000D+01 2 4 F 0.5678431D-01 0.1000000D+01 3 2 F 0.0000000D+00 0.0000000D+00 4 4 T 0.9658781D+00 0.1000000D+01 5 3 F 0.0000000D+00 0.1000000D+01 6 9 F 0.0000000D+00 0.1062543D+00 7 7 F 0.0000000D+00 0.0000000D+00 8 10 T 0.1000000D+01 0.1000000D+01 9 10 F 0.1652737D-01 0.1620568D+00 10 10 F 0.0000000D+00 0.5761877D-01 11 10 F 0.0000000D+00 0.0000000D+00 12 10 F 0.2027908D-01 0.2027917D-01 13 10 T 0.8322908D+00 0.1000000D+01 14 10 F 0.0000000D+00 0.0000000D+00 cminpack-1.3.4/examples/ref/chkdrvc.ref000644 000765 000765 00000017205 12225167750 020004 0ustar00devernay000000 000000 problem 1 with dimension 2 is F first function vector 2.0770000e+00 -2.8292900e+00 function difference vector -1.6048551e-08 4.7636896e-07 error vector 3.6441652e-02 1.0000000e+00 problem 2 with dimension 4 is F first function vector -8.1070000e+00 -1.6859953e+00 1.8741610e+00 1.5952160e+01 function difference vector 2.1387637e-07 -2.5123287e-08 -3.5781055e-08 4.7541143e-07 error vector 1.0000000e+00 1.0000000e+00 5.6784314e-02 1.0000000e+00 problem 3 with dimension 2 is F first function vector 1.0777100e+03 3.0019279e-01 function difference vector 3.2148063e-05 -7.0575175e-09 error vector 0.0000000e+00 0.0000000e+00 problem 4 with dimension 4 is T first function vector -5.4127112e+03 -1.9649458e+03 -4.8718278e+03 -1.7769432e+03 function difference vector 2.3220785e-04 5.3351694e-05 2.0899135e-04 4.8083460e-05 error vector 9.8314445e-01 1.0000000e+00 9.6587806e-01 1.0000000e+00 problem 5 with dimension 3 is F first function vector -5.0987696e+01 -1.1441658e+00 1.2300000e-01 function difference vector 1.8328421e-08 -1.3196221e-07 1.8328428e-09 error vector 1.0000000e+00 0.0000000e+00 1.0000000e+00 problem 6 with dimension 9 is F first function vector -5.7930631e+00 -3.3390751e+01 -3.4683179e+01 -3.6368725e+01 -3.7947668e+01 -3.9431326e+01 -4.0834243e+01 -4.2170791e+01 -4.3453299e+01 function difference vector 4.5150085e-07 8.2526081e-07 1.0470759e-06 1.2208782e-06 1.3636127e-06 1.4852995e-06 1.5920150e-06 1.6876970e-06 1.7750240e-06 error vector 0.0000000e+00 4.4776909e-02 5.8948123e-02 7.0484722e-02 7.9955256e-02 8.8016532e-02 9.5043433e-02 1.0127560e-01 1.0687673e-01 problem 7 with dimension 7 is F first function vector 3.5142857e-02 -4.5634667e-02 2.1936396e-01 2.1302816e-01 2.5865828e-01 2.3088814e-01 5.9195986e-02 function difference vector 1.5424831e-08 2.0602874e-08 2.3769456e-08 5.3491546e-08 9.7040762e-08 1.5766330e-07 2.1121844e-07 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 8 with dimension 10 is T first function vector -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -9.9928526e-01 function difference vector 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 1.0650436e-10 error vector 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 with dimension 10 is F first function vector -3.8266208e-01 4.8185552e-01 -5.0497059e-01 4.8364359e-01 -5.0327111e-01 4.8731586e-01 -4.9982317e-01 4.9409864e-01 -4.9324735e-01 3.8308496e-01 function difference vector 5.7745994e-09 -7.0787115e-09 7.6314004e-09 -7.0535194e-09 7.6581295e-09 -7.0385017e-09 7.6852619e-09 -7.0470895e-09 6.4950392e-09 -2.8185304e-09 error vector 3.4189481e-02 1.6205676e-01 2.4769060e-02 8.2442013e-02 1.6527366e-02 7.4836913e-02 1.8515282e-02 1.0342218e-01 3.2259557e-02 1.2358623e-01 problem 10 with dimension 10 is F first function vector -1.6796677e-01 4.6728538e-02 -2.2043167e-01 1.7378706e-02 -2.2845451e-01 2.8983382e-02 -2.0089459e-01 6.9050605e-02 -1.5510284e-01 1.1399106e-01 function difference vector 3.2947051e-09 8.1481072e-10 5.4136278e-09 2.3810444e-09 6.4019805e-09 2.7647869e-09 6.1660951e-09 1.8821412e-09 4.6452768e-09 9.1337315e-10 error vector 0.0000000e+00 8.3217918e-03 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 4.4819193e-02 problem 11 with dimension 10 is F first function vector 1.4839305e-01 -4.6502477e-02 1.4892203e-01 3.0207835e-03 1.4945101e-01 5.2544044e-02 1.4997998e-01 1.0206730e-01 1.5050896e-01 1.5159056e-01 function difference vector 3.2845368e-09 1.8641646e-09 3.2687728e-09 3.3339513e-09 3.2530085e-09 4.8037387e-09 3.2372434e-09 6.2735230e-09 3.2214782e-09 7.7433100e-09 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 12 with dimension 10 is F first function vector -1.0878876e+05 -2.1757715e+05 -3.2636603e+05 -4.3515443e+05 -5.4394331e+05 -6.5273170e+05 -7.6152058e+05 -8.7030898e+05 -9.7909786e+05 -1.0878862e+06 function difference vector 2.2496541e-03 4.4992989e-03 6.7489363e-03 8.9985810e-03 1.1248218e-02 1.3497863e-02 1.5747500e-02 1.7997145e-02 2.0246784e-02 2.2496427e-02 error vector 2.0279172e-02 2.0279078e-02 2.0279130e-02 2.0279094e-02 2.0279122e-02 2.0279099e-02 2.0279119e-02 2.0279101e-02 2.0279116e-02 2.0279103e-02 problem 13 with dimension 10 is T first function vector -3.1372580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 -2.0462580e+00 function difference vector 9.9234522e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 6.8314610e-08 error vector 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 9.5783592e-01 problem 14 with dimension 10 is F first function vector -8.2193683e+00 -4.4028887e+00 -8.2496263e+00 -4.4331467e+00 -8.2798843e+00 -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252757e+00 function difference vector 3.5987758e-07 2.1860611e-07 3.9058166e-07 2.4931019e-07 4.2128574e-07 2.8001427e-07 4.3113925e-07 2.8001427e-07 4.3113925e-07 2.5916370e-07 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 summary of 14 tests of chkder nprob n status errmin errmax 1 2 F 3.6441652e-02 1.0000000e+00 2 4 F 5.6784314e-02 1.0000000e+00 3 2 F 0.0000000e+00 0.0000000e+00 4 4 T 9.6587806e-01 1.0000000e+00 5 3 F 0.0000000e+00 1.0000000e+00 6 9 F 0.0000000e+00 1.0687673e-01 7 7 F 0.0000000e+00 0.0000000e+00 8 10 T 1.0000000e+00 1.0000000e+00 9 10 F 1.6527366e-02 1.6205676e-01 10 10 F 0.0000000e+00 4.4819193e-02 11 10 F 0.0000000e+00 0.0000000e+00 12 10 F 2.0279078e-02 2.0279172e-02 13 10 T 8.3229083e-01 1.0000000e+00 14 10 F 0.0000000e+00 0.0000000e+00 cminpack-1.3.4/examples/ref/hchkdrvc.ref000644 000765 000765 00000017205 12303616324 020145 0ustar00devernay000000 000000 problem 1 with dimension 2 is F first function vector 2.0781250e+00 -2.8320312e+00 function difference vector -3.5156250e-02 9.7656250e-01 error vector 0.0000000e+00 5.4150391e-01 problem 2 with dimension 4 is F first function vector -8.1093750e+00 -1.6855469e+00 1.8750000e+00 1.5953125e+01 function difference vector 4.5312500e-01 -5.2734375e-02 -7.4218750e-02 1.0156250e+00 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 3 with dimension 2 is F first function vector 1.0780000e+03 3.0029297e-01 function difference vector 6.8000000e+01 -1.4648438e-02 error vector 0.0000000e+00 0.0000000e+00 problem 4 with dimension 4 is T first function vector -5.4120000e+03 -1.9650000e+03 -4.8720000e+03 -1.7770000e+03 function difference vector 4.6800000e+02 1.1000000e+02 4.2400000e+02 9.9000000e+01 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 5 with dimension 3 is F first function vector -5.0968750e+01 -1.1425781e+00 1.2298584e-01 function difference vector 3.1250000e-02 -2.7832031e-01 3.8452148e-03 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 6 with dimension 9 is F first function vector -5.7968750e+00 -3.3406250e+01 -3.4687500e+01 -3.6375000e+01 -3.7937500e+01 -3.9406250e+01 -4.0812500e+01 -4.2156250e+01 -4.3437500e+01 function difference vector 8.9843750e-01 1.6718750e+00 2.1562500e+00 2.5312500e+00 2.8125000e+00 3.0312500e+00 3.2500000e+00 3.4687500e+00 3.6562500e+00 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 7 with dimension 7 is F first function vector 3.5156250e-02 -4.5562744e-02 2.1936035e-01 2.1313477e-01 2.5878906e-01 2.3120117e-01 5.9967041e-02 function difference vector 3.2348633e-02 4.6386719e-02 5.8959961e-02 1.3500977e-01 2.5927734e-01 4.5629883e-01 6.9824219e-01 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 8 with dimension 10 is T first function vector -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -9.9951172e-01 function difference vector 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 1.7187500e-01 4.8828125e-04 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 9 with dimension 10 is F first function vector -3.8256836e-01 4.8193359e-01 -5.0488281e-01 4.8364258e-01 -5.0292969e-01 4.8730469e-01 -4.9975586e-01 4.9414062e-01 -4.9316406e-01 3.8256836e-01 function difference vector 1.2207031e-02 -1.4892578e-02 1.5869141e-02 -1.4648438e-02 1.5625000e-02 -1.4648438e-02 1.5869141e-02 -1.4648438e-02 1.3671875e-02 -5.8593750e-03 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 10 with dimension 10 is F first function vector -1.6784668e-01 4.6783447e-02 -2.2033691e-01 1.7379761e-02 -2.2839355e-01 2.8976440e-02 -2.0092773e-01 6.8969727e-02 -1.5515137e-01 1.1395264e-01 function difference vector 6.9580078e-03 1.7089844e-03 1.1230469e-02 5.0659180e-03 1.3427734e-02 5.8441162e-03 1.2939453e-02 4.0893555e-03 9.7656250e-03 1.8920898e-03 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 11 with dimension 10 is F first function vector 1.4843750e-01 -4.6264648e-02 1.4941406e-01 3.5495758e-03 1.5039062e-01 5.3344727e-02 1.5136719e-01 1.0314941e-01 1.5234375e-01 1.5295410e-01 function difference vector 7.2021484e-03 3.9672852e-03 7.2021484e-03 6.8969727e-03 7.2021484e-03 9.8266602e-03 7.2021484e-03 1.2756348e-02 7.2021484e-03 1.5747070e-02 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 12 with dimension 10 is F first function vector -inf -inf -inf -inf -inf -inf -inf -inf -inf -inf function difference vector -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 13 with dimension 10 is T first function vector -3.1367188e+00 2.0117188e-01 -2.2597656e+00 2.0117188e-01 -2.2597656e+00 2.0117188e-01 -2.2597656e+00 2.0117188e-01 -2.2597656e+00 -2.0449219e+00 function difference vector 2.0703125e-01 7.0312500e-02 1.7968750e-01 7.0312500e-02 1.7968750e-01 7.0312500e-02 1.7968750e-01 7.0312500e-02 1.7968750e-01 1.4062500e-01 error vector 0.0000000e+00 4.7924805e-01 0.0000000e+00 4.7924805e-01 0.0000000e+00 4.7924805e-01 0.0000000e+00 4.7924805e-01 0.0000000e+00 0.0000000e+00 problem 14 with dimension 10 is F first function vector -8.2187500e+00 -4.4023438e+00 -8.2500000e+00 -4.4335938e+00 -8.2812500e+00 -4.4648438e+00 -8.1718750e+00 -4.4648438e+00 -8.1718750e+00 -4.3242188e+00 function difference vector 7.3437500e-01 4.4531250e-01 7.9687500e-01 5.0976562e-01 8.5937500e-01 5.7226562e-01 8.7890625e-01 5.7226562e-01 8.7890625e-01 5.2734375e-01 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 summary of 14 tests of chkder nprob n status errmin errmax 1 2 F 0.0000000e+00 5.4150391e-01 2 4 F 0.0000000e+00 0.0000000e+00 3 2 F 0.0000000e+00 0.0000000e+00 4 4 T 0.0000000e+00 0.0000000e+00 5 3 F 0.0000000e+00 0.0000000e+00 6 9 F 0.0000000e+00 0.0000000e+00 7 7 F 0.0000000e+00 0.0000000e+00 8 10 T 0.0000000e+00 0.0000000e+00 9 10 F 0.0000000e+00 0.0000000e+00 10 10 F 0.0000000e+00 0.0000000e+00 11 10 F 0.0000000e+00 0.0000000e+00 12 10 F 0.0000000e+00 0.0000000e+00 13 10 T 0.0000000e+00 4.7924805e-01 14 10 F 0.0000000e+00 0.0000000e+00 cminpack-1.3.4/examples/ref/hhybdrvc.ref000644 000765 000765 00000067234 12303616324 020171 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9257812e+00 final l2 norm of the residuals 1.9531250e-02 number of function evaluations 24 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 1.0000000e+00 1.0019531e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution -1.2000000e+02 1.0000000e+02 problem 2 dimension 4 initial l2 norm of the residuals 1.4664062e+01 final l2 norm of the residuals 5.9604645e-08 number of function evaluations 27 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 3.9398670e-05 -3.9339066e-06 1.3136864e-04 1.3136864e-04 problem 2 dimension 4 initial l2 norm of the residuals 1.2710000e+03 final l2 norm of the residuals 5.9604645e-08 number of function evaluations 42 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 2.4199486e-04 -2.4199486e-05 1.2278557e-04 1.2278557e-04 problem 2 dimension 4 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 3.0000000e+02 -1.0000000e+02 0.0000000e+00 1.0000000e+02 problem 3 dimension 2 initial l2 norm of the residuals 1.0654297e+00 final l2 norm of the residuals 1.3038635e-02 number of function evaluations 18 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 2.0861626e-05 4.8437500e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 0.0000000e+00 1.0000000e+01 problem 4 dimension 4 initial l2 norm of the residuals 8.5520000e+03 final l2 norm of the residuals 2.2497559e-01 number of function evaluations 27 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.0146484e+00 1.0390625e+00 -9.1943359e-01 8.5644531e-01 problem 4 dimension 4 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution -3.0000000e+01 -1.0000000e+01 -3.0000000e+01 -1.0000000e+01 problem 4 dimension 4 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution -3.0000000e+02 -1.0000000e+02 -3.0000000e+02 -1.0000000e+02 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 6.1416626e-04 number of function evaluations 14 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 3.8504601e-05 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 1.0293750e+02 final l2 norm of the residuals 3.2005310e-03 number of function evaluations 15 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 -2.0122528e-04 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9150000e+02 final l2 norm of the residuals 9.9150000e+02 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution -1.0000000e+02 0.0000000e+00 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8500000e+01 final l2 norm of the residuals 5.3680420e-02 number of function evaluations 30 number of Jacobian evaluations 4 exit parameter 1 final approximate solution -7.9956055e-02 9.8291016e-01 7.4584961e-02 7.9101562e-02 -4.6020508e-02 2.9980469e-01 problem 6 dimension 6 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 problem 6 dimension 9 initial l2 norm of the residuals 8.8812500e+01 final l2 norm of the residuals 6.9238281e-01 number of function evaluations 10 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.9877930e-01 1.1533203e+00 -1.5771484e-01 3.0200195e-01 -9.1943359e-01 2.5439453e-01 1.1259766e+00 -5.5029297e-01 -1.1822510e-01 problem 6 dimension 9 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 problem 7 dimension 5 initial l2 norm of the residuals 2.2570801e-01 final l2 norm of the residuals 1.1070251e-02 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 8.1665039e-02 3.1494141e-01 4.9877930e-01 6.8847656e-01 9.1552734e-01 problem 7 dimension 5 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.6660156e+00 3.3320312e+00 5.0000000e+00 6.6640625e+00 8.3281250e+00 problem 7 dimension 5 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.6656250e+01 3.3312500e+01 5.0000000e+01 6.6625000e+01 8.3312500e+01 problem 7 dimension 6 initial l2 norm of the residuals 2.1533203e-01 final l2 norm of the residuals 5.9890747e-03 number of function evaluations 11 number of Jacobian evaluations 1 exit parameter 3 final approximate solution 6.6955566e-02 3.6621094e-01 2.8930664e-01 7.1386719e-01 6.3085938e-01 9.3261719e-01 problem 7 dimension 6 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.4277344e+00 2.8554688e+00 4.2851562e+00 5.7109375e+00 7.1406250e+00 8.5703125e+00 problem 7 dimension 6 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.4281250e+01 2.8562500e+01 4.2843750e+01 5.7125000e+01 7.1375000e+01 8.5687500e+01 problem 7 dimension 7 initial l2 norm of the residuals 1.8371582e-01 final l2 norm of the residuals 1.6342163e-02 number of function evaluations 10 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 5.4992676e-02 2.3327637e-01 3.4179688e-01 4.9951172e-01 6.6601562e-01 7.6123047e-01 9.4335938e-01 problem 7 dimension 7 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+00 2.5000000e+00 3.7500000e+00 5.0000000e+00 6.2500000e+00 7.5000000e+00 8.7500000e+00 problem 7 dimension 7 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+01 2.5000000e+01 3.7500000e+01 5.0000000e+01 6.2500000e+01 7.5000000e+01 8.7500000e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9628906e-01 final l2 norm of the residuals 1.2432861e-01 number of function evaluations 9 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 6.5917969e-02 2.1032715e-01 2.9589844e-01 4.8583984e-01 5.1171875e-01 7.4121094e-01 7.5390625e-01 9.3701172e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.7041016e-01 final l2 norm of the residuals 1.5783691e-01 number of function evaluations 8 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 9.1308594e-02 2.0617676e-01 2.7783203e-01 4.1113281e-01 5.2929688e-01 5.6054688e-01 7.5488281e-01 7.5732422e-01 9.1162109e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6531250e+01 final l2 norm of the residuals 1.6531250e+01 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 8 dimension 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 8 dimension 30 initial l2 norm of the residuals 8.3500000e+01 final l2 norm of the residuals 8.3500000e+01 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 8 dimension 40 initial l2 norm of the residuals 1.2800000e+02 final l2 norm of the residuals 1.2800000e+02 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 9 dimension 10 initial l2 norm of the residuals 2.7954102e-02 final l2 norm of the residuals 2.2244453e-04 number of function evaluations 3 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3121338e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01 -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2636719e-01 final l2 norm of the residuals 1.9133091e-04 number of function evaluations 5 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3212891e-02 -8.1665039e-02 -1.1462402e-01 -1.4111328e-01 -1.6003418e-01 -1.7004395e-01 -1.6931152e-01 -1.5539551e-01 -1.2548828e-01 -7.5500488e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0650000e+02 final l2 norm of the residuals 2.2244453e-04 number of function evaluations 16 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.3121338e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01 -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 1.2207031e-04 number of function evaluations 3 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5283203e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 2.4414062e-04 number of function evaluations 5 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5270996e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3600000e+02 final l2 norm of the residuals 1.2207031e-04 number of function evaluations 15 number of Jacobian evaluations 1 exit parameter 3 final approximate solution -1.5283203e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5195312e-01 final l2 norm of the residuals 2.7704239e-04 number of function evaluations 3 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3182373e-02 -8.1542969e-02 -1.1444092e-01 -1.4099121e-01 -1.5991211e-01 -1.6979980e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1171875e+00 final l2 norm of the residuals 1.2266636e-04 number of function evaluations 5 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3151855e-02 -8.1542969e-02 -1.1450195e-01 -1.4099121e-01 -1.5991211e-01 -1.6992188e-01 -1.6918945e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2690000e+03 final l2 norm of the residuals 8.2244873e-03 number of function evaluations 24 number of Jacobian evaluations 1 exit parameter 3 final approximate solution -4.3670654e-02 -8.2580566e-02 -1.1621094e-01 -1.4331055e-01 -1.6381836e-01 -1.7346191e-01 -1.7150879e-01 -1.5637207e-01 -1.2585449e-01 -7.5805664e-02 problem 11 dimension 10 initial l2 norm of the residuals 9.3688965e-02 final l2 norm of the residuals 3.0574799e-03 number of function evaluations 21 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 4.6691895e-02 4.7637939e-02 4.8767090e-02 5.1727295e-02 5.3161621e-02 5.4443359e-02 5.9356689e-02 1.8859863e-01 1.5747070e-01 1.3061523e-01 problem 11 dimension 10 initial l2 norm of the residuals 2.0296875e+01 final l2 norm of the residuals 4.3975830e-02 number of function evaluations 40 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 8.6730957e-02 9.1979980e-02 1.0479736e-01 1.0754395e-01 1.2060547e-01 1.5197754e-01 1.5332031e-01 1.3061523e-01 1.4758301e-01 1.0601807e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3437500e+01 final l2 norm of the residuals 4.2148438e+00 number of function evaluations 7 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.7531250e+01 1.2921875e+01 1.2656250e+01 1.2718750e+01 1.2796875e+01 1.2718750e+01 1.2703125e+01 1.2437500e+01 1.2507812e+01 1.3062500e+01 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 8.9990234e-01 7.9980469e-01 7.0019531e-01 6.0009766e-01 5.0000000e-01 4.0014648e-01 3.0029297e-01 2.0019531e-01 1.0021973e-01 2.4414062e-04 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 9.0000000e+00 8.0000000e+00 7.0000000e+00 6.0000000e+00 5.0000000e+00 4.0000000e+00 3.0039062e+00 2.0019531e+00 1.0019531e+00 2.4414062e-03 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 9.0000000e+01 8.0000000e+01 7.0000000e+01 6.0000000e+01 5.0000000e+01 4.0000000e+01 3.0031250e+01 2.0015625e+01 1.0023438e+01 2.4414062e-02 problem 13 dimension 10 initial l2 norm of the residuals 4.5820312e+00 final l2 norm of the residuals 5.9394836e-03 number of function evaluations 5 number of Jacobian evaluations 1 exit parameter 3 final approximate solution -5.7031250e-01 -6.8164062e-01 -7.0166016e-01 -7.0507812e-01 -7.0458984e-01 -7.0117188e-01 -6.9189453e-01 -6.6650391e-01 -5.9667969e-01 -4.1699219e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3900000e+02 final l2 norm of the residuals 4.8599243e-03 number of function evaluations 22 number of Jacobian evaluations 2 exit parameter 3 final approximate solution -5.7080078e-01 -6.8212891e-01 -7.0263672e-01 -7.0556641e-01 -7.0507812e-01 -7.0117188e-01 -6.9189453e-01 -6.6552734e-01 -5.9619141e-01 -4.1650391e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3392000e+04 final l2 norm of the residuals 7.7018738e-03 number of function evaluations 17 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -5.7080078e-01 -6.8164062e-01 -7.0214844e-01 -7.0556641e-01 -7.0507812e-01 -7.0166016e-01 -6.9189453e-01 -6.6601562e-01 -5.9619141e-01 -4.1503906e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8968750e+01 final l2 norm of the residuals 6.0157776e-03 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.2895508e-01 -4.7656250e-01 -5.1953125e-01 -5.5810547e-01 -5.9277344e-01 -6.2451172e-01 -6.2304688e-01 -6.2158203e-01 -6.2060547e-01 -5.8593750e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7136000e+04 final l2 norm of the residuals 4.2358398e-02 number of function evaluations 17 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.3579102e-01 -4.7973633e-01 -5.2099609e-01 -5.5908203e-01 -5.9326172e-01 -6.2548828e-01 -6.2402344e-01 -6.2207031e-01 -6.2060547e-01 -5.8642578e-01 problem 14 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 summary of 55 calls to hybrd1 nprob n nfev njev info final l2 norm 1 2 24 5 1 1.9531250e-02 1 2 8 1 1 0.0000000e+00 1 2 11 2 4 inf 2 4 27 3 1 5.9604645e-08 2 4 42 5 1 5.9604645e-08 2 4 11 2 4 inf 3 2 18 3 1 1.3038635e-02 3 2 11 2 4 1.0000000e+00 4 4 27 2 1 2.2497559e-01 4 4 11 2 4 -nan 4 4 11 2 4 -nan 5 3 14 3 1 6.1416626e-04 5 3 15 3 1 3.2005310e-03 5 3 11 2 4 9.9150000e+02 6 6 30 4 1 5.3680420e-02 6 6 11 2 4 -nan 6 9 10 2 1 6.9238281e-01 6 9 11 2 4 -nan 7 5 6 1 1 1.1070251e-02 7 5 11 2 4 -nan 7 5 11 2 4 nan 7 6 11 1 3 5.9890747e-03 7 6 11 2 4 nan 7 6 11 2 4 nan 7 7 10 2 1 1.6342163e-02 7 7 11 2 4 nan 7 7 11 2 4 nan 7 8 9 2 1 1.2432861e-01 7 9 8 2 1 1.5783691e-01 8 10 11 2 4 1.6531250e+01 8 10 11 2 4 inf 8 10 11 2 4 inf 8 30 11 2 4 8.3500000e+01 8 40 11 2 4 1.2800000e+02 9 10 3 1 1 2.2244453e-04 9 10 5 1 1 1.9133091e-04 9 10 16 2 1 2.2244453e-04 10 1 3 1 1 1.2207031e-04 10 1 5 1 1 2.4414062e-04 10 1 15 1 3 1.2207031e-04 10 10 3 1 1 2.7704239e-04 10 10 5 1 1 1.2266636e-04 10 10 24 1 3 8.2244873e-03 11 10 21 3 1 3.0574799e-03 11 10 40 6 1 4.3975830e-02 11 10 7 2 1 4.2148438e+00 12 10 11 2 4 -nan 12 10 11 2 4 -nan 12 10 11 2 4 -nan 13 10 5 1 3 5.9394836e-03 13 10 22 2 3 4.8599243e-03 13 10 17 2 1 7.7018738e-03 14 10 8 1 1 6.0157776e-03 14 10 17 2 1 4.2358398e-02 14 10 11 2 4 -nan cminpack-1.3.4/examples/ref/hhyjdrvc.ref000644 000765 000765 00000067234 12303616324 020201 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9257812e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution -1.2000000e+02 1.0000000e+02 problem 2 dimension 4 initial l2 norm of the residuals 1.4664062e+01 final l2 norm of the residuals 5.9604645e-08 number of function evaluations 28 number of jacobian evaluations 3 exit parameter 1 final approximate solution 2.3245811e-04 -2.3245811e-05 1.2421608e-04 1.2421608e-04 problem 2 dimension 4 initial l2 norm of the residuals 1.2710000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 27 number of jacobian evaluations 2 exit parameter 1 final approximate solution 4.4107437e-05 -4.4107437e-06 -4.3332577e-05 -4.3332577e-05 problem 2 dimension 4 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 3.0000000e+02 -1.0000000e+02 0.0000000e+00 1.0000000e+02 problem 3 dimension 2 initial l2 norm of the residuals 1.0654297e+00 final l2 norm of the residuals 1.1634827e-02 number of function evaluations 25 number of jacobian evaluations 3 exit parameter 1 final approximate solution 2.1219254e-05 4.7500000e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 0.0000000e+00 1.0000000e+01 problem 4 dimension 4 initial l2 norm of the residuals 8.5520000e+03 final l2 norm of the residuals 1.7578125e-01 number of function evaluations 20 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.0009766e+00 1.0126953e+00 -9.3212891e-01 8.8085938e-01 problem 4 dimension 4 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution -3.0000000e+01 -1.0000000e+01 -3.0000000e+01 -1.0000000e+01 problem 4 dimension 4 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution -3.0000000e+02 -1.0000000e+02 -3.0000000e+02 -1.0000000e+02 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 2.1667480e-02 number of function evaluations 14 number of jacobian evaluations 3 exit parameter 1 final approximate solution 9.9902344e-01 -1.2130737e-03 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 1.0293750e+02 final l2 norm of the residuals 2.1877289e-03 number of function evaluations 17 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.3732910e-04 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9150000e+02 final l2 norm of the residuals 1.5129089e-02 number of function evaluations 35 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.0000000e+00 9.4985962e-04 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8500000e+01 final l2 norm of the residuals 1.9433594e-01 number of function evaluations 24 number of jacobian evaluations 3 exit parameter 1 final approximate solution -2.1740723e-01 1.0429688e+00 -2.0837402e-01 3.9892578e-01 -2.4902344e-01 2.3168945e-01 problem 6 dimension 6 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 problem 6 dimension 9 initial l2 norm of the residuals 8.8812500e+01 final l2 norm of the residuals 1.5661621e-01 number of function evaluations 25 number of jacobian evaluations 3 exit parameter 1 final approximate solution -1.4855957e-01 1.0234375e+00 -1.9287109e-01 4.7631836e-01 -2.0031738e-01 1.2042236e-01 1.6296387e-02 2.5619507e-02 1.8493652e-02 problem 6 dimension 9 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 problem 7 dimension 5 initial l2 norm of the residuals 2.2570801e-01 final l2 norm of the residuals 9.3231201e-03 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 1 final approximate solution 8.3007812e-02 3.1298828e-01 5.0097656e-01 6.8505859e-01 9.1748047e-01 problem 7 dimension 5 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.6660156e+00 3.3320312e+00 5.0000000e+00 6.6640625e+00 8.3281250e+00 problem 7 dimension 5 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.6656250e+01 3.3312500e+01 5.0000000e+01 6.6625000e+01 8.3312500e+01 problem 7 dimension 6 initial l2 norm of the residuals 2.1533203e-01 final l2 norm of the residuals 1.2006760e-03 number of function evaluations 9 number of jacobian evaluations 2 exit parameter 1 final approximate solution 6.6894531e-02 3.6645508e-01 2.8881836e-01 7.1093750e-01 6.3378906e-01 9.3310547e-01 problem 7 dimension 6 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.4277344e+00 2.8554688e+00 4.2851562e+00 5.7109375e+00 7.1406250e+00 8.5703125e+00 problem 7 dimension 6 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.4281250e+01 2.8562500e+01 4.2843750e+01 5.7125000e+01 7.1375000e+01 8.5687500e+01 problem 7 dimension 7 initial l2 norm of the residuals 1.8371582e-01 final l2 norm of the residuals 2.4414062e-02 number of function evaluations 4 number of jacobian evaluations 1 exit parameter 3 final approximate solution 6.2988281e-02 2.4389648e-01 3.3374023e-01 5.0000000e-01 6.6552734e-01 7.5634766e-01 9.3701172e-01 problem 7 dimension 7 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+00 2.5000000e+00 3.7500000e+00 5.0000000e+00 6.2500000e+00 7.5000000e+00 8.7500000e+00 problem 7 dimension 7 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+01 2.5000000e+01 3.7500000e+01 5.0000000e+01 6.2500000e+01 7.5000000e+01 8.7500000e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9628906e-01 final l2 norm of the residuals 1.5234375e-01 number of function evaluations 7 number of jacobian evaluations 2 exit parameter 1 final approximate solution 6.0668945e-02 1.9433594e-01 3.1909180e-01 4.3750000e-01 5.6396484e-01 6.7724609e-01 8.0810547e-01 9.3847656e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.7041016e-01 final l2 norm of the residuals 1.6394043e-01 number of function evaluations 6 number of jacobian evaluations 2 exit parameter 1 final approximate solution 4.4769287e-02 1.8212891e-01 2.8344727e-01 3.8452148e-01 5.0878906e-01 6.0009766e-01 7.2509766e-01 8.1591797e-01 9.5410156e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6531250e+01 final l2 norm of the residuals 1.6531250e+01 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 8 dimension 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 8 dimension 30 initial l2 norm of the residuals 8.3500000e+01 final l2 norm of the residuals 8.3500000e+01 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 8 dimension 40 initial l2 norm of the residuals 1.2800000e+02 final l2 norm of the residuals 1.2800000e+02 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 5.0000000e-01 problem 9 dimension 10 initial l2 norm of the residuals 2.7954102e-02 final l2 norm of the residuals 2.0611286e-04 number of function evaluations 8 number of jacobian evaluations 2 exit parameter 3 final approximate solution -4.3151855e-02 -8.1542969e-02 -1.1437988e-01 -1.4086914e-01 -1.5979004e-01 -1.6967773e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5317383e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2636719e-01 final l2 norm of the residuals 2.1624565e-04 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 3 final approximate solution -4.3151855e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01 -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0650000e+02 final l2 norm of the residuals 1.9276142e-04 number of function evaluations 21 number of jacobian evaluations 2 exit parameter 3 final approximate solution -4.3121338e-02 -8.1481934e-02 -1.1437988e-01 -1.4086914e-01 -1.5979004e-01 -1.6967773e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5317383e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 1.2207031e-04 number of function evaluations 4 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5283203e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 2.4414062e-04 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5270996e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3600000e+02 final l2 norm of the residuals 8.3600000e+02 number of function evaluations 3 number of jacobian evaluations 1 exit parameter 1 final approximate solution -2.5000000e+01 problem 10 dimension 10 initial l2 norm of the residuals 2.5195312e-01 final l2 norm of the residuals 1.1938810e-04 number of function evaluations 4 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3182373e-02 -8.1542969e-02 -1.1456299e-01 -1.4099121e-01 -1.5991211e-01 -1.6992188e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1171875e+00 final l2 norm of the residuals 3.1781197e-04 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3151855e-02 -8.1542969e-02 -1.1450195e-01 -1.4099121e-01 -1.5979004e-01 -1.6979980e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2690000e+03 final l2 norm of the residuals 1.2690000e+03 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution -8.2656250e+00 -1.4867188e+01 -1.9843750e+01 -2.3125000e+01 -2.4796875e+01 -2.4796875e+01 -2.3140625e+01 -1.9843750e+01 -1.4890625e+01 -8.2968750e+00 problem 11 dimension 10 initial l2 norm of the residuals 9.3688965e-02 final l2 norm of the residuals 7.2021484e-03 number of function evaluations 19 number of jacobian evaluations 5 exit parameter 1 final approximate solution 5.5450439e-02 5.7189941e-02 5.9143066e-02 6.1096191e-02 6.2744141e-02 6.6284180e-02 2.1496582e-01 1.7517090e-01 9.5153809e-02 8.2885742e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0296875e+01 final l2 norm of the residuals 3.8356781e-03 number of function evaluations 31 number of jacobian evaluations 6 exit parameter 1 final approximate solution 4.8004150e-02 4.9041748e-02 5.0140381e-02 5.3009033e-02 5.4382324e-02 5.6518555e-02 5.9051514e-02 1.8811035e-01 1.5502930e-01 1.2255859e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3437500e+01 final l2 norm of the residuals 4.4296875e+00 number of function evaluations 13 number of jacobian evaluations 4 exit parameter 1 final approximate solution 3.0125000e+01 1.8703125e+01 1.2906250e+01 1.2812500e+01 1.2804688e+01 1.2843750e+01 1.3078125e+01 6.2578125e+00 1.2312500e+01 1.2484375e+01 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 8.9990234e-01 7.9980469e-01 7.0019531e-01 6.0009766e-01 5.0000000e-01 4.0014648e-01 3.0029297e-01 2.0019531e-01 1.0021973e-01 2.4414062e-04 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 9.0000000e+00 8.0000000e+00 7.0000000e+00 6.0000000e+00 5.0000000e+00 4.0000000e+00 3.0039062e+00 2.0019531e+00 1.0019531e+00 2.4414062e-03 problem 12 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 9.0000000e+01 8.0000000e+01 7.0000000e+01 6.0000000e+01 5.0000000e+01 4.0000000e+01 3.0031250e+01 2.0015625e+01 1.0023438e+01 2.4414062e-02 problem 13 dimension 10 initial l2 norm of the residuals 4.5820312e+00 final l2 norm of the residuals 5.9394836e-03 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 3 final approximate solution -5.7031250e-01 -6.8164062e-01 -7.0166016e-01 -7.0507812e-01 -7.0458984e-01 -7.0117188e-01 -6.9189453e-01 -6.6650391e-01 -5.9667969e-01 -4.1699219e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3900000e+02 final l2 norm of the residuals 1.1337280e-02 number of function evaluations 20 number of jacobian evaluations 1 exit parameter 3 final approximate solution -5.7080078e-01 -6.8212891e-01 -7.0214844e-01 -7.0605469e-01 -7.0605469e-01 -7.0312500e-01 -6.9238281e-01 -6.6455078e-01 -5.9521484e-01 -4.1528320e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3392000e+04 final l2 norm of the residuals 6.0386658e-03 number of function evaluations 17 number of jacobian evaluations 2 exit parameter 1 final approximate solution -5.7080078e-01 -6.8212891e-01 -7.0214844e-01 -7.0556641e-01 -7.0507812e-01 -7.0166016e-01 -6.9238281e-01 -6.6601562e-01 -5.9619141e-01 -4.1552734e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8968750e+01 final l2 norm of the residuals 4.9285889e-03 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.2895508e-01 -4.7680664e-01 -5.1953125e-01 -5.5810547e-01 -5.9277344e-01 -6.2451172e-01 -6.2304688e-01 -6.2109375e-01 -6.2060547e-01 -5.8642578e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7136000e+04 final l2 norm of the residuals 5.0048828e-02 number of function evaluations 17 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.3701172e-01 -4.7998047e-01 -5.2148438e-01 -5.5957031e-01 -5.9326172e-01 -6.2597656e-01 -6.2402344e-01 -6.2207031e-01 -6.2109375e-01 -5.8691406e-01 problem 14 dimension 10 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 summary of 55 calls to hybrj1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 8 1 1 0.0000000e+00 1 2 11 2 4 inf 2 4 28 3 1 5.9604645e-08 2 4 27 2 1 0.0000000e+00 2 4 11 2 4 inf 3 2 25 3 1 1.1634827e-02 3 2 11 2 4 1.0000000e+00 4 4 20 2 1 1.7578125e-01 4 4 11 2 4 -nan 4 4 11 2 4 -nan 5 3 14 3 1 2.1667480e-02 5 3 17 4 1 2.1877289e-03 5 3 35 8 1 1.5129089e-02 6 6 24 3 1 1.9433594e-01 6 6 11 2 4 -nan 6 9 25 3 1 1.5661621e-01 6 9 11 2 4 -nan 7 5 5 1 1 9.3231201e-03 7 5 11 2 4 -nan 7 5 11 2 4 nan 7 6 9 2 1 1.2006760e-03 7 6 11 2 4 nan 7 6 11 2 4 nan 7 7 4 1 3 2.4414062e-02 7 7 11 2 4 nan 7 7 11 2 4 nan 7 8 7 2 1 1.5234375e-01 7 9 6 2 1 1.6394043e-01 8 10 11 2 4 1.6531250e+01 8 10 11 2 4 inf 8 10 11 2 4 inf 8 30 11 2 4 8.3500000e+01 8 40 11 2 4 1.2800000e+02 9 10 8 2 3 2.0611286e-04 9 10 6 1 3 2.1624565e-04 9 10 21 2 3 1.9276142e-04 10 1 4 1 1 1.2207031e-04 10 1 5 1 1 2.4414062e-04 10 1 3 1 1 8.3600000e+02 10 10 4 1 1 1.1938810e-04 10 10 5 1 1 3.1781197e-04 10 10 11 2 4 1.2690000e+03 11 10 19 5 1 7.2021484e-03 11 10 31 6 1 3.8356781e-03 11 10 13 4 1 4.4296875e+00 12 10 11 2 4 -nan 12 10 11 2 4 -nan 12 10 11 2 4 -nan 13 10 5 1 3 5.9394836e-03 13 10 20 1 3 1.1337280e-02 13 10 17 2 1 6.0386658e-03 14 10 8 1 1 4.9285889e-03 14 10 17 2 1 5.0048828e-02 14 10 11 2 4 -nan cminpack-1.3.4/examples/ref/hibmdpdrc.ref000644 000765 000765 00000000720 12225167750 020306 0ustar00devernay000000 000000 MACHAR constants ibeta = 2 it = 11 irnd = 5 ngrd = 0 machep = -10 negep = -11 iexp = 5 minexp = -14 maxexp = 16 eps = 9.7656250e-04 epsneg = 4.8828125e-04 xmin = 6.1035156e-05 xmax = 6.5504000e+04 DPMPAR constants and relative differences epsmch = 9.7656250e-04 rerr(1) = 0.0000000e+00 dwarf = 6.1035156e-05 rerr(2) = 0.0000000e+00 giant = 6.5504000e+04 rerr(3) = 0.0000000e+00 cminpack-1.3.4/examples/ref/hlmddrvc.ref000644 000765 000765 00000063660 12303616324 020162 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2343750e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -9.9707031e-01 -1.0019531e+00 -1.0000000e+00 -1.0039062e+00 -1.0039062e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0546875e+00 final l2 norm of the residuals 6.6875000e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0117188e+00 -1.0312500e+00 -9.8925781e-01 -9.8339844e-01 -9.8925781e-01 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9150000e+02 final l2 norm of the residuals 2.9150000e+02 number of function evaluations 600 number of jacobian evaluations 599 exit parameter 5 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1000000e+03 final l2 norm of the residuals 3.1000000e+03 number of function evaluations 600 number of jacobian evaluations 599 exit parameter 5 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2606250e+02 final l2 norm of the residuals 1.9160156e+00 number of function evaluations 8 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 -4.2875000e+01 4.6937500e+01 -1.3718750e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7470000e+03 final l2 norm of the residuals 3.6855469e+00 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 1.0000000e+00 -3.7281250e+01 2.1625000e+01 2.4296875e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9257812e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 17 number of jacobian evaluations 13 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 300 number of jacobian evaluations 299 exit parameter 5 final approximate solution -1.2000000e+02 1.0000000e+02 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 -1.1920929e-07 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0293750e+02 final l2 norm of the residuals 2.1457672e-04 number of function evaluations 18 number of jacobian evaluations 13 exit parameter 2 final approximate solution 1.0000000e+00 1.3351440e-05 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9150000e+02 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 17 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 0.0000000e+00 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4664062e+01 final l2 norm of the residuals 1.1920929e-07 number of function evaluations 500 number of jacobian evaluations 496 exit parameter 5 final approximate solution 1.7035007e-04 -1.7046928e-05 2.6166439e-05 2.6166439e-05 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2710000e+03 final l2 norm of the residuals 1.1920929e-07 number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 2.2959709e-04 -2.2947788e-05 7.5936317e-05 7.5936317e-05 problem 6 dimensions 4 4 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 3.0000000e+02 -1.0000000e+02 0.0000000e+00 1.0000000e+02 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0015625e+01 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 2 final approximate solution 1.1382812e+01 -9.0478516e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432000e+04 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 300 number of jacobian evaluations 297 exit parameter 5 final approximate solution 1.1617188e+01 -8.8769531e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 300 number of jacobian evaluations 299 exit parameter 5 final approximate solution 5.0000000e+01 -2.0000000e+02 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4570312e+00 final l2 norm of the residuals 9.0454102e-02 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 3 final approximate solution 8.2275391e-02 1.1298828e+00 2.3457031e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6156250e+01 final l2 norm of the residuals 4.1835938e+00 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 3 final approximate solution 8.4228516e-01 -1.8150000e+03 1.8975000e+02 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8400000e+02 final l2 norm of the residuals 3.8400000e+02 number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.3059082e-02 final l2 norm of the residuals 1.7608643e-02 number of function evaluations 7 number of jacobian evaluations 5 exit parameter 3 final approximate solution 1.9238281e-01 1.8811035e-01 1.1462402e-01 1.3537598e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9785156e+00 final l2 norm of the residuals 3.3050537e-02 number of function evaluations 9 number of jacobian evaluations 6 exit parameter 1 final approximate solution 4.8754883e-01 -9.0156250e+00 -1.4351562e+01 -8.6640625e+00 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9953125e+01 final l2 norm of the residuals 4.3304443e-02 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 2.7832031e-01 9.0437500e+01 1.0706250e+02 4.6531250e+01 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 2.0004272e-02 4.0000000e+03 2.5000000e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 2.0007324e-01 4.0000000e+04 2.5000000e+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 4.7485352e-02 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 2 final approximate solution -1.4404297e-02 1.0117188e+00 -2.2741699e-01 1.2460938e+00 -1.4941406e+00 9.8535156e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4360000e+03 final l2 norm of the residuals 4.5440674e-02 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 2 final approximate solution -1.5304565e-02 1.0117188e+00 -2.2717285e-01 1.2431641e+00 -1.4912109e+00 9.8339844e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 700 number of jacobian evaluations 699 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 6.7863464e-03 number of function evaluations 8 number of jacobian evaluations 6 exit parameter 2 final approximate solution -6.6280365e-05 1.0000000e+00 -1.4404297e-02 4.4848633e-01 -3.2055664e-01 3.3837891e-01 5.4980469e-01 -9.5361328e-01 5.0927734e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088000e+04 final l2 norm of the residuals 3.9238281e+00 number of function evaluations 1000 number of jacobian evaluations 999 exit parameter 5 final approximate solution 3.5205078e-01 1.0771484e+00 7.0410156e-01 -2.5507812e+00 1.1578125e+01 -2.2828125e+01 2.6093750e+01 -1.5460938e+01 4.0234375e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 1000 number of jacobian evaluations 999 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 1.3786316e-02 number of function evaluations 9 number of jacobian evaluations 5 exit parameter 2 final approximate solution -2.8610229e-06 1.0009766e+00 -2.9998779e-02 5.2441406e-01 -6.8603516e-01 1.8994141e+00 -3.1777344e+00 3.2421875e+00 -6.1474609e-01 -1.8837891e+00 1.7119141e+00 -4.2846680e-01 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9216000e+04 final l2 norm of the residuals 1.9453125e+01 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 2 final approximate solution 6.2402344e-01 1.2597656e+00 1.4736328e+00 -5.2109375e+00 1.5468750e+01 -3.1894531e+00 -3.3718750e+01 2.5984375e+01 4.4531250e+01 -5.0875000e+01 -5.6796875e+00 1.5742188e+01 problem 11 dimensions 12 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 1300 number of jacobian evaluations 1299 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2125000e+01 final l2 norm of the residuals 1.1557341e-04 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4500000e+01 final l2 norm of the residuals 1.1179688e+01 number of function evaluations 10 number of jacobian evaluations 6 exit parameter 1 final approximate solution 2.4621582e-01 2.6977539e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8160000e+03 final l2 norm of the residuals 2.8160000e+03 number of function evaluations 500 number of jacobian evaluations 250 exit parameter 5 final approximate solution 2.5000000e+01 5.0000000e+00 -5.0000000e+00 -1.0000000e+00 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 2.5000000e+02 5.0000000e+01 -5.0000000e+01 -1.0000000e+01 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 2.5000000e+03 5.0000000e+02 -5.0000000e+02 -1.0000000e+02 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8857422e+00 final l2 norm of the residuals 1.8857422e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 200 number of jacobian evaluations 199 exit parameter 5 final approximate solution 5.0000000e+00 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 200 number of jacobian evaluations 199 exit parameter 5 final approximate solution 5.0000000e+01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9628906e-01 final l2 norm of the residuals 1.3720703e-01 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 7.4218750e-02 2.4121094e-01 2.5781250e-01 5.3027344e-01 4.7070312e-01 7.3974609e-01 7.5976562e-01 9.2480469e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.7041016e-01 final l2 norm of the residuals 9.1003418e-02 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 7.2937012e-02 2.0349121e-01 2.6977539e-01 4.1137695e-01 4.9975586e-01 5.8837891e-01 7.2998047e-01 7.9638672e-01 9.2675781e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8420410e-01 final l2 norm of the residuals 1.4660645e-01 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 2 final approximate solution 6.3415527e-02 1.8835449e-01 2.2192383e-01 4.1943359e-01 3.7426758e-01 6.2646484e-01 5.7958984e-01 7.7929688e-01 8.1103516e-01 9.3701172e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6531250e+01 final l2 norm of the residuals 4.3945312e-03 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 9.7900391e-01 1.2109375e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 1100 number of jacobian evaluations 1099 exit parameter 5 final approximate solution 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 1100 number of jacobian evaluations 1099 exit parameter 5 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3500000e+01 final l2 norm of the residuals 9.6862793e-02 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 9.9462891e-01 9.9560547e-01 9.9707031e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9560547e-01 9.9511719e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9414062e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 1.1074219e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2800000e+02 final l2 norm of the residuals 1.6064453e-01 number of function evaluations 4 number of jacobian evaluations 3 exit parameter 2 final approximate solution 1.0019531e+00 1.0126953e+00 1.0087891e+00 1.0087891e+00 1.0097656e+00 1.0097656e+00 1.0097656e+00 1.0097656e+00 1.0087891e+00 1.0117188e+00 1.0087891e+00 1.0087891e+00 1.0087891e+00 1.0097656e+00 1.0087891e+00 1.0097656e+00 1.0087891e+00 1.0087891e+00 1.0087891e+00 1.0087891e+00 1.0087891e+00 1.0087891e+00 1.0097656e+00 1.0097656e+00 1.0087891e+00 1.0097656e+00 1.0097656e+00 1.0087891e+00 1.0097656e+00 1.0097656e+00 1.0097656e+00 1.0097656e+00 1.0097656e+00 1.0087891e+00 1.0087891e+00 1.0097656e+00 1.0097656e+00 1.0087891e+00 1.0087891e+00 6.4062500e-01 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3652344e-01 final l2 norm of the residuals 9.3688965e-03 number of function evaluations 7 number of jacobian evaluations 4 exit parameter 2 final approximate solution 3.7426758e-01 1.7978516e+00 -1.3261719e+00 1.2580872e-02 2.2705078e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4453125e+00 final l2 norm of the residuals 4.4531250e-01 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 2 final approximate solution 1.1503906e+00 1.9213867e-01 5.3710938e-01 5.2294922e-01 3.9355469e-01 2.5019531e+00 1.6044922e+00 4.3007812e+00 2.4746094e+00 4.5976562e+00 5.6640625e+00 summary of 53 calls to lmder1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 3 2.2343750e+00 1 5 50 3 2 3 6.6875000e+00 2 5 10 600 599 5 2.9150000e+02 2 5 50 600 599 5 3.1000000e+03 3 5 10 8 4 2 1.9160156e+00 3 5 50 4 2 2 3.6855469e+00 4 2 2 17 13 2 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 300 299 5 inf 5 3 3 10 7 2 0.0000000e+00 5 3 3 18 13 2 2.1457672e-04 5 3 3 17 14 2 0.0000000e+00 6 4 4 500 496 5 1.1920929e-07 6 4 4 500 499 5 1.1920929e-07 6 4 4 500 499 5 inf 7 2 2 5 3 2 7.0000000e+00 7 2 2 300 297 5 7.0000000e+00 7 2 2 300 299 5 -nan 8 3 15 5 4 3 9.0454102e-02 8 3 15 5 4 3 4.1835938e+00 8 3 15 400 399 5 3.8400000e+02 9 4 11 7 5 3 1.7608643e-02 9 4 11 9 6 1 3.3050537e-02 9 4 11 7 6 2 4.3304443e-02 10 3 16 400 399 5 -nan 10 3 16 400 399 5 -nan 11 6 31 5 4 2 4.7485352e-02 11 6 31 10 9 2 4.5440674e-02 11 6 31 700 699 5 -nan 11 9 31 8 6 2 6.7863464e-03 11 9 31 1000 999 5 3.9238281e+00 11 9 31 1000 999 5 -nan 11 12 31 9 5 2 1.3786316e-02 11 12 31 6 5 2 1.9453125e+01 11 12 31 1300 1299 5 -nan 12 3 10 5 4 2 1.1557341e-04 13 2 10 10 6 1 1.1179688e+01 14 4 20 500 250 5 2.8160000e+03 14 4 20 500 499 5 -nan 14 4 20 500 499 5 -nan 15 1 8 1 1 4 1.8857422e+00 15 1 8 200 199 5 nan 15 1 8 200 199 5 nan 15 8 8 4 2 2 1.3720703e-01 15 9 9 4 2 2 9.1003418e-02 15 10 10 5 2 2 1.4660645e-01 16 10 10 10 7 2 4.3945312e-03 16 10 10 1100 1099 5 inf 16 10 10 1100 1099 5 inf 16 30 30 7 6 2 9.6862793e-02 16 40 40 4 3 2 1.6064453e-01 17 5 33 7 4 2 9.3688965e-03 18 11 65 5 3 2 4.4531250e-01 cminpack-1.3.4/examples/ref/hlmfdrvc.ref000644 000765 000765 00000063660 12303616324 020164 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2402344e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.0253906e+00 -1.0273438e+00 -1.0292969e+00 -1.0302734e+00 -8.8330078e-01 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0546875e+00 final l2 norm of the residuals 6.7109375e+00 number of function evaluations 6 number of Jacobian evaluations 3 exit parameter 1 final approximate solution -7.5488281e-01 -9.7656250e-01 -9.7460938e-01 -1.0156250e+00 -1.0107422e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9150000e+02 final l2 norm of the residuals 1.7060547e+00 number of function evaluations 5 number of Jacobian evaluations 3 exit parameter 2 final approximate solution 5.6542969e-01 1.2353516e+00 -1.4054688e+01 2.6781250e+01 -1.3562500e+01 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1000000e+03 final l2 norm of the residuals 4.5429688e+00 number of function evaluations 5 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 6.3769531e-01 1.0976562e+00 3.3691406e-02 8.1054688e-02 -6.4843750e-01 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2606250e+02 final l2 norm of the residuals 1.9160156e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 1.0000000e+00 -3.2875000e+01 3.3968750e+01 -8.9921875e+00 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7470000e+03 final l2 norm of the residuals 3.6855469e+00 number of function evaluations 5 number of Jacobian evaluations 3 exit parameter 3 final approximate solution 1.0000000e+00 2.5170898e-01 -4.2553711e-01 2.0117188e-01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9257812e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 15 number of Jacobian evaluations 11 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400000e+03 final l2 norm of the residuals 9.7656250e-03 number of function evaluations 23 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 1.0009766e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution -1.2000000e+02 1.0000000e+02 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 4.7683716e-05 number of function evaluations 9 number of Jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 2.8610229e-06 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0293750e+02 final l2 norm of the residuals 1.4901161e-04 number of function evaluations 20 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 -9.5367432e-06 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9150000e+02 final l2 norm of the residuals 4.9218750e+00 number of function evaluations 7 number of Jacobian evaluations 4 exit parameter 3 final approximate solution -9.9902344e-01 3.3294678e-02 4.8945312e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4664062e+01 final l2 norm of the residuals 4.7683716e-07 number of function evaluations 17 number of Jacobian evaluations 16 exit parameter 3 final approximate solution 5.1689148e-04 -5.1677227e-05 3.1924248e-04 3.1924248e-04 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2710000e+03 final l2 norm of the residuals 9.5963478e-06 number of function evaluations 18 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.9874573e-03 -1.9872189e-04 2.4819374e-04 2.4819374e-04 problem 6 dimensions 4 4 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 3.0000000e+02 -1.0000000e+02 0.0000000e+00 1.0000000e+02 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0015625e+01 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 6 number of Jacobian evaluations 3 exit parameter 3 final approximate solution 1.1484375e+01 -8.9941406e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432000e+04 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 11 number of Jacobian evaluations 8 exit parameter 1 final approximate solution 1.1382812e+01 -8.9990234e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 5.0000000e+01 -2.0000000e+02 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4570312e+00 final l2 norm of the residuals 9.0454102e-02 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 3 final approximate solution 8.1970215e-02 1.1191406e+00 2.3574219e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6156250e+01 final l2 norm of the residuals 4.8554688e+00 number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 1.9067383e-01 4.3360000e+03 -3.3960000e+03 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8400000e+02 final l2 norm of the residuals 4.0117188e+00 number of function evaluations 8 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 8.0957031e-01 5.3937500e+01 3.7281250e+01 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.3059082e-02 final l2 norm of the residuals 1.7745972e-02 number of function evaluations 10 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 1.9091797e-01 2.4291992e-01 1.3720703e-01 1.5820312e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9785156e+00 final l2 norm of the residuals 3.8159180e-01 number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 2.3010254e-02 -1.5625000e-02 1.3812500e+01 1.3429688e+01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9953125e+01 final l2 norm of the residuals 4.0679932e-02 number of function evaluations 12 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 1.2683105e-01 9.1000000e+01 4.8843750e+01 2.0796875e+01 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 2.0004272e-02 4.0000000e+03 2.5000000e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 2.0007324e-01 4.0000000e+04 2.5000000e+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 1.3342285e-01 number of function evaluations 8 number of Jacobian evaluations 7 exit parameter 2 final approximate solution -7.0068359e-02 1.0166016e+00 -1.1077881e-02 1.3923645e-02 2.4804688e-01 1.3793945e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4360000e+03 final l2 norm of the residuals 1.3549805e-01 number of function evaluations 15 number of Jacobian evaluations 11 exit parameter 2 final approximate solution -6.7687988e-02 9.7119141e-01 2.9199219e-01 -6.3427734e-01 8.1982422e-01 -3.5705566e-02 problem 11 dimensions 6 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 1.1785889e-01 number of function evaluations 10 number of Jacobian evaluations 6 exit parameter 2 final approximate solution -6.2500000e-02 1.0175781e+00 2.3097992e-03 -1.6647339e-02 3.1030273e-01 1.2731934e-01 -6.3049316e-02 3.3081055e-02 1.1878967e-02 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088000e+04 final l2 norm of the residuals 5.2148438e+00 number of function evaluations 12 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 3.2641602e-01 4.0112305e-01 6.5859375e+00 -1.0171875e+01 1.3818359e+00 8.4765625e-01 8.9296875e+00 -1.8242188e+00 -3.3007812e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 1.3891602e-01 number of function evaluations 8 number of Jacobian evaluations 6 exit parameter 2 final approximate solution -1.0728836e-06 1.0292969e+00 7.5759888e-03 -6.4964294e-03 6.4926147e-03 1.1660156e+00 -3.7011719e-01 -4.8901367e-01 2.0034790e-02 1.4099121e-01 -2.0996094e-01 2.6269531e-01 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9216000e+04 final l2 norm of the residuals 6.6503906e-01 number of function evaluations 14 number of Jacobian evaluations 13 exit parameter 2 final approximate solution 3.8720703e-01 1.1718750e+00 4.6435547e-01 2.6977539e-01 1.8054199e-01 4.8754883e-01 2.2324219e+00 1.8554688e+00 5.8898926e-03 -1.4117188e+01 1.2375000e+01 -3.1884766e-01 problem 11 dimensions 12 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2125000e+01 final l2 norm of the residuals 1.1557341e-04 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4500000e+01 final l2 norm of the residuals 1.1195312e+01 number of function evaluations 11 number of Jacobian evaluations 7 exit parameter 1 final approximate solution 2.5341797e-01 2.6660156e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8160000e+03 final l2 norm of the residuals 1.2940000e+03 number of function evaluations 202 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 1.3390625e+01 5.9765625e+00 5.4296875e+00 2.9121094e+00 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 2.5000000e+02 5.0000000e+01 -5.0000000e+01 -1.0000000e+01 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 2.5000000e+03 5.0000000e+02 -5.0000000e+02 -1.0000000e+02 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8857422e+00 final l2 norm of the residuals 1.8808594e+00 number of function evaluations 2 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.1074219e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 5.0000000e+00 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 5.0000000e+01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9628906e-01 final l2 norm of the residuals 1.0198975e-01 number of function evaluations 4 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 8.3862305e-02 2.2375488e-01 3.0444336e-01 4.7436523e-01 5.2783203e-01 7.0654297e-01 7.7929688e-01 9.2138672e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.7041016e-01 final l2 norm of the residuals 8.5021973e-02 number of function evaluations 4 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 6.7077637e-02 2.1215820e-01 2.5537109e-01 4.2407227e-01 5.0292969e-01 5.7958984e-01 7.4560547e-01 7.9785156e-01 9.3359375e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8420410e-01 final l2 norm of the residuals 9.5947266e-02 number of function evaluations 5 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 6.8481445e-02 1.7553711e-01 2.5366211e-01 3.7158203e-01 4.2700195e-01 5.9228516e-01 6.0058594e-01 7.7490234e-01 8.1982422e-01 9.3945312e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6531250e+01 final l2 norm of the residuals 6.4697266e-02 number of function evaluations 6 number of Jacobian evaluations 3 exit parameter 2 final approximate solution 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 1.0224609e+00 7.6562500e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 201 number of Jacobian evaluations 200 exit parameter 5 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3500000e+01 final l2 norm of the residuals 6.0668945e-02 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 9.9951172e-01 1.0117188e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2800000e+02 final l2 norm of the residuals 2.0825195e-01 number of function evaluations 11 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 9.7753906e-01 9.9853516e-01 9.9511719e-01 9.9414062e-01 9.9414062e-01 9.9462891e-01 9.9560547e-01 9.9462891e-01 9.9609375e-01 9.9511719e-01 9.9560547e-01 9.9560547e-01 9.9511719e-01 9.9560547e-01 9.9560547e-01 9.9511719e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9560547e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9560547e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 9.9511719e-01 1.1542969e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3652344e-01 final l2 norm of the residuals 2.1072388e-02 number of function evaluations 5 number of Jacobian evaluations 3 exit parameter 2 final approximate solution 3.6791992e-01 1.4394531e+00 -9.5800781e-01 1.1543274e-02 2.5070190e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4453125e+00 final l2 norm of the residuals 4.0185547e-01 number of function evaluations 5 number of Jacobian evaluations 3 exit parameter 2 final approximate solution 1.1562500e+00 2.1484375e-01 5.2001953e-01 5.5761719e-01 4.0625000e-01 2.4746094e+00 1.3730469e+00 5.3164062e+00 2.4414062e+00 4.5976562e+00 5.6562500e+00 summary of 53 calls to lmdif1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 1 2.2402344e+00 1 5 50 6 3 1 6.7109375e+00 2 5 10 5 3 2 1.7060547e+00 2 5 50 5 2 2 4.5429688e+00 3 5 10 3 2 2 1.9160156e+00 3 5 50 5 3 3 3.6855469e+00 4 2 2 15 11 2 0.0000000e+00 4 2 2 23 16 2 9.7656250e-03 4 2 2 201 200 5 inf 5 3 3 9 7 2 4.7683716e-05 5 3 3 20 15 2 1.4901161e-04 5 3 3 7 4 3 4.9218750e+00 6 4 4 17 16 3 4.7683716e-07 6 4 4 18 15 2 9.5963478e-06 6 4 4 201 200 5 inf 7 2 2 6 3 3 7.0000000e+00 7 2 2 11 8 1 7.0000000e+00 7 2 2 201 200 5 -nan 8 3 15 5 4 3 9.0454102e-02 8 3 15 201 200 5 4.8554688e+00 8 3 15 8 4 1 4.0117188e+00 9 4 11 10 6 2 1.7745972e-02 9 4 11 201 200 5 3.8159180e-01 9 4 11 12 9 1 4.0679932e-02 10 3 16 201 200 5 -nan 10 3 16 201 200 5 -nan 11 6 31 8 7 2 1.3342285e-01 11 6 31 15 11 2 1.3549805e-01 11 6 31 201 200 5 -nan 11 9 31 10 6 2 1.1785889e-01 11 9 31 12 9 2 5.2148438e+00 11 9 31 201 200 5 -nan 11 12 31 8 6 2 1.3891602e-01 11 12 31 14 13 2 6.6503906e-01 11 12 31 201 200 5 -nan 12 3 10 5 4 2 1.1557341e-04 13 2 10 11 7 1 1.1195312e+01 14 4 20 202 200 5 1.2940000e+03 14 4 20 201 200 5 -nan 14 4 20 201 200 5 -nan 15 1 8 2 1 1 1.8808594e+00 15 1 8 201 200 5 nan 15 1 8 201 200 5 nan 15 8 8 4 2 2 1.0198975e-01 15 9 9 4 2 2 8.5021973e-02 15 10 10 5 2 2 9.5947266e-02 16 10 10 6 3 2 6.4697266e-02 16 10 10 201 200 5 inf 16 10 10 201 200 5 inf 16 30 30 5 4 2 6.0668945e-02 16 40 40 11 8 2 2.0825195e-01 17 5 33 5 3 2 2.1072388e-02 18 11 65 5 3 2 4.0185547e-01 cminpack-1.3.4/examples/ref/hlmsdrvc.ref000644 000765 000765 00000063653 12303616324 020203 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2343750e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0000000e+00 -1.0039062e+00 -9.9902344e-01 -1.0019531e+00 -1.0000000e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0546875e+00 final l2 norm of the residuals 6.6875000e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0175781e+00 -9.9951172e-01 -9.9316406e-01 -1.0029297e+00 -9.9560547e-01 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9150000e+02 final l2 norm of the residuals 2.9150000e+02 number of function evaluations 600 number of jacobian evaluations 599 exit parameter 5 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1000000e+03 final l2 norm of the residuals 3.1000000e+03 number of function evaluations 600 number of jacobian evaluations 599 exit parameter 5 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2606250e+02 final l2 norm of the residuals 2.1796875e+00 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 1.0000000e+00 3.3250000e+01 -1.2656250e+02 7.8375000e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7470000e+03 final l2 norm of the residuals 3.6855469e+00 number of function evaluations 7 number of jacobian evaluations 2 exit parameter 2 final approximate solution 1.0000000e+00 1.5693359e+00 -3.8320312e+00 2.0976562e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9257812e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 300 number of jacobian evaluations 299 exit parameter 5 final approximate solution -1.2000000e+02 1.0000000e+02 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 0.0000000e+00 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0293750e+02 final l2 norm of the residuals 2.7418137e-04 number of function evaluations 18 number of jacobian evaluations 13 exit parameter 2 final approximate solution 1.0000000e+00 1.7166138e-05 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9150000e+02 final l2 norm of the residuals 5.9604645e-06 number of function evaluations 16 number of jacobian evaluations 13 exit parameter 2 final approximate solution 1.0000000e+00 2.3841858e-07 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4664062e+01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of jacobian evaluations 15 exit parameter 4 final approximate solution 9.0003014e-05 -9.0003014e-06 3.7550926e-05 3.7550926e-05 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2710000e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 19 number of jacobian evaluations 18 exit parameter 4 final approximate solution 1.1265278e-04 -1.1265278e-05 2.1100044e-05 2.1100044e-05 problem 6 dimensions 4 4 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 3.0000000e+02 -1.0000000e+02 0.0000000e+00 1.0000000e+02 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0015625e+01 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 2 final approximate solution 1.1375000e+01 -9.0527344e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432000e+04 final l2 norm of the residuals 7.0000000e+00 number of function evaluations 300 number of jacobian evaluations 297 exit parameter 5 final approximate solution 1.1625000e+01 -8.8671875e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 300 number of jacobian evaluations 299 exit parameter 5 final approximate solution 5.0000000e+01 -2.0000000e+02 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4570312e+00 final l2 norm of the residuals 9.0454102e-02 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 3 final approximate solution 8.2336426e-02 1.1308594e+00 2.3457031e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6156250e+01 final l2 norm of the residuals 5.3320312e+00 number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 8.5937500e-02 -5.9500000e+01 -1.5390625e+01 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8400000e+02 final l2 norm of the residuals 4.1757812e+00 number of function evaluations 4 number of jacobian evaluations 3 exit parameter 3 final approximate solution 8.4033203e-01 -9.6480000e+03 1.0000000e+02 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.3059082e-02 final l2 norm of the residuals 1.7547607e-02 number of function evaluations 8 number of jacobian evaluations 6 exit parameter 3 final approximate solution 1.9262695e-01 1.9396973e-01 1.2298584e-01 1.3732910e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9785156e+00 final l2 norm of the residuals 3.3142090e-02 number of function evaluations 10 number of jacobian evaluations 6 exit parameter 1 final approximate solution 4.7021484e-01 -8.7734375e+00 -1.3453125e+01 -8.1250000e+00 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9953125e+01 final l2 norm of the residuals 4.3029785e-02 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 2.7929688e-01 5.9718750e+01 7.2250000e+01 2.9781250e+01 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 2.0004272e-02 4.0000000e+03 2.5000000e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 400 number of jacobian evaluations 399 exit parameter 5 final approximate solution 2.0007324e-01 4.0000000e+04 2.5000000e+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 4.6844482e-02 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution -1.5914917e-02 1.0126953e+00 -2.4389648e-01 1.2958984e+00 -1.5585938e+00 1.0117188e+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4360000e+03 final l2 norm of the residuals 5.0567627e-02 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 2 final approximate solution -1.5129089e-02 1.0117188e+00 -2.2900391e-01 1.2519531e+00 -1.5048828e+00 9.9072266e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 700 number of jacobian evaluations 699 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 7.0114136e-03 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution -3.5190582e-04 9.9951172e-01 8.5067749e-03 3.1054688e-01 -5.5419922e-02 3.5693359e-01 -9.2651367e-02 -2.2827148e-01 2.5756836e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088000e+04 final l2 norm of the residuals 5.8398438e+00 number of function evaluations 1000 number of jacobian evaluations 998 exit parameter 5 final approximate solution 3.3081055e-01 1.0556641e+00 1.0820312e+00 -5.6015625e+00 1.9687500e+01 -2.9312500e+01 1.7593750e+01 1.7480469e+00 -4.1328125e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 1000 number of jacobian evaluations 999 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4765625e+00 final l2 norm of the residuals 8.2015991e-03 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.1539459e-04 1.0000000e+00 -2.3193359e-03 3.6132812e-01 -9.9609375e-02 2.1276855e-01 1.9665527e-01 -2.9272461e-01 6.4941406e-02 1.7333984e-01 -9.5825195e-02 3.9062500e-02 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9216000e+04 final l2 norm of the residuals 1.9216000e+04 number of function evaluations 1300 number of jacobian evaluations 1299 exit parameter 5 final approximate solution 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01 problem 11 dimensions 12 31 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 1300 number of jacobian evaluations 1299 exit parameter 5 final approximate solution 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 1.0000000e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2125000e+01 final l2 norm of the residuals 1.1557341e-04 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4500000e+01 final l2 norm of the residuals 1.1179688e+01 number of function evaluations 10 number of jacobian evaluations 6 exit parameter 1 final approximate solution 2.4621582e-01 2.6977539e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8160000e+03 final l2 norm of the residuals 2.8160000e+03 number of function evaluations 500 number of jacobian evaluations 250 exit parameter 5 final approximate solution 2.5000000e+01 5.0000000e+00 -5.0000000e+00 -1.0000000e+00 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 2.5000000e+02 5.0000000e+01 -5.0000000e+01 -1.0000000e+01 problem 14 dimensions 4 20 initial l2 norm of the residuals -nan final l2 norm of the residuals -nan number of function evaluations 500 number of jacobian evaluations 499 exit parameter 5 final approximate solution 2.5000000e+03 5.0000000e+02 -5.0000000e+02 -1.0000000e+02 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8857422e+00 final l2 norm of the residuals 1.8857422e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 200 number of jacobian evaluations 199 exit parameter 5 final approximate solution 5.0000000e+00 problem 15 dimensions 1 8 initial l2 norm of the residuals nan final l2 norm of the residuals nan number of function evaluations 200 number of jacobian evaluations 199 exit parameter 5 final approximate solution 5.0000000e+01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9628906e-01 final l2 norm of the residuals 1.3464355e-01 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 7.4584961e-02 2.4011230e-01 2.5952148e-01 5.2832031e-01 4.7143555e-01 7.3974609e-01 7.5976562e-01 9.2480469e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.7041016e-01 final l2 norm of the residuals 9.0698242e-02 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 7.2937012e-02 2.0349121e-01 2.6977539e-01 4.1137695e-01 5.0000000e-01 5.8789062e-01 7.3046875e-01 7.9638672e-01 9.2675781e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8420410e-01 final l2 norm of the residuals 1.4611816e-01 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 2 final approximate solution 6.3110352e-02 1.8859863e-01 2.2094727e-01 4.1992188e-01 3.7402344e-01 6.2500000e-01 5.8056641e-01 7.7783203e-01 8.1103516e-01 9.3652344e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6531250e+01 final l2 norm of the residuals 1.6342163e-02 number of function evaluations 9 number of jacobian evaluations 6 exit parameter 2 final approximate solution 9.6923828e-01 9.6972656e-01 9.6972656e-01 9.7021484e-01 9.6972656e-01 9.6972656e-01 9.7021484e-01 9.7070312e-01 9.7119141e-01 1.3027344e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 1100 number of jacobian evaluations 1099 exit parameter 5 final approximate solution 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 5.0000000e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals inf final l2 norm of the residuals inf number of function evaluations 1100 number of jacobian evaluations 1099 exit parameter 5 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3500000e+01 final l2 norm of the residuals 2.1350098e-01 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 1.0009766e+00 9.5214844e-01 1.0146484e+00 1.0058594e+00 1.0156250e+00 1.0146484e+00 1.0234375e+00 1.0166016e+00 1.0224609e+00 1.0234375e+00 1.0175781e+00 1.0087891e+00 1.0175781e+00 1.0117188e+00 1.0195312e+00 1.0195312e+00 1.0195312e+00 1.0117188e+00 1.0117188e+00 1.0175781e+00 1.0156250e+00 1.0205078e+00 1.0439453e+00 1.0263672e+00 1.0253906e+00 1.0244141e+00 1.0263672e+00 1.0244141e+00 1.0253906e+00 5.0000000e-01 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2800000e+02 final l2 norm of the residuals 2.8076172e-01 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 2 final approximate solution 1.0019531e+00 1.0019531e+00 1.0039062e+00 1.0253906e+00 1.0253906e+00 1.0361328e+00 1.0273438e+00 1.0195312e+00 1.0117188e+00 1.0458984e+00 1.0156250e+00 1.0136719e+00 1.0166016e+00 1.0156250e+00 1.0283203e+00 1.0332031e+00 1.0302734e+00 1.0214844e+00 1.0234375e+00 1.0185547e+00 1.0136719e+00 1.0117188e+00 1.0156250e+00 1.0068359e+00 1.0136719e+00 1.0029297e+00 1.0019531e+00 9.9707031e-01 9.9609375e-01 9.9853516e-01 9.9023438e-01 9.9853516e-01 9.9853516e-01 9.9023438e-01 1.0019531e+00 1.0117188e+00 1.0097656e+00 1.0117188e+00 1.0175781e+00 5.0000000e-01 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3652344e-01 final l2 norm of the residuals 1.1810303e-02 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 2 final approximate solution 3.6938477e-01 1.5009766e+00 -1.0244141e+00 1.1726379e-02 2.4642944e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4453125e+00 final l2 norm of the residuals 4.4726562e-01 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 2 final approximate solution 1.1494141e+00 1.9116211e-01 5.3613281e-01 5.2441406e-01 3.9184570e-01 2.5312500e+00 1.6171875e+00 4.3125000e+00 2.4765625e+00 4.5976562e+00 5.6640625e+00 summary of 53 calls to lmstr1 nprob n m nfev njev info final L2 norm 1 5 10 3 2 3 2.2343750e+00 1 5 50 3 2 2 6.6875000e+00 2 5 10 600 599 5 2.9150000e+02 2 5 50 600 599 5 3.1000000e+03 3 5 10 4 2 2 2.1796875e+00 3 5 50 7 2 2 3.6855469e+00 4 2 2 21 15 2 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 300 299 5 inf 5 3 3 10 7 2 0.0000000e+00 5 3 3 18 13 2 2.7418137e-04 5 3 3 16 13 2 5.9604645e-06 6 4 4 16 15 4 0.0000000e+00 6 4 4 19 18 4 0.0000000e+00 6 4 4 500 499 5 inf 7 2 2 5 3 2 7.0000000e+00 7 2 2 300 297 5 7.0000000e+00 7 2 2 300 299 5 -nan 8 3 15 5 4 3 9.0454102e-02 8 3 15 400 399 5 5.3320312e+00 8 3 15 4 3 3 4.1757812e+00 9 4 11 8 6 3 1.7547607e-02 9 4 11 10 6 1 3.3142090e-02 9 4 11 7 6 2 4.3029785e-02 10 3 16 400 399 5 -nan 10 3 16 400 399 5 -nan 11 6 31 6 4 2 4.6844482e-02 11 6 31 10 9 2 5.0567627e-02 11 6 31 700 699 5 -nan 11 9 31 10 7 2 7.0114136e-03 11 9 31 1000 998 5 5.8398438e+00 11 9 31 1000 999 5 -nan 11 12 31 6 4 2 8.2015991e-03 11 12 31 1300 1299 5 1.9216000e+04 11 12 31 1300 1299 5 -nan 12 3 10 5 4 2 1.1557341e-04 13 2 10 10 6 1 1.1179688e+01 14 4 20 500 250 5 2.8160000e+03 14 4 20 500 499 5 -nan 14 4 20 500 499 5 -nan 15 1 8 1 1 4 1.8857422e+00 15 1 8 200 199 5 nan 15 1 8 200 199 5 nan 15 8 8 4 2 2 1.3464355e-01 15 9 9 4 2 2 9.0698242e-02 15 10 10 5 2 2 1.4611816e-01 16 10 10 9 6 2 1.6342163e-02 16 10 10 1100 1099 5 inf 16 10 10 1100 1099 5 inf 16 30 30 4 2 2 2.1350098e-01 16 40 40 4 2 2 2.8076172e-01 17 5 33 5 3 2 1.1810303e-02 18 11 65 5 3 2 4.4726562e-01 cminpack-1.3.4/examples/ref/htchkderc.ref000644 000765 000765 00000001451 12225167750 020313 0ustar00devernay000000 000000 fvec -1.181641 -1.429688 -1.606445 -1.745117 -1.84082 -1.920898 -1.983398 -2.023438 -2.46875 -2.828125 -3.472656 -4.4375 -6.046875 -9.265625 -18.92188 fvecp - fvec -0.01660156 -0.0078125 -0.0009765625 0.00390625 0.008789062 0.01074219 0.01367188 0.01757812 0.02929688 0.04882812 0.0703125 0.109375 0.1679688 0.2890625 0.65625 err 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cminpack-1.3.4/examples/ref/htchkderc_box.ref000644 000765 000765 00000001451 12303616324 021154 0ustar00devernay000000 000000 fvec -0.9829102 -1.111328 -1.213867 -1.306641 -1.37207 -1.43457 -1.486328 -1.518555 -1.820312 -1.987305 -2.365234 -2.925781 -3.863281 -5.738281 -11.35938 fvecp - fvec -0.02685547 -0.02636719 -0.02539062 -0.0234375 -0.02246094 -0.02050781 -0.01953125 -0.01855469 -0.01660156 -0.01269531 -0.005859375 0 0.01367188 0.0390625 0.1171875 err 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cminpack-1.3.4/examples/ref/htenormc.ref000644 000765 000765 00000000325 12275245232 020167 0ustar00devernay000000 000000 dpmpar(2) = 6.103516e-05, dpmpar(3) = 65504 rdwarf = 0.015625, rgiant = 127.9375 norm/rdwarf (naive) = 1 norm/rdwarf (enorm) = 1 norm/agiant (naive) = 0.99755859375 norm/agiant (enorm) = 1.0009765625 cminpack-1.3.4/examples/ref/htfdjac2c.ref000644 000765 000765 00000002064 12225167750 020205 0ustar00devernay000000 000000 fvec -1.181641 -1.429688 -1.606445 -1.745117 -1.84082 -1.920898 -1.983398 -2.023438 -2.46875 -2.828125 -3.472656 -4.4375 -6.046875 -9.265625 -18.92188 fvecp - fvec -0.01660156 -0.0078125 -0.0009765625 0.00390625 0.008789062 0.01074219 0.01367188 0.01757812 0.02929688 0.04882812 0.0703125 0.109375 0.1679688 0.2890625 0.65625 errd 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 err 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cminpack-1.3.4/examples/ref/hthybrd1c.ref000644 000765 000765 00000000436 12225167750 020246 0ustar00devernay000000 000000 final L2 norm of the residuals 0.005523682 exit parameter 3 final approximates solution -0.5703125 -0.6816406 -0.7016602 -0.7041016 -0.7016602 -0.6918945 -0.6665039 -0.5966797 -0.4169922 cminpack-1.3.4/examples/ref/hthybrdc.ref000644 000765 000765 00000000521 12225167750 020160 0ustar00devernay000000 000000 final l2 norm of the residuals 0.005523682 number of function evaluations 8 exit parameter 3 final approximate solution -0.5703125 -0.6816406 -0.7016602 -0.7041016 -0.7016602 -0.6918945 -0.6665039 -0.5966797 -0.4169922 cminpack-1.3.4/examples/ref/hthybrj1c.ref000644 000765 000765 00000000440 12225167750 020247 0ustar00devernay000000 000000 final l2 norm of the residuals 0.005523682 exit parameter 3 final approximate solution -0.5703125 -0.6816406 -0.7016602 -0.7041016 -0.7016602 -0.6918945 -0.6665039 -0.5966797 -0.4169922 cminpack-1.3.4/examples/ref/hthybrjc.ref000644 000765 000765 00000000574 12225167750 020176 0ustar00devernay000000 000000 final l2 norm of the residuals 0.005523682 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 3 final approximate solution -0.5703125 -0.6816406 -0.7016602 -0.7041016 -0.7016602 -0.6918945 -0.6665039 -0.5966797 -0.4169922 cminpack-1.3.4/examples/ref/hthybrjc_box.ref000644 000765 000765 00000000574 12303616324 021037 0ustar00devernay000000 000000 final l2 norm of the residuals 0.7592773 number of function evaluations 18 number of jacobian evaluations 3 exit parameter 1 final approximate solution -0.4714355 -0.5 -0.6098633 -0.6938477 -0.7182617 -0.7133789 -0.6884766 -0.6108398 -0.4208984 cminpack-1.3.4/examples/ref/htlmder1c.ref000644 000765 000765 00000000272 12303616324 020230 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 exit parameter 3 final approximate solution 0.08227539 1.129883 2.345703 cminpack-1.3.4/examples/ref/htlmderc.ref000644 000765 000765 00000000705 12303616324 020150 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 3 final approximate solution 0.08227539 1.129883 2.345703 covariance 0.0001536608 0.002882004 -0.002670288 0.002882004 0.0947876 -0.09106445 -0.002670288 -0.09106445 0.08789062 cminpack-1.3.4/examples/ref/htlmderc_box.ref000644 000765 000765 00000000705 12303616324 021020 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09051514 number of function evaluations 7 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 0.08349609 1.175781 2.300781 covariance 6.765127e-05 0.0001003146 0 0.0001003146 0.0004017353 0 0 0 0 cminpack-1.3.4/examples/ref/htlmdif1c.ref000644 000765 000765 00000000266 12225167750 020232 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 exit parameter 3 final approximate solution 0.08197021 1.119141 2.357422 cminpack-1.3.4/examples/ref/htlmdifc.ref000644 000765 000765 00000000625 12225167750 020150 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 number of function evaluations 17 exit parameter 3 final approximate solution 0.08197021 1.119141 2.357422 covariance 0.0001525879 0.002954483 -0.002780914 0.002954483 0.1014404 -0.09899902 -0.002780914 -0.09899902 0.09692383 cminpack-1.3.4/examples/ref/htlmstr1c.ref000644 000765 000765 00000000272 12225167750 020275 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 exit parameter 3 final approximate solution 0.08233643 1.130859 2.345703 cminpack-1.3.4/examples/ref/htlmstrc.ref000644 000765 000765 00000000705 12225167750 020215 0ustar00devernay000000 000000 final l2 norm of the residuals 0.0904541 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 3 final approximate solution 0.08233643 1.130859 2.345703 covariance 0.0001517534 0.002840042 -0.002630234 0.002840042 0.09368896 -0.08996582 -0.002630234 -0.08996582 0.08673096 cminpack-1.3.4/examples/ref/hybdrv.ref000644 000765 000765 00000061126 12305351626 017653 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 0.4919350D+01 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 22 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 1 dimension 2 initial l2 norm of the residuals 0.1340063D+04 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 9 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 1 dimension 2 initial l2 norm of the residuals 0.1430001D+06 final l2 norm of the residuals 0.5373479D-12 number of function evaluations 9 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 2 dimension 4 initial l2 norm of the residuals 0.1466288D+02 final l2 norm of the residuals 0.1658388D-33 number of function evaluations 108 exit parameter 4 final approximate solution -0.1717233D-17 0.1717233D-18 0.4885792D-17 0.4885792D-17 problem 2 dimension 4 initial l2 norm of the residuals 0.1270984D+04 final l2 norm of the residuals 0.9820406D-35 number of function evaluations 112 exit parameter 4 final approximate solution 0.1137339D-17 -0.1137339D-18 0.1509232D-17 0.1509232D-17 problem 2 dimension 4 initial l2 norm of the residuals 0.1268879D+06 final l2 norm of the residuals 0.4843140D-34 number of function evaluations 143 exit parameter 4 final approximate solution 0.2071579D-17 -0.2071579D-18 0.3365608D-17 0.3365608D-17 problem 3 dimension 2 initial l2 norm of the residuals 0.1065487D+01 final l2 norm of the residuals 0.1712421D-08 number of function evaluations 181 exit parameter 1 final approximate solution 0.1098159D-04 0.9106147D+01 problem 3 dimension 2 initial l2 norm of the residuals 0.1000000D+01 final l2 norm of the residuals 0.3744485D-07 number of function evaluations 11 exit parameter 1 final approximate solution 0.1098159D-04 0.9106147D+01 problem 4 dimension 4 initial l2 norm of the residuals 0.8550557D+04 final l2 norm of the residuals 0.3998844D-10 number of function evaluations 94 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 4 dimension 4 initial l2 norm of the residuals 0.7349823D+07 final l2 norm of the residuals 0.1285689D-11 number of function evaluations 234 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 4 dimension 4 initial l2 norm of the residuals 0.7273070D+10 final l2 norm of the residuals 0.4568910D-09 number of function evaluations 494 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 5 dimension 3 initial l2 norm of the residuals 0.5000000D+02 final l2 norm of the residuals 0.2753440D-12 number of function evaluations 27 exit parameter 1 final approximate solution 0.1000000D+01 -0.1612103D-13 -0.8125674D-34 problem 5 dimension 3 initial l2 norm of the residuals 0.1029563D+03 final l2 norm of the residuals 0.2251025D-09 number of function evaluations 32 exit parameter 1 final approximate solution 0.1000000D+01 0.1388634D-10 0.0000000D+00 problem 5 dimension 3 initial l2 norm of the residuals 0.9912618D+03 final l2 norm of the residuals 0.1610831D-12 number of function evaluations 40 exit parameter 1 final approximate solution 0.1000000D+01 0.1238719D-14 0.0000000D+00 problem 6 dimension 6 initial l2 norm of the residuals 0.6848587D+02 final l2 norm of the residuals 0.3208563D-12 number of function evaluations 96 exit parameter 1 final approximate solution -0.1572509D-01 0.1012435D+01 -0.2329916D+00 0.1260430D+01 -0.1513729D+01 0.9929964D+00 problem 6 dimension 6 initial l2 norm of the residuals 0.3531259D+07 final l2 norm of the residuals 0.2333047D-10 number of function evaluations 310 exit parameter 1 final approximate solution -0.1572509D-01 0.1012435D+01 -0.2329916D+00 0.1260430D+01 -0.1513729D+01 0.9929964D+00 problem 6 dimension 9 initial l2 norm of the residuals 0.8878955D+02 final l2 norm of the residuals 0.3267200D-14 number of function evaluations 167 exit parameter 1 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 6 dimension 9 initial l2 norm of the residuals 0.1015108D+08 final l2 norm of the residuals 0.1716655D-11 number of function evaluations 175 exit parameter 1 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 7 dimension 5 initial l2 norm of the residuals 0.2257066D+00 final l2 norm of the residuals 0.3540441D-11 number of function evaluations 17 exit parameter 1 final approximate solution 0.8375126D-01 0.3127293D+00 0.5000000D+00 0.6872707D+00 0.9162487D+00 problem 7 dimension 5 initial l2 norm of the residuals 0.4117243D+07 final l2 norm of the residuals 0.1158079D-11 number of function evaluations 259 exit parameter 1 final approximate solution 0.6872707D+00 0.9162487D+00 0.5000000D+00 0.8375126D-01 0.3127293D+00 problem 7 dimension 5 initial l2 norm of the residuals 0.5636130D+12 final l2 norm of the residuals 0.4076007D-09 number of function evaluations 536 exit parameter 1 final approximate solution 0.5000000D+00 0.6872707D+00 0.8375126D-01 0.3127293D+00 0.9162487D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.2154720D+00 final l2 norm of the residuals 0.6867966D-09 number of function evaluations 25 exit parameter 1 final approximate solution 0.6687659D-01 0.3666823D+00 0.2887407D+00 0.7112593D+00 0.6333177D+00 0.9331234D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.1307925D+09 final l2 norm of the residuals 0.1003427D-11 number of function evaluations 173 exit parameter 1 final approximate solution 0.9331234D+00 0.2887407D+00 0.6687659D-01 0.7112593D+00 0.3666823D+00 0.6333177D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.1875579D+15 final l2 norm of the residuals 0.1182988D-10 number of function evaluations 266 exit parameter 1 final approximate solution 0.3666823D+00 0.6333177D+00 0.7112593D+00 0.6687659D-01 0.9331234D+00 0.2887407D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.1837679D+00 final l2 norm of the residuals 0.2398700D-08 number of function evaluations 20 exit parameter 1 final approximate solution 0.5806915D-01 0.2351716D+00 0.3380441D+00 0.5000000D+00 0.6619559D+00 0.7648284D+00 0.9419309D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.4269328D+10 final l2 norm of the residuals 0.9095716D-09 number of function evaluations 630 exit parameter 1 final approximate solution 0.3380441D+00 0.5000000D+00 0.2351716D+00 0.7648284D+00 0.9419309D+00 0.5806915D-01 0.6619559D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.6414317D+17 final l2 norm of the residuals 0.2491665D+15 number of function evaluations 180 exit parameter 4 final approximate solution -0.3267366D+02 -0.2996210D+02 -0.8587775D+02 0.2222113D+02 0.5957249D+02 -0.1038026D+01 0.8600843D+02 problem 7 dimension 8 initial l2 norm of the residuals 0.1965139D+00 final l2 norm of the residuals 0.6440509D-01 number of function evaluations 120 exit parameter 4 final approximate solution 0.4985640D-01 0.1986351D+00 0.2698288D+00 0.4992723D+00 0.5007277D+00 0.7301712D+00 0.8013649D+00 0.9501437D+00 problem 7 dimension 9 initial l2 norm of the residuals 0.1699499D+00 final l2 norm of the residuals 0.1889808D-08 number of function evaluations 41 exit parameter 1 final approximate solution 0.4420535D-01 0.1994907D+00 0.2356191D+00 0.4160469D+00 0.5000000D+00 0.5839531D+00 0.7643809D+00 0.8005093D+00 0.9557947D+00 problem 8 dimension 10 initial l2 norm of the residuals 0.1653022D+02 final l2 norm of the residuals 0.1925301D-13 number of function evaluations 31 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 10 initial l2 norm of the residuals 0.9765624D+07 final l2 norm of the residuals 0.4440892D-15 number of function evaluations 31 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 10 initial l2 norm of the residuals 0.9765625D+17 final l2 norm of the residuals 0.1299849D-12 number of function evaluations 40 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 30 initial l2 norm of the residuals 0.8347604D+02 final l2 norm of the residuals 0.1390247D-12 number of function evaluations 120 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 40 initial l2 norm of the residuals 0.1280264D+03 final l2 norm of the residuals 0.1055840D-12 number of function evaluations 153 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 9 dimension 10 initial l2 norm of the residuals 0.2808058D-01 final l2 norm of the residuals 0.2514039D-14 number of function evaluations 16 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 9 dimension 10 initial l2 norm of the residuals 0.5255526D+00 final l2 norm of the residuals 0.1726095D-12 number of function evaluations 19 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 9 dimension 10 initial l2 norm of the residuals 0.1065739D+03 final l2 norm of the residuals 0.4177561D-09 number of function evaluations 52 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 1 initial l2 norm of the residuals 0.1279297D+00 final l2 norm of the residuals 0.2775558D-16 number of function evaluations 7 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 1 initial l2 norm of the residuals 0.2562500D+01 final l2 norm of the residuals 0.5551115D-16 number of function evaluations 9 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 1 initial l2 norm of the residuals 0.8361172D+03 final l2 norm of the residuals 0.5551115D-16 number of function evaluations 16 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 10 initial l2 norm of the residuals 0.2518270D+00 final l2 norm of the residuals 0.5009132D-14 number of function evaluations 16 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 10 initial l2 norm of the residuals 0.6116833D+01 final l2 norm of the residuals 0.2188310D-12 number of function evaluations 19 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 10 initial l2 norm of the residuals 0.1269309D+04 final l2 norm of the residuals 0.3022340D-14 number of function evaluations 39 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 11 dimension 10 initial l2 norm of the residuals 0.8411753D-01 final l2 norm of the residuals 0.5296400D-02 number of function evaluations 130 exit parameter 4 final approximate solution 0.5526168D-01 0.5695771D-01 0.5889083D-01 0.6113625D-01 0.6377876D-01 0.6700506D-01 0.2079408D+00 0.1642667D+00 0.8644045D-01 0.9133610D-01 problem 11 dimension 10 initial l2 norm of the residuals 0.2030519D+02 final l2 norm of the residuals 0.5916907D-10 number of function evaluations 84 exit parameter 1 final approximate solution 0.3439629D-01 0.3503232D-01 0.3571920D-01 0.3646522D-01 0.3728091D-01 0.3817986D-01 0.3918014D-01 0.4030650D-01 0.1797202D+00 0.1562409D+00 problem 11 dimension 10 initial l2 norm of the residuals 0.9336937D+02 final l2 norm of the residuals 0.1824033D-08 number of function evaluations 85 exit parameter 1 final approximate solution 0.1888395D+02 0.2516777D+02 0.1888528D+02 0.1888602D+02 0.1888684D+02 0.1888774D+02 0.1888874D+02 0.1888986D+02 0.1902928D+02 0.1900580D+02 problem 12 dimension 10 initial l2 norm of the residuals 0.2240213D+07 final l2 norm of the residuals 0.5886077D-11 number of function evaluations 31 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 12 dimension 10 initial l2 norm of the residuals 0.5223438D+08 final l2 norm of the residuals 0.9391515D-12 number of function evaluations 35 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 12 dimension 10 initial l2 norm of the residuals 0.1592365D+12 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 84 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 13 dimension 10 initial l2 norm of the residuals 0.4582576D+01 final l2 norm of the residuals 0.1493879D-07 number of function evaluations 21 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818070D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 13 dimension 10 initial l2 norm of the residuals 0.6391009D+03 final l2 norm of the residuals 0.5056867D-08 number of function evaluations 59 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 13 dimension 10 initial l2 norm of the residuals 0.6333758D+05 final l2 norm of the residuals 0.9878833D-10 number of function evaluations 42 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1897367D+02 final l2 norm of the residuals 0.2057898D-08 number of function evaluations 30 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1713092D+05 final l2 norm of the residuals 0.7953611D-08 number of function evaluations 45 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1594986D+08 final l2 norm of the residuals 0.4526426D-09 number of function evaluations 58 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 1summary of 55 calls to hybrd1 nprob n nfev info final l2 norm 1 2 22 1 0.0000000D+00 1 2 9 1 0.0000000D+00 1 2 9 1 0.5373479D-12 2 4 108 4 0.1658388D-33 2 4 112 4 0.9820406D-35 2 4 143 4 0.4843140D-34 3 2 181 1 0.1712421D-08 3 2 11 1 0.3744485D-07 4 4 94 1 0.3998844D-10 4 4 234 1 0.1285689D-11 4 4 494 1 0.4568910D-09 5 3 27 1 0.2753440D-12 5 3 32 1 0.2251025D-09 5 3 40 1 0.1610831D-12 6 6 96 1 0.3208563D-12 6 6 310 1 0.2333047D-10 6 9 167 1 0.3267200D-14 6 9 175 1 0.1716655D-11 7 5 17 1 0.3540441D-11 7 5 259 1 0.1158079D-11 7 5 536 1 0.4076007D-09 7 6 25 1 0.6867966D-09 7 6 173 1 0.1003427D-11 7 6 266 1 0.1182988D-10 7 7 20 1 0.2398700D-08 7 7 630 1 0.9095716D-09 7 7 180 4 0.2491665D+15 7 8 120 4 0.6440509D-01 7 9 41 1 0.1889808D-08 8 10 31 1 0.1925301D-13 8 10 31 1 0.4440892D-15 8 10 40 1 0.1299849D-12 8 30 120 1 0.1390247D-12 8 40 153 1 0.1055840D-12 9 10 16 1 0.2514039D-14 9 10 19 1 0.1726095D-12 9 10 52 1 0.4177561D-09 10 1 7 1 0.2775558D-16 10 1 9 1 0.5551115D-16 10 1 16 1 0.5551115D-16 10 10 16 1 0.5009132D-14 10 10 19 1 0.2188310D-12 10 10 39 1 0.3022340D-14 11 10 130 4 0.5296400D-02 11 10 84 1 0.5916907D-10 11 10 85 1 0.1824033D-08 12 10 31 1 0.5886077D-11 12 10 35 1 0.9391515D-12 12 10 84 1 0.0000000D+00 13 10 21 1 0.1493879D-07 13 10 59 1 0.5056867D-08 13 10 42 1 0.9878833D-10 14 10 30 1 0.2057898D-08 14 10 45 1 0.7953611D-08 14 10 58 1 0.4526426D-09 cminpack-1.3.4/examples/ref/hybdrvc.ref000644 000765 000765 00000067234 12274453162 020027 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 5.3734794e-13 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 1.6583881e-34 number of function evaluations 96 number of Jacobian evaluations 3 exit parameter 4 final approximate solution -1.7172327e-18 1.7172327e-19 4.8857917e-18 4.8857917e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 9.8204058e-36 number of function evaluations 100 number of Jacobian evaluations 3 exit parameter 4 final approximate solution 1.1373388e-18 -1.1373388e-19 1.5092319e-18 1.5092319e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 3.5326233e-35 number of function evaluations 127 number of Jacobian evaluations 7 exit parameter 4 final approximate solution 1.6474368e-18 -1.6474368e-19 2.8757752e-18 2.8757752e-18 problem 3 dimension 2 initial l2 norm of the residuals 1.0654866e+00 final l2 norm of the residuals 1.7124214e-09 number of function evaluations 169 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 3.7444845e-08 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505574e+03 final l2 norm of the residuals 3.9988440e-11 number of function evaluations 86 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 1.2856890e-12 number of function evaluations 198 number of Jacobian evaluations 9 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730700e+09 final l2 norm of the residuals 4.5689102e-10 number of function evaluations 342 number of Jacobian evaluations 38 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 2.7534401e-13 number of function evaluations 18 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 -1.6121030e-14 -8.1256745e-35 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 2.2510251e-10 number of function evaluations 20 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.3886338e-11 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 1.6108311e-13 number of function evaluations 28 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.2387194e-15 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8485872e+01 final l2 norm of the residuals 3.2085628e-13 number of function evaluations 60 number of Jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312586e+06 final l2 norm of the residuals 2.3330469e-11 number of function evaluations 244 number of Jacobian evaluations 11 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789552e+01 final l2 norm of the residuals 3.2672000e-15 number of function evaluations 95 number of Jacobian evaluations 8 exit parameter 1 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151080e+07 final l2 norm of the residuals 1.7166545e-12 number of function evaluations 112 number of Jacobian evaluations 7 exit parameter 1 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 7 dimension 5 initial l2 norm of the residuals 2.2570657e-01 final l2 norm of the residuals 3.5404408e-12 number of function evaluations 12 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 8.3751256e-02 3.1272930e-01 5.0000000e-01 6.8727070e-01 9.1624874e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172432e+06 final l2 norm of the residuals 1.1580794e-12 number of function evaluations 139 number of Jacobian evaluations 24 exit parameter 1 final approximate solution 6.8727070e-01 9.1624874e-01 5.0000000e-01 8.3751256e-02 3.1272930e-01 problem 7 dimension 5 initial l2 norm of the residuals 5.6361303e+11 final l2 norm of the residuals 8.6364763e-10 number of function evaluations 216 number of Jacobian evaluations 42 exit parameter 1 final approximate solution 6.8727070e-01 3.1272930e-01 8.3751257e-02 9.1624874e-01 5.0000000e-01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547198e-01 final l2 norm of the residuals 6.8679664e-10 number of function evaluations 13 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876591e-02 3.6668230e-01 2.8874067e-01 7.1125933e-01 6.3331770e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079247e+08 final l2 norm of the residuals 1.0034267e-12 number of function evaluations 95 number of Jacobian evaluations 13 exit parameter 1 final approximate solution 9.3312341e-01 2.8874067e-01 6.6876591e-02 7.1125933e-01 3.6668230e-01 6.3331770e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755789e+14 final l2 norm of the residuals 8.4793498e-12 number of function evaluations 137 number of Jacobian evaluations 24 exit parameter 1 final approximate solution 2.8874067e-01 6.3331770e-01 7.1125933e-01 9.3312341e-01 3.6668230e-01 6.6876591e-02 problem 7 dimension 7 initial l2 norm of the residuals 1.8376789e-01 final l2 norm of the residuals 2.3987001e-09 number of function evaluations 13 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.8069150e-02 2.3517161e-01 3.3804410e-01 5.0000000e-01 6.6195591e-01 7.6482839e-01 9.4193085e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693282e+09 final l2 norm of the residuals 9.0957159e-10 number of function evaluations 294 number of Jacobian evaluations 48 exit parameter 1 final approximate solution 3.3804409e-01 5.0000000e-01 2.3517161e-01 7.6482839e-01 9.4193085e-01 5.8069150e-02 6.6195591e-01 problem 7 dimension 7 initial l2 norm of the residuals 6.4143166e+16 final l2 norm of the residuals 3.2740173e+14 number of function evaluations 64 number of Jacobian evaluations 10 exit parameter 4 final approximate solution -5.8426648e+01 -8.6451000e+00 -8.8719883e+01 -9.9793839e+00 7.3220548e+01 3.1247878e+01 8.7157466e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4405091e-02 number of function evaluations 56 number of Jacobian evaluations 8 exit parameter 4 final approximate solution 4.9856402e-02 1.9863513e-01 2.6982883e-01 4.9927232e-01 5.0072773e-01 7.3017122e-01 8.0136492e-01 9.5014366e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 1.8898075e-09 number of function evaluations 23 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.9253009e-14 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 4.4408921e-16 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 1.2998488e-13 number of function evaluations 20 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.3902475e-13 number of function evaluations 30 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 1.0558402e-13 number of function evaluations 33 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080582e-02 final l2 norm of the residuals 2.5140385e-15 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555258e-01 final l2 norm of the residuals 1.7260946e-13 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657390e+02 final l2 norm of the residuals 4.1775615e-10 number of function evaluations 42 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 2.7755576e-17 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 15 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182701e-01 final l2 norm of the residuals 5.0091317e-15 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168330e+00 final l2 norm of the residuals 2.1883100e-13 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693089e+03 final l2 norm of the residuals 3.0223404e-15 number of function evaluations 19 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4117534e-02 final l2 norm of the residuals 5.2963744e-03 number of function evaluations 60 number of Jacobian evaluations 7 exit parameter 4 final approximate solution 5.5261171e-02 5.6957153e-02 5.8890230e-02 6.1135579e-02 6.3778015e-02 6.7004183e-02 2.0794171e-01 1.6426807e-01 8.6437149e-02 9.1332221e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 5.9143616e-11 number of function evaluations 34 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 3.4396289e-02 3.5032316e-02 3.5719196e-02 3.6465224e-02 3.7280912e-02 3.8179863e-02 3.9180141e-02 4.0306503e-02 1.7972019e-01 1.5624088e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3369375e+01 final l2 norm of the residuals 1.8210307e-09 number of function evaluations 45 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.8883952e+01 2.5167774e+01 1.8885275e+01 1.8886021e+01 1.8886837e+01 1.8887736e+01 1.8888736e+01 1.8889862e+01 1.9029276e+01 1.9005797e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 5.8860770e-12 number of function evaluations 21 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 9.3915146e-13 number of function evaluations 25 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 8.9546999e-13 number of function evaluations 42 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 13 dimension 10 initial l2 norm of the residuals 4.5825757e+00 final l2 norm of the residuals 1.4938794e-08 number of function evaluations 11 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910093e+02 final l2 norm of the residuals 5.0568673e-09 number of function evaluations 49 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337583e+04 final l2 norm of the residuals 9.8788330e-11 number of function evaluations 22 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973666e+01 final l2 norm of the residuals 2.0578981e-09 number of function evaluations 20 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 7.9536112e-09 number of function evaluations 25 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 4.5264262e-10 number of function evaluations 38 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 summary of 55 calls to hybrd1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 7 1 1 0.0000000e+00 1 2 7 1 1 5.3734794e-13 2 4 96 3 4 1.6583881e-34 2 4 100 3 4 9.8204058e-36 2 4 127 7 4 3.5326233e-35 3 2 169 6 1 1.7124214e-09 3 2 9 1 1 3.7444845e-08 4 4 86 2 1 3.9988440e-11 4 4 198 9 1 1.2856890e-12 4 4 342 38 1 4.5689102e-10 5 3 18 3 1 2.7534401e-13 5 3 20 4 1 2.2510251e-10 5 3 28 4 1 1.6108311e-13 6 6 60 6 1 3.2085628e-13 6 6 244 11 1 2.3330469e-11 6 9 95 8 1 3.2672000e-15 6 9 112 7 1 1.7166545e-12 7 5 12 1 1 3.5404408e-12 7 5 139 24 1 1.1580794e-12 7 5 216 42 1 8.6364763e-10 7 6 13 2 1 6.8679664e-10 7 6 95 13 1 1.0034267e-12 7 6 137 24 1 8.4793498e-12 7 7 13 1 1 2.3987001e-09 7 7 294 48 1 9.0957159e-10 7 7 64 10 4 3.2740173e+14 7 8 56 8 4 6.4405091e-02 7 9 23 2 1 1.8898075e-09 8 10 11 2 1 1.9253009e-14 8 10 11 2 1 4.4408921e-16 8 10 20 2 1 1.2998488e-13 8 30 30 3 1 1.3902475e-13 8 40 33 3 1 1.0558402e-13 9 10 6 1 1 2.5140385e-15 9 10 9 1 1 1.7260946e-13 9 10 42 1 1 4.1775615e-10 10 1 6 1 1 2.7755576e-17 10 1 8 1 1 5.5511151e-17 10 1 15 1 1 5.5511151e-17 10 10 6 1 1 5.0091317e-15 10 10 9 1 1 2.1883100e-13 10 10 19 2 1 3.0223404e-15 11 10 60 7 4 5.2963744e-03 11 10 34 5 1 5.9143616e-11 11 10 45 4 1 1.8210307e-09 12 10 21 1 1 5.8860770e-12 12 10 25 1 1 9.3915146e-13 12 10 42 4 1 8.9546999e-13 13 10 11 1 1 1.4938794e-08 13 10 49 1 1 5.0568673e-09 13 10 22 2 1 9.8788330e-11 14 10 20 1 1 2.0578981e-09 14 10 25 2 1 7.9536112e-09 14 10 38 2 1 4.5264262e-10 cminpack-1.3.4/examples/ref/hyjdrv.ref000644 000765 000765 00000067234 12305351616 017670 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 0.4919350D+01 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 1 dimension 2 initial l2 norm of the residuals 0.1340063D+04 final l2 norm of the residuals 0.2886580D-13 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 1 dimension 2 initial l2 norm of the residuals 0.1430001D+06 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 problem 2 dimension 4 initial l2 norm of the residuals 0.1466288D+02 final l2 norm of the residuals 0.6046010D-34 number of function evaluations 105 number of jacobian evaluations 6 exit parameter 4 final approximate solution 0.2695067D-17 -0.2695067D-18 0.3749757D-17 0.3749757D-17 problem 2 dimension 4 initial l2 norm of the residuals 0.1270984D+04 final l2 norm of the residuals 0.5013400D-34 number of function evaluations 124 number of jacobian evaluations 6 exit parameter 4 final approximate solution 0.2961048D-17 -0.2961048D-18 0.3392094D-17 0.3392094D-17 problem 2 dimension 4 initial l2 norm of the residuals 0.1268879D+06 final l2 norm of the residuals 0.2112179D-33 number of function evaluations 143 number of jacobian evaluations 13 exit parameter 4 final approximate solution -0.1125674D-16 0.1125674D-17 -0.6482313D-17 -0.6482313D-17 problem 3 dimension 2 initial l2 norm of the residuals 0.1065487D+01 final l2 norm of the residuals 0.1712673D-08 number of function evaluations 169 number of jacobian evaluations 6 exit parameter 1 final approximate solution 0.1098159D-04 0.9106147D+01 problem 3 dimension 2 initial l2 norm of the residuals 0.1000000D+01 final l2 norm of the residuals 0.3744062D-07 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.1098159D-04 0.9106147D+01 problem 4 dimension 4 initial l2 norm of the residuals 0.8550557D+04 final l2 norm of the residuals 0.3983947D-10 number of function evaluations 86 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 4 dimension 4 initial l2 norm of the residuals 0.7349823D+07 final l2 norm of the residuals 0.3771377D-09 number of function evaluations 202 number of jacobian evaluations 8 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 4 dimension 4 initial l2 norm of the residuals 0.7273070D+10 final l2 norm of the residuals 0.3478935D-10 number of function evaluations 386 number of jacobian evaluations 35 exit parameter 1 final approximate solution -0.9679740D+00 0.9471391D+00 -0.9695163D+00 0.9512477D+00 problem 5 dimension 3 initial l2 norm of the residuals 0.5000000D+02 final l2 norm of the residuals 0.2753440D-12 number of function evaluations 18 number of jacobian evaluations 3 exit parameter 1 final approximate solution 0.1000000D+01 -0.1612103D-13 0.0000000D+00 problem 5 dimension 3 initial l2 norm of the residuals 0.1029563D+03 final l2 norm of the residuals 0.2250995D-09 number of function evaluations 20 number of jacobian evaluations 4 exit parameter 1 final approximate solution 0.1000000D+01 0.1388617D-10 0.0000000D+00 problem 5 dimension 3 initial l2 norm of the residuals 0.9912618D+03 final l2 norm of the residuals 0.7202777D-09 number of function evaluations 37 number of jacobian evaluations 8 exit parameter 1 final approximate solution 0.1000000D+01 0.3234657D-10 0.0000000D+00 problem 6 dimension 6 initial l2 norm of the residuals 0.6848587D+02 final l2 norm of the residuals 0.3591108D-12 number of function evaluations 60 number of jacobian evaluations 6 exit parameter 1 final approximate solution -0.1572509D-01 0.1012435D+01 -0.2329916D+00 0.1260430D+01 -0.1513729D+01 0.9929964D+00 problem 6 dimension 6 initial l2 norm of the residuals 0.3531259D+07 final l2 norm of the residuals 0.3971695D-13 number of function evaluations 140 number of jacobian evaluations 6 exit parameter 1 final approximate solution -0.1572509D-01 0.1012435D+01 -0.2329916D+00 0.1260430D+01 -0.1513729D+01 0.9929964D+00 problem 6 dimension 9 initial l2 norm of the residuals 0.8878955D+02 final l2 norm of the residuals 0.5300605D-11 number of function evaluations 92 number of jacobian evaluations 4 exit parameter 1 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 6 dimension 9 initial l2 norm of the residuals 0.1015108D+08 final l2 norm of the residuals 0.3823081D-01 number of function evaluations 290 number of jacobian evaluations 12 exit parameter 4 final approximate solution 0.3119912D+00 0.1089342D+01 0.1379293D+01 -0.1175426D+02 0.6265968D+02 -0.1636005D+03 0.2326239D+03 -0.1697823D+03 0.5076762D+02 problem 7 dimension 5 initial l2 norm of the residuals 0.2257066D+00 final l2 norm of the residuals 0.6045759D-12 number of function evaluations 10 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.8375126D-01 0.3127293D+00 0.5000000D+00 0.6872707D+00 0.9162487D+00 problem 7 dimension 5 initial l2 norm of the residuals 0.4117243D+07 final l2 norm of the residuals 0.3782524D-10 number of function evaluations 134 number of jacobian evaluations 25 exit parameter 1 final approximate solution 0.8375126D-01 0.5000000D+00 0.3127293D+00 0.9162487D+00 0.6872707D+00 problem 7 dimension 5 initial l2 norm of the residuals 0.5636130D+12 final l2 norm of the residuals 0.1381501D-09 number of function evaluations 244 number of jacobian evaluations 47 exit parameter 1 final approximate solution 0.6872707D+00 0.5000000D+00 0.8375126D-01 0.3127293D+00 0.9162487D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.2154720D+00 final l2 norm of the residuals 0.1434346D-10 number of function evaluations 13 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.6687659D-01 0.3666823D+00 0.2887407D+00 0.7112593D+00 0.6333177D+00 0.9331234D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.1307925D+09 final l2 norm of the residuals 0.9427397D-10 number of function evaluations 91 number of jacobian evaluations 13 exit parameter 1 final approximate solution 0.9331234D+00 0.3666823D+00 0.6687659D-01 0.7112593D+00 0.2887407D+00 0.6333177D+00 problem 7 dimension 6 initial l2 norm of the residuals 0.1875579D+15 final l2 norm of the residuals 0.1953644D-09 number of function evaluations 137 number of jacobian evaluations 19 exit parameter 1 final approximate solution 0.6687659D-01 0.7112593D+00 0.2887407D+00 0.9331234D+00 0.6333177D+00 0.3666823D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.1837679D+00 final l2 norm of the residuals 0.1935566D-09 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.5806915D-01 0.2351716D+00 0.3380441D+00 0.5000000D+00 0.6619559D+00 0.7648284D+00 0.9419309D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.4269328D+10 final l2 norm of the residuals 0.6180272D-10 number of function evaluations 326 number of jacobian evaluations 49 exit parameter 1 final approximate solution 0.3380441D+00 0.2351716D+00 0.9419309D+00 0.7648284D+00 0.6619559D+00 0.5806915D-01 0.5000000D+00 problem 7 dimension 7 initial l2 norm of the residuals 0.6414317D+17 final l2 norm of the residuals 0.6655717D+13 number of function evaluations 53 number of jacobian evaluations 12 exit parameter 4 final approximate solution -0.4649136D+02 -0.1039521D+02 -0.7517577D+01 0.1217934D+02 0.4297678D+02 0.2373113D+02 0.4306104D+02 problem 7 dimension 8 initial l2 norm of the residuals 0.1965139D+00 final l2 norm of the residuals 0.6440512D-01 number of function evaluations 56 number of jacobian evaluations 8 exit parameter 4 final approximate solution 0.4985640D-01 0.1986351D+00 0.2698288D+00 0.4992723D+00 0.5007277D+00 0.7301712D+00 0.8013649D+00 0.9501436D+00 problem 7 dimension 9 initial l2 norm of the residuals 0.1699499D+00 final l2 norm of the residuals 0.2699639D-08 number of function evaluations 22 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.4420535D-01 0.1994907D+00 0.2356191D+00 0.4160469D+00 0.5000000D+00 0.5839531D+00 0.7643809D+00 0.8005093D+00 0.9557947D+00 problem 8 dimension 10 initial l2 norm of the residuals 0.1653022D+02 final l2 norm of the residuals 0.1114710D-13 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 10 initial l2 norm of the residuals 0.9765624D+07 final l2 norm of the residuals 0.8685322D-14 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 10 initial l2 norm of the residuals 0.9765625D+17 final l2 norm of the residuals 0.1007921D-13 number of function evaluations 17 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 8 dimension 30 initial l2 norm of the residuals 0.8347604D+02 final l2 norm of the residuals 0.1213683D-12 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 8 dimension 40 initial l2 norm of the residuals 0.1280264D+03 final l2 norm of the residuals 0.1115411D-12 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 9 dimension 10 initial l2 norm of the residuals 0.2808058D-01 final l2 norm of the residuals 0.2514039D-14 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 9 dimension 10 initial l2 norm of the residuals 0.5255526D+00 final l2 norm of the residuals 0.1726010D-12 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 9 dimension 10 initial l2 norm of the residuals 0.1065739D+03 final l2 norm of the residuals 0.4175448D-09 number of function evaluations 42 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 1 initial l2 norm of the residuals 0.1279297D+00 final l2 norm of the residuals 0.2775558D-16 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 1 initial l2 norm of the residuals 0.2562500D+01 final l2 norm of the residuals 0.5551115D-16 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 1 initial l2 norm of the residuals 0.8361172D+03 final l2 norm of the residuals 0.2775558D-16 number of function evaluations 15 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.1528139D+00 problem 10 dimension 10 initial l2 norm of the residuals 0.2518270D+00 final l2 norm of the residuals 0.4992924D-14 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 10 initial l2 norm of the residuals 0.6116833D+01 final l2 norm of the residuals 0.2188257D-12 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 10 dimension 10 initial l2 norm of the residuals 0.1269309D+04 final l2 norm of the residuals 0.3062380D-14 number of function evaluations 19 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00 -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01 problem 11 dimension 10 initial l2 norm of the residuals 0.8411753D-01 final l2 norm of the residuals 0.5296392D-02 number of function evaluations 60 number of jacobian evaluations 7 exit parameter 4 final approximate solution 0.5526154D-01 0.5695755D-01 0.5889067D-01 0.6113606D-01 0.6377856D-01 0.6700482D-01 0.2079410D+00 0.1642671D+00 0.8643948D-01 0.9133506D-01 problem 11 dimension 10 initial l2 norm of the residuals 0.2030519D+02 final l2 norm of the residuals 0.5916701D-10 number of function evaluations 34 number of jacobian evaluations 5 exit parameter 1 final approximate solution 0.3439629D-01 0.3503232D-01 0.3571920D-01 0.3646522D-01 0.3728091D-01 0.3817986D-01 0.3918014D-01 0.4030650D-01 0.1797202D+00 0.1562409D+00 problem 11 dimension 10 initial l2 norm of the residuals 0.9336937D+02 final l2 norm of the residuals 0.1513856D-08 number of function evaluations 44 number of jacobian evaluations 4 exit parameter 1 final approximate solution 0.1888395D+02 0.2516777D+02 0.1888528D+02 0.1888602D+02 0.1888684D+02 0.1888774D+02 0.1888874D+02 0.1888986D+02 0.1902928D+02 0.1900580D+02 problem 12 dimension 10 initial l2 norm of the residuals 0.2240213D+07 final l2 norm of the residuals 0.5357531D-11 number of function evaluations 21 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 12 dimension 10 initial l2 norm of the residuals 0.5223438D+08 final l2 norm of the residuals 0.1259162D-09 number of function evaluations 25 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 12 dimension 10 initial l2 norm of the residuals 0.1592365D+12 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 38 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 13 dimension 10 initial l2 norm of the residuals 0.4582576D+01 final l2 norm of the residuals 0.1493879D-07 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818070D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 13 dimension 10 initial l2 norm of the residuals 0.6391009D+03 final l2 norm of the residuals 0.5192934D-08 number of function evaluations 49 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 13 dimension 10 initial l2 norm of the residuals 0.6333758D+05 final l2 norm of the residuals 0.9878903D-10 number of function evaluations 22 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00 -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1897367D+02 final l2 norm of the residuals 0.2057897D-08 number of function evaluations 20 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1713092D+05 final l2 norm of the residuals 0.7953613D-08 number of function evaluations 25 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 problem 14 dimension 10 initial l2 norm of the residuals 0.1594986D+08 final l2 norm of the residuals 0.4526431D-09 number of function evaluations 38 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00 -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00 1summary of 55 calls to hybrj1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000D+00 1 2 7 1 1 0.2886580D-13 1 2 7 1 1 0.0000000D+00 2 4 105 6 4 0.6046010D-34 2 4 124 6 4 0.5013400D-34 2 4 143 13 4 0.2112179D-33 3 2 169 6 1 0.1712673D-08 3 2 9 1 1 0.3744062D-07 4 4 86 2 1 0.3983947D-10 4 4 202 8 1 0.3771377D-09 4 4 386 35 1 0.3478935D-10 5 3 18 3 1 0.2753440D-12 5 3 20 4 1 0.2250995D-09 5 3 37 8 1 0.7202777D-09 6 6 60 6 1 0.3591108D-12 6 6 140 6 1 0.3971695D-13 6 9 92 4 1 0.5300605D-11 6 9 290 12 4 0.3823081D-01 7 5 10 1 1 0.6045759D-12 7 5 134 25 1 0.3782524D-10 7 5 244 47 1 0.1381501D-09 7 6 13 2 1 0.1434346D-10 7 6 91 13 1 0.9427397D-10 7 6 137 19 1 0.1953644D-09 7 7 11 1 1 0.1935566D-09 7 7 326 49 1 0.6180272D-10 7 7 53 12 4 0.6655717D+13 7 8 56 8 4 0.6440512D-01 7 9 22 2 1 0.2699639D-08 8 10 11 2 1 0.1114710D-13 8 10 11 2 1 0.8685322D-14 8 10 17 2 1 0.1007921D-13 8 30 12 2 1 0.1213683D-12 8 40 12 2 1 0.1115411D-12 9 10 6 1 1 0.2514039D-14 9 10 9 1 1 0.1726010D-12 9 10 42 1 1 0.4175448D-09 10 1 6 1 1 0.2775558D-16 10 1 8 1 1 0.5551115D-16 10 1 15 1 1 0.2775558D-16 10 10 6 1 1 0.4992924D-14 10 10 9 1 1 0.2188257D-12 10 10 19 2 1 0.3062380D-14 11 10 60 7 4 0.5296392D-02 11 10 34 5 1 0.5916701D-10 11 10 44 4 1 0.1513856D-08 12 10 21 1 1 0.5357531D-11 12 10 25 1 1 0.1259162D-09 12 10 38 2 1 0.0000000D+00 13 10 11 1 1 0.1493879D-07 13 10 49 1 1 0.5192934D-08 13 10 22 2 1 0.9878903D-10 14 10 20 1 1 0.2057897D-08 14 10 25 2 1 0.7953613D-08 14 10 38 2 1 0.4526431D-09 cminpack-1.3.4/examples/ref/hyjdrvc.ref000644 000765 000765 00000067234 12274453162 020037 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 2.8865799e-14 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.0460100e-35 number of function evaluations 105 number of jacobian evaluations 6 exit parameter 4 final approximate solution 2.6950668e-18 -2.6950668e-19 3.7497570e-18 3.7497570e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 5.1548784e-35 number of function evaluations 118 number of jacobian evaluations 7 exit parameter 4 final approximate solution 2.9249006e-18 -2.9249006e-19 3.4433850e-18 3.4433850e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 1.6136521e-34 number of function evaluations 175 number of jacobian evaluations 16 exit parameter 4 final approximate solution -9.6794799e-18 9.6794799e-19 -5.7104418e-18 -5.7104418e-18 problem 3 dimension 2 initial l2 norm of the residuals 1.0654866e+00 final l2 norm of the residuals 1.7126732e-09 number of function evaluations 169 number of jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 3.7440617e-08 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505574e+03 final l2 norm of the residuals 3.9839466e-11 number of function evaluations 86 number of jacobian evaluations 2 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 3.7713773e-10 number of function evaluations 202 number of jacobian evaluations 8 exit parameter 1 final approximate solution -9.6797403e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730700e+09 final l2 norm of the residuals 3.4789348e-11 number of function evaluations 386 number of jacobian evaluations 35 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 2.7534405e-13 number of function evaluations 18 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 -1.6121033e-14 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 2.2509949e-10 number of function evaluations 20 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.3886171e-11 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 7.2027771e-10 number of function evaluations 37 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.0000000e+00 3.2346572e-11 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8485872e+01 final l2 norm of the residuals 3.5911084e-13 number of function evaluations 60 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312586e+06 final l2 norm of the residuals 3.9716952e-14 number of function evaluations 140 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789552e+01 final l2 norm of the residuals 5.3006054e-12 number of function evaluations 92 number of jacobian evaluations 4 exit parameter 1 final approximate solution -1.5307039e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151080e+07 final l2 norm of the residuals 3.8230808e-02 number of function evaluations 290 number of jacobian evaluations 12 exit parameter 4 final approximate solution 3.1199119e-01 1.0893424e+00 1.3792932e+00 -1.1754265e+01 6.2659676e+01 -1.6360049e+02 2.3262392e+02 -1.6978231e+02 5.0767617e+01 problem 7 dimension 5 initial l2 norm of the residuals 2.2570657e-01 final l2 norm of the residuals 6.0457589e-13 number of function evaluations 10 number of jacobian evaluations 1 exit parameter 1 final approximate solution 8.3751256e-02 3.1272930e-01 5.0000000e-01 6.8727070e-01 9.1624874e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172432e+06 final l2 norm of the residuals 3.7825240e-11 number of function evaluations 134 number of jacobian evaluations 25 exit parameter 1 final approximate solution 8.3751257e-02 5.0000000e-01 3.1272930e-01 9.1624874e-01 6.8727070e-01 problem 7 dimension 5 initial l2 norm of the residuals 5.6361303e+11 final l2 norm of the residuals 1.3374486e-10 number of function evaluations 241 number of jacobian evaluations 49 exit parameter 1 final approximate solution 3.1272930e-01 6.8727070e-01 8.3751257e-02 5.0000000e-01 9.1624874e-01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547198e-01 final l2 norm of the residuals 1.4343465e-11 number of function evaluations 13 number of jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876591e-02 3.6668230e-01 2.8874067e-01 7.1125933e-01 6.3331770e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079247e+08 final l2 norm of the residuals 9.4273970e-11 number of function evaluations 91 number of jacobian evaluations 13 exit parameter 1 final approximate solution 9.3312341e-01 3.6668230e-01 6.6876591e-02 7.1125933e-01 2.8874067e-01 6.3331770e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755789e+14 final l2 norm of the residuals 4.8578341e-11 number of function evaluations 161 number of jacobian evaluations 19 exit parameter 1 final approximate solution 6.6876591e-02 9.3312341e-01 2.8874067e-01 6.3331770e-01 7.1125933e-01 3.6668230e-01 problem 7 dimension 7 initial l2 norm of the residuals 1.8376789e-01 final l2 norm of the residuals 1.9355663e-10 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution 5.8069150e-02 2.3517161e-01 3.3804409e-01 5.0000000e-01 6.6195591e-01 7.6482839e-01 9.4193085e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693282e+09 final l2 norm of the residuals 9.4850560e-10 number of function evaluations 287 number of jacobian evaluations 45 exit parameter 1 final approximate solution 5.8069150e-02 7.6482839e-01 5.0000000e-01 3.3804410e-01 9.4193085e-01 2.3517161e-01 6.6195591e-01 problem 7 dimension 7 initial l2 norm of the residuals 6.4143166e+16 final l2 norm of the residuals 6.6689395e+12 number of function evaluations 48 number of jacobian evaluations 11 exit parameter 4 final approximate solution -4.6510183e+01 -1.0476168e+01 -7.3372811e+00 1.2103936e+01 4.3027770e+01 2.3762797e+01 4.3039762e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4405122e-02 number of function evaluations 56 number of jacobian evaluations 8 exit parameter 4 final approximate solution 4.9856400e-02 1.9863513e-01 2.6982882e-01 4.9927230e-01 5.0072770e-01 7.3017118e-01 8.0136487e-01 9.5014360e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 2.6996389e-09 number of function evaluations 22 number of jacobian evaluations 2 exit parameter 1 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.1147104e-14 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 8.6853223e-15 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 1.0079211e-14 number of function evaluations 17 number of jacobian evaluations 2 exit parameter 1 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.2136830e-13 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 1.1154112e-13 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080582e-02 final l2 norm of the residuals 2.5140385e-15 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555258e-01 final l2 norm of the residuals 1.7260101e-13 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657390e+02 final l2 norm of the residuals 4.1754484e-10 number of function evaluations 42 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 3.3306691e-16 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 2.7755576e-17 number of function evaluations 24 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182701e-01 final l2 norm of the residuals 8.5698726e-12 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168330e+00 final l2 norm of the residuals 2.7315309e-12 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693089e+03 final l2 norm of the residuals 7.9371720e-14 number of function evaluations 48 number of jacobian evaluations 3 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4117534e-02 final l2 norm of the residuals 5.2963921e-03 number of function evaluations 60 number of jacobian evaluations 7 exit parameter 4 final approximate solution 5.5261544e-02 5.6957555e-02 5.8890667e-02 6.1136063e-02 6.3778558e-02 6.7004825e-02 2.0794103e-01 1.6426711e-01 8.6439479e-02 9.1335063e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 5.9167519e-11 number of function evaluations 34 number of jacobian evaluations 5 exit parameter 1 final approximate solution 3.4396289e-02 3.5032316e-02 3.5719196e-02 3.6465224e-02 3.7280912e-02 3.8179863e-02 3.9180141e-02 4.0306503e-02 1.7972019e-01 1.5624088e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3369375e+01 final l2 norm of the residuals 1.5134044e-09 number of function evaluations 44 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.8883952e+01 2.5167774e+01 1.8885275e+01 1.8886021e+01 1.8886837e+01 1.8887736e+01 1.8888736e+01 1.8889862e+01 1.9029276e+01 1.9005797e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 5.3575313e-12 number of function evaluations 21 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 1.2591618e-10 number of function evaluations 25 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 38 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 13 dimension 10 initial l2 norm of the residuals 4.5825757e+00 final l2 norm of the residuals 1.4938794e-08 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910093e+02 final l2 norm of the residuals 5.1929336e-09 number of function evaluations 49 number of jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337583e+04 final l2 norm of the residuals 9.8789030e-11 number of function evaluations 22 number of jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973666e+01 final l2 norm of the residuals 2.0578971e-09 number of function evaluations 20 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 7.9536129e-09 number of function evaluations 25 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 4.5264308e-10 number of function evaluations 38 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 summary of 55 calls to hybrj1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 7 1 1 2.8865799e-14 1 2 7 1 1 0.0000000e+00 2 4 105 6 4 6.0460100e-35 2 4 118 7 4 5.1548784e-35 2 4 175 16 4 1.6136521e-34 3 2 169 6 1 1.7126732e-09 3 2 9 1 1 3.7440617e-08 4 4 86 2 1 3.9839466e-11 4 4 202 8 1 3.7713773e-10 4 4 386 35 1 3.4789348e-11 5 3 18 3 1 2.7534405e-13 5 3 20 4 1 2.2509949e-10 5 3 37 8 1 7.2027771e-10 6 6 60 6 1 3.5911084e-13 6 6 140 6 1 3.9716952e-14 6 9 92 4 1 5.3006054e-12 6 9 290 12 4 3.8230808e-02 7 5 10 1 1 6.0457589e-13 7 5 134 25 1 3.7825240e-11 7 5 241 49 1 1.3374486e-10 7 6 13 2 1 1.4343465e-11 7 6 91 13 1 9.4273970e-11 7 6 161 19 1 4.8578341e-11 7 7 11 1 1 1.9355663e-10 7 7 287 45 1 9.4850560e-10 7 7 48 11 4 6.6689395e+12 7 8 56 8 4 6.4405122e-02 7 9 22 2 1 2.6996389e-09 8 10 11 2 1 1.1147104e-14 8 10 11 2 1 8.6853223e-15 8 10 17 2 1 1.0079211e-14 8 30 12 2 1 1.2136830e-13 8 40 12 2 1 1.1154112e-13 9 10 6 1 1 2.5140385e-15 9 10 9 1 1 1.7260101e-13 9 10 42 1 1 4.1754484e-10 10 1 6 1 1 3.3306691e-16 10 1 8 1 1 5.5511151e-17 10 1 24 2 1 2.7755576e-17 10 10 8 1 1 8.5698726e-12 10 10 9 1 1 2.7315309e-12 10 10 48 3 1 7.9371720e-14 11 10 60 7 4 5.2963921e-03 11 10 34 5 1 5.9167519e-11 11 10 44 4 1 1.5134044e-09 12 10 21 1 1 5.3575313e-12 12 10 25 1 1 1.2591618e-10 12 10 38 2 1 0.0000000e+00 13 10 11 1 1 1.4938794e-08 13 10 49 1 1 5.1929336e-09 13 10 22 2 1 9.8789030e-11 14 10 20 1 1 2.0578971e-09 14 10 25 2 1 7.9536129e-09 14 10 38 2 1 4.5264308e-10 cminpack-1.3.4/examples/ref/ibmdpdr.ref000644 000765 000765 00000000717 12225167750 020001 0ustar00devernay000000 000000 1MACHAR constants ibeta = 2 it = 53 irnd = 5 ngrd = 0 machep = -52 negep = -53 iexp = 11 minexp = -1022 maxexp = 1024 eps = 0.2220446D-15 epsneg = 0.1110223D-15 xmin = 0.2225074-307 xmax = 0.1797693+309 dpmpar constants and relative differences epsmch = 0.2220446D-15 rerr(1) = 0.0000000D+00 dwarf = 0.2225074-307 rerr(2) = 0.0000000D+00 giant = 0.1797693+309 rerr(3) = 0.0000000D+00 cminpack-1.3.4/examples/ref/ibmdpdrc.ref000644 000765 000765 00000000720 12225167750 020136 0ustar00devernay000000 000000 MACHAR constants ibeta = 2 it = 53 irnd = 5 ngrd = 0 machep = -52 negep = -53 iexp = 11 minexp = -1022 maxexp = 1024 eps = 2.2204460e-16 epsneg = 1.1102230e-16 xmin = 2.2250739e-308 xmax = 1.7976931e+308 DPMPAR constants and relative differences epsmch = 2.2204460e-16 rerr(1) = 0.0000000e+00 dwarf = 2.2250739e-308 rerr(2) = 0.0000000e+00 giant = 1.7976931e+308 rerr(3) = 0.0000000e+00 cminpack-1.3.4/examples/ref/lchkdrvc.ref000644 000765 000765 00000017205 12225167750 020160 0ustar00devernay000000 000000 problem 1 with dimension 2 is F first function vector 2.0770000e+00 -2.8292900e+00 function difference vector -1.6048551e-08 4.7636896e-07 error vector 3.6441652e-02 1.0000000e+00 problem 2 with dimension 4 is F first function vector -8.1070000e+00 -1.6859953e+00 1.8741610e+00 1.5952160e+01 function difference vector 2.1387637e-07 -2.5123287e-08 -3.5781055e-08 4.7541143e-07 error vector 1.0000000e+00 1.0000000e+00 5.6784314e-02 1.0000000e+00 problem 3 with dimension 2 is F first function vector 1.0777100e+03 3.0019279e-01 function difference vector 3.2148063e-05 -7.0575175e-09 error vector 0.0000000e+00 0.0000000e+00 problem 4 with dimension 4 is T first function vector -5.4127112e+03 -1.9649458e+03 -4.8718278e+03 -1.7769432e+03 function difference vector 2.3220785e-04 5.3351694e-05 2.0899135e-04 4.8083460e-05 error vector 9.8314445e-01 1.0000000e+00 9.6587806e-01 1.0000000e+00 problem 5 with dimension 3 is F first function vector -5.0987696e+01 -1.1441658e+00 1.2300000e-01 function difference vector 1.8328421e-08 -1.3196221e-07 1.8328428e-09 error vector 1.0000000e+00 0.0000000e+00 1.0000000e+00 problem 6 with dimension 9 is F first function vector -5.7930631e+00 -3.3390751e+01 -3.4683179e+01 -3.6368725e+01 -3.7947668e+01 -3.9431326e+01 -4.0834243e+01 -4.2170791e+01 -4.3453299e+01 function difference vector 4.5150085e-07 8.2526081e-07 1.0470759e-06 1.2208782e-06 1.3636127e-06 1.4852995e-06 1.5920150e-06 1.6876970e-06 1.7750240e-06 error vector 0.0000000e+00 4.4776909e-02 5.8948123e-02 7.0484722e-02 7.9955256e-02 8.8016532e-02 9.5043433e-02 1.0127560e-01 1.0687673e-01 problem 7 with dimension 7 is F first function vector 3.5142857e-02 -4.5634667e-02 2.1936396e-01 2.1302816e-01 2.5865828e-01 2.3088814e-01 5.9195986e-02 function difference vector 1.5424831e-08 2.0602874e-08 2.3769456e-08 5.3491546e-08 9.7040762e-08 1.5766330e-07 2.1121844e-07 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 8 with dimension 10 is T first function vector -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -9.9928526e-01 function difference vector 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 8.3789228e-08 8.0123543e-08 1.0650436e-10 error vector 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 with dimension 10 is F first function vector -3.8266208e-01 4.8185552e-01 -5.0497059e-01 4.8364359e-01 -5.0327111e-01 4.8731586e-01 -4.9982317e-01 4.9409864e-01 -4.9324735e-01 3.8308496e-01 function difference vector 5.7745994e-09 -7.0787115e-09 7.6314004e-09 -7.0535194e-09 7.6581295e-09 -7.0385017e-09 7.6852619e-09 -7.0470895e-09 6.4950392e-09 -2.8185304e-09 error vector 3.4189481e-02 1.6205676e-01 2.4769060e-02 8.2442013e-02 1.6527366e-02 7.4836913e-02 1.8515282e-02 1.0342218e-01 3.2259557e-02 1.2358623e-01 problem 10 with dimension 10 is F first function vector -1.6796677e-01 4.6728538e-02 -2.2043167e-01 1.7378706e-02 -2.2845451e-01 2.8983382e-02 -2.0089459e-01 6.9050605e-02 -1.5510284e-01 1.1399106e-01 function difference vector 3.2947051e-09 8.1481072e-10 5.4136278e-09 2.3810444e-09 6.4019805e-09 2.7647869e-09 6.1660951e-09 1.8821412e-09 4.6452768e-09 9.1337315e-10 error vector 0.0000000e+00 8.3217918e-03 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 4.4819193e-02 problem 11 with dimension 10 is F first function vector 1.4839305e-01 -4.6502477e-02 1.4892203e-01 3.0207835e-03 1.4945101e-01 5.2544044e-02 1.4997998e-01 1.0206730e-01 1.5050896e-01 1.5159056e-01 function difference vector 3.2845368e-09 1.8641646e-09 3.2687728e-09 3.3339513e-09 3.2530085e-09 4.8037387e-09 3.2372434e-09 6.2735230e-09 3.2214782e-09 7.7433100e-09 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 12 with dimension 10 is F first function vector -1.0878876e+05 -2.1757715e+05 -3.2636603e+05 -4.3515443e+05 -5.4394331e+05 -6.5273170e+05 -7.6152058e+05 -8.7030898e+05 -9.7909786e+05 -1.0878862e+06 function difference vector 2.2496541e-03 4.4992989e-03 6.7489363e-03 8.9985810e-03 1.1248218e-02 1.3497863e-02 1.5747500e-02 1.7997145e-02 2.0246784e-02 2.2496427e-02 error vector 2.0279172e-02 2.0279078e-02 2.0279130e-02 2.0279094e-02 2.0279122e-02 2.0279099e-02 2.0279119e-02 2.0279101e-02 2.0279116e-02 2.0279103e-02 problem 13 with dimension 10 is T first function vector -3.1372580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 -2.0462580e+00 function difference vector 9.9234522e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 3.4846602e-08 8.6166204e-08 6.8314610e-08 error vector 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 8.3229083e-01 1.0000000e+00 9.5783592e-01 problem 14 with dimension 10 is F first function vector -8.2193683e+00 -4.4028887e+00 -8.2496263e+00 -4.4331467e+00 -8.2798843e+00 -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252757e+00 function difference vector 3.5987758e-07 2.1860611e-07 3.9058166e-07 2.4931019e-07 4.2128574e-07 2.8001427e-07 4.3113925e-07 2.8001427e-07 4.3113925e-07 2.5916370e-07 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 summary of 14 tests of chkder nprob n status errmin errmax 1 2 F 3.6441652e-02 1.0000000e+00 2 4 F 5.6784314e-02 1.0000000e+00 3 2 F 0.0000000e+00 0.0000000e+00 4 4 T 9.6587806e-01 1.0000000e+00 5 3 F 0.0000000e+00 1.0000000e+00 6 9 F 0.0000000e+00 1.0687673e-01 7 7 F 0.0000000e+00 0.0000000e+00 8 10 T 1.0000000e+00 1.0000000e+00 9 10 F 1.6527366e-02 1.6205676e-01 10 10 F 0.0000000e+00 4.4819193e-02 11 10 F 0.0000000e+00 0.0000000e+00 12 10 F 2.0279078e-02 2.0279172e-02 13 10 T 8.3229083e-01 1.0000000e+00 14 10 F 0.0000000e+00 0.0000000e+00 cminpack-1.3.4/examples/ref/lhybdrvc.ref000644 000765 000765 00000067234 12303616324 020175 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 2.8865799e-14 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.7329231e-35 number of function evaluations 125 number of Jacobian evaluations 6 exit parameter 4 final approximate solution 3.1762199e-18 -3.1762199e-19 3.9431257e-18 3.9431257e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 1.7219216e-35 number of function evaluations 100 number of Jacobian evaluations 3 exit parameter 4 final approximate solution 1.5060210e-18 -1.5060210e-19 1.9984715e-18 1.9984715e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 1.0135415e-33 number of function evaluations 112 number of Jacobian evaluations 5 exit parameter 4 final approximate solution 1.5156390e-17 -1.5156390e-18 1.5160264e-17 1.5160264e-17 problem 3 dimension 2 initial l2 norm of the residuals 1.0654866e+00 final l2 norm of the residuals 1.7124937e-09 number of function evaluations 169 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 3.7444845e-08 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505574e+03 final l2 norm of the residuals 4.0021793e-11 number of function evaluations 86 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 5.2355556e-10 number of function evaluations 202 number of Jacobian evaluations 8 exit parameter 1 final approximate solution -9.6797403e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730700e+09 final l2 norm of the residuals 6.5921991e-10 number of function evaluations 387 number of Jacobian evaluations 34 exit parameter 1 final approximate solution -9.6797403e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 2.7534540e-13 number of function evaluations 18 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 -1.6121124e-14 -4.4523839e-35 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 2.2509998e-10 number of function evaluations 20 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.3886176e-11 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 1.6108272e-13 number of function evaluations 28 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.2385175e-15 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8485872e+01 final l2 norm of the residuals 3.0736102e-13 number of function evaluations 60 number of Jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312586e+06 final l2 norm of the residuals 2.3345119e-11 number of function evaluations 244 number of Jacobian evaluations 11 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789552e+01 final l2 norm of the residuals 1.2156859e-11 number of function evaluations 75 number of Jacobian evaluations 5 exit parameter 1 final approximate solution -1.5307033e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151080e+07 final l2 norm of the residuals 3.7112886e-12 number of function evaluations 112 number of Jacobian evaluations 8 exit parameter 1 final approximate solution -1.5307038e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 7 dimension 5 initial l2 norm of the residuals 2.2570657e-01 final l2 norm of the residuals 3.5407065e-12 number of function evaluations 12 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 8.3751256e-02 3.1272930e-01 5.0000000e-01 6.8727070e-01 9.1624874e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172432e+06 final l2 norm of the residuals 1.7872609e-10 number of function evaluations 141 number of Jacobian evaluations 23 exit parameter 1 final approximate solution 6.8727070e-01 5.0000000e-01 3.1272930e-01 9.1624874e-01 8.3751256e-02 problem 7 dimension 5 initial l2 norm of the residuals 5.6361303e+11 final l2 norm of the residuals 1.4643014e-09 number of function evaluations 265 number of Jacobian evaluations 53 exit parameter 1 final approximate solution 5.0000000e-01 3.1272930e-01 8.3751257e-02 6.8727071e-01 9.1624874e-01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547198e-01 final l2 norm of the residuals 6.9014105e-10 number of function evaluations 13 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876591e-02 3.6668230e-01 2.8874067e-01 7.1125933e-01 6.3331770e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079247e+08 final l2 norm of the residuals 4.6202317e-11 number of function evaluations 93 number of Jacobian evaluations 13 exit parameter 1 final approximate solution 9.3312341e-01 2.8874067e-01 6.6876591e-02 6.3331770e-01 3.6668230e-01 7.1125933e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755789e+14 final l2 norm of the residuals 5.3465737e-12 number of function evaluations 155 number of Jacobian evaluations 23 exit parameter 1 final approximate solution 6.6876591e-02 7.1125933e-01 3.6668230e-01 2.8874067e-01 9.3312341e-01 6.3331770e-01 problem 7 dimension 7 initial l2 norm of the residuals 1.8376789e-01 final l2 norm of the residuals 2.3987000e-09 number of function evaluations 13 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.8069150e-02 2.3517161e-01 3.3804410e-01 5.0000000e-01 6.6195591e-01 7.6482839e-01 9.4193085e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693282e+09 final l2 norm of the residuals 1.6276543e-09 number of function evaluations 282 number of Jacobian evaluations 40 exit parameter 1 final approximate solution 3.3804409e-01 2.3517161e-01 6.6195591e-01 7.6482839e-01 9.4193085e-01 5.8069150e-02 5.0000000e-01 problem 7 dimension 7 initial l2 norm of the residuals 6.4143166e+16 final l2 norm of the residuals 6.3747400e+13 number of function evaluations 48 number of Jacobian evaluations 10 exit parameter 4 final approximate solution -4.9056418e+01 5.3734774e+01 -5.7165974e+00 -6.6355327e+01 3.6288515e+01 5.3862362e+01 6.4047330e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4405083e-02 number of function evaluations 56 number of Jacobian evaluations 8 exit parameter 4 final approximate solution 4.9856394e-02 1.9863512e-01 2.6982883e-01 4.9927232e-01 5.0072772e-01 7.3017123e-01 8.0136492e-01 9.5014367e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 1.8898062e-09 number of function evaluations 23 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 7.2292486e-15 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 9.3680721e-15 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 3.3987370e-11 number of function evaluations 28 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 2.8342670e-14 number of function evaluations 24 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 1.0673735e+00 problem 8 dimension 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 1.7656107e-13 number of function evaluations 12 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080582e-02 final l2 norm of the residuals 2.5008575e-15 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555258e-01 final l2 norm of the residuals 1.7260946e-13 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657390e+02 final l2 norm of the residuals 4.1686421e-10 number of function evaluations 42 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 2.7755576e-17 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 15 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182701e-01 final l2 norm of the residuals 5.0091317e-15 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168330e+00 final l2 norm of the residuals 2.1883100e-13 number of function evaluations 9 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693089e+03 final l2 norm of the residuals 3.0154185e-15 number of function evaluations 19 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4117534e-02 final l2 norm of the residuals 5.2963740e-03 number of function evaluations 60 number of Jacobian evaluations 7 exit parameter 4 final approximate solution 5.5261191e-02 5.6957155e-02 5.8890228e-02 6.1135571e-02 6.3778013e-02 6.7004177e-02 2.0794168e-01 1.6426807e-01 8.6437139e-02 9.1332304e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 5.9156709e-11 number of function evaluations 34 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 3.4396289e-02 3.5032316e-02 3.5719196e-02 3.6465224e-02 3.7280912e-02 3.8179863e-02 3.9180141e-02 4.0306503e-02 1.7972019e-01 1.5624088e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3369375e+01 final l2 norm of the residuals 1.8197812e-09 number of function evaluations 45 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.8883952e+01 2.5167774e+01 1.8885275e+01 1.8886021e+01 1.8886837e+01 1.8887736e+01 1.8888736e+01 1.8889862e+01 1.9029276e+01 1.9005797e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 4.3113603e-12 number of function evaluations 21 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 1.2582008e-10 number of function evaluations 25 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 2.9091854e-12 number of function evaluations 44 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 13 dimension 10 initial l2 norm of the residuals 4.5825757e+00 final l2 norm of the residuals 1.4938793e-08 number of function evaluations 11 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910093e+02 final l2 norm of the residuals 4.9598367e-09 number of function evaluations 49 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337583e+04 final l2 norm of the residuals 9.8788296e-11 number of function evaluations 22 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973666e+01 final l2 norm of the residuals 2.0578981e-09 number of function evaluations 20 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 7.9536120e-09 number of function evaluations 25 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 4.5264294e-10 number of function evaluations 38 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 summary of 55 calls to hybrd1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 7 1 1 2.8865799e-14 1 2 7 1 1 0.0000000e+00 2 4 125 6 4 6.7329231e-35 2 4 100 3 4 1.7219216e-35 2 4 112 5 4 1.0135415e-33 3 2 169 6 1 1.7124937e-09 3 2 9 1 1 3.7444845e-08 4 4 86 2 1 4.0021793e-11 4 4 202 8 1 5.2355556e-10 4 4 387 34 1 6.5921991e-10 5 3 18 3 1 2.7534540e-13 5 3 20 4 1 2.2509998e-10 5 3 28 4 1 1.6108272e-13 6 6 60 6 1 3.0736102e-13 6 6 244 11 1 2.3345119e-11 6 9 75 5 1 1.2156859e-11 6 9 112 8 1 3.7112886e-12 7 5 12 1 1 3.5407065e-12 7 5 141 23 1 1.7872609e-10 7 5 265 53 1 1.4643014e-09 7 6 13 2 1 6.9014105e-10 7 6 93 13 1 4.6202317e-11 7 6 155 23 1 5.3465737e-12 7 7 13 1 1 2.3987000e-09 7 7 282 40 1 1.6276543e-09 7 7 48 10 4 6.3747400e+13 7 8 56 8 4 6.4405083e-02 7 9 23 2 1 1.8898062e-09 8 10 11 2 1 7.2292486e-15 8 10 11 2 1 9.3680721e-15 8 10 28 2 1 3.3987370e-11 8 30 24 3 1 2.8342670e-14 8 40 12 2 1 1.7656107e-13 9 10 6 1 1 2.5008575e-15 9 10 9 1 1 1.7260946e-13 9 10 42 1 1 4.1686421e-10 10 1 6 1 1 2.7755576e-17 10 1 8 1 1 5.5511151e-17 10 1 15 1 1 5.5511151e-17 10 10 6 1 1 5.0091317e-15 10 10 9 1 1 2.1883100e-13 10 10 19 2 1 3.0154185e-15 11 10 60 7 4 5.2963740e-03 11 10 34 5 1 5.9156709e-11 11 10 45 4 1 1.8197812e-09 12 10 21 1 1 4.3113603e-12 12 10 25 1 1 1.2582008e-10 12 10 44 4 1 2.9091854e-12 13 10 11 1 1 1.4938793e-08 13 10 49 1 1 4.9598367e-09 13 10 22 2 1 9.8788296e-11 14 10 20 1 1 2.0578981e-09 14 10 25 2 1 7.9536120e-09 14 10 38 2 1 4.5264294e-10 cminpack-1.3.4/examples/ref/lhyjdrvc.ref000644 000765 000765 00000067234 12303616324 020205 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 5.7731597e-14 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 2.6867397e-13 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 9.3898145e-34 number of function evaluations 129 number of jacobian evaluations 9 exit parameter 4 final approximate solution 2.6037645e-17 -2.6037645e-18 1.1774788e-17 1.1774788e-17 problem 2 dimension 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 1.1660001e-34 number of function evaluations 115 number of jacobian evaluations 5 exit parameter 4 final approximate solution 3.7293367e-18 -3.7293367e-19 5.2078569e-18 5.2078569e-18 problem 2 dimension 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 1.5037667e-34 number of function evaluations 136 number of jacobian evaluations 8 exit parameter 4 final approximate solution 7.6974662e-18 -7.6974662e-19 8.0401606e-19 8.0401606e-19 problem 3 dimension 2 initial l2 norm of the residuals 1.0654866e+00 final l2 norm of the residuals 1.7126732e-09 number of function evaluations 169 number of jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 3.7440617e-08 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981593e-05 9.1061467e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505574e+03 final l2 norm of the residuals 3.9864938e-11 number of function evaluations 86 number of jacobian evaluations 2 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 3.7708389e-10 number of function evaluations 202 number of jacobian evaluations 8 exit parameter 1 final approximate solution -9.6797403e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730700e+09 final l2 norm of the residuals 3.4765464e-11 number of function evaluations 386 number of jacobian evaluations 35 exit parameter 1 final approximate solution -9.6797402e-01 9.4713914e-01 -9.6951631e-01 9.5124767e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 2.7534405e-13 number of function evaluations 18 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 -1.6121033e-14 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 2.2509949e-10 number of function evaluations 20 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 1.3886171e-11 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 7.2027771e-10 number of function evaluations 37 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.0000000e+00 3.2346572e-11 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8485872e+01 final l2 norm of the residuals 3.6180943e-13 number of function evaluations 60 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312586e+06 final l2 norm of the residuals 1.8534688e-14 number of function evaluations 140 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725086e-02 1.0124349e+00 -2.3299163e-01 1.2604301e+00 -1.5137289e+00 9.9299643e-01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789552e+01 final l2 norm of the residuals 8.0753333e-12 number of function evaluations 92 number of jacobian evaluations 4 exit parameter 1 final approximate solution -1.5307039e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151080e+07 final l2 norm of the residuals 3.7094147e-02 number of function evaluations 312 number of jacobian evaluations 12 exit parameter 4 final approximate solution 3.0813774e-01 1.0878564e+00 1.3158256e+00 -1.1048784e+01 5.9015736e+01 -1.5405742e+02 2.1915326e+02 -1.6003569e+02 4.7905036e+01 problem 7 dimension 5 initial l2 norm of the residuals 2.2570657e-01 final l2 norm of the residuals 6.0581676e-13 number of function evaluations 10 number of jacobian evaluations 1 exit parameter 1 final approximate solution 8.3751256e-02 3.1272930e-01 5.0000000e-01 6.8727070e-01 9.1624874e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172432e+06 final l2 norm of the residuals 3.6753202e-10 number of function evaluations 139 number of jacobian evaluations 25 exit parameter 1 final approximate solution 8.3751256e-02 5.0000000e-01 6.8727070e-01 9.1624874e-01 3.1272930e-01 problem 7 dimension 5 initial l2 norm of the residuals 5.6361303e+11 final l2 norm of the residuals 2.3439011e-13 number of function evaluations 240 number of jacobian evaluations 49 exit parameter 1 final approximate solution 5.0000000e-01 6.8727070e-01 8.3751256e-02 3.1272930e-01 9.1624874e-01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547198e-01 final l2 norm of the residuals 1.4343271e-11 number of function evaluations 13 number of jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876591e-02 3.6668230e-01 2.8874067e-01 7.1125933e-01 6.3331770e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079247e+08 final l2 norm of the residuals 7.9707626e-11 number of function evaluations 91 number of jacobian evaluations 13 exit parameter 1 final approximate solution 9.3312341e-01 3.6668230e-01 6.6876591e-02 7.1125933e-01 2.8874067e-01 6.3331770e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755789e+14 final l2 norm of the residuals 1.7052372e-09 number of function evaluations 149 number of jacobian evaluations 21 exit parameter 1 final approximate solution 6.6876591e-02 2.8874067e-01 7.1125933e-01 9.3312341e-01 3.6668230e-01 6.3331770e-01 problem 7 dimension 7 initial l2 norm of the residuals 1.8376789e-01 final l2 norm of the residuals 1.9401758e-10 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution 5.8069150e-02 2.3517161e-01 3.3804409e-01 5.0000000e-01 6.6195591e-01 7.6482839e-01 9.4193085e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693282e+09 final l2 norm of the residuals 4.3338116e-11 number of function evaluations 278 number of jacobian evaluations 41 exit parameter 1 final approximate solution 5.0000000e-01 5.8069150e-02 7.6482839e-01 2.3517161e-01 3.3804409e-01 9.4193085e-01 6.6195591e-01 problem 7 dimension 7 initial l2 norm of the residuals 6.4143166e+16 final l2 norm of the residuals 7.5499342e-10 number of function evaluations 462 number of jacobian evaluations 72 exit parameter 1 final approximate solution 3.3804409e-01 7.6482839e-01 5.0000000e-01 5.8069150e-02 9.4193085e-01 2.3517161e-01 6.6195591e-01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4405122e-02 number of function evaluations 56 number of jacobian evaluations 8 exit parameter 4 final approximate solution 4.9856400e-02 1.9863513e-01 2.6982882e-01 4.9927230e-01 5.0072770e-01 7.3017118e-01 8.0136487e-01 9.5014360e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 5.1363371e-10 number of function evaluations 23 number of jacobian evaluations 2 exit parameter 1 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 9.5382309e-15 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 4.0716587e-15 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 7.0654161e-15 number of function evaluations 14 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 2.5110722e-13 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 8 dimension 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 4.0976706e-14 number of function evaluations 12 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080582e-02 final l2 norm of the residuals 2.5294765e-15 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555258e-01 final l2 norm of the residuals 1.7259548e-13 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657390e+02 final l2 norm of the residuals 4.1767728e-10 number of function evaluations 42 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 3.3306691e-16 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 5.5511151e-17 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 2.7755576e-17 number of function evaluations 24 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182701e-01 final l2 norm of the residuals 8.5698726e-12 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168330e+00 final l2 norm of the residuals 2.7315309e-12 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693089e+03 final l2 norm of the residuals 7.9316980e-14 number of function evaluations 48 number of jacobian evaluations 3 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4117534e-02 final l2 norm of the residuals 5.2963921e-03 number of function evaluations 60 number of jacobian evaluations 7 exit parameter 4 final approximate solution 5.5261544e-02 5.6957555e-02 5.8890667e-02 6.1136063e-02 6.3778558e-02 6.7004825e-02 2.0794103e-01 1.6426711e-01 8.6439479e-02 9.1335063e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 5.9166994e-11 number of function evaluations 34 number of jacobian evaluations 5 exit parameter 1 final approximate solution 3.4396289e-02 3.5032316e-02 3.5719196e-02 3.6465224e-02 3.7280912e-02 3.8179863e-02 3.9180141e-02 4.0306503e-02 1.7972019e-01 1.5624088e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3369375e+01 final l2 norm of the residuals 1.5135565e-09 number of function evaluations 44 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.8883952e+01 2.5167774e+01 1.8885275e+01 1.8886021e+01 1.8886837e+01 1.8887736e+01 1.8888736e+01 1.8889862e+01 1.9029276e+01 1.9005797e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 5.3575313e-12 number of function evaluations 21 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 1.2582008e-10 number of function evaluations 25 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 37 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 13 dimension 10 initial l2 norm of the residuals 4.5825757e+00 final l2 norm of the residuals 1.4938793e-08 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910093e+02 final l2 norm of the residuals 4.9865007e-09 number of function evaluations 49 number of jacobian evaluations 1 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337583e+04 final l2 norm of the residuals 9.8789021e-11 number of function evaluations 22 number of jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01 -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973666e+01 final l2 norm of the residuals 2.0578968e-09 number of function evaluations 20 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 7.9536129e-09 number of function evaluations 25 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 4.5264308e-10 number of function evaluations 38 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01 -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01 summary of 55 calls to hybrj1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 7 1 1 5.7731597e-14 1 2 7 1 1 2.6867397e-13 2 4 129 9 4 9.3898145e-34 2 4 115 5 4 1.1660001e-34 2 4 136 8 4 1.5037667e-34 3 2 169 6 1 1.7126732e-09 3 2 9 1 1 3.7440617e-08 4 4 86 2 1 3.9864938e-11 4 4 202 8 1 3.7708389e-10 4 4 386 35 1 3.4765464e-11 5 3 18 3 1 2.7534405e-13 5 3 20 4 1 2.2509949e-10 5 3 37 8 1 7.2027771e-10 6 6 60 6 1 3.6180943e-13 6 6 140 6 1 1.8534688e-14 6 9 92 4 1 8.0753333e-12 6 9 312 12 4 3.7094147e-02 7 5 10 1 1 6.0581676e-13 7 5 139 25 1 3.6753202e-10 7 5 240 49 1 2.3439011e-13 7 6 13 2 1 1.4343271e-11 7 6 91 13 1 7.9707626e-11 7 6 149 21 1 1.7052372e-09 7 7 11 1 1 1.9401758e-10 7 7 278 41 1 4.3338116e-11 7 7 462 72 1 7.5499342e-10 7 8 56 8 4 6.4405122e-02 7 9 23 2 1 5.1363371e-10 8 10 11 2 1 9.5382309e-15 8 10 11 2 1 4.0716587e-15 8 10 14 2 1 7.0654161e-15 8 30 12 2 1 2.5110722e-13 8 40 12 2 1 4.0976706e-14 9 10 6 1 1 2.5294765e-15 9 10 9 1 1 1.7259548e-13 9 10 42 1 1 4.1767728e-10 10 1 6 1 1 3.3306691e-16 10 1 8 1 1 5.5511151e-17 10 1 24 2 1 2.7755576e-17 10 10 8 1 1 8.5698726e-12 10 10 9 1 1 2.7315309e-12 10 10 48 3 1 7.9316980e-14 11 10 60 7 4 5.2963921e-03 11 10 34 5 1 5.9166994e-11 11 10 44 4 1 1.5135565e-09 12 10 21 1 1 5.3575313e-12 12 10 25 1 1 1.2582008e-10 12 10 37 2 1 0.0000000e+00 13 10 11 1 1 1.4938793e-08 13 10 49 1 1 4.9865007e-09 13 10 22 2 1 9.8789021e-11 14 10 20 1 1 2.0578968e-09 14 10 25 2 1 7.9536129e-09 14 10 38 2 1 4.5264308e-10 cminpack-1.3.4/examples/ref/libmdpdrc.ref000644 000765 000765 00000000720 12225167750 020312 0ustar00devernay000000 000000 MACHAR constants ibeta = 2 it = 53 irnd = 5 ngrd = 0 machep = -52 negep = -53 iexp = 11 minexp = -1022 maxexp = 1024 eps = 2.2204460e-16 epsneg = 1.1102230e-16 xmin = 2.2250739e-308 xmax = 1.7976931e+308 DPMPAR constants and relative differences epsmch = 2.2204460e-16 rerr(1) = 0.0000000e+00 dwarf = 2.2250739e-308 rerr(2) = 0.0000000e+00 giant = 1.7976931e+308 rerr(3) = 0.0000000e+00 cminpack-1.3.4/examples/ref/llmddrvc.ref000644 000765 000765 00000063660 12303616324 020166 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.8153698e+02 -9.0268492e+01 -4.7189022e+01 -4.4634246e+01 1.3646418e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.8305009e+02 9.2025047e+01 -1.9625042e+02 4.6512524e+01 7.1261354e+00 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -2.1036153e+02 3.2120421e+01 8.1134568e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.6130541e+02 3.1521877e+02 -3.1705905e+02 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 9.9365238e-17 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 1.0000000e+00 -6.2433020e-18 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.0446789e-19 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 6.5639108e-21 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 3.1387778e-29 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 -1.9721523e-30 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 2.4437311e-33 number of function evaluations 58 number of jacobian evaluations 57 exit parameter 4 final approximate solution 3.3042352e-17 -3.3042352e-18 5.2867763e-18 5.2867763e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 9.5458248e-34 number of function evaluations 61 number of jacobian evaluations 60 exit parameter 4 final approximate solution 2.0651470e-17 -2.0651470e-18 3.3042352e-18 3.3042352e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 3.7288378e-34 number of function evaluations 65 number of jacobian evaluations 64 exit parameter 4 final approximate solution 1.2907169e-17 -1.2907169e-18 2.0651470e-18 2.0651470e-18 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682791e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679604e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410577e-02 1.1330367e+00 2.3436946e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 8.4066667e-01 -1.5884803e+08 -1.6437867e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 8.4066667e-01 -1.5894617e+08 -1.6446491e+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126265e-01 1.2305280e-01 1.3605322e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052193e-02 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 1.7536277e-02 number of function evaluations 500 number of jacobian evaluations 375 exit parameter 5 final approximate solution 1.9267822e-01 1.9412770e-01 1.2357617e-01 1.3738773e-01 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 3 final approximate solution 5.6096365e-03 6.1813463e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 7.9229524e+02 number of function evaluations 400 number of jacobian evaluations 348 exit parameter 5 final approximate solution 1.4659420e-11 3.3638870e+04 9.0044409e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -1.5724962e-02 1.0124349e+00 -2.3299172e-01 1.2604310e+00 -1.5137303e+00 9.9299727e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725190e-02 1.0124349e+00 -2.3299155e-01 1.2604293e+00 -1.5137278e+00 9.9299573e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724702e-02 1.0124349e+00 -2.3299192e-01 1.2604329e+00 -1.5137332e+00 9.9299902e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 3 final approximate solution -1.5307064e-05 9.9978970e-01 1.4763963e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044031e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 20 number of jacobian evaluations 16 exit parameter 3 final approximate solution -1.5307036e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 3 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 3 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 1.7554167e-16 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295429e+02 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -1.1591247e+01 1.3202487e+01 -4.0357480e-01 2.3673622e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -1.1595927e+01 1.3204187e+01 -4.0341736e-01 2.3677114e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295431e+02 number of function evaluations 237 number of jacobian evaluations 221 exit parameter 1 final approximate solution -1.1590261e+01 1.3202063e+01 -4.0369125e-01 2.3666284e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153665e-02 1.9309164e-01 2.6632859e-01 4.9999933e-01 5.0000067e-01 7.3367141e-01 8.0690836e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 1.7285145e-16 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620267e-02 1.6670878e-01 2.3917102e-01 3.9888529e-01 3.9888367e-01 6.0111633e-01 6.0111471e-01 7.6082898e-01 8.3329122e-01 9.4037973e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.0996253e-14 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 5.6664896e-15 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 2.3341102e-15 number of function evaluations 22 number of jacobian evaluations 20 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.2736102e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 1.0673735e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 3.2656036e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358465e+00 -1.4646868e+00 1.2867534e-02 2.2122701e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942856e-01 7.5417977e-01 9.0430008e-01 1.3657995e+00 4.8237320e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmder1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 2 2.2360680e+00 1 5 50 3 2 2 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 3 2 1 3.4826302e+00 3 5 10 3 2 1 1.9097274e+00 3 5 50 3 2 1 3.6917294e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 11 8 2 9.9365238e-17 5 3 3 20 15 2 1.0446789e-19 5 3 3 19 16 2 3.1387778e-29 6 4 4 58 57 4 2.4437311e-33 6 4 4 61 60 4 9.5458248e-34 6 4 4 65 64 4 3.7288378e-34 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 37 36 1 4.1747687e+00 8 3 15 14 13 1 4.1747687e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 78 70 1 3.2052193e-02 9 4 11 500 375 5 1.7536277e-02 10 3 16 126 116 3 9.3779451e+00 10 3 16 400 348 5 7.9229524e+02 11 6 31 8 7 1 4.7829594e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 8 7 3 1.1831146e-03 11 9 31 20 16 3 1.1831146e-03 11 9 31 19 16 3 1.1831146e-03 11 12 31 10 9 3 2.1731040e-05 11 12 31 13 12 2 2.1731040e-05 11 12 31 34 28 2 2.1731040e-05 12 3 10 7 6 2 1.7554167e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 254 236 1 2.9295429e+02 14 4 20 53 42 1 2.9295427e+02 14 4 20 237 221 1 2.9295431e+02 15 1 8 1 1 4 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 1.7285145e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 14 12 2 1.0996253e-14 16 10 10 13 8 2 5.6664896e-15 16 10 10 22 20 2 2.3341102e-15 16 30 30 19 14 2 1.2736102e-13 16 40 40 19 14 2 3.2656036e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/llmfdrvc.ref000644 000765 000765 00000063660 12303616324 020170 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.0000001e+00 -1.0000001e+00 -1.0000001e+00 -1.0000001e+00 -1.0000001e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.8153698e+02 -9.0268492e+01 -4.7189022e+01 -4.4634246e+01 1.3646418e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 4 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.8305009e+02 9.2025047e+01 -1.9625042e+02 4.6512524e+01 7.1261354e+00 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 4 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -2.1036153e+02 3.2120421e+01 8.1134568e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 4 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 5.3438572e+01 1.0507522e+02 -1.0551797e+02 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 22 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 2.2204460e-15 number of function evaluations 8 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 1.3095172e-24 number of function evaluations 12 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 1.0000000e+00 8.2279395e-26 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 3.9349508e-18 number of function evaluations 20 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 -2.4724025e-19 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 2.9410901e-23 number of function evaluations 19 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 -1.8479414e-24 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 2.2457141e-21 number of function evaluations 240 number of Jacobian evaluations 191 exit parameter 5 final approximate solution 3.9985632e-11 -3.9985632e-12 1.8965862e-11 1.8965862e-11 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 1.1058919e-23 number of function evaluations 238 number of Jacobian evaluations 191 exit parameter 5 final approximate solution 2.8137399e-12 -2.8137399e-13 1.3150055e-12 1.3150055e-12 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 2.6875607e-21 number of function evaluations 236 number of Jacobian evaluations 192 exit parameter 5 final approximate solution 4.3448748e-11 -4.3448748e-12 1.6489673e-11 1.6489673e-11 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of Jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682792e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679605e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of Jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410574e-02 1.1330366e+00 2.3436947e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 39 number of Jacobian evaluations 38 exit parameter 1 final approximate solution 8.4066668e-01 -1.6159201e+08 -1.6399377e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747688e+00 number of function evaluations 12 number of Jacobian evaluations 11 exit parameter 1 final approximate solution 8.4066668e-01 -6.1947688e+07 -6.3915538e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of Jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126271e-01 1.2305283e-01 1.3605325e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052193e-02 number of function evaluations 81 number of Jacobian evaluations 73 exit parameter 1 final approximate solution 3.9707619e+05 -1.4075877e+01 -1.7970545e+07 -1.1210050e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 3.0712644e-02 number of function evaluations 236 number of Jacobian evaluations 192 exit parameter 5 final approximate solution 3.1889875e-03 7.4743721e+02 7.3116249e+00 4.9374237e+00 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 126 number of Jacobian evaluations 116 exit parameter 1 final approximate solution 5.6096376e-03 6.1813462e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 6.2375992e+04 number of function evaluations 4 number of Jacobian evaluations 3 exit parameter 4 final approximate solution 1.3823523e+00 -3.6636336e+03 -2.2573445e+01 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 5.1046620e-02 number of function evaluations 8 number of Jacobian evaluations 7 exit parameter 1 final approximate solution -1.3890151e-24 1.0136384e+00 -2.4430340e-01 1.3737708e+00 -1.6856393e+00 1.0980970e+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of Jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725342e-02 1.0124348e+00 -2.3299123e-01 1.2604277e+00 -1.5137255e+00 9.9299452e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of Jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724511e-02 1.0124349e+00 -2.3299212e-01 1.2604345e+00 -1.5137355e+00 9.9300035e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1832136e-03 number of function evaluations 7 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 1.4030071e-22 9.9978965e-01 1.4781571e-02 1.4631641e-01 1.0009664e+00 -2.6181025e+00 4.1049670e+00 -3.1440487e+00 1.0527706e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 27 number of Jacobian evaluations 15 exit parameter 2 final approximate solution -1.5269840e-05 9.9978967e-01 1.4765380e-02 1.4632933e-01 1.0008750e+00 -2.6178472e+00 4.1045393e+00 -3.1436946e+00 1.0526466e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 27 number of Jacobian evaluations 16 exit parameter 2 final approximate solution -1.5427069e-05 9.9978975e-01 1.4761942e-02 1.4636023e-01 1.0007469e+00 -2.6175710e+00 4.1042150e+00 -3.1434981e+00 1.0525983e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1732666e-05 number of function evaluations 19 number of Jacobian evaluations 9 exit parameter 2 final approximate solution -1.8474583e-23 1.0000015e+00 -5.5283987e-04 3.4761319e-01 -1.5498280e-01 1.0445788e+00 -3.2235369e+00 7.2449098e+00 -1.0220812e+01 9.0370434e+00 -4.5261772e+00 1.0093225e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1733705e-05 number of function evaluations 29 number of Jacobian evaluations 14 exit parameter 2 final approximate solution 2.1574839e-07 1.0000015e+00 -5.5328562e-04 3.4762691e-01 -1.5508536e-01 1.0449720e+00 -3.2243978e+00 7.2460165e+00 -1.0221607e+01 9.0372968e+00 -4.5261645e+00 1.0093024e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 6.2295873e-02 number of function evaluations 45 number of Jacobian evaluations 29 exit parameter 2 final approximate solution 2.6980768e-04 1.0071351e+00 -5.5555361e-01 6.0129293e+00 -5.8774862e+00 -1.6714544e+02 1.0171006e+03 -2.7835752e+03 4.2626345e+03 -3.7654325e+03 1.7963185e+03 -3.5892973e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 2.4196750e-16 number of function evaluations 7 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295606e+02 number of function evaluations 212 number of Jacobian evaluations 197 exit parameter 5 final approximate solution -1.1566173e+01 1.3193525e+01 -4.0536878e-01 2.3565540e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 47 number of Jacobian evaluations 36 exit parameter 1 final approximate solution -1.1595736e+01 1.3204115e+01 -4.0345958e-01 2.3674399e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295445e+02 number of function evaluations 212 number of Jacobian evaluations 198 exit parameter 5 final approximate solution -1.1585620e+01 1.3200323e+01 -4.0299056e-01 2.3720726e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 2 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.0000001e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of Jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of Jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of Jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153666e-02 1.9309164e-01 2.6632860e-01 4.9999934e-01 5.0000067e-01 7.3367141e-01 8.0690837e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 3.3173509e-16 number of function evaluations 12 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620271e-02 1.6670879e-01 2.3917103e-01 3.9888529e-01 3.9888367e-01 6.0111634e-01 6.0111471e-01 7.6082899e-01 8.3329123e-01 9.4037974e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 1 final approximate solution -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 -5.4691298e-02 1.1546913e+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 5.0009355e-15 number of function evaluations 13 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 1.5987212e-14 number of function evaluations 22 number of Jacobian evaluations 20 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.1841974e-13 number of function evaluations 11 number of Jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 2.9952031e-13 number of function evaluations 11 number of Jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of Jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358465e+00 -1.4646867e+00 1.2867534e-02 2.2122701e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942857e-01 7.5417977e-01 9.0430008e-01 1.3657995e+00 4.8237319e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmdif1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 1 2.2360680e+00 1 5 50 3 2 1 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 4 2 1 3.4826302e+00 3 5 10 4 2 1 1.9097274e+00 3 5 50 4 2 1 3.6917294e+00 4 2 2 22 16 2 0.0000000e+00 4 2 2 8 5 2 2.2204460e-15 4 2 2 7 5 2 0.0000000e+00 5 3 3 12 9 2 1.3095172e-24 5 3 3 20 15 2 3.9349508e-18 5 3 3 19 16 2 2.9410901e-23 6 4 4 240 191 5 2.2457141e-21 6 4 4 238 191 5 1.1058919e-23 6 4 4 236 192 5 2.6875607e-21 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 39 38 1 4.1747687e+00 8 3 15 12 11 1 4.1747688e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 81 73 1 3.2052193e-02 9 4 11 236 192 5 3.0712644e-02 10 3 16 126 116 1 9.3779451e+00 10 3 16 4 3 4 6.2375992e+04 11 6 31 8 7 1 5.1046620e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 7 6 1 1.1832136e-03 11 9 31 27 15 2 1.1831146e-03 11 9 31 27 16 2 1.1831146e-03 11 12 31 19 9 2 2.1732666e-05 11 12 31 29 14 2 2.1733705e-05 11 12 31 45 29 2 6.2295873e-02 12 3 10 7 6 2 2.4196750e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 212 197 5 2.9295606e+02 14 4 20 47 36 1 2.9295427e+02 14 4 20 212 198 5 2.9295445e+02 15 1 8 2 1 1 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 3.3173509e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 7 5 1 1.0000000e+00 16 10 10 13 8 2 5.0009355e-15 16 10 10 22 20 2 1.5987212e-14 16 30 30 11 10 2 1.1841974e-13 16 40 40 11 10 2 2.9952031e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/llmsdrvc.ref000644 000765 000765 00000063653 12303616324 020207 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 2.5870517e+02 -1.5729225e+01 1.3072979e+02 -7.3646127e+00 -1.1796696e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 9.0599798e+01 7.6675815e+01 8.4636891e+01 3.8837907e+01 -1.3063681e+02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 5.7248808e+02 -2.7281786e+02 -8.1586533e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -1.4537178e+02 1.4389437e+02 -3.5227154e+01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 9.9365244e-17 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 1.0000000e+00 -6.2433024e-18 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.0446789e-19 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 6.5639108e-21 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 3.1387778e-29 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 -1.9721523e-30 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.1093279e-34 number of function evaluations 58 number of jacobian evaluations 57 exit parameter 4 final approximate solution 1.6521176e-17 -1.6521176e-18 2.6433882e-18 2.6433882e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 9.5458248e-34 number of function evaluations 61 number of jacobian evaluations 60 exit parameter 4 final approximate solution 2.0651470e-17 -2.0651470e-18 3.3042352e-18 3.3042352e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 3.7288378e-34 number of function evaluations 65 number of jacobian evaluations 64 exit parameter 4 final approximate solution 1.2907169e-17 -1.2907169e-18 2.0651470e-18 2.0651470e-18 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682791e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679604e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410577e-02 1.1330367e+00 2.3436946e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 8.4066667e-01 -1.5884803e+08 -1.6437867e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 8.4066667e-01 -1.5894617e+08 -1.6446491e+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126265e-01 1.2305280e-01 1.3605322e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052193e-02 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 497 number of jacobian evaluations 382 exit parameter 1 final approximate solution 1.9280620e-01 1.9129885e-01 1.2305962e-01 1.3606998e-01 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 3 final approximate solution 5.6096365e-03 6.1813463e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 8.0212850e+02 number of function evaluations 400 number of jacobian evaluations 348 exit parameter 5 final approximate solution 8.2696063e-12 3.4764457e+04 9.1661979e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -1.5724962e-02 1.0124349e+00 -2.3299172e-01 1.2604310e+00 -1.5137303e+00 9.9299727e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725190e-02 1.0124349e+00 -2.3299155e-01 1.2604293e+00 -1.5137278e+00 9.9299573e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724702e-02 1.0124349e+00 -2.3299192e-01 1.2604329e+00 -1.5137332e+00 9.9299902e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 2 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 20 number of jacobian evaluations 16 exit parameter 2 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution -1.5306952e-05 9.9978970e-01 1.4763963e-02 1.4634234e-01 1.0008210e+00 -2.6177310e+00 4.1044030e+00 -3.1436122e+00 1.0526264e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 2.4196750e-16 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295429e+02 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -1.1591250e+01 1.3202488e+01 -4.0357470e-01 2.3673625e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -1.1595927e+01 1.3204187e+01 -4.0341736e-01 2.3677114e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295430e+02 number of function evaluations 240 number of jacobian evaluations 224 exit parameter 1 final approximate solution -1.1590584e+01 1.3202187e+01 -4.0365222e-01 2.3668540e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153665e-02 1.9309164e-01 2.6632859e-01 4.9999933e-01 5.0000067e-01 7.3367141e-01 8.0690836e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 2.8820371e-16 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620267e-02 1.6670878e-01 2.3917102e-01 3.9888529e-01 3.9888367e-01 6.0111633e-01 6.0111471e-01 7.6082898e-01 8.3329122e-01 9.4037973e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 7.7118556e-15 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 8.0059321e-16 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 1.3989251e-14 number of function evaluations 29 number of jacobian evaluations 26 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 3.0626866e-15 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 1.0673735e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 2.9952031e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358465e+00 -1.4646868e+00 1.2867534e-02 2.2122701e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942856e-01 7.5417977e-01 9.0430008e-01 1.3657995e+00 4.8237320e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmstr1 nprob n m nfev njev info final L2 norm 1 5 10 3 2 2 2.2360680e+00 1 5 50 3 2 2 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 3 2 1 3.4826302e+00 3 5 10 3 2 1 1.9097274e+00 3 5 50 3 2 1 3.6917294e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 11 8 2 9.9365244e-17 5 3 3 20 15 2 1.0446789e-19 5 3 3 19 16 2 3.1387778e-29 6 4 4 58 57 4 6.1093279e-34 6 4 4 61 60 4 9.5458248e-34 6 4 4 65 64 4 3.7288378e-34 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 37 36 1 4.1747687e+00 8 3 15 14 13 1 4.1747687e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 78 70 1 3.2052193e-02 9 4 11 497 382 1 1.7535838e-02 10 3 16 126 116 3 9.3779451e+00 10 3 16 400 348 5 8.0212850e+02 11 6 31 8 7 1 4.7829594e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 8 7 2 1.1831146e-03 11 9 31 20 16 2 1.1831146e-03 11 9 31 18 15 1 1.1831146e-03 11 12 31 10 9 2 2.1731040e-05 11 12 31 13 12 2 2.1731040e-05 11 12 31 34 28 2 2.1731040e-05 12 3 10 7 6 2 2.4196750e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 254 236 1 2.9295429e+02 14 4 20 53 42 1 2.9295427e+02 14 4 20 240 224 1 2.9295430e+02 15 1 8 1 1 4 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 2.8820371e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 14 12 2 7.7118556e-15 16 10 10 13 8 2 8.0059321e-16 16 10 10 29 26 2 1.3989251e-14 16 30 30 19 14 2 3.0626866e-15 16 40 40 19 14 2 2.9952031e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/lmddrv.ref000644 000765 000765 00000063653 12305351633 017652 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 0.5000000D+01 final l2 norm of the residuals 0.2236068D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 problem 1 dimensions 5 50 initial l2 norm of the residuals 0.8062258D+01 final l2 norm of the residuals 0.6708204D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 problem 2 dimensions 5 10 initial l2 norm of the residuals 0.2915219D+03 final l2 norm of the residuals 0.1463850D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.1677968D+03 -0.8339841D+02 0.2211100D+03 -0.4119920D+02 -0.3275936D+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 0.3101600D+04 final l2 norm of the residuals 0.3482630D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.2030000D+02 -0.9650000D+01 -0.1652452D+03 -0.4325000D+01 0.1105331D+03 problem 3 dimensions 5 10 initial l2 norm of the residuals 0.1260397D+03 final l2 norm of the residuals 0.1909727D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 -0.2103615D+03 0.3212042D+02 0.8113457D+02 0.1000000D+01 problem 3 dimensions 5 50 initial l2 norm of the residuals 0.1748950D+04 final l2 norm of the residuals 0.3691729D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.3321495D+03 -0.4396852D+03 0.1636969D+03 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.4919350D+01 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1340063D+04 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1430001D+06 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.5000000D+02 final l2 norm of the residuals 0.9936523D-16 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.1000000D+01 -0.6243302D-17 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.1029563D+03 final l2 norm of the residuals 0.1044679D-18 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 0.1000000D+01 0.6563911D-20 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.9912618D+03 final l2 norm of the residuals 0.3138778D-28 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 0.1000000D+01 -0.1972152D-29 0.0000000D+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1466288D+02 final l2 norm of the residuals 0.6109328D-33 number of function evaluations 59 number of jacobian evaluations 58 exit parameter 4 final approximate solution 0.1652118D-16 -0.1652118D-17 0.2643388D-17 0.2643388D-17 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1270984D+04 final l2 norm of the residuals 0.9103608D-39 number of function evaluations 72 number of jacobian evaluations 71 exit parameter 4 final approximate solution 0.2016745D-19 -0.2016745D-20 0.3226792D-20 0.3226792D-20 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1268879D+06 final l2 norm of the residuals 0.2330524D-34 number of function evaluations 68 number of jacobian evaluations 67 exit parameter 4 final approximate solution 0.3226792D-17 -0.3226792D-18 0.5162867D-18 0.5162867D-18 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.2001250D+02 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 0.1141248D+02 -0.8968279D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1243283D+05 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1141300D+02 -0.8967960D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1142645D+08 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 0.1141278D+02 -0.8968051D+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.6456136D+01 final l2 norm of the residuals 0.9063596D-01 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 0.8241058D-01 0.1133037D+01 0.2343695D+01 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3614185D+02 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 0.8406667D+00 -0.1588480D+09 -0.1643787D+09 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3841147D+03 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 0.8406667D+00 -0.1589462D+09 -0.1644649D+09 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.7289151D-01 final l2 norm of the residuals 0.1753584D-01 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 0.1928078D+00 0.1912627D+00 0.1230528D+00 0.1360532D+00 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2979370D+01 final l2 norm of the residuals 0.3205219D-01 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 0.7286755D+06 -0.1407588D+02 -0.3297780D+08 -0.2057159D+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2995906D+02 final l2 norm of the residuals 0.1753584D-01 number of function evaluations 500 number of jacobian evaluations 380 exit parameter 5 final approximate solution 0.1927984D+00 0.1914737D+00 0.1230925D+00 0.1361510D+00 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4115347D+05 final l2 norm of the residuals 0.9377945D+01 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 2 final approximate solution 0.5609636D-02 0.6181346D+04 0.3452236D+03 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4168217D+07 final l2 norm of the residuals 0.7946453D+03 number of function evaluations 400 number of jacobian evaluations 346 exit parameter 5 final approximate solution 0.1287545D-10 0.3389213D+05 0.9041072D+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -0.1572496D-01 0.1012435D+01 -0.2329917D+00 0.1260431D+01 -0.1513730D+01 0.9929973D+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6433126D+04 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -0.1572519D-01 0.1012435D+01 -0.2329915D+00 0.1260429D+01 -0.1513728D+01 0.9929957D+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6742560D+06 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -0.1572470D-01 0.1012435D+01 -0.2329919D+00 0.1260433D+01 -0.1513733D+01 0.9929990D+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 3 final approximate solution -0.1530706D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1208813D+05 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 19 number of jacobian evaluations 15 exit parameter 1 final approximate solution -0.1530713D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1269109D+07 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 3 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 3 final approximate solution -0.6638060D-08 0.1000002D+01 -0.5639322D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.1922076D+05 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 3 final approximate solution -0.6637102D-08 0.1000002D+01 -0.5639322D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.2018918D+07 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 2 final approximate solution -0.6638060D-08 0.1000002D+01 -0.5639322D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 12 dimensions 3 10 initial l2 norm of the residuals 0.3211158D+02 final l2 norm of the residuals 0.2419675D-15 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+02 0.1000000D+01 problem 13 dimensions 2 10 initial l2 norm of the residuals 0.6458565D+02 final l2 norm of the residuals 0.1115178D+02 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.2578199D+00 0.2578300D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.2815438D+04 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -0.1159126D+02 0.1320249D+02 -0.4035744D+00 0.2367363D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.5550734D+06 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -0.1159593D+02 0.1320419D+02 -0.4034174D+00 0.2367711D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.6121125D+08 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 237 number of jacobian evaluations 221 exit parameter 1 final approximate solution -0.1159026D+02 0.1320206D+02 -0.4036878D+00 0.2366652D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1886238D+01 final l2 norm of the residuals 0.1886238D+01 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 0.5000000D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.5383344D+10 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1180887D+19 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 8 8 initial l2 norm of the residuals 0.1965139D+00 final l2 norm of the residuals 0.5930324D-01 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 0.4315366D-01 0.1930916D+00 0.2663286D+00 0.4999993D+00 0.5000007D+00 0.7336714D+00 0.8069084D+00 0.9568463D+00 problem 15 dimensions 9 9 initial l2 norm of the residuals 0.1699499D+00 final l2 norm of the residuals 0.1760084D-15 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 0.4420535D-01 0.1994907D+00 0.2356191D+00 0.4160469D+00 0.5000000D+00 0.5839531D+00 0.7643809D+00 0.8005093D+00 0.9557947D+00 problem 15 dimensions 10 10 initial l2 norm of the residuals 0.1837478D+00 final l2 norm of the residuals 0.8064710D-01 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.5962027D-01 0.1667088D+00 0.2391710D+00 0.3988853D+00 0.3988837D+00 0.6011163D+00 0.6011147D+00 0.7608290D+00 0.8332912D+00 0.9403797D+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.1653022D+02 final l2 norm of the residuals 0.8662586D-14 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765624D+07 final l2 norm of the residuals 0.5000936D-14 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765625D+17 final l2 norm of the residuals 0.5329071D-14 number of function evaluations 22 number of jacobian evaluations 20 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 0.8347604D+02 final l2 norm of the residuals 0.1482786D-12 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.1067374D+01 problem 16 dimensions 40 40 initial l2 norm of the residuals 0.1280264D+03 final l2 norm of the residuals 0.2024535D-12 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 17 dimensions 5 33 initial l2 norm of the residuals 0.9375640D+00 final l2 norm of the residuals 0.7392493D-02 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 0.3754100D+00 0.1935847D+01 -0.1464687D+01 0.1286753D-01 0.2212270D-01 problem 18 dimensions 11 65 initial l2 norm of the residuals 0.1446865D+01 final l2 norm of the residuals 0.2003440D+00 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1309977D+01 0.4315525D+00 0.6336613D+00 0.5994286D+00 0.7541798D+00 0.9043001D+00 0.1365799D+01 0.4823732D+01 0.2398685D+01 0.4568876D+01 0.5675342D+01 1summary of 53 calls to lmder1 nprob n m nfev njev info final l2 norm 1 5 10 3 2 3 0.2236068D+01 1 5 50 3 2 3 0.6708204D+01 2 5 10 3 2 1 0.1463850D+01 2 5 50 3 2 1 0.3482630D+01 3 5 10 3 2 1 0.1909727D+01 3 5 50 3 2 1 0.3691729D+01 4 2 2 21 16 4 0.0000000D+00 4 2 2 8 5 2 0.0000000D+00 4 2 2 6 4 2 0.0000000D+00 5 3 3 11 8 2 0.9936523D-16 5 3 3 20 15 2 0.1044679D-18 5 3 3 19 16 2 0.3138778D-28 6 4 4 59 58 4 0.6109328D-33 6 4 4 72 71 4 0.9103608D-39 6 4 4 68 67 4 0.2330524D-34 7 2 2 14 8 1 0.6998875D+01 7 2 2 19 12 1 0.6998875D+01 7 2 2 24 17 1 0.6998875D+01 8 3 15 6 5 1 0.9063596D-01 8 3 15 37 36 1 0.4174769D+01 8 3 15 14 13 1 0.4174769D+01 9 4 11 18 16 1 0.1753584D-01 9 4 11 78 70 1 0.3205219D-01 9 4 11 500 380 5 0.1753584D-01 10 3 16 126 116 2 0.9377945D+01 10 3 16 400 346 5 0.7946453D+03 11 6 31 8 7 1 0.4782959D-01 11 6 31 14 13 1 0.4782959D-01 11 6 31 15 14 1 0.4782959D-01 11 9 31 8 7 3 0.1183115D-02 11 9 31 19 15 1 0.1183115D-02 11 9 31 19 16 3 0.1183115D-02 11 12 31 10 9 3 0.2173104D-04 11 12 31 13 12 3 0.2173104D-04 11 12 31 34 28 2 0.2173104D-04 12 3 10 7 6 2 0.2419675D-15 13 2 10 21 12 1 0.1115178D+02 14 4 20 254 236 1 0.2929543D+03 14 4 20 53 42 1 0.2929543D+03 14 4 20 237 221 1 0.2929543D+03 15 1 8 1 1 4 0.1886238D+01 15 1 8 29 28 1 0.1884248D+01 15 1 8 47 46 1 0.1884248D+01 15 8 8 39 20 1 0.5930324D-01 15 9 9 12 9 2 0.1760084D-15 15 10 10 25 12 1 0.8064710D-01 16 10 10 14 12 2 0.8662586D-14 16 10 10 13 8 2 0.5000936D-14 16 10 10 22 20 2 0.5329071D-14 16 30 30 19 14 2 0.1482786D-12 16 40 40 19 14 2 0.2024535D-12 17 5 33 18 15 1 0.7392493D-02 18 11 65 16 12 1 0.2003440D+00 cminpack-1.3.4/examples/ref/lmddrvc.ref000644 000765 000765 00000063660 12274453162 020020 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.6779682e+02 -8.3398409e+01 2.2111004e+02 -4.1199205e+01 -3.2759364e+01 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -2.0299999e+01 -9.6499995e+00 -1.6524520e+02 -4.3249998e+00 1.1053306e+02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -2.1036153e+02 3.2120421e+01 8.1134568e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 3.3214949e+02 -4.3968519e+02 1.6369688e+02 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 9.9365231e-17 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 1.0000000e+00 -6.2433016e-18 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.0446789e-19 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 6.5639108e-21 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 3.1387778e-29 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 -1.9721523e-30 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.1093279e-34 number of function evaluations 59 number of jacobian evaluations 58 exit parameter 4 final approximate solution 1.6521176e-17 -1.6521176e-18 2.6433882e-18 2.6433882e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 9.1036079e-40 number of function evaluations 72 number of jacobian evaluations 71 exit parameter 4 final approximate solution 2.0167451e-20 -2.0167451e-21 3.2267922e-21 3.2267922e-21 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 2.3305236e-35 number of function evaluations 68 number of jacobian evaluations 67 exit parameter 4 final approximate solution 3.2267922e-18 -3.2267922e-19 5.1628675e-19 5.1628675e-19 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682791e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679604e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410577e-02 1.1330367e+00 2.3436946e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 8.4066667e-01 -1.5884803e+08 -1.6437867e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 8.4066667e-01 -1.5894617e+08 -1.6446491e+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126265e-01 1.2305280e-01 1.3605322e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052193e-02 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 1.7535840e-02 number of function evaluations 500 number of jacobian evaluations 380 exit parameter 5 final approximate solution 1.9279841e-01 1.9147368e-01 1.2309248e-01 1.3615096e-01 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 2 final approximate solution 5.6096365e-03 6.1813463e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 7.9940769e+02 number of function evaluations 400 number of jacobian evaluations 345 exit parameter 5 final approximate solution 9.7280559e-12 3.4443130e+04 9.1202916e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -1.5724962e-02 1.0124349e+00 -2.3299172e-01 1.2604310e+00 -1.5137303e+00 9.9299727e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725190e-02 1.0124349e+00 -2.3299155e-01 1.2604293e+00 -1.5137278e+00 9.9299573e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724702e-02 1.0124349e+00 -2.3299192e-01 1.2604329e+00 -1.5137332e+00 9.9299902e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 3 final approximate solution -1.5307064e-05 9.9978970e-01 1.4763963e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044031e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 19 number of jacobian evaluations 15 exit parameter 1 final approximate solution -1.5307133e-05 9.9978970e-01 1.4763963e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044031e+00 -3.1436122e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 3 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 10 number of jacobian evaluations 9 exit parameter 3 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 3 final approximate solution -6.6371022e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 2.4196750e-16 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295429e+02 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -1.1591255e+01 1.3202490e+01 -4.0357449e-01 2.3673631e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -1.1595927e+01 1.3204187e+01 -4.0341736e-01 2.3677114e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295431e+02 number of function evaluations 237 number of jacobian evaluations 221 exit parameter 1 final approximate solution -1.1590260e+01 1.3202063e+01 -4.0368768e-01 2.3666530e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153665e-02 1.9309164e-01 2.6632859e-01 4.9999933e-01 5.0000067e-01 7.3367141e-01 8.0690836e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 1.7600835e-16 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620267e-02 1.6670878e-01 2.3917102e-01 3.9888529e-01 3.9888367e-01 6.0111633e-01 6.0111471e-01 7.6082898e-01 8.3329122e-01 9.4037973e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 8.6625859e-15 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 5.0009355e-15 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 8.3739082e-15 number of function evaluations 22 number of jacobian evaluations 20 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.4827859e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 1.0673735e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 2.0245354e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358465e+00 -1.4646868e+00 1.2867534e-02 2.2122701e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942856e-01 7.5417977e-01 9.0430008e-01 1.3657995e+00 4.8237320e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmder1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 3 2.2360680e+00 1 5 50 3 2 3 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 3 2 1 3.4826302e+00 3 5 10 3 2 1 1.9097274e+00 3 5 50 3 2 1 3.6917294e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 11 8 2 9.9365231e-17 5 3 3 20 15 2 1.0446789e-19 5 3 3 19 16 2 3.1387778e-29 6 4 4 59 58 4 6.1093279e-34 6 4 4 72 71 4 9.1036079e-40 6 4 4 68 67 4 2.3305236e-35 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 37 36 1 4.1747687e+00 8 3 15 14 13 1 4.1747687e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 78 70 1 3.2052193e-02 9 4 11 500 380 5 1.7535840e-02 10 3 16 126 116 2 9.3779451e+00 10 3 16 400 345 5 7.9940769e+02 11 6 31 8 7 1 4.7829594e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 8 7 3 1.1831146e-03 11 9 31 19 15 1 1.1831146e-03 11 9 31 19 16 3 1.1831146e-03 11 12 31 10 9 3 2.1731040e-05 11 12 31 13 12 3 2.1731040e-05 11 12 31 34 28 2 2.1731040e-05 12 3 10 7 6 2 2.4196750e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 254 236 1 2.9295429e+02 14 4 20 53 42 1 2.9295427e+02 14 4 20 237 221 1 2.9295431e+02 15 1 8 1 1 4 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 1.7600835e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 14 12 2 8.6625859e-15 16 10 10 13 8 2 5.0009355e-15 16 10 10 22 20 2 8.3739082e-15 16 30 30 19 14 2 1.4827859e-13 16 40 40 19 14 2 2.0245354e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/lmfdrv.ref000644 000765 000765 00000063653 12305351611 017650 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 0.5000000D+01 final l2 norm of the residuals 0.2236068D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 problem 1 dimensions 5 50 initial l2 norm of the residuals 0.8062258D+01 final l2 norm of the residuals 0.6708204D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.9999999D+00 -0.9999999D+00 -0.9999999D+00 -0.9999999D+00 -0.9999999D+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 0.2915219D+03 final l2 norm of the residuals 0.1463850D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.1677968D+03 -0.8339841D+02 0.2211100D+03 -0.4119920D+02 -0.3275936D+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 0.3101600D+04 final l2 norm of the residuals 0.3482630D+01 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 1 final approximate solution -0.2030000D+02 -0.9650000D+01 -0.1652452D+03 -0.4325000D+01 0.1105331D+03 problem 3 dimensions 5 10 initial l2 norm of the residuals 0.1260397D+03 final l2 norm of the residuals 0.1909727D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 -0.2103615D+03 0.3212042D+02 0.8113457D+02 0.1000000D+01 problem 3 dimensions 5 50 initial l2 norm of the residuals 0.1748950D+04 final l2 norm of the residuals 0.3691729D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.1103866D+03 -0.1465594D+03 0.5473401D+02 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.4919350D+01 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 22 number of jacobian evaluations 16 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1340063D+04 final l2 norm of the residuals 0.2220446D-14 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1430001D+06 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 7 number of jacobian evaluations 5 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.5000000D+02 final l2 norm of the residuals 0.2268944D-15 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.1000000D+01 0.1425620D-16 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.1029563D+03 final l2 norm of the residuals 0.1129685D-16 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 0.1000000D+01 0.7098021D-18 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.9912618D+03 final l2 norm of the residuals 0.4337144D-21 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 0.1000000D+01 -0.2725108D-22 0.0000000D+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1466288D+02 final l2 norm of the residuals 0.3872589D-20 number of function evaluations 241 number of jacobian evaluations 190 exit parameter 5 final approximate solution 0.5263054D-10 -0.5263054D-11 0.2465982D-10 0.2465982D-10 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1270984D+04 final l2 norm of the residuals 0.2716944D-20 number of function evaluations 239 number of jacobian evaluations 191 exit parameter 5 final approximate solution 0.4417018D-10 -0.4417018D-11 0.2043853D-10 0.2043853D-10 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1268879D+06 final l2 norm of the residuals 0.7100324D-20 number of function evaluations 237 number of jacobian evaluations 191 exit parameter 5 final approximate solution 0.7114478D-10 -0.7114478D-11 0.3363832D-10 0.3363832D-10 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.2001250D+02 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 0.1141248D+02 -0.8968279D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1243283D+05 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1141300D+02 -0.8967960D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1142645D+08 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 0.1141278D+02 -0.8968051D+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.6456136D+01 final l2 norm of the residuals 0.9063596D-01 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 0.8241058D-01 0.1133037D+01 0.2343695D+01 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3614185D+02 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 42 number of jacobian evaluations 41 exit parameter 1 final approximate solution 0.8406667D+00 -0.2370848D+09 -0.2404887D+09 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3841147D+03 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 12 number of jacobian evaluations 11 exit parameter 1 final approximate solution 0.8406667D+00 -0.6605876D+08 -0.6952091D+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.7289151D-01 final l2 norm of the residuals 0.1753584D-01 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 0.1928078D+00 0.1912628D+00 0.1230528D+00 0.1360533D+00 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2979370D+01 final l2 norm of the residuals 0.3205219D-01 number of function evaluations 77 number of jacobian evaluations 68 exit parameter 1 final approximate solution 0.1829225D+06 -0.1407587D+02 -0.8278551D+07 -0.5164171D+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2995906D+02 final l2 norm of the residuals 0.3070912D-01 number of function evaluations 229 number of jacobian evaluations 193 exit parameter 5 final approximate solution 0.3731182D-02 0.6367392D+03 0.7288615D+01 0.4922700D+01 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4115347D+05 final l2 norm of the residuals 0.9377945D+01 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 1 final approximate solution 0.5609635D-02 0.6181347D+04 0.3452236D+03 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4168217D+07 final l2 norm of the residuals 0.6237599D+05 number of function evaluations 4 number of jacobian evaluations 3 exit parameter 4 final approximate solution 0.1382352D+01 -0.3663634D+04 -0.2257365D+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.5104662D-01 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -0.1389015D-23 0.1013638D+01 -0.2443034D+00 0.1373771D+01 -0.1685639D+01 0.1098097D+01 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6433126D+04 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -0.1572519D-01 0.1012435D+01 -0.2329916D+00 0.1260430D+01 -0.1513728D+01 0.9929959D+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6742560D+06 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -0.1572475D-01 0.1012435D+01 -0.2329918D+00 0.1260432D+01 -0.1513732D+01 0.9929986D+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.1183214D-02 number of function evaluations 9 number of jacobian evaluations 8 exit parameter 1 final approximate solution 0.1403007D-21 0.9997896D+00 0.1478229D-01 0.1463070D+00 0.1001012D+01 -0.2618209D+01 0.4105100D+01 -0.3144132D+01 0.1052792D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1208813D+05 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 29 number of jacobian evaluations 17 exit parameter 2 final approximate solution -0.1502306D-04 0.9997897D+00 0.1476368D-01 0.1463488D+00 0.1000792D+01 -0.2617666D+01 0.4104329D+01 -0.3143570D+01 0.1052617D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1269109D+07 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 28 number of jacobian evaluations 16 exit parameter 2 final approximate solution -0.1532379D-04 0.9997897D+00 0.1476311D-01 0.1463525D+00 0.1000778D+01 -0.2617638D+01 0.4104296D+01 -0.3143549D+01 0.1052612D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.2173128D-04 number of function evaluations 22 number of jacobian evaluations 11 exit parameter 2 final approximate solution -0.1847464D-22 0.1000002D+01 -0.5664287D-03 0.3478755D+00 -0.1572557D+00 0.1055543D+01 -0.3255800D+01 0.7305175D+01 -0.1029263D+02 0.9089961D+01 -0.4548150D+01 0.1013255D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.1922076D+05 final l2 norm of the residuals 0.2173188D-04 number of function evaluations 26 number of jacobian evaluations 13 exit parameter 2 final approximate solution 0.9744480D-07 0.1000002D+01 -0.5599460D-03 0.3477832D+00 -0.1565911D+00 0.1052712D+01 -0.3248142D+01 0.7291658D+01 -0.1027712D+02 0.9078802D+01 -0.4543583D+01 0.1012444D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.2018918D+07 final l2 norm of the residuals 0.2173286D-04 number of function evaluations 54 number of jacobian evaluations 30 exit parameter 2 final approximate solution -0.2091129D-07 0.1000002D+01 -0.5571966D-03 0.3477159D+00 -0.1559411D+00 0.1049321D+01 -0.3237501D+01 0.7270621D+01 -0.1025071D+02 0.9058370D+01 -0.4534698D+01 0.1010782D+01 problem 12 dimensions 3 10 initial l2 norm of the residuals 0.3211158D+02 final l2 norm of the residuals 0.1841097D-15 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+02 0.1000000D+01 problem 13 dimensions 2 10 initial l2 norm of the residuals 0.6458565D+02 final l2 norm of the residuals 0.1115178D+02 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.2578199D+00 0.2578300D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.2815438D+04 final l2 norm of the residuals 0.2929571D+03 number of function evaluations 212 number of jacobian evaluations 197 exit parameter 5 final approximate solution -0.1155962D+02 0.1319117D+02 -0.4017151D+00 0.2392897D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.5550734D+06 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 47 number of jacobian evaluations 36 exit parameter 1 final approximate solution -0.1159575D+02 0.1320412D+02 -0.4035077D+00 0.2367059D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.6121125D+08 final l2 norm of the residuals 0.2929544D+03 number of function evaluations 212 number of jacobian evaluations 197 exit parameter 5 final approximate solution -0.1158645D+02 0.1320063D+02 -0.4032512D+00 0.2370161D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1886238D+01 final l2 norm of the residuals 0.1886238D+01 number of function evaluations 2 number of jacobian evaluations 1 exit parameter 1 final approximate solution 0.5000000D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.5383344D+10 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1180887D+19 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 8 8 initial l2 norm of the residuals 0.1965139D+00 final l2 norm of the residuals 0.5930324D-01 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 0.4315367D-01 0.1930916D+00 0.2663286D+00 0.4999993D+00 0.5000007D+00 0.7336714D+00 0.8069084D+00 0.9568463D+00 problem 15 dimensions 9 9 initial l2 norm of the residuals 0.1699499D+00 final l2 norm of the residuals 0.1087510D-15 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 0.4420535D-01 0.1994907D+00 0.2356191D+00 0.4160469D+00 0.5000000D+00 0.5839531D+00 0.7643809D+00 0.8005093D+00 0.9557947D+00 problem 15 dimensions 10 10 initial l2 norm of the residuals 0.1837478D+00 final l2 norm of the residuals 0.8064710D-01 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.5962027D-01 0.1667088D+00 0.2391710D+00 0.3988853D+00 0.3988837D+00 0.6011163D+00 0.6011147D+00 0.7608290D+00 0.8332912D+00 0.9403797D+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.1653022D+02 final l2 norm of the residuals 0.1000000D+01 number of function evaluations 7 number of jacobian evaluations 5 exit parameter 1 final approximate solution -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 0.1154691D+02 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765624D+07 final l2 norm of the residuals 0.1465494D-13 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765625D+17 final l2 norm of the residuals 0.1000000D+01 number of function evaluations 34 number of jacobian evaluations 32 exit parameter 1 final approximate solution -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 0.1105466D+02 problem 16 dimensions 30 30 initial l2 norm of the residuals 0.8347604D+02 final l2 norm of the residuals 0.4304688D-13 number of function evaluations 11 number of jacobian evaluations 10 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 16 dimensions 40 40 initial l2 norm of the residuals 0.1280264D+03 final l2 norm of the residuals 0.3695687D-12 number of function evaluations 11 number of jacobian evaluations 10 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 17 dimensions 5 33 initial l2 norm of the residuals 0.9375640D+00 final l2 norm of the residuals 0.7392493D-02 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 0.3754100D+00 0.1935845D+01 -0.1464685D+01 0.1286753D-01 0.2212271D-01 problem 18 dimensions 11 65 initial l2 norm of the residuals 0.1446865D+01 final l2 norm of the residuals 0.2003440D+00 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1309977D+01 0.4315525D+00 0.6336613D+00 0.5994286D+00 0.7541798D+00 0.9043001D+00 0.1365799D+01 0.4823732D+01 0.2398685D+01 0.4568876D+01 0.5675342D+01 1summary of 53 calls to lmdif1 nprob n m nfev njev info final l2 norm 1 5 10 3 2 1 0.2236068D+01 1 5 50 3 2 1 0.6708204D+01 2 5 10 3 2 1 0.1463850D+01 2 5 50 5 2 1 0.3482630D+01 3 5 10 3 2 1 0.1909727D+01 3 5 50 3 2 1 0.3691729D+01 4 2 2 22 16 2 0.0000000D+00 4 2 2 8 5 2 0.2220446D-14 4 2 2 7 5 2 0.0000000D+00 5 3 3 11 8 2 0.2268944D-15 5 3 3 20 15 2 0.1129685D-16 5 3 3 19 16 2 0.4337144D-21 6 4 4 241 190 5 0.3872589D-20 6 4 4 239 191 5 0.2716944D-20 6 4 4 237 191 5 0.7100324D-20 7 2 2 14 8 1 0.6998875D+01 7 2 2 19 12 1 0.6998875D+01 7 2 2 24 17 1 0.6998875D+01 8 3 15 6 5 1 0.9063596D-01 8 3 15 42 41 1 0.4174769D+01 8 3 15 12 11 1 0.4174769D+01 9 4 11 18 16 1 0.1753584D-01 9 4 11 77 68 1 0.3205219D-01 9 4 11 229 193 5 0.3070912D-01 10 3 16 126 116 1 0.9377945D+01 10 3 16 4 3 4 0.6237599D+05 11 6 31 8 7 1 0.5104662D-01 11 6 31 14 13 1 0.4782959D-01 11 6 31 15 14 1 0.4782959D-01 11 9 31 9 8 1 0.1183214D-02 11 9 31 29 17 2 0.1183115D-02 11 9 31 28 16 2 0.1183115D-02 11 12 31 22 11 2 0.2173128D-04 11 12 31 26 13 2 0.2173188D-04 11 12 31 54 30 2 0.2173286D-04 12 3 10 7 6 2 0.1841097D-15 13 2 10 21 12 1 0.1115178D+02 14 4 20 212 197 5 0.2929571D+03 14 4 20 47 36 1 0.2929543D+03 14 4 20 212 197 5 0.2929544D+03 15 1 8 2 1 1 0.1886238D+01 15 1 8 29 28 1 0.1884248D+01 15 1 8 47 46 1 0.1884248D+01 15 8 8 39 20 1 0.5930324D-01 15 9 9 12 9 2 0.1087510D-15 15 10 10 25 12 1 0.8064710D-01 16 10 10 7 5 1 0.1000000D+01 16 10 10 13 8 2 0.1465494D-13 16 10 10 34 32 1 0.1000000D+01 16 30 30 11 10 2 0.4304688D-13 16 40 40 11 10 2 0.3695687D-12 17 5 33 18 15 1 0.7392493D-02 18 11 65 16 12 1 0.2003440D+00 cminpack-1.3.4/examples/ref/lmfdrvc.ref000644 000765 000765 00000063660 12274453162 020022 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -9.9999996e-01 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -9.9999989e-01 -9.9999989e-01 -9.9999989e-01 -9.9999989e-01 -9.9999989e-01 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -1.6779682e+02 -8.3398409e+01 2.2111004e+02 -4.1199205e+01 -3.2759364e+01 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 5 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -2.0299999e+01 -9.6499995e+00 -1.6524520e+02 -4.3249998e+00 1.1053306e+02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -2.1036153e+02 3.2120421e+01 8.1134568e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 3 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.1038660e+02 -1.4655944e+02 5.4734012e+01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 22 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 2.2204460e-15 number of function evaluations 8 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 8.6617632e-17 number of function evaluations 11 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 1.0000000e+00 -5.4423463e-18 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.1296851e-17 number of function evaluations 20 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 7.0980209e-19 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 7.8016363e-23 number of function evaluations 19 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 4.9019126e-24 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 1.1138530e-23 number of function evaluations 235 number of Jacobian evaluations 192 exit parameter 5 final approximate solution 2.5434075e-12 -2.5434075e-13 6.9489054e-13 6.9489054e-13 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 2.6976056e-21 number of function evaluations 236 number of Jacobian evaluations 192 exit parameter 5 final approximate solution 4.4007789e-11 -4.4007789e-12 2.0384062e-11 2.0384062e-11 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 1.5238485e-22 number of function evaluations 239 number of Jacobian evaluations 191 exit parameter 5 final approximate solution 1.0422573e-11 -1.0422573e-12 4.9279439e-12 4.9279439e-12 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of Jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682791e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679604e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of Jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410577e-02 1.1330367e+00 2.3436946e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 42 number of Jacobian evaluations 41 exit parameter 1 final approximate solution 8.4066667e-01 -2.3708475e+08 -2.4048867e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747688e+00 number of function evaluations 12 number of Jacobian evaluations 11 exit parameter 1 final approximate solution 8.4066669e-01 -6.6058762e+07 -6.9520911e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of Jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126276e-01 1.2305282e-01 1.3605327e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052194e-02 number of function evaluations 77 number of Jacobian evaluations 68 exit parameter 1 final approximate solution 1.8292249e+05 -1.4075873e+01 -8.2785511e+06 -5.1641708e+06 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 3.0709117e-02 number of function evaluations 229 number of Jacobian evaluations 193 exit parameter 5 final approximate solution 3.7311815e-03 6.3673921e+02 7.2886152e+00 4.9226995e+00 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 127 number of Jacobian evaluations 117 exit parameter 3 final approximate solution 5.6096366e-03 6.1813463e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 6.2375992e+04 number of function evaluations 4 number of Jacobian evaluations 3 exit parameter 4 final approximate solution 1.3823518e+00 -3.6636342e+03 -2.2573652e+01 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 5.1046620e-02 number of function evaluations 8 number of Jacobian evaluations 7 exit parameter 1 final approximate solution -1.3890151e-24 1.0136384e+00 -2.4430338e-01 1.3737707e+00 -1.6856393e+00 1.0980970e+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of Jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725188e-02 1.0124349e+00 -2.3299165e-01 1.2604296e+00 -1.5137281e+00 9.9299589e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of Jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724754e-02 1.0124349e+00 -2.3299184e-01 1.2604324e+00 -1.5137325e+00 9.9299862e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1832136e-03 number of function evaluations 9 number of Jacobian evaluations 8 exit parameter 1 final approximate solution 1.4030070e-22 9.9978965e-01 1.4782292e-02 1.4630699e-01 1.0010116e+00 -2.6182093e+00 4.1050998e+00 -3.1441324e+00 1.0527917e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 29 number of Jacobian evaluations 17 exit parameter 2 final approximate solution -1.5023065e-05 9.9978972e-01 1.4763678e-02 1.4634881e-01 1.0007919e+00 -2.6176662e+00 4.1043288e+00 -3.1435698e+00 1.0526171e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 28 number of Jacobian evaluations 16 exit parameter 2 final approximate solution -1.5323786e-05 9.9978966e-01 1.4763113e-02 1.4635249e-01 1.0007779e+00 -2.6176380e+00 4.1042958e+00 -3.1435495e+00 1.0526118e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1731283e-05 number of function evaluations 22 number of Jacobian evaluations 11 exit parameter 2 final approximate solution -1.8474637e-23 1.0000017e+00 -5.6642870e-04 3.4787546e-01 -1.5725570e-01 1.0555429e+00 -3.2558004e+00 7.3051748e+00 -1.0292631e+01 9.0899607e+00 -4.5481497e+00 1.0132549e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1731881e-05 number of function evaluations 26 number of Jacobian evaluations 13 exit parameter 2 final approximate solution 9.7444800e-08 1.0000015e+00 -5.5994597e-04 3.4778325e-01 -1.5659113e-01 1.0527117e+00 -3.2481418e+00 7.2916582e+00 -1.0277116e+01 9.0788016e+00 -4.5435831e+00 1.0124440e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 2.1732863e-05 number of function evaluations 54 number of Jacobian evaluations 30 exit parameter 2 final approximate solution -2.0911286e-08 1.0000015e+00 -5.5719655e-04 3.4771593e-01 -1.5594105e-01 1.0493206e+00 -3.2375007e+00 7.2706212e+00 -1.0250707e+01 9.0583704e+00 -4.5346979e+00 1.0107819e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 1.8410966e-16 number of function evaluations 7 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295526e+02 number of function evaluations 213 number of Jacobian evaluations 197 exit parameter 5 final approximate solution -1.1573786e+01 1.3196252e+01 -4.0709165e-01 2.3391777e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 49 number of Jacobian evaluations 38 exit parameter 1 final approximate solution -1.1595252e+01 1.3203937e+01 -4.0343758e-01 2.3676793e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295442e+02 number of function evaluations 212 number of Jacobian evaluations 197 exit parameter 5 final approximate solution -1.1586353e+01 1.3200591e+01 -4.0420616e-01 2.3635101e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 2 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.0000001e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of Jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of Jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of Jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153666e-02 1.9309164e-01 2.6632860e-01 4.9999934e-01 5.0000067e-01 7.3367141e-01 8.0690837e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 1.0875102e-16 number of function evaluations 12 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620271e-02 1.6670879e-01 2.3917103e-01 3.9888529e-01 3.9888367e-01 6.0111634e-01 6.0111472e-01 7.6082899e-01 8.3329123e-01 9.4037974e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 1 final approximate solution -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 1.1546913e+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 1.4654944e-14 number of function evaluations 13 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 34 number of Jacobian evaluations 32 exit parameter 1 final approximate solution -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 1.1054656e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 4.3046885e-14 number of function evaluations 11 number of Jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 3.6956867e-13 number of function evaluations 11 number of Jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of Jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358472e+00 -1.4646874e+00 1.2867535e-02 2.2122699e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of Jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942856e-01 7.5417978e-01 9.0430006e-01 1.3657995e+00 4.8237320e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmdif1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 1 2.2360680e+00 1 5 50 3 2 1 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 5 2 1 3.4826302e+00 3 5 10 3 2 1 1.9097274e+00 3 5 50 3 2 1 3.6917294e+00 4 2 2 22 16 2 0.0000000e+00 4 2 2 8 5 2 2.2204460e-15 4 2 2 7 5 2 0.0000000e+00 5 3 3 11 8 2 8.6617632e-17 5 3 3 20 15 2 1.1296851e-17 5 3 3 19 16 2 7.8016363e-23 6 4 4 235 192 5 1.1138530e-23 6 4 4 236 192 5 2.6976056e-21 6 4 4 239 191 5 1.5238485e-22 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 42 41 1 4.1747687e+00 8 3 15 12 11 1 4.1747688e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 77 68 1 3.2052194e-02 9 4 11 229 193 5 3.0709117e-02 10 3 16 127 117 3 9.3779451e+00 10 3 16 4 3 4 6.2375992e+04 11 6 31 8 7 1 5.1046620e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 9 8 1 1.1832136e-03 11 9 31 29 17 2 1.1831146e-03 11 9 31 28 16 2 1.1831146e-03 11 12 31 22 11 2 2.1731283e-05 11 12 31 26 13 2 2.1731881e-05 11 12 31 54 30 2 2.1732863e-05 12 3 10 7 6 2 1.8410966e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 213 197 5 2.9295526e+02 14 4 20 49 38 1 2.9295427e+02 14 4 20 212 197 5 2.9295442e+02 15 1 8 2 1 1 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 1.0875102e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 7 5 1 1.0000000e+00 16 10 10 13 8 2 1.4654944e-14 16 10 10 34 32 1 1.0000000e+00 16 30 30 11 10 2 4.3046885e-14 16 40 40 11 10 2 3.6956867e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/lmsdrv.ref000644 000765 000765 00000063653 12305351606 017671 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 0.5000000D+01 final l2 norm of the residuals 0.2236068D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 problem 1 dimensions 5 50 initial l2 norm of the residuals 0.8062258D+01 final l2 norm of the residuals 0.6708204D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 problem 2 dimensions 5 10 initial l2 norm of the residuals 0.2915219D+03 final l2 norm of the residuals 0.1463850D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.2561515D+03 -0.1557990D+02 0.1294492D+03 -0.7289948D+01 -0.1168073D+03 problem 2 dimensions 5 50 initial l2 norm of the residuals 0.3101600D+04 final l2 norm of the residuals 0.3482630D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.9059980D+02 0.7667581D+02 0.8463689D+02 0.3883791D+02 -0.1306368D+03 problem 3 dimensions 5 10 initial l2 norm of the residuals 0.1260397D+03 final l2 norm of the residuals 0.1909727D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 0.2146513D+03 -0.1024194D+03 -0.3046700D+02 0.1000000D+01 problem 3 dimensions 5 50 initial l2 norm of the residuals 0.1748950D+04 final l2 norm of the residuals 0.3691729D+01 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 0.1000000D+01 -0.1453733D+03 0.1438958D+03 -0.3522752D+02 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.4919350D+01 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1340063D+04 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 4 dimensions 2 2 initial l2 norm of the residuals 0.1430001D+06 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.5000000D+02 final l2 norm of the residuals 0.9936524D-16 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.1000000D+01 -0.6243302D-17 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.1029563D+03 final l2 norm of the residuals 0.1044679D-18 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 0.1000000D+01 0.6563911D-20 0.0000000D+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 0.9912618D+03 final l2 norm of the residuals 0.3138778D-28 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 0.1000000D+01 -0.1972152D-29 0.0000000D+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1466288D+02 final l2 norm of the residuals 0.6109328D-33 number of function evaluations 58 number of jacobian evaluations 57 exit parameter 4 final approximate solution 0.1652118D-16 -0.1652118D-17 0.2643388D-17 0.2643388D-17 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1270984D+04 final l2 norm of the residuals 0.9545825D-33 number of function evaluations 61 number of jacobian evaluations 60 exit parameter 4 final approximate solution 0.2065147D-16 -0.2065147D-17 0.3304235D-17 0.3304235D-17 problem 6 dimensions 4 4 initial l2 norm of the residuals 0.1268879D+06 final l2 norm of the residuals 0.3728838D-33 number of function evaluations 65 number of jacobian evaluations 64 exit parameter 4 final approximate solution 0.1290717D-16 -0.1290717D-17 0.2065147D-17 0.2065147D-17 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.2001250D+02 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 0.1141248D+02 -0.8968279D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1243283D+05 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1141300D+02 -0.8967960D+00 problem 7 dimensions 2 2 initial l2 norm of the residuals 0.1142645D+08 final l2 norm of the residuals 0.6998875D+01 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 0.1141278D+02 -0.8968051D+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.6456136D+01 final l2 norm of the residuals 0.9063596D-01 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 0.8241058D-01 0.1133037D+01 0.2343695D+01 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3614185D+02 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 0.8406667D+00 -0.1588480D+09 -0.1643787D+09 problem 8 dimensions 3 15 initial l2 norm of the residuals 0.3841147D+03 final l2 norm of the residuals 0.4174769D+01 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 0.8406667D+00 -0.1589462D+09 -0.1644649D+09 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.7289151D-01 final l2 norm of the residuals 0.1753584D-01 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 0.1928078D+00 0.1912627D+00 0.1230528D+00 0.1360532D+00 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2979370D+01 final l2 norm of the residuals 0.3205219D-01 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 0.7286755D+06 -0.1407588D+02 -0.3297780D+08 -0.2057159D+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 0.2995906D+02 final l2 norm of the residuals 0.1753584D-01 number of function evaluations 500 number of jacobian evaluations 383 exit parameter 5 final approximate solution 0.1928081D+00 0.1912560D+00 0.1230515D+00 0.1360501D+00 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4115347D+05 final l2 norm of the residuals 0.9377945D+01 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 3 final approximate solution 0.5609636D-02 0.6181346D+04 0.3452236D+03 problem 10 dimensions 3 16 initial l2 norm of the residuals 0.4168217D+07 final l2 norm of the residuals 0.8010923D+03 number of function evaluations 400 number of jacobian evaluations 353 exit parameter 5 final approximate solution 0.8798278D-11 0.3464175D+05 0.9148701D+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -0.1572496D-01 0.1012435D+01 -0.2329917D+00 0.1260431D+01 -0.1513730D+01 0.9929973D+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6433126D+04 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -0.1572519D-01 0.1012435D+01 -0.2329915D+00 0.1260429D+01 -0.1513728D+01 0.9929957D+00 problem 11 dimensions 6 31 initial l2 norm of the residuals 0.6742560D+06 final l2 norm of the residuals 0.4782959D-01 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -0.1572470D-01 0.1012435D+01 -0.2329919D+00 0.1260433D+01 -0.1513733D+01 0.9929990D+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 3 final approximate solution -0.1530706D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1208813D+05 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 20 number of jacobian evaluations 16 exit parameter 3 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 9 31 initial l2 norm of the residuals 0.1269109D+07 final l2 norm of the residuals 0.1183115D-02 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution -0.1530704D-04 0.9997897D+00 0.1476396D-01 0.1463423D+00 0.1000821D+01 -0.2617731D+01 0.4104403D+01 -0.3143612D+01 0.1052626D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.5477226D+01 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 9 number of jacobian evaluations 8 exit parameter 3 final approximate solution -0.6602659D-08 0.1000002D+01 -0.5639321D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.1922076D+05 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 2 final approximate solution -0.6638060D-08 0.1000002D+01 -0.5639322D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 11 dimensions 12 31 initial l2 norm of the residuals 0.2018918D+07 final l2 norm of the residuals 0.2173104D-04 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 3 final approximate solution -0.6637951D-08 0.1000002D+01 -0.5639322D-03 0.3478205D+00 -0.1567315D+00 0.1052815D+01 -0.3247271D+01 0.7288435D+01 -0.1027185D+02 0.9074114D+01 -0.4541375D+01 0.1012012D+01 problem 12 dimensions 3 10 initial l2 norm of the residuals 0.3211158D+02 final l2 norm of the residuals 0.0000000D+00 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+02 0.1000000D+01 problem 13 dimensions 2 10 initial l2 norm of the residuals 0.6458565D+02 final l2 norm of the residuals 0.1115178D+02 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.2578199D+00 0.2578300D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.2815438D+04 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -0.1159125D+02 0.1320249D+02 -0.4035748D+00 0.2367362D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.5550734D+06 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -0.1159593D+02 0.1320419D+02 -0.4034174D+00 0.2367711D+00 problem 14 dimensions 4 20 initial l2 norm of the residuals 0.6121125D+08 final l2 norm of the residuals 0.2929543D+03 number of function evaluations 237 number of jacobian evaluations 221 exit parameter 1 final approximate solution -0.1159026D+02 0.1320206D+02 -0.4036925D+00 0.2366620D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1886238D+01 final l2 norm of the residuals 0.1886238D+01 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 0.5000000D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.5383344D+10 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 1 8 initial l2 norm of the residuals 0.1180887D+19 final l2 norm of the residuals 0.1884248D+01 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 0.9817315D+00 problem 15 dimensions 8 8 initial l2 norm of the residuals 0.1965139D+00 final l2 norm of the residuals 0.5930324D-01 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 0.4315366D-01 0.1930916D+00 0.2663286D+00 0.4999993D+00 0.5000007D+00 0.7336714D+00 0.8069084D+00 0.9568463D+00 problem 15 dimensions 9 9 initial l2 norm of the residuals 0.1699499D+00 final l2 norm of the residuals 0.2828182D-15 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 0.4420535D-01 0.1994907D+00 0.2356191D+00 0.4160469D+00 0.5000000D+00 0.5839531D+00 0.7643809D+00 0.8005093D+00 0.9557947D+00 problem 15 dimensions 10 10 initial l2 norm of the residuals 0.1837478D+00 final l2 norm of the residuals 0.8064710D-01 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.5962027D-01 0.1667088D+00 0.2391710D+00 0.3988853D+00 0.3988837D+00 0.6011163D+00 0.6011147D+00 0.7608290D+00 0.8332912D+00 0.9403797D+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.1653022D+02 final l2 norm of the residuals 0.1023575D-14 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765624D+07 final l2 norm of the residuals 0.3996803D-14 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 0.9765625D+17 final l2 norm of the residuals 0.2010699D-14 number of function evaluations 29 number of jacobian evaluations 26 exit parameter 2 final approximate solution 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.9794303D+00 0.1205697D+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 0.8347604D+02 final l2 norm of the residuals 0.1889283D-12 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.9977542D+00 0.1067374D+01 problem 16 dimensions 40 40 initial l2 norm of the residuals 0.1280264D+03 final l2 norm of the residuals 0.2045771D-12 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 problem 17 dimensions 5 33 initial l2 norm of the residuals 0.9375640D+00 final l2 norm of the residuals 0.7392493D-02 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 0.3754100D+00 0.1935847D+01 -0.1464687D+01 0.1286753D-01 0.2212270D-01 problem 18 dimensions 11 65 initial l2 norm of the residuals 0.1446865D+01 final l2 norm of the residuals 0.2003440D+00 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 0.1309977D+01 0.4315525D+00 0.6336613D+00 0.5994286D+00 0.7541798D+00 0.9043001D+00 0.1365799D+01 0.4823732D+01 0.2398685D+01 0.4568876D+01 0.5675342D+01 1summary of 53 calls to lmstr1 nprob n m nfev njev info final l2 norm 1 5 10 3 2 2 0.2236068D+01 1 5 50 3 2 3 0.6708204D+01 2 5 10 3 2 1 0.1463850D+01 2 5 50 3 2 1 0.3482630D+01 3 5 10 3 2 1 0.1909727D+01 3 5 50 3 2 1 0.3691729D+01 4 2 2 21 16 4 0.0000000D+00 4 2 2 8 5 2 0.0000000D+00 4 2 2 6 4 2 0.0000000D+00 5 3 3 11 8 2 0.9936524D-16 5 3 3 20 15 2 0.1044679D-18 5 3 3 19 16 2 0.3138778D-28 6 4 4 58 57 4 0.6109328D-33 6 4 4 61 60 4 0.9545825D-33 6 4 4 65 64 4 0.3728838D-33 7 2 2 14 8 1 0.6998875D+01 7 2 2 19 12 1 0.6998875D+01 7 2 2 24 17 1 0.6998875D+01 8 3 15 6 5 1 0.9063596D-01 8 3 15 37 36 1 0.4174769D+01 8 3 15 14 13 1 0.4174769D+01 9 4 11 18 16 1 0.1753584D-01 9 4 11 78 70 1 0.3205219D-01 9 4 11 500 383 5 0.1753584D-01 10 3 16 126 116 3 0.9377945D+01 10 3 16 400 353 5 0.8010923D+03 11 6 31 8 7 1 0.4782959D-01 11 6 31 14 13 1 0.4782959D-01 11 6 31 15 14 1 0.4782959D-01 11 9 31 8 7 3 0.1183115D-02 11 9 31 20 16 3 0.1183115D-02 11 9 31 19 16 2 0.1183115D-02 11 12 31 9 8 3 0.2173104D-04 11 12 31 13 12 2 0.2173104D-04 11 12 31 34 28 3 0.2173104D-04 12 3 10 7 6 2 0.0000000D+00 13 2 10 21 12 1 0.1115178D+02 14 4 20 254 236 1 0.2929543D+03 14 4 20 53 42 1 0.2929543D+03 14 4 20 237 221 1 0.2929543D+03 15 1 8 1 1 4 0.1886238D+01 15 1 8 29 28 1 0.1884248D+01 15 1 8 47 46 1 0.1884248D+01 15 8 8 39 20 1 0.5930324D-01 15 9 9 12 9 2 0.2828182D-15 15 10 10 25 12 1 0.8064710D-01 16 10 10 14 12 2 0.1023575D-14 16 10 10 13 8 2 0.3996803D-14 16 10 10 29 26 2 0.2010699D-14 16 30 30 19 14 2 0.1889283D-12 16 40 40 19 14 2 0.2045771D-12 17 5 33 18 15 1 0.7392493D-02 18 11 65 16 12 1 0.2003440D+00 cminpack-1.3.4/examples/ref/lmsdrvc.ref000644 000765 000765 00000063653 12274453162 020041 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622577e+00 final l2 norm of the residuals 6.7082039e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152187e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 2.5615151e+02 -1.5579896e+01 1.2944922e+02 -7.2899480e+00 -1.1680735e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016004e+03 final l2 norm of the residuals 3.4826302e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 9.0599798e+01 7.6675815e+01 8.4636891e+01 3.8837907e+01 -1.3063681e+02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603968e+02 final l2 norm of the residuals 1.9097274e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 2.1465133e+02 -1.0241940e+02 -3.0466997e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917294e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 -1.4537326e+02 1.4389584e+02 -3.5227516e+01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193496e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300005e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 9.9365244e-17 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 1.0000000e+00 -6.2433024e-18 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.0446789e-19 number of function evaluations 20 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 6.5639108e-21 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126182e+02 final l2 norm of the residuals 3.1387778e-29 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 -1.9721523e-30 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.1093279e-34 number of function evaluations 58 number of jacobian evaluations 57 exit parameter 4 final approximate solution 1.6521176e-17 -1.6521176e-18 2.6433882e-18 2.6433882e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709839e+03 final l2 norm of the residuals 9.5458248e-34 number of function evaluations 61 number of jacobian evaluations 60 exit parameter 4 final approximate solution 2.0651470e-17 -2.0651470e-18 3.3042352e-18 3.3042352e-18 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688790e+05 final l2 norm of the residuals 3.7288378e-34 number of function evaluations 65 number of jacobian evaluations 64 exit parameter 4 final approximate solution 1.2907169e-17 -1.2907169e-18 2.0651470e-18 2.0651470e-18 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012496e+01 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 14 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.1412484e+01 -8.9682791e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 19 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.1413005e+01 -8.9679604e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9988752e+00 number of function evaluations 24 number of jacobian evaluations 17 exit parameter 1 final approximate solution 1.1412782e+01 -8.9680511e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561363e+00 final l2 norm of the residuals 9.0635960e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution 8.2410577e-02 1.1330367e+00 2.3436946e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141853e+01 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 37 number of jacobian evaluations 36 exit parameter 1 final approximate solution 8.4066667e-01 -1.5884803e+08 -1.6437867e+08 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411468e+02 final l2 norm of the residuals 4.1747687e+00 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution 8.4066667e-01 -1.5894617e+08 -1.6446491e+08 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891510e-02 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 18 number of jacobian evaluations 16 exit parameter 1 final approximate solution 1.9280781e-01 1.9126265e-01 1.2305280e-01 1.3605322e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2052193e-02 number of function evaluations 78 number of jacobian evaluations 70 exit parameter 1 final approximate solution 7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959062e+01 final l2 norm of the residuals 1.7535838e-02 number of function evaluations 500 number of jacobian evaluations 383 exit parameter 5 final approximate solution 1.9280811e-01 1.9125601e-01 1.2305155e-01 1.3605015e-01 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153467e+04 final l2 norm of the residuals 9.3779451e+00 number of function evaluations 126 number of jacobian evaluations 116 exit parameter 2 final approximate solution 5.6096365e-03 6.1813463e+03 3.4522363e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682169e+06 final l2 norm of the residuals 8.0110176e+02 number of function evaluations 400 number of jacobian evaluations 353 exit parameter 5 final approximate solution 8.7951509e-12 3.4642449e+04 9.1488009e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 1 final approximate solution -1.5724962e-02 1.0124349e+00 -2.3299172e-01 1.2604310e+00 -1.5137303e+00 9.9299727e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331258e+03 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 14 number of jacobian evaluations 13 exit parameter 1 final approximate solution -1.5725190e-02 1.0124349e+00 -2.3299155e-01 1.2604293e+00 -1.5137278e+00 9.9299573e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425604e+05 final l2 norm of the residuals 4.7829594e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 1 final approximate solution -1.5724702e-02 1.0124349e+00 -2.3299192e-01 1.2604329e+00 -1.5137332e+00 9.9299902e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 8 number of jacobian evaluations 7 exit parameter 3 final approximate solution -1.5307064e-05 9.9978970e-01 1.4763963e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044031e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 20 number of jacobian evaluations 16 exit parameter 3 final approximate solution -1.5307036e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691093e+06 final l2 norm of the residuals 1.1831146e-03 number of function evaluations 19 number of jacobian evaluations 16 exit parameter 2 final approximate solution -1.5307037e-05 9.9978970e-01 1.4763964e-02 1.4634233e-01 1.0008211e+00 -2.6177311e+00 4.1044032e+00 -3.1436123e+00 1.0526264e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772256e+00 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 9 number of jacobian evaluations 8 exit parameter 3 final approximate solution -6.6026593e-09 1.0000016e+00 -5.6393215e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472711e+00 7.2884348e+00 -1.0271848e+01 9.0741135e+00 -4.5413754e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220759e+04 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 13 number of jacobian evaluations 12 exit parameter 2 final approximate solution -6.6380605e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 2.1731040e-05 number of function evaluations 34 number of jacobian evaluations 28 exit parameter 3 final approximate solution -6.6379511e-09 1.0000016e+00 -5.6393221e-04 3.4782054e-01 -1.5673150e-01 1.0528152e+00 -3.2472712e+00 7.2884349e+00 -1.0271848e+01 9.0741136e+00 -4.5413755e+00 1.0120119e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 2.4196750e-16 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585650e+01 final l2 norm of the residuals 1.1151779e+01 number of function evaluations 21 number of jacobian evaluations 12 exit parameter 1 final approximate solution 2.5781993e-01 2.5782998e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154384e+03 final l2 norm of the residuals 2.9295429e+02 number of function evaluations 254 number of jacobian evaluations 236 exit parameter 1 final approximate solution -1.1591249e+01 1.3202487e+01 -4.0357475e-01 2.3673624e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507335e+05 final l2 norm of the residuals 2.9295427e+02 number of function evaluations 53 number of jacobian evaluations 42 exit parameter 1 final approximate solution -1.1595927e+01 1.3204187e+01 -4.0341736e-01 2.3677114e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211252e+07 final l2 norm of the residuals 2.9295431e+02 number of function evaluations 237 number of jacobian evaluations 221 exit parameter 1 final approximate solution -1.1590261e+01 1.3202063e+01 -4.0369213e-01 2.3666223e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862380e+00 final l2 norm of the residuals 1.8862380e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833444e+09 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 29 number of jacobian evaluations 28 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808873e+18 final l2 norm of the residuals 1.8842482e+00 number of function evaluations 47 number of jacobian evaluations 46 exit parameter 1 final approximate solution 9.8173149e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9303236e-02 number of function evaluations 39 number of jacobian evaluations 20 exit parameter 1 final approximate solution 4.3153665e-02 1.9309164e-01 2.6632859e-01 4.9999933e-01 5.0000067e-01 7.3367141e-01 8.0690836e-01 9.5684634e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994993e-01 final l2 norm of the residuals 2.8281819e-16 number of function evaluations 12 number of jacobian evaluations 9 exit parameter 2 final approximate solution 4.4205346e-02 1.9949067e-01 2.3561911e-01 4.1604691e-01 5.0000000e-01 5.8395309e-01 7.6438089e-01 8.0050933e-01 9.5579465e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647100e-02 number of function evaluations 25 number of jacobian evaluations 12 exit parameter 1 final approximate solution 5.9620267e-02 1.6670878e-01 2.3917102e-01 3.9888529e-01 3.9888367e-01 6.0111633e-01 6.0111471e-01 7.6082898e-01 8.3329122e-01 9.4037973e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.0235751e-15 number of function evaluations 14 number of jacobian evaluations 12 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 3.9968029e-15 number of function evaluations 13 number of jacobian evaluations 8 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656250e+16 final l2 norm of the residuals 2.0106994e-15 number of function evaluations 29 number of jacobian evaluations 26 exit parameter 2 final approximate solution 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 9.7943030e-01 1.2056970e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.8892829e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 9.9775422e-01 1.0673735e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802636e+02 final l2 norm of the residuals 2.0457705e-13 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756402e-01 final l2 norm of the residuals 7.3924926e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 1 final approximate solution 3.7541005e-01 1.9358465e+00 -1.4646868e+00 1.2867534e-02 2.2122701e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468654e+00 final l2 norm of the residuals 2.0034404e-01 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 1 final approximate solution 1.3099766e+00 4.3155248e-01 6.3366126e-01 5.9942856e-01 7.5417977e-01 9.0430008e-01 1.3657995e+00 4.8237320e+00 2.3986848e+00 4.5688755e+00 5.6753421e+00 summary of 53 calls to lmstr1 nprob n m nfev njev info final L2 norm 1 5 10 3 2 2 2.2360680e+00 1 5 50 3 2 3 6.7082039e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 3 2 1 3.4826302e+00 3 5 10 3 2 1 1.9097274e+00 3 5 50 3 2 1 3.6917294e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 11 8 2 9.9365244e-17 5 3 3 20 15 2 1.0446789e-19 5 3 3 19 16 2 3.1387778e-29 6 4 4 58 57 4 6.1093279e-34 6 4 4 61 60 4 9.5458248e-34 6 4 4 65 64 4 3.7288378e-34 7 2 2 14 8 1 6.9988752e+00 7 2 2 19 12 1 6.9988752e+00 7 2 2 24 17 1 6.9988752e+00 8 3 15 6 5 1 9.0635960e-02 8 3 15 37 36 1 4.1747687e+00 8 3 15 14 13 1 4.1747687e+00 9 4 11 18 16 1 1.7535838e-02 9 4 11 78 70 1 3.2052193e-02 9 4 11 500 383 5 1.7535838e-02 10 3 16 126 116 2 9.3779451e+00 10 3 16 400 353 5 8.0110176e+02 11 6 31 8 7 1 4.7829594e-02 11 6 31 14 13 1 4.7829594e-02 11 6 31 15 14 1 4.7829594e-02 11 9 31 8 7 3 1.1831146e-03 11 9 31 20 16 3 1.1831146e-03 11 9 31 19 16 2 1.1831146e-03 11 12 31 9 8 3 2.1731040e-05 11 12 31 13 12 2 2.1731040e-05 11 12 31 34 28 3 2.1731040e-05 12 3 10 7 6 2 2.4196750e-16 13 2 10 21 12 1 1.1151779e+01 14 4 20 254 236 1 2.9295429e+02 14 4 20 53 42 1 2.9295427e+02 14 4 20 237 221 1 2.9295431e+02 15 1 8 1 1 4 1.8862380e+00 15 1 8 29 28 1 1.8842482e+00 15 1 8 47 46 1 1.8842482e+00 15 8 8 39 20 1 5.9303236e-02 15 9 9 12 9 2 2.8281819e-16 15 10 10 25 12 1 8.0647100e-02 16 10 10 14 12 2 1.0235751e-15 16 10 10 13 8 2 3.9968029e-15 16 10 10 29 26 2 2.0106994e-15 16 30 30 19 14 2 1.8892829e-13 16 40 40 19 14 2 2.0457705e-13 17 5 33 18 15 1 7.3924926e-03 18 11 65 16 12 1 2.0034404e-01 cminpack-1.3.4/examples/ref/ltchkderc.ref000644 000765 000765 00000001451 12225167750 020317 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468977 -2.827562 -3.473582 -4.437612 -6.047662 -9.267761 -18.91806 fvecp - fvec -7.724666e-09 -3.432406e-09 -2.034843e-10 2.313685e-09 4.331078e-09 5.984096e-09 7.363281e-09 8.53147e-09 1.488591e-08 2.33585e-08 3.522012e-08 5.301255e-08 8.26666e-08 1.419747e-07 3.19899e-07 err 0.1141397 0.09943516 0.09674474 0.09980447 0.1073116 0.1220445 0.1526814 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/ltchkderc_box.ref000644 000765 000765 00000001451 12303616324 021160 0ustar00devernay000000 000000 fvec -0.9829917 -1.111746 -1.214351 -1.306448 -1.372163 -1.434587 -1.486078 -1.518468 -1.820838 -1.987333 -2.364425 -2.925063 -3.862792 -5.738252 -11.35463 fvecp - fvec -1.293763e-08 -1.22842e-08 -1.167235e-08 -1.110506e-08 -1.058151e-08 -1.009919e-08 -9.654869e-09 -9.245206e-09 -7.99478e-09 -6.327542e-09 -3.993411e-09 -4.922134e-10 5.343114e-09 1.701377e-08 5.202575e-08 err 0.2393293 0.2130632 0.2026053 0.2000738 0.2031623 0.2144393 0.2422281 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/ltfdjac2c.ref000644 000765 000765 00000002064 12225167750 020211 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468977 -2.827562 -3.473582 -4.437612 -6.047662 -9.267761 -18.91806 fvecp - fvec -7.724666e-09 -3.432406e-09 -2.034843e-10 2.313685e-09 4.331078e-09 5.984096e-09 7.363281e-09 8.53147e-09 1.488591e-08 2.33585e-08 3.522012e-08 5.301255e-08 8.26666e-08 1.419747e-07 3.19899e-07 errd 1 1 1 1 0.995393 1 1 1 1 1 1 1 1 1 1 err 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/lthybrd1c.ref000644 000765 000765 00000000436 12225167750 020252 0ustar00devernay000000 000000 final L2 norm of the residuals 1.192636e-08 exit parameter 1 final approximates solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/lthybrdc.ref000644 000765 000765 00000000521 12225167750 020164 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 number of function evaluations 14 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/lthybrj1c.ref000644 000765 000765 00000000440 12225167750 020253 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/lthybrjc.ref000644 000765 000765 00000000574 12225167750 020202 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/lthybrjc_box.ref000644 000765 000765 00000000574 12303616324 021043 0ustar00devernay000000 000000 final l2 norm of the residuals 0.7585268 number of function evaluations 21 number of jacobian evaluations 2 exit parameter 5 final approximate solution -0.4715775 -0.5 -0.6075997 -0.6912395 -0.715058 -0.7148161 -0.689358 -0.613326 -0.4219724 cminpack-1.3.4/examples/ref/ltlmder1c.ref000644 000765 000765 00000000272 12225167750 020243 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 cminpack-1.3.4/examples/ref/ltlmderc.ref000644 000765 000765 00000000705 12225167750 020163 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778727 cminpack-1.3.4/examples/ref/ltlmderc_box.ref000644 000765 000765 00000000705 12303616324 021024 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09071386 number of function evaluations 10 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 0.08371095 1.178309 2.3 covariance 0.0001536684 0.002994926 -0 0.002994926 0.1026389 -0 -0 -0 0 cminpack-1.3.4/examples/ref/ltlmdif1c.ref000644 000765 000765 00000000266 12303616324 020227 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241057 1.133037 2.343695 cminpack-1.3.4/examples/ref/ltlmdifc.ref000644 000765 000765 00000000625 12303616324 020145 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 21 exit parameter 1 final approximate solution 0.08241057 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778728 cminpack-1.3.4/examples/ref/ltlmstr1c.ref000644 000765 000765 00000000272 12225167750 020301 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 cminpack-1.3.4/examples/ref/ltlmstrc.ref000644 000765 000765 00000000705 12225167750 020221 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778727 cminpack-1.3.4/examples/ref/schkdrvc.ref000644 000765 000765 00000017205 12225167750 020167 0ustar00devernay000000 000000 problem 1 with dimension 2 is F first function vector 2.0770001e+00 -2.8292906e+00 function difference vector -3.7193298e-04 1.1035204e-02 error vector 8.2365036e-02 8.3581984e-01 problem 2 with dimension 4 is F first function vector -8.1070004e+00 -1.6859951e+00 1.8741612e+00 1.5952158e+01 function difference vector 4.9562454e-03 -5.8221817e-04 -8.2933903e-04 1.1022568e-02 error vector 1.0000000e+00 1.0000000e+00 1.2842835e-01 9.2242539e-01 problem 3 with dimension 2 is F first function vector 1.0777100e+03 3.0019280e-01 function difference vector 7.4499512e-01 -1.6349554e-04 error vector 0.0000000e+00 0.0000000e+00 problem 4 with dimension 4 is T first function vector -5.4127114e+03 -1.9649459e+03 -4.8718281e+03 -1.7769432e+03 function difference vector 5.3779297e+00 1.2358398e+00 4.8403320e+00 1.1137695e+00 error vector 9.2019463e-01 1.0000000e+00 9.2583168e-01 1.0000000e+00 problem 5 with dimension 3 is F first function vector -5.0987698e+01 -1.1441660e+00 1.2300000e-01 function difference vector 4.2343140e-04 -3.0577183e-03 4.2468309e-05 error vector 0.0000000e+00 0.0000000e+00 1.0000000e+00 problem 6 with dimension 9 is F first function vector -5.7930632e+00 -3.3390751e+01 -3.4683182e+01 -3.6368725e+01 -3.7947666e+01 -3.9431324e+01 -4.0834240e+01 -4.2170792e+01 -4.3453300e+01 function difference vector 1.0456562e-02 1.9123077e-02 2.4261475e-02 2.8285980e-02 3.1589508e-02 3.4408569e-02 3.6880493e-02 3.9100647e-02 4.1122437e-02 error vector 0.0000000e+00 1.0118186e-01 1.3322668e-01 1.5934974e-01 1.8083851e-01 1.9908608e-01 2.1500312e-01 2.2902226e-01 2.4173902e-01 problem 7 with dimension 7 is F first function vector 3.5142865e-02 -4.5634698e-02 2.1936406e-01 2.1302824e-01 2.5865841e-01 2.3088835e-01 5.9196357e-02 function difference vector 3.5738945e-04 4.7776103e-04 5.5180490e-04 1.2420118e-03 2.2545755e-03 3.6663264e-03 4.9198084e-03 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 8 with dimension 10 is T first function vector -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -9.9928528e-01 function difference vector 1.8568039e-03 1.9416809e-03 1.8568039e-03 1.9416809e-03 1.8568039e-03 1.9416809e-03 1.8568039e-03 1.9416809e-03 1.8568039e-03 2.5033951e-06 error vector 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 0.0000000e+00 problem 9 with dimension 10 is F first function vector -3.8266212e-01 4.8185554e-01 -5.0497061e-01 4.8364362e-01 -5.0327110e-01 4.8731589e-01 -4.9982318e-01 4.9409863e-01 -4.9324730e-01 3.8308498e-01 function difference vector 1.3381243e-04 -1.6403198e-04 1.7684698e-04 -1.6343594e-04 1.7738342e-04 -1.6307831e-04 1.7806888e-04 -1.6328692e-04 1.5047193e-04 -6.5296888e-05 error vector 7.7286750e-02 3.6626393e-01 5.5991054e-02 1.8636526e-01 3.7315384e-02 1.6918576e-01 4.1837122e-02 2.3379742e-01 7.2901577e-02 2.7944452e-01 problem 10 with dimension 10 is F first function vector -1.6796678e-01 4.6728544e-02 -2.2043169e-01 1.7378714e-02 -2.2845450e-01 2.8983397e-02 -2.0089458e-01 6.9050625e-02 -1.5510282e-01 1.1399107e-01 function difference vector 7.6338649e-05 1.8876046e-05 1.2545288e-04 5.5165961e-05 1.4831126e-04 6.4063817e-05 1.4287233e-04 4.3608248e-05 1.0761619e-04 2.1159649e-05 error vector 0.0000000e+00 1.8855684e-02 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 1.0135500e-01 problem 11 with dimension 10 is F first function vector 1.4839309e-01 -4.6502445e-02 1.4892209e-01 3.0207883e-03 1.4945090e-01 5.2543905e-02 1.4997971e-01 1.0206725e-01 1.5050900e-01 1.5159014e-01 function difference vector 7.5802207e-05 4.2930245e-05 7.5504184e-05 7.7023869e-05 7.5027347e-05 1.1135638e-04 7.5027347e-05 1.4521182e-04 7.4073672e-05 1.7954409e-04 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 problem 12 with dimension 10 is F first function vector -1.0878875e+05 -2.1757712e+05 -3.2636600e+05 -4.3515438e+05 -5.4394325e+05 -6.5273162e+05 -7.6152050e+05 -8.7030888e+05 -9.7909769e+05 -1.0878861e+06 function difference vector 5.2101562e+01 1.0420312e+02 1.5631250e+02 2.0840625e+02 2.6050000e+02 3.1262500e+02 3.6475000e+02 4.1681250e+02 4.6887500e+02 5.2100000e+02 error vector 4.5876272e-02 4.5875799e-02 4.5869421e-02 4.5875601e-02 4.5879330e-02 4.5869261e-02 4.5862090e-02 4.5875505e-02 4.5885939e-02 4.5879237e-02 problem 13 with dimension 10 is T first function vector -3.1372583e+00 1.9974256e-01 -2.2602584e+00 1.9974256e-01 -2.2602584e+00 1.9974256e-01 -2.2602584e+00 1.9974256e-01 -2.2602584e+00 -2.0462575e+00 function difference vector 2.2993088e-03 8.0680847e-04 1.9965172e-03 8.0680847e-04 1.9965172e-03 8.0680847e-04 1.9965172e-03 8.0680847e-04 1.9965172e-03 1.5823841e-03 error vector 1.0000000e+00 6.8162960e-01 1.0000000e+00 6.8162960e-01 1.0000000e+00 6.8162960e-01 1.0000000e+00 6.8162960e-01 1.0000000e+00 9.9744910e-01 problem 14 with dimension 10 is F first function vector -8.2193689e+00 -4.4028883e+00 -8.2496271e+00 -4.4331465e+00 -8.2798843e+00 -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252754e+00 function difference vector 8.3370209e-03 5.0635338e-03 9.0484619e-03 5.7749748e-03 9.7589493e-03 6.4864159e-03 9.9868774e-03 6.4864159e-03 9.9868774e-03 6.0033798e-03 error vector 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 summary of 14 tests of chkder nprob n status errmin errmax 1 2 F 8.2365036e-02 8.3581984e-01 2 4 F 1.2842835e-01 1.0000000e+00 3 2 F 0.0000000e+00 0.0000000e+00 4 4 T 9.2019463e-01 1.0000000e+00 5 3 F 0.0000000e+00 1.0000000e+00 6 9 F 0.0000000e+00 2.4173902e-01 7 7 F 0.0000000e+00 0.0000000e+00 8 10 T 0.0000000e+00 1.0000000e+00 9 10 F 3.7315384e-02 3.6626393e-01 10 10 F 0.0000000e+00 1.0135500e-01 11 10 F 0.0000000e+00 0.0000000e+00 12 10 F 4.5862090e-02 4.5885939e-02 13 10 T 6.8162960e-01 1.0000000e+00 14 10 F 0.0000000e+00 0.0000000e+00 cminpack-1.3.4/examples/ref/shybdrvc.ref000644 000765 000765 00000067234 12303616324 020204 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193501e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300006e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 1.5549184e-16 number of function evaluations 53 number of Jacobian evaluations 3 exit parameter 4 final approximate solution -1.5753046e-09 1.5753046e-10 4.5913842e-09 4.5913842e-09 problem 2 dimension 4 initial l2 norm of the residuals 1.2709838e+03 final l2 norm of the residuals 2.8144827e-17 number of function evaluations 61 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 1.9527913e-09 -1.9527913e-10 2.5538518e-09 2.5538518e-09 problem 2 dimension 4 initial l2 norm of the residuals 1.2688791e+05 final l2 norm of the residuals 9.4115770e-17 number of function evaluations 67 number of Jacobian evaluations 4 exit parameter 4 final approximate solution 4.0011638e-09 -4.0011638e-10 4.6503628e-09 4.6503628e-09 problem 3 dimension 2 initial l2 norm of the residuals 1.0654867e+00 final l2 norm of the residuals 1.3041419e-07 number of function evaluations 166 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981595e-05 9.1061468e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 8.2734023e-06 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981500e-05 9.1061487e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505576e+03 final l2 norm of the residuals 9.5140949e-06 number of function evaluations 78 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -9.6797884e-01 9.4714844e-01 -9.6951151e-01 9.5123833e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 2.7211872e-05 number of function evaluations 153 number of Jacobian evaluations 5 exit parameter 1 final approximate solution -9.6797347e-01 9.4713813e-01 -9.6951681e-01 9.5124871e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730701e+09 final l2 norm of the residuals 1.1292311e-05 number of function evaluations 261 number of Jacobian evaluations 17 exit parameter 1 final approximate solution -9.6797311e-01 9.4713736e-01 -9.6951723e-01 9.5124942e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 3.9367433e-06 number of function evaluations 16 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 9.9999994e-01 2.4450128e-07 -1.3564453e-15 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 9.2124429e-07 number of function evaluations 17 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 9.9999994e-01 -4.4135504e-08 9.7555961e-18 problem 5 dimension 3 initial l2 norm of the residuals 9.9126184e+02 final l2 norm of the residuals 1.2282692e-07 number of function evaluations 51 number of Jacobian evaluations 10 exit parameter 1 final approximate solution 1.0000000e+00 7.7175173e-09 1.1848855e-13 problem 6 dimension 6 initial l2 norm of the residuals 6.8485870e+01 final l2 norm of the residuals 6.0666152e-06 number of function evaluations 67 number of Jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725369e-02 1.0124348e+00 -2.3299237e-01 1.2604319e+00 -1.5137317e+00 9.9299741e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312585e+06 final l2 norm of the residuals 1.6459311e+01 number of function evaluations 90 number of Jacobian evaluations 11 exit parameter 4 final approximate solution -2.8812926e+00 1.0873652e+01 -1.2288150e+01 2.5643299e+01 -4.4287178e+01 2.8034943e+01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789551e+01 final l2 norm of the residuals 1.1804732e-03 number of function evaluations 129 number of Jacobian evaluations 17 exit parameter 1 final approximate solution -1.4731798e-03 9.9933147e-01 2.9052624e-02 4.0073055e-04 1.5935067e+00 -3.8702135e+00 5.5327001e+00 -3.9793146e+00 1.2483358e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151079e+07 final l2 norm of the residuals 5.3987587e+01 number of function evaluations 70 number of Jacobian evaluations 8 exit parameter 1 final approximate solution -5.6411495e+00 3.0561060e+01 -9.5884109e+01 2.0685359e+02 -2.7513443e+02 4.0453635e+02 -6.9807312e+02 6.7073407e+02 -2.3327190e+02 problem 7 dimension 5 initial l2 norm of the residuals 2.2570655e-01 final l2 norm of the residuals 3.0695301e-06 number of function evaluations 10 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 8.3750911e-02 3.1273001e-01 4.9999925e-01 6.8727130e-01 9.1624850e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172450e+06 final l2 norm of the residuals 1.4986605e-06 number of function evaluations 119 number of Jacobian evaluations 25 exit parameter 1 final approximate solution 8.3751321e-02 3.1272894e-01 6.8727040e-01 5.0000042e-01 9.1624886e-01 problem 7 dimension 5 initial l2 norm of the residuals 5.6361314e+11 final l2 norm of the residuals 4.2101651e+08 number of function evaluations 108 number of Jacobian evaluations 11 exit parameter 4 final approximate solution -2.8738356e-01 -5.1594181e+01 3.4576969e+01 4.4720112e+01 4.4673126e+01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547182e-01 final l2 norm of the residuals 2.0102592e-05 number of function evaluations 10 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876546e-02 3.6668932e-01 2.8873348e-01 7.1125305e-01 6.3332415e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079254e+08 final l2 norm of the residuals 1.9487459e-05 number of function evaluations 66 number of Jacobian evaluations 13 exit parameter 1 final approximate solution 2.8873873e-01 9.3312323e-01 3.6668804e-01 6.6875584e-02 6.3331324e-01 7.1126115e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755800e+14 final l2 norm of the residuals 1.7774957e+14 number of function evaluations 17 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.1231697e+01 2.3038582e+01 4.0234558e+01 5.9294502e+01 7.3570175e+01 8.3340881e+01 problem 7 dimension 7 initial l2 norm of the residuals 1.8376790e-01 final l2 norm of the residuals 1.0666718e-05 number of function evaluations 8 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 5.8070701e-02 2.3516858e-01 3.3804706e-01 4.9999875e-01 6.6195601e-01 7.6482880e-01 9.4193006e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693284e+09 final l2 norm of the residuals 4.2693284e+09 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+00 2.5000000e+00 3.7500000e+00 5.0000000e+00 6.2500000e+00 7.5000000e+00 8.7500000e+00 problem 7 dimension 7 initial l2 norm of the residuals 6.4143172e+16 final l2 norm of the residuals 6.4143172e+16 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 1.2500000e+01 2.5000000e+01 3.7500000e+01 5.0000000e+01 6.2500000e+01 7.5000000e+01 8.7500000e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4920083e-02 number of function evaluations 45 number of Jacobian evaluations 8 exit parameter 4 final approximate solution 5.1471338e-02 1.9807488e-01 2.7040380e-01 5.0511068e-01 4.9597305e-01 7.3118556e-01 8.0297345e-01 9.5045084e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994981e-01 final l2 norm of the residuals 1.0916410e-04 number of function evaluations 18 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 4.4197164e-02 1.9953178e-01 2.3556828e-01 4.1609466e-01 4.9996135e-01 5.8395451e-01 7.6439464e-01 8.0050129e-01 9.5579600e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 4.4707458e-06 number of function evaluations 14 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 9.9999946e-01 1.0000048e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 33 number of Jacobian evaluations 6 exit parameter 4 final approximate solution -1.1509103e-01 -1.1508475e-01 -1.1508603e-01 -1.1508778e-01 -1.1508711e-01 -1.1508659e-01 -1.1508745e-01 -1.1508780e-01 -1.1508723e-01 1.2150873e+01 problem 8 dimension 10 initial l2 norm of the residuals 9.7656252e+16 final l2 norm of the residuals 9.7656252e+16 number of function evaluations 11 number of Jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.7161998e-05 number of function evaluations 13 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 9.9999440e-01 1.0001686e+00 problem 8 dimension 40 initial l2 norm of the residuals 1.2802637e+02 final l2 norm of the residuals 3.0235657e-05 number of function evaluations 15 number of Jacobian evaluations 3 exit parameter 1 final approximate solution 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 9.9873394e-01 1.0506511e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080592e-02 final l2 norm of the residuals 2.0028850e-08 number of function evaluations 4 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164987e-02 -8.1577167e-02 -1.1448573e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908999e-01 -1.5524954e-01 -1.2535590e-01 -7.5416535e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555257e-01 final l2 norm of the residuals 6.7585084e-08 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164991e-02 -8.1577189e-02 -1.1448579e-01 -1.4097369e-01 -1.5990885e-01 -1.6987740e-01 -1.6909018e-01 -1.5524971e-01 -1.2535603e-01 -7.5416617e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657391e+02 final l2 norm of the residuals 9.8602250e-06 number of function evaluations 31 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3168999e-02 -8.1584916e-02 -1.1449504e-01 -1.4097954e-01 -1.5990651e-01 -1.6986884e-01 -1.6907977e-01 -1.5523884e-01 -1.2534785e-01 -7.5412512e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 5 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 1.4901161e-08 number of function evaluations 14 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281390e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182697e-01 final l2 norm of the residuals 1.9168827e-08 number of function evaluations 4 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908997e-01 -1.5524952e-01 -1.2535587e-01 -7.5416513e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168327e+00 final l2 norm of the residuals 5.8406397e-07 number of function evaluations 6 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164998e-02 -8.1577197e-02 -1.1448579e-01 -1.4097370e-01 -1.5990886e-01 -1.6987741e-01 -1.6909020e-01 -1.5524973e-01 -1.2535603e-01 -7.5416610e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693087e+03 final l2 norm of the residuals 1.5432589e-08 number of function evaluations 17 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990870e-01 -1.6987720e-01 -1.6908999e-01 -1.5524954e-01 -1.2535587e-01 -7.5416528e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4120534e-02 final l2 norm of the residuals 5.3142733e-03 number of function evaluations 67 number of Jacobian evaluations 11 exit parameter 4 final approximate solution 5.5369183e-02 5.7086289e-02 5.9046667e-02 6.1328571e-02 6.3881919e-02 6.7237578e-02 2.0792514e-01 1.6400783e-01 8.7385967e-02 9.1098309e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 2.8176619e-06 number of function evaluations 28 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 4.2964712e-02 4.3976635e-02 4.5093656e-02 4.6339113e-02 4.7743205e-02 4.9357653e-02 5.1239945e-02 1.9520886e-01 1.6497894e-01 6.0149502e-02 problem 11 dimension 10 initial l2 norm of the residuals 9.3369370e+01 final l2 norm of the residuals 1.5691033e-02 number of function evaluations 37 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 1.8912127e+01 2.5193624e+01 1.8910522e+01 1.8915770e+01 1.8924824e+01 1.9090677e+01 1.8933659e+01 1.8941313e+01 1.8984051e+01 1.8932606e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 44 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 1.0000000e+00 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 4.9092266e+05 number of function evaluations 20 number of Jacobian evaluations 3 exit parameter 4 final approximate solution 3.1703512e+01 1.1665982e-01 -6.3146033e+02 -5.8982849e-01 3.3040405e+02 -1.5025178e+03 4.2257257e+02 1.4545090e+01 -3.5027106e+02 9.3841687e+02 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 5.6049429e+03 number of function evaluations 27 number of Jacobian evaluations 4 exit parameter 4 final approximate solution -1.0965344e+03 7.2777893e+02 -4.2828740e+03 -1.3187314e+03 -8.5446289e+01 -2.0954412e+03 1.7478848e+03 1.3359832e+03 4.6405585e+02 3.7205737e+02 problem 13 dimension 10 initial l2 norm of the residuals 4.5825758e+00 final l2 norm of the residuals 3.8072812e-05 number of function evaluations 7 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -5.7071590e-01 -6.8180329e-01 -7.0220965e-01 -7.0551234e-01 -7.0490927e-01 -7.0150012e-01 -6.9189209e-01 -6.6579729e-01 -5.9603453e-01 -4.1641471e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910095e+02 final l2 norm of the residuals 2.9802322e-07 number of function evaluations 60 number of Jacobian evaluations 3 exit parameter 1 final approximate solution -5.7072210e-01 -6.8180692e-01 -7.0221007e-01 -7.0551068e-01 -7.0490617e-01 -7.0149660e-01 -6.9188929e-01 -6.6579652e-01 -5.9603512e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337582e+04 final l2 norm of the residuals 9.4964244e-06 number of function evaluations 19 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072300e-01 -6.8180704e-01 -7.0221013e-01 -7.0551068e-01 -7.0490628e-01 -7.0149696e-01 -6.9189012e-01 -6.6579801e-01 -5.9603685e-01 -4.1641277e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973665e+01 final l2 norm of the residuals 2.0957385e-04 number of function evaluations 11 number of Jacobian evaluations 1 exit parameter 1 final approximate solution -4.2831260e-01 -4.7659481e-01 -5.1965940e-01 -5.5810648e-01 -5.9250420e-01 -6.2449384e-01 -6.2322783e-01 -6.2138480e-01 -6.2045062e-01 -5.8648789e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 2.3235139e-04 number of function evaluations 20 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2833534e-01 -4.7656971e-01 -5.1965076e-01 -5.5809981e-01 -5.9250998e-01 -6.2451160e-01 -6.2323725e-01 -6.2138838e-01 -6.2044895e-01 -5.8646911e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 7.3460091e-05 number of function evaluations 31 number of Jacobian evaluations 2 exit parameter 1 final approximate solution -4.2831323e-01 -4.7658759e-01 -5.1965231e-01 -5.5809963e-01 -5.9250820e-01 -6.2450194e-01 -6.2323916e-01 -6.2139487e-01 -6.2045264e-01 -5.8646935e-01 summary of 55 calls to hybrd1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 8 1 1 0.0000000e+00 1 2 8 1 1 0.0000000e+00 2 4 53 3 4 1.5549184e-16 2 4 61 3 1 2.8144827e-17 2 4 67 4 4 9.4115770e-17 3 2 166 6 1 1.3041419e-07 3 2 7 1 1 8.2734023e-06 4 4 78 2 1 9.5140949e-06 4 4 153 5 1 2.7211872e-05 4 4 261 17 1 1.1292311e-05 5 3 16 3 1 3.9367433e-06 5 3 17 4 1 9.2124429e-07 5 3 51 10 1 1.2282692e-07 6 6 67 6 1 6.0666152e-06 6 6 90 11 4 1.6459311e+01 6 9 129 17 1 1.1804732e-03 6 9 70 8 1 5.3987587e+01 7 5 10 1 1 3.0695301e-06 7 5 119 25 1 1.4986605e-06 7 5 108 11 4 4.2101651e+08 7 6 10 2 1 2.0102592e-05 7 6 66 13 1 1.9487459e-05 7 6 17 2 1 1.7774957e+14 7 7 8 2 1 1.0666718e-05 7 7 11 2 4 4.2693284e+09 7 7 11 2 4 6.4143172e+16 7 8 45 8 4 6.4920083e-02 7 9 18 2 1 1.0916410e-04 8 10 14 3 1 4.4707458e-06 8 10 33 6 4 1.0000000e+00 8 10 11 2 4 9.7656252e+16 8 30 13 2 1 1.7161998e-05 8 40 15 3 1 3.0235657e-05 9 10 4 1 1 2.0028850e-08 9 10 6 1 1 6.7585084e-08 9 10 31 1 1 9.8602250e-06 10 1 5 1 1 0.0000000e+00 10 1 6 1 1 0.0000000e+00 10 1 14 1 1 1.4901161e-08 10 10 4 1 1 1.9168827e-08 10 10 6 1 1 5.8406397e-07 10 10 17 2 1 1.5432589e-08 11 10 67 11 4 5.3142733e-03 11 10 28 5 1 2.8176619e-06 11 10 37 9 1 1.5691033e-02 12 10 44 5 1 0.0000000e+00 12 10 20 3 4 4.9092266e+05 12 10 27 4 4 5.6049429e+03 13 10 7 1 1 3.8072812e-05 13 10 60 3 1 2.9802322e-07 13 10 19 2 1 9.4964244e-06 14 10 11 1 1 2.0957385e-04 14 10 20 2 1 2.3235139e-04 14 10 31 2 1 7.3460091e-05 cminpack-1.3.4/examples/ref/shyjdrvc.ref000644 000765 000765 00000067234 12303616324 020214 0ustar00devernay000000 000000 problem 1 dimension 2 initial l2 norm of the residuals 4.9193501e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 3.0994415e-05 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000031e+00 problem 1 dimension 2 initial l2 norm of the residuals 1.4300006e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0000000e+00 1.0000000e+00 problem 2 dimension 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 9.1213967e-18 number of function evaluations 64 number of jacobian evaluations 5 exit parameter 4 final approximate solution -1.3178475e-09 1.3178475e-10 -1.4441786e-09 -1.4441786e-09 problem 2 dimension 4 initial l2 norm of the residuals 1.2709838e+03 final l2 norm of the residuals 4.3054092e-17 number of function evaluations 57 number of jacobian evaluations 3 exit parameter 4 final approximate solution -2.7626124e-09 2.7626124e-10 -3.1425580e-09 -3.1425580e-09 problem 2 dimension 4 initial l2 norm of the residuals 1.2688791e+05 final l2 norm of the residuals 3.3167943e-18 number of function evaluations 70 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.4365831e-09 -1.4365831e-10 4.3874487e-10 4.3874487e-10 problem 3 dimension 2 initial l2 norm of the residuals 1.0654867e+00 final l2 norm of the residuals 4.7594266e-08 number of function evaluations 168 number of jacobian evaluations 6 exit parameter 1 final approximate solution 1.0981594e-05 9.1061468e+00 problem 3 dimension 2 initial l2 norm of the residuals 1.0000000e+00 final l2 norm of the residuals 8.1905828e-06 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 1.0981501e-05 9.1061487e+00 problem 4 dimension 4 initial l2 norm of the residuals 8.5505576e+03 final l2 norm of the residuals 1.4612488e-05 number of function evaluations 84 number of jacobian evaluations 2 exit parameter 1 final approximate solution -9.6796274e-01 9.4711733e-01 -9.6952754e-01 9.5126945e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.3498230e+06 final l2 norm of the residuals 7.0295471e-05 number of function evaluations 192 number of jacobian evaluations 7 exit parameter 1 final approximate solution -9.6802872e-01 9.4724482e-01 -9.6946198e-01 9.5114231e-01 problem 4 dimension 4 initial l2 norm of the residuals 7.2730701e+09 final l2 norm of the residuals 8.0397449e-06 number of function evaluations 352 number of jacobian evaluations 27 exit parameter 1 final approximate solution -9.6797252e-01 9.4713622e-01 -9.6951789e-01 9.5125073e-01 problem 5 dimension 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 3.2887851e-06 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 9.9999994e-01 2.0321841e-07 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 3.6600181e-08 number of function evaluations 19 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.0000000e+00 2.2996574e-09 0.0000000e+00 problem 5 dimension 3 initial l2 norm of the residuals 9.9126184e+02 final l2 norm of the residuals 5.3028920e-08 number of function evaluations 36 number of jacobian evaluations 8 exit parameter 1 final approximate solution 1.0000000e+00 3.3319054e-09 0.0000000e+00 problem 6 dimension 6 initial l2 norm of the residuals 6.8485870e+01 final l2 norm of the residuals 1.4315057e-06 number of function evaluations 58 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5725432e-02 1.0124347e+00 -2.3299037e-01 1.2604253e+00 -1.5137230e+00 9.9299335e-01 problem 6 dimension 6 initial l2 norm of the residuals 3.5312585e+06 final l2 norm of the residuals 4.5457618e-06 number of function evaluations 72 number of jacobian evaluations 7 exit parameter 1 final approximate solution -1.5725890e-02 1.0124348e+00 -2.3299146e-01 1.2604259e+00 -1.5137224e+00 9.9299222e-01 problem 6 dimension 9 initial l2 norm of the residuals 8.8789551e+01 final l2 norm of the residuals 4.4975568e-06 number of function evaluations 85 number of jacobian evaluations 6 exit parameter 1 final approximate solution -1.5297170e-05 9.9978960e-01 1.4771627e-02 1.4625373e-01 1.0012460e+00 -2.6187584e+00 4.1057220e+00 -3.1444709e+00 1.0528497e+00 problem 6 dimension 9 initial l2 norm of the residuals 1.0151079e+07 final l2 norm of the residuals 6.6859561e-01 number of function evaluations 106 number of jacobian evaluations 10 exit parameter 1 final approximate solution 4.6702427e-01 2.7569652e+00 -5.9141953e+01 5.3408136e+02 -2.0914543e+03 4.2389595e+03 -4.6103960e+03 2.5420134e+03 -5.5105341e+02 problem 7 dimension 5 initial l2 norm of the residuals 2.2570655e-01 final l2 norm of the residuals 3.6521178e-05 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution 8.3755739e-02 3.1272420e-01 5.0000000e-01 6.8727583e-01 9.1624427e-01 problem 7 dimension 5 initial l2 norm of the residuals 4.1172450e+06 final l2 norm of the residuals 7.1370760e-06 number of function evaluations 135 number of jacobian evaluations 24 exit parameter 1 final approximate solution 8.3751582e-02 5.0000221e-01 6.8726915e-01 3.1272793e-01 9.1624916e-01 problem 7 dimension 5 initial l2 norm of the residuals 5.6361314e+11 final l2 norm of the residuals 4.7142170e+08 number of function evaluations 108 number of jacobian evaluations 14 exit parameter 4 final approximate solution -5.4530479e+01 -7.9413409e+00 1.3895516e+01 -1.3231560e+01 5.5531525e+01 problem 7 dimension 6 initial l2 norm of the residuals 2.1547182e-01 final l2 norm of the residuals 1.7030106e-06 number of function evaluations 10 number of jacobian evaluations 2 exit parameter 1 final approximate solution 6.6876598e-02 3.6668319e-01 2.8873965e-01 7.1126038e-01 6.3331681e-01 9.3312341e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.3079254e+08 final l2 norm of the residuals 5.2770069e-06 number of function evaluations 70 number of jacobian evaluations 14 exit parameter 1 final approximate solution 3.6668503e-01 6.3331521e-01 6.6876583e-02 7.1126193e-01 9.3312341e-01 2.8873792e-01 problem 7 dimension 6 initial l2 norm of the residuals 1.8755800e+14 final l2 norm of the residuals 1.8755800e+14 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 1.4285715e+01 2.8571430e+01 4.2857147e+01 5.7142860e+01 7.1428574e+01 8.5714294e+01 problem 7 dimension 7 initial l2 norm of the residuals 1.8376790e-01 final l2 norm of the residuals 1.7317556e-04 number of function evaluations 9 number of jacobian evaluations 1 exit parameter 1 final approximate solution 5.8082171e-02 2.3512772e-01 3.3809543e-01 4.9995753e-01 6.6196579e-01 7.6484597e-01 9.4192535e-01 problem 7 dimension 7 initial l2 norm of the residuals 4.2693284e+09 final l2 norm of the residuals 1.1527198e-05 number of function evaluations 252 number of jacobian evaluations 44 exit parameter 1 final approximate solution 5.0000238e-01 2.3517540e-01 3.3804002e-01 5.8068056e-02 6.6195565e-01 7.6482743e-01 9.4193107e-01 problem 7 dimension 7 initial l2 norm of the residuals 6.4143172e+16 final l2 norm of the residuals 5.1379834e+13 number of function evaluations 46 number of jacobian evaluations 12 exit parameter 4 final approximate solution 4.9905979e+01 5.5982544e+01 3.6108978e+01 3.5824638e+01 -6.4949944e+01 5.2997307e+01 5.5733734e+01 problem 7 dimension 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 6.4404607e-02 number of function evaluations 56 number of jacobian evaluations 8 exit parameter 4 final approximate solution 4.9856197e-02 1.9863509e-01 2.6982883e-01 4.9927196e-01 5.0072867e-01 7.3017186e-01 8.0136555e-01 9.5014453e-01 problem 7 dimension 9 initial l2 norm of the residuals 1.6994981e-01 final l2 norm of the residuals 3.3593704e-05 number of function evaluations 18 number of jacobian evaluations 2 exit parameter 1 final approximate solution 4.4206861e-02 1.9948216e-01 2.3563011e-01 4.1604108e-01 4.9999818e-01 5.8396095e-01 7.6436365e-01 8.0052453e-01 9.5579231e-01 problem 8 dimension 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 4.5024199e-06 number of function evaluations 9 number of jacobian evaluations 2 exit parameter 1 final approximate solution 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 9.9999934e-01 1.0000054e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 1.5078915e-06 number of function evaluations 36 number of jacobian evaluations 6 exit parameter 1 final approximate solution 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 9.9999940e-01 1.0000058e+00 problem 8 dimension 10 initial l2 norm of the residuals 9.7656252e+16 final l2 norm of the residuals 9.7656252e+16 number of function evaluations 11 number of jacobian evaluations 2 exit parameter 4 final approximate solution 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 5.0000000e+01 problem 8 dimension 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 8.9945761e-06 number of function evaluations 18 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 1.0000083e+00 9.9975842e-01 problem 8 dimension 40 initial l2 norm of the residuals 1.2802637e+02 final l2 norm of the residuals 3.4050012e-05 number of function evaluations 16 number of jacobian evaluations 3 exit parameter 1 final approximate solution 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 9.9877089e-01 1.0491517e+00 problem 9 dimension 10 initial l2 norm of the residuals 2.8080592e-02 final l2 norm of the residuals 2.6579430e-08 number of function evaluations 4 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164987e-02 -8.1577167e-02 -1.1448573e-01 -1.4097360e-01 -1.5990871e-01 -1.6987722e-01 -1.6909000e-01 -1.5524955e-01 -1.2535590e-01 -7.5416543e-02 problem 9 dimension 10 initial l2 norm of the residuals 5.2555257e-01 final l2 norm of the residuals 6.7943475e-08 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164991e-02 -8.1577182e-02 -1.1448578e-01 -1.4097369e-01 -1.5990885e-01 -1.6987740e-01 -1.6909018e-01 -1.5524971e-01 -1.2535603e-01 -7.5416610e-02 problem 9 dimension 10 initial l2 norm of the residuals 1.0657391e+02 final l2 norm of the residuals 7.0747551e-06 number of function evaluations 30 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3165427e-02 -8.1577897e-02 -1.1448573e-01 -1.4097078e-01 -1.5990174e-01 -1.6987063e-01 -1.6908687e-01 -1.5524666e-01 -1.2535365e-01 -7.5415403e-02 problem 10 dimension 1 initial l2 norm of the residuals 1.2792969e-01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 5 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 1 initial l2 norm of the residuals 2.5625000e+00 final l2 norm of the residuals 1.4901161e-08 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -1.5281390e-01 problem 10 dimension 1 initial l2 norm of the residuals 8.3611719e+02 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 23 number of jacobian evaluations 2 exit parameter 1 final approximate solution -1.5281388e-01 problem 10 dimension 10 initial l2 norm of the residuals 2.5182697e-01 final l2 norm of the residuals 4.5146109e-08 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990871e-01 -1.6987722e-01 -1.6909000e-01 -1.5524955e-01 -1.2535587e-01 -7.5416528e-02 problem 10 dimension 10 initial l2 norm of the residuals 6.1168327e+00 final l2 norm of the residuals 3.9818809e-07 number of function evaluations 6 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.3164961e-02 -8.1577122e-02 -1.1448567e-01 -1.4097354e-01 -1.5990870e-01 -1.6987725e-01 -1.6909009e-01 -1.5524970e-01 -1.2535606e-01 -7.5416662e-02 problem 10 dimension 10 initial l2 norm of the residuals 1.2693087e+03 final l2 norm of the residuals 9.8533917e-07 number of function evaluations 45 number of jacobian evaluations 3 exit parameter 1 final approximate solution -4.3165080e-02 -8.1577346e-02 -1.1448593e-01 -1.4097366e-01 -1.5990855e-01 -1.6987684e-01 -1.6908954e-01 -1.5524912e-01 -1.2535559e-01 -7.5416386e-02 problem 11 dimension 10 initial l2 norm of the residuals 8.4120534e-02 final l2 norm of the residuals 5.2958368e-03 number of function evaluations 57 number of jacobian evaluations 8 exit parameter 4 final approximate solution 5.5279694e-02 5.6983635e-02 5.8922779e-02 6.1167419e-02 6.3826047e-02 6.7071036e-02 2.0796692e-01 1.6418971e-01 8.6474232e-02 9.1640025e-02 problem 11 dimension 10 initial l2 norm of the residuals 2.0305195e+01 final l2 norm of the residuals 1.5992504e-06 number of function evaluations 31 number of jacobian evaluations 5 exit parameter 1 final approximate solution 3.4395915e-02 3.5031989e-02 3.5718851e-02 3.6464818e-02 3.7280425e-02 3.8179357e-02 3.9179917e-02 4.0306460e-02 1.7972031e-01 1.5624082e-01 problem 11 dimension 10 initial l2 norm of the residuals 9.3369370e+01 final l2 norm of the residuals 8.9314650e-05 number of function evaluations 31 number of jacobian evaluations 4 exit parameter 1 final approximate solution 1.8883986e+01 2.5167809e+01 1.8885305e+01 1.8886059e+01 1.8886923e+01 1.8887789e+01 1.8888823e+01 1.8889912e+01 1.9029278e+01 1.9005856e+01 problem 12 dimension 10 initial l2 norm of the residuals 2.2402135e+06 final l2 norm of the residuals 3.9703064e-03 number of function evaluations 20 number of jacobian evaluations 1 exit parameter 1 final approximate solution 9.9999946e-01 9.9999893e-01 9.9999845e-01 9.9999791e-01 9.9999738e-01 9.9999684e-01 9.9999630e-01 9.9999583e-01 9.9999529e-01 9.9999475e-01 problem 12 dimension 10 initial l2 norm of the residuals 5.2234376e+07 final l2 norm of the residuals 4.8075180e-04 number of function evaluations 37 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000001e+00 1.0000001e+00 1.0000002e+00 1.0000002e+00 1.0000004e+00 1.0000004e+00 1.0000005e+00 1.0000005e+00 1.0000006e+00 1.0000006e+00 problem 12 dimension 10 initial l2 norm of the residuals 1.5923646e+11 final l2 norm of the residuals 4.5143771e-03 number of function evaluations 58 number of jacobian evaluations 5 exit parameter 1 final approximate solution 9.9999940e-01 9.9999881e-01 9.9999821e-01 9.9999762e-01 9.9999702e-01 9.9999642e-01 9.9999583e-01 9.9999523e-01 9.9999464e-01 9.9999404e-01 problem 13 dimension 10 initial l2 norm of the residuals 4.5825758e+00 final l2 norm of the residuals 3.8122751e-05 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution -5.7071590e-01 -6.8180329e-01 -7.0220959e-01 -7.0551234e-01 -7.0490927e-01 -7.0150012e-01 -6.9189209e-01 -6.6579729e-01 -5.9603453e-01 -4.1641474e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3910095e+02 final l2 norm of the residuals 4.9511334e-07 number of function evaluations 29 number of jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072216e-01 -6.8180698e-01 -7.0221007e-01 -7.0551062e-01 -7.0490611e-01 -7.0149660e-01 -6.9188929e-01 -6.6579652e-01 -5.9603512e-01 -4.1641226e-01 problem 13 dimension 10 initial l2 norm of the residuals 6.3337582e+04 final l2 norm of the residuals 9.2025020e-06 number of function evaluations 19 number of jacobian evaluations 2 exit parameter 1 final approximate solution -5.7072300e-01 -6.8180704e-01 -7.0221013e-01 -7.0551068e-01 -7.0490628e-01 -7.0149696e-01 -6.9189006e-01 -6.6579795e-01 -5.9603685e-01 -4.1641280e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.8973665e+01 final l2 norm of the residuals 2.0989163e-04 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -4.2831272e-01 -4.7659484e-01 -5.1965940e-01 -5.5810654e-01 -5.9250426e-01 -6.2449384e-01 -6.2322783e-01 -6.2138474e-01 -6.2045062e-01 -5.8648789e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.7130922e+04 final l2 norm of the residuals 2.3286082e-04 number of function evaluations 20 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2833540e-01 -4.7656971e-01 -5.1965076e-01 -5.5809981e-01 -5.9250993e-01 -6.2451166e-01 -6.2323731e-01 -6.2138826e-01 -6.2044889e-01 -5.8646911e-01 problem 14 dimension 10 initial l2 norm of the residuals 1.5949860e+07 final l2 norm of the residuals 7.3764968e-05 number of function evaluations 31 number of jacobian evaluations 2 exit parameter 1 final approximate solution -4.2831326e-01 -4.7658756e-01 -5.1965231e-01 -5.5809957e-01 -5.9250820e-01 -6.2450194e-01 -6.2323922e-01 -6.2139493e-01 -6.2045258e-01 -5.8646935e-01 summary of 55 calls to hybrj1 nprob n nfev njev info final l2 norm 1 2 16 3 1 0.0000000e+00 1 2 7 1 1 3.0994415e-05 1 2 8 1 1 0.0000000e+00 2 4 64 5 4 9.1213967e-18 2 4 57 3 4 4.3054092e-17 2 4 70 3 1 3.3167943e-18 3 2 168 6 1 4.7594266e-08 3 2 7 1 1 8.1905828e-06 4 4 84 2 1 1.4612488e-05 4 4 192 7 1 7.0295471e-05 4 4 352 27 1 8.0397449e-06 5 3 16 3 1 3.2887851e-06 5 3 19 4 1 3.6600181e-08 5 3 36 8 1 5.3028920e-08 6 6 58 6 1 1.4315057e-06 6 6 72 7 1 4.5457618e-06 6 9 85 6 1 4.4975568e-06 6 9 106 10 1 6.6859561e-01 7 5 7 1 1 3.6521178e-05 7 5 135 24 1 7.1370760e-06 7 5 108 14 4 4.7142170e+08 7 6 10 2 1 1.7030106e-06 7 6 70 14 1 5.2770069e-06 7 6 11 2 4 1.8755800e+14 7 7 9 1 1 1.7317556e-04 7 7 252 44 1 1.1527198e-05 7 7 46 12 4 5.1379834e+13 7 8 56 8 4 6.4404607e-02 7 9 18 2 1 3.3593704e-05 8 10 9 2 1 4.5024199e-06 8 10 36 6 1 1.5078915e-06 8 10 11 2 4 9.7656252e+16 8 30 18 3 1 8.9945761e-06 8 40 16 3 1 3.4050012e-05 9 10 4 1 1 2.6579430e-08 9 10 6 1 1 6.7943475e-08 9 10 30 1 1 7.0747551e-06 10 1 5 1 1 0.0000000e+00 10 1 6 1 1 1.4901161e-08 10 1 23 2 1 0.0000000e+00 10 10 6 1 1 4.5146109e-08 10 10 6 1 1 3.9818809e-07 10 10 45 3 1 9.8533917e-07 11 10 57 8 4 5.2958368e-03 11 10 31 5 1 1.5992504e-06 11 10 31 4 1 8.9314650e-05 12 10 20 1 1 3.9703064e-03 12 10 37 2 1 4.8075180e-04 12 10 58 5 1 4.5143771e-03 13 10 7 1 1 3.8122751e-05 13 10 29 2 1 4.9511334e-07 13 10 19 2 1 9.2025020e-06 14 10 11 1 1 2.0989163e-04 14 10 20 2 1 2.3286082e-04 14 10 31 2 1 7.3764968e-05 cminpack-1.3.4/examples/ref/sibmdpdrc.ref000644 000765 000765 00000000720 12225167750 020321 0ustar00devernay000000 000000 MACHAR constants ibeta = 2 it = 24 irnd = 5 ngrd = 0 machep = -23 negep = -24 iexp = 8 minexp = -126 maxexp = 128 eps = 1.1920929e-07 epsneg = 5.9604645e-08 xmin = 1.1754944e-38 xmax = 3.4028235e+38 DPMPAR constants and relative differences epsmch = 1.1920929e-07 rerr(1) = 0.0000000e+00 dwarf = 1.1754944e-38 rerr(2) = 0.0000000e+00 giant = 3.4028235e+38 rerr(3) = 0.0000000e+00 cminpack-1.3.4/examples/ref/slmddrvc.ref000644 000765 000765 00000063660 12303616324 020175 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -9.9999952e-01 -1.0000007e+00 -1.0000000e+00 -9.9999988e-01 -9.9999988e-01 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622559e+00 final l2 norm of the residuals 6.7082019e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 2 final approximate solution -1.0000035e+00 -1.0000026e+00 -9.9999678e-01 -9.9999905e-01 -9.9999702e-01 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152188e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution -2.2588153e+02 -1.1244076e+02 1.3659315e+01 -5.5720322e+01 1.2656184e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016003e+03 final l2 norm of the residuals 3.4826331e+00 number of function evaluations 6 number of jacobian evaluations 3 exit parameter 1 final approximate solution -5.4328296e+02 -2.7114148e+02 2.5691464e+02 -1.3507065e+02 1.7102687e+02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603967e+02 final l2 norm of the residuals 1.9097276e+00 number of function evaluations 4 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 2.0025868e+02 -1.5069496e+01 -8.8783112e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917312e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 2.1951398e+02 -6.2690464e+01 -6.2731403e+01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193501e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300006e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 4.4930580e-08 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 2.8230716e-09 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.1145794e-09 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 -7.0031092e-11 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126184e+02 final l2 norm of the residuals 5.6543193e-14 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 3.5527137e-15 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 6.4623485e-27 number of function evaluations 69 number of jacobian evaluations 63 exit parameter 2 final approximate solution 5.1628674e-19 -5.1628675e-20 8.2606004e-20 8.2606004e-20 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709838e+03 final l2 norm of the residuals 6.1098873e-18 number of function evaluations 39 number of jacobian evaluations 35 exit parameter 4 final approximate solution 2.0955804e-09 -2.0955804e-10 8.5170071e-10 8.5170071e-10 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688791e+05 final l2 norm of the residuals 2.6869068e-17 number of function evaluations 38 number of jacobian evaluations 37 exit parameter 4 final approximate solution 3.4647418e-09 -3.4647418e-10 5.5436100e-10 5.5436100e-10 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012497e+01 final l2 norm of the residuals 6.9989629e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 1 final approximate solution 1.1467421e+01 -8.9349121e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988751e+00 number of function evaluations 16 number of jacobian evaluations 11 exit parameter 1 final approximate solution 1.1413025e+01 -8.9679456e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9989057e+00 number of function evaluations 19 number of jacobian evaluations 15 exit parameter 1 final approximate solution 1.1433799e+01 -8.9629227e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561362e+00 final l2 norm of the residuals 9.0635926e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 3 final approximate solution 8.2411841e-02 1.1330799e+00 2.3436494e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141850e+01 final l2 norm of the residuals 4.1761765e+00 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 1 final approximate solution 8.4089166e-01 -6.1763335e+03 -4.2086240e+03 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411469e+02 final l2 norm of the residuals 4.1747694e+00 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 1 final approximate solution 8.4066647e-01 -8.5064220e+06 -8.7856800e+06 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891504e-02 final l2 norm of the residuals 1.7536076e-02 number of function evaluations 8 number of jacobian evaluations 6 exit parameter 1 final approximate solution 1.9289611e-01 1.8919709e-01 1.2262850e-01 1.3510437e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2069419e-02 number of function evaluations 45 number of jacobian evaluations 37 exit parameter 1 final approximate solution 1.5692028e+01 -1.3921324e+01 -7.0222900e+02 -4.3778134e+02 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959064e+01 final l2 norm of the residuals 4.2413365e-02 number of function evaluations 27 number of jacobian evaluations 22 exit parameter 1 final approximate solution 4.2699429e-01 1.9289895e+03 3.5498347e+03 1.4433916e+03 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153469e+04 final l2 norm of the residuals 9.4535589e+00 number of function evaluations 121 number of jacobian evaluations 113 exit parameter 2 final approximate solution 5.6651235e-03 6.1731343e+03 3.4494714e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682162e+06 final l2 norm of the residuals 7.8786133e+02 number of function evaluations 400 number of jacobian evaluations 343 exit parameter 5 final approximate solution 1.8935223e-11 3.3143027e+04 8.9325427e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 4.7829498e-02 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 3 final approximate solution -1.5717413e-02 1.0124357e+00 -2.3299858e-01 1.2604904e+00 -1.5138190e+00 9.9305004e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331255e+03 final l2 norm of the residuals 4.7829639e-02 number of function evaluations 11 number of jacobian evaluations 10 exit parameter 1 final approximate solution -1.5674235e-02 1.0124398e+00 -2.3302884e-01 1.2607987e+00 -1.5142854e+00 9.9333340e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425606e+05 final l2 norm of the residuals 4.7829773e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 2 final approximate solution -1.5724849e-02 1.0124350e+00 -2.3299317e-01 1.2604369e+00 -1.5137382e+00 9.9300092e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 1.1828617e-03 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution -1.4855133e-05 9.9978983e-01 1.4757290e-02 1.4641514e-01 1.0005054e+00 -2.6170321e+00 4.1035690e+00 -3.1431003e+00 1.0524997e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1829071e-03 number of function evaluations 18 number of jacobian evaluations 14 exit parameter 2 final approximate solution -1.4970014e-05 9.9979007e-01 1.4766950e-02 1.4629370e-01 1.0010304e+00 -2.6181364e+00 4.1048002e+00 -3.1438017e+00 1.0526609e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691092e+06 final l2 norm of the residuals 1.1831208e-03 number of function evaluations 18 number of jacobian evaluations 14 exit parameter 2 final approximate solution -1.3805926e-05 9.9978852e-01 1.4741883e-02 1.4663905e-01 9.9946523e-01 -2.6147170e+00 4.1008682e+00 -3.1415048e+00 1.0521210e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 2.0561098e-05 number of function evaluations 11 number of jacobian evaluations 9 exit parameter 2 final approximate solution -6.2324688e-09 1.0000014e+00 -5.3333642e-04 3.4717202e-01 -1.5083563e-01 1.0236337e+00 -3.1602321e+00 7.1247549e+00 -1.0076208e+01 8.9298401e+00 -4.4814916e+00 1.0013056e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220758e+04 final l2 norm of the residuals 1.9776897e-05 number of function evaluations 16 number of jacobian evaluations 12 exit parameter 2 final approximate solution -8.5890861e-08 1.0000015e+00 -5.8637606e-04 3.4815130e-01 -1.5882498e-01 1.0598881e+00 -3.2607327e+00 7.3020487e+00 -1.0276423e+01 9.0701962e+00 -4.5371962e+00 1.0108839e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 1.0051661e+01 number of function evaluations 16 number of jacobian evaluations 10 exit parameter 2 final approximate solution 2.7567571e-01 1.0304637e+00 3.5803875e-01 -1.3093984e-01 8.8270845e+00 -9.2631538e+01 4.7920035e+02 -1.3673835e+03 2.2844734e+03 -2.2304595e+03 1.1819130e+03 -2.6373825e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585655e+01 final l2 norm of the residuals 1.1151858e+01 number of function evaluations 15 number of jacobian evaluations 9 exit parameter 1 final approximate solution 2.5829586e-01 2.5753188e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154382e+03 final l2 norm of the residuals 2.9317929e+02 number of function evaluations 171 number of jacobian evaluations 161 exit parameter 1 final approximate solution -1.1275230e+01 1.3089792e+01 -4.2264831e-01 2.2736965e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507331e+05 final l2 norm of the residuals 2.9298224e+02 number of function evaluations 27 number of jacobian evaluations 20 exit parameter 1 final approximate solution -1.1700173e+01 1.3243497e+01 -4.1554391e-01 2.2582424e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211256e+07 final l2 norm of the residuals 2.9338193e+02 number of function evaluations 82 number of jacobian evaluations 75 exit parameter 1 final approximate solution -1.1160712e+01 1.3042220e+01 -4.2213714e-01 2.3013921e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862381e+00 final l2 norm of the residuals 1.8862381e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833446e+09 final l2 norm of the residuals 1.8842582e+00 number of function evaluations 25 number of jacobian evaluations 24 exit parameter 1 final approximate solution 9.8180389e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808874e+18 final l2 norm of the residuals 1.8842576e+00 number of function evaluations 43 number of jacobian evaluations 42 exit parameter 1 final approximate solution 9.8180157e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9314549e-02 number of function evaluations 24 number of jacobian evaluations 13 exit parameter 2 final approximate solution 4.3417875e-02 1.9331421e-01 2.6631495e-01 4.9977866e-01 5.0022137e-01 7.3368502e-01 8.0668586e-01 9.5658213e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994981e-01 final l2 norm of the residuals 2.0906749e-07 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 4.4205330e-02 1.9949065e-01 2.3561913e-01 4.1604686e-01 5.0000006e-01 5.8395302e-01 7.6438093e-01 8.0050927e-01 9.5579463e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647513e-02 number of function evaluations 15 number of jacobian evaluations 7 exit parameter 1 final approximate solution 5.9669994e-02 1.6677600e-01 2.3921290e-01 3.9873391e-01 3.9908117e-01 6.0091877e-01 6.0126609e-01 7.6078707e-01 8.3322400e-01 9.4032997e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 2.6927846e-06 number of function evaluations 13 number of jacobian evaluations 11 exit parameter 2 final approximate solution 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 9.7943038e-01 1.2056965e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 1.8506258e-06 number of function evaluations 12 number of jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 1.0000011e+00 9.9999088e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656252e+16 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 19 number of jacobian evaluations 17 exit parameter 1 final approximate solution 4.3799043e-02 4.3799356e-02 4.3799341e-02 4.3799251e-02 4.3799207e-02 4.3799236e-02 4.3799207e-02 4.3799326e-02 4.3799326e-02 1.0562008e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 1 final approximate solution 5.8032632e-02 5.8079064e-02 5.8082432e-02 5.8081180e-02 5.8076262e-02 5.8084339e-02 5.8082074e-02 5.8078259e-02 5.8086991e-02 5.8079958e-02 5.8082193e-02 5.8080465e-02 5.8080256e-02 5.8082253e-02 5.8080703e-02 5.8080018e-02 5.8079183e-02 5.8080971e-02 5.8082074e-02 5.8079869e-02 5.8080137e-02 5.8081180e-02 5.8081448e-02 5.8080465e-02 5.8080405e-02 5.8080524e-02 5.8080643e-02 5.8080852e-02 5.8080882e-02 2.9257614e+01 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802637e+02 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.9019017e-01 1.9026804e-01 1.9027019e-01 1.9026044e-01 1.9025868e-01 1.9025177e-01 1.9027010e-01 1.9027081e-01 1.9027758e-01 1.9026250e-01 1.9027060e-01 1.9026637e-01 1.9027019e-01 1.9025967e-01 1.9026160e-01 1.9026306e-01 1.9026107e-01 1.9026375e-01 1.9026193e-01 1.9026220e-01 1.9026378e-01 1.9026217e-01 1.9026375e-01 1.9026235e-01 1.9026411e-01 1.9026300e-01 1.9026360e-01 1.9026390e-01 1.9026372e-01 1.9026381e-01 1.9026315e-01 1.9026348e-01 1.9026312e-01 1.9026357e-01 1.9026378e-01 1.9026408e-01 1.9026351e-01 1.9026351e-01 1.9026360e-01 3.3389500e+01 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756407e-01 final l2 norm of the residuals 7.3924954e-03 number of function evaluations 17 number of jacobian evaluations 14 exit parameter 1 final approximate solution 3.7541008e-01 1.9358472e+00 -1.4646875e+00 1.2867537e-02 2.2122702e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468656e+00 final l2 norm of the residuals 2.0034410e-01 number of function evaluations 15 number of jacobian evaluations 11 exit parameter 3 final approximate solution 1.3099747e+00 4.3154839e-01 6.3365942e-01 5.9943390e-01 7.5416678e-01 9.0433115e-01 1.3658434e+00 4.8234978e+00 2.3986933e+00 4.5688639e+00 5.6753392e+00 summary of 53 calls to lmder1: nprob n m nfev njev info final L2 norm 1 5 10 3 2 3 2.2360680e+00 1 5 50 3 2 2 6.7082019e+00 2 5 10 3 2 1 1.4638501e+00 2 5 50 6 3 1 3.4826331e+00 3 5 10 4 2 1 1.9097276e+00 3 5 50 3 2 1 3.6917312e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 8 5 2 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 10 7 2 4.4930580e-08 5 3 3 19 14 2 1.1145794e-09 5 3 3 18 15 2 5.6543193e-14 6 4 4 69 63 2 6.4623485e-27 6 4 4 39 35 4 6.1098873e-18 6 4 4 38 37 4 2.6869068e-17 7 2 2 8 5 1 6.9989629e+00 7 2 2 16 11 1 6.9988751e+00 7 2 2 19 15 1 6.9989057e+00 8 3 15 6 5 3 9.0635926e-02 8 3 15 7 6 1 4.1761765e+00 8 3 15 5 4 1 4.1747694e+00 9 4 11 8 6 1 1.7536076e-02 9 4 11 45 37 1 3.2069419e-02 9 4 11 27 22 1 4.2413365e-02 10 3 16 121 113 2 9.4535589e+00 10 3 16 400 343 5 7.8786133e+02 11 6 31 7 6 3 4.7829498e-02 11 6 31 11 10 1 4.7829639e-02 11 6 31 15 14 2 4.7829773e-02 11 9 31 7 6 2 1.1828617e-03 11 9 31 18 14 2 1.1829071e-03 11 9 31 18 14 2 1.1831208e-03 11 12 31 11 9 2 2.0561098e-05 11 12 31 16 12 2 1.9776897e-05 11 12 31 16 10 2 1.0051661e+01 12 3 10 6 5 2 0.0000000e+00 13 2 10 15 9 1 1.1151858e+01 14 4 20 171 161 1 2.9317929e+02 14 4 20 27 20 1 2.9298224e+02 14 4 20 82 75 1 2.9338193e+02 15 1 8 1 1 4 1.8862381e+00 15 1 8 25 24 1 1.8842582e+00 15 1 8 43 42 1 1.8842576e+00 15 8 8 24 13 2 5.9314549e-02 15 9 9 11 8 2 2.0906749e-07 15 10 10 15 7 1 8.0647513e-02 16 10 10 13 11 2 2.6927846e-06 16 10 10 12 10 2 1.8506258e-06 16 10 10 19 17 1 1.0000000e+00 16 30 30 5 2 1 1.0000000e+00 16 40 40 5 2 1 1.0000000e+00 17 5 33 17 14 1 7.3924954e-03 18 11 65 15 11 3 2.0034410e-01 cminpack-1.3.4/examples/ref/slmfdrvc.ref000644 000765 000765 00000063660 12303616324 020177 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360680e+00 number of function evaluations 4 number of Jacobian evaluations 3 exit parameter 1 final approximate solution -9.9976343e-01 -9.9976349e-01 -9.9976385e-01 -9.9969363e-01 -9.9976343e-01 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622559e+00 final l2 norm of the residuals 6.7082057e+00 number of function evaluations 4 number of Jacobian evaluations 3 exit parameter 1 final approximate solution -1.0024935e+00 -1.0024942e+00 -1.0006326e+00 -1.0024887e+00 -1.0018734e+00 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152188e+02 final l2 norm of the residuals 1.4697045e+00 number of function evaluations 6 number of Jacobian evaluations 2 exit parameter 2 final approximate solution 1.1321195e+02 -1.3362515e+00 -2.2255301e+01 1.2408030e+02 -1.0798904e+02 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016003e+03 final l2 norm of the residuals 3.4826636e+00 number of function evaluations 7 number of Jacobian evaluations 4 exit parameter 1 final approximate solution -8.1100816e-01 2.1100849e-01 -5.1226735e-01 3.9031878e-01 7.8829423e-02 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603967e+02 final l2 norm of the residuals 1.9097391e+00 number of function evaluations 6 number of Jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 1.7034796e+02 3.3046219e+01 -1.0991441e+02 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6919355e+00 number of function evaluations 11 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 1.0000000e+00 3.2585971e-03 1.4245026e+00 -1.0622244e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193501e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 22 number of Jacobian evaluations 16 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 1.1920929e-06 number of function evaluations 8 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 9.9999988e-01 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300006e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 5.4542014e-08 number of function evaluations 10 number of Jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 3.4269760e-09 1.2747846e-19 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 4.7826476e-10 number of function evaluations 19 number of Jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 -3.0013325e-11 5.8786309e-14 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126184e+02 final l2 norm of the residuals 1.3740234e-11 number of function evaluations 20 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 -8.6330942e-13 2.3879553e-17 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 1.7848865e-14 number of function evaluations 41 number of Jacobian evaluations 32 exit parameter 2 final approximate solution 1.1286673e-07 -1.1286673e-08 5.3202360e-08 5.3202360e-08 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709838e+03 final l2 norm of the residuals 1.4786386e-13 number of function evaluations 45 number of Jacobian evaluations 36 exit parameter 2 final approximate solution 3.0675008e-07 -3.0675007e-08 9.7326804e-08 9.7326804e-08 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688791e+05 final l2 norm of the residuals 8.5951308e-16 number of function evaluations 49 number of Jacobian evaluations 43 exit parameter 4 final approximate solution 2.4757183e-08 -2.4757183e-09 1.1695818e-08 1.1695818e-08 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012497e+01 final l2 norm of the residuals 6.9989924e+00 number of function evaluations 8 number of Jacobian evaluations 4 exit parameter 1 final approximate solution 1.1466326e+01 -8.9261216e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988756e+00 number of function evaluations 16 number of Jacobian evaluations 11 exit parameter 1 final approximate solution 1.1412451e+01 -8.9683729e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9989395e+00 number of function evaluations 19 number of Jacobian evaluations 15 exit parameter 1 final approximate solution 1.1371325e+01 -8.9990902e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561362e+00 final l2 norm of the residuals 9.0635955e-02 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 8.2428202e-02 1.1335746e+00 2.3431785e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141850e+01 final l2 norm of the residuals 4.1753497e+00 number of function evaluations 10 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 8.4062588e-01 -1.4753039e+04 -1.0396338e+04 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411469e+02 final l2 norm of the residuals 4.1747766e+00 number of function evaluations 5 number of Jacobian evaluations 4 exit parameter 3 final approximate solution 8.4060788e-01 -1.5793479e+06 -2.8772775e+05 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891504e-02 final l2 norm of the residuals 1.7535927e-02 number of function evaluations 8 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 1.9283542e-01 1.9171472e-01 1.2368494e-01 1.3618235e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2103930e-02 number of function evaluations 38 number of Jacobian evaluations 32 exit parameter 1 final approximate solution 5.3304453e+00 -1.3606566e+01 -2.3319855e+02 -1.4522066e+02 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959064e+01 final l2 norm of the residuals 1.7535923e-02 number of function evaluations 67 number of Jacobian evaluations 53 exit parameter 1 final approximate solution 1.9281533e-01 1.9019927e-01 1.2245105e-01 1.3560534e-01 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153469e+04 final l2 norm of the residuals 1.2981203e+01 number of function evaluations 156 number of Jacobian evaluations 148 exit parameter 2 final approximate solution 6.1575812e-03 6.1038892e+03 3.4260889e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682162e+06 final l2 norm of the residuals 2.7072710e+01 number of function evaluations 212 number of Jacobian evaluations 197 exit parameter 5 final approximate solution 7.2689634e-03 5.9671484e+03 3.3795099e+02 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 1.7147580e-01 number of function evaluations 7 number of Jacobian evaluations 6 exit parameter 1 final approximate solution 9.0529997e-12 9.4508231e-01 4.9917105e-01 -9.4340652e-01 1.0483757e+00 -1.7248490e-06 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331255e+03 final l2 norm of the residuals 4.7845893e-02 number of function evaluations 17 number of Jacobian evaluations 12 exit parameter 2 final approximate solution -1.6249392e-02 1.0119015e+00 -2.2741006e-01 1.2410009e+00 -1.4899821e+00 9.8242831e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425606e+05 final l2 norm of the residuals 4.7832731e-02 number of function evaluations 20 number of Jacobian evaluations 16 exit parameter 2 final approximate solution -1.6138526e-02 1.0122237e+00 -2.3128112e-01 1.2541332e+00 -1.5060322e+00 9.8918515e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 2.9982859e-03 number of function evaluations 15 number of Jacobian evaluations 6 exit parameter 2 final approximate solution 2.2261744e-13 9.9998349e-01 -2.2112695e-04 3.4135413e-01 3.1021335e-03 -1.1904036e-01 8.2775009e-01 -9.8064518e-01 4.8518914e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 2.6633304e-03 number of function evaluations 24 number of Jacobian evaluations 15 exit parameter 2 final approximate solution 1.4058310e-11 9.9964702e-01 -6.8555662e-04 3.6403978e-01 -8.3234496e-02 2.4364498e-03 7.8125983e-01 -1.0146316e+00 5.0877088e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691092e+06 final l2 norm of the residuals 5.3021852e-03 number of function evaluations 22 number of Jacobian evaluations 17 exit parameter 2 final approximate solution -1.8041793e-03 1.0005498e+00 2.0613239e-05 3.2092401e-01 -3.6350120e-02 2.7701476e-01 5.0431057e-03 -2.8397775e-01 2.6987892e-01 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 3.0702035e-04 number of function evaluations 13 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 1.5300955e-13 1.0000889e+00 -1.0739048e-03 3.3758509e-01 -1.2078556e-02 1.6773212e-01 -3.8757101e-02 -2.1288041e-02 2.0308548e-01 -4.6106383e-02 -1.4558227e-01 1.1382063e-01 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220758e+04 final l2 norm of the residuals 1.5569972e-01 number of function evaluations 25 number of Jacobian evaluations 16 exit parameter 2 final approximate solution -2.0832296e-02 1.0155444e+00 -2.5162458e-02 3.3915204e-01 -4.6169701e-01 -2.7113163e+00 1.1249305e+01 -1.6682754e+00 -2.5566235e+01 2.3591436e+01 2.3864892e-01 -4.4921432e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 7.4688956e-02 number of function evaluations 29 number of Jacobian evaluations 21 exit parameter 2 final approximate solution 1.7378242e-03 9.8752105e-01 -1.5454113e-03 -2.3181227e-01 1.1366383e+01 -4.4994061e+01 1.4100939e+01 2.9605533e+02 -8.0071252e+02 9.4164886e+02 -5.3977161e+02 1.2311846e+02 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 3.0225415e-08 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 9.9999990e+00 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585655e+01 final l2 norm of the residuals 1.1151854e+01 number of function evaluations 15 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 2.5829187e-01 2.5753096e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154382e+03 final l2 norm of the residuals 2.9329004e+02 number of function evaluations 163 number of Jacobian evaluations 151 exit parameter 1 final approximate solution -1.1205066e+01 1.3064331e+01 -4.1485760e-01 1.9371355e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507331e+05 final l2 norm of the residuals 2.9296634e+02 number of function evaluations 25 number of Jacobian evaluations 20 exit parameter 1 final approximate solution -1.1665783e+01 1.3230092e+01 -4.0100783e-01 2.5383824e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211256e+07 final l2 norm of the residuals 2.9299112e+02 number of function evaluations 30 number of Jacobian evaluations 25 exit parameter 1 final approximate solution -1.1481577e+01 1.3161572e+01 -4.5015016e-01 2.1535961e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862381e+00 final l2 norm of the residuals 1.8862375e+00 number of function evaluations 2 number of Jacobian evaluations 1 exit parameter 1 final approximate solution 5.0012302e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833446e+09 final l2 norm of the residuals 1.8842816e+00 number of function evaluations 25 number of Jacobian evaluations 24 exit parameter 1 final approximate solution 9.8186415e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808874e+18 final l2 norm of the residuals 1.8842816e+00 number of function evaluations 43 number of Jacobian evaluations 42 exit parameter 1 final approximate solution 9.8186445e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9324905e-02 number of function evaluations 22 number of Jacobian evaluations 13 exit parameter 2 final approximate solution 4.3774646e-02 1.9385180e-01 2.6664251e-01 5.0025666e-01 5.0066817e-01 7.3403645e-01 8.0721664e-01 9.5695710e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994981e-01 final l2 norm of the residuals 1.3888700e-07 number of function evaluations 12 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 4.4205330e-02 1.9949068e-01 2.3561908e-01 4.1604689e-01 5.0000000e-01 5.8395308e-01 7.6438093e-01 8.0050927e-01 9.5579463e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647901e-02 number of function evaluations 15 number of Jacobian evaluations 7 exit parameter 1 final approximate solution 5.9763812e-02 1.6687962e-01 2.3938300e-01 3.9893362e-01 3.9908576e-01 6.0114175e-01 6.0132498e-01 7.6102966e-01 8.3343679e-01 9.4050324e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 1.0000138e+00 number of function evaluations 7 number of Jacobian evaluations 5 exit parameter 3 final approximate solution -2.1667862e-01 -2.1667862e-01 -2.1667863e-01 -2.1667863e-01 -2.1667868e-01 -2.1667862e-01 -2.1667862e-01 -2.1667862e-01 -2.1667865e-01 1.3166784e+01 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 4.0815039e-06 number of function evaluations 12 number of Jacobian evaluations 10 exit parameter 2 final approximate solution 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 1.0000021e+00 9.9997872e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656252e+16 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 22 number of Jacobian evaluations 20 exit parameter 2 final approximate solution -5.6864314e-02 -5.6864318e-02 -5.6864277e-02 -5.6864280e-02 -5.6864318e-02 -5.6864314e-02 -5.6864314e-02 -5.6864277e-02 -5.6864303e-02 1.1568686e+01 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 5.9604645e-07 number of function evaluations 9 number of Jacobian evaluations 8 exit parameter 2 final approximate solution 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 9.9998963e-01 1.0003003e+00 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802637e+02 final l2 norm of the residuals 6.7171022e-06 number of function evaluations 10 number of Jacobian evaluations 9 exit parameter 2 final approximate solution 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 1.0000079e+00 9.9969280e-01 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756407e-01 final l2 norm of the residuals 7.3931883e-03 number of function evaluations 19 number of Jacobian evaluations 16 exit parameter 3 final approximate solution 3.7554947e-01 1.9523901e+00 -1.4813358e+00 1.2900786e-02 2.2056615e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468656e+00 final l2 norm of the residuals 2.0034409e-01 number of function evaluations 15 number of Jacobian evaluations 11 exit parameter 3 final approximate solution 1.3099626e+00 4.3151525e-01 6.3364059e-01 5.9937352e-01 7.5407225e-01 9.0467232e-01 1.3654983e+00 4.8238635e+00 2.3986797e+00 4.5688705e+00 5.6753511e+00 summary of 53 calls to lmdif1: nprob n m nfev njev info final L2 norm 1 5 10 4 3 1 2.2360680e+00 1 5 50 4 3 1 6.7082057e+00 2 5 10 6 2 2 1.4697045e+00 2 5 50 7 4 1 3.4826636e+00 3 5 10 6 2 1 1.9097391e+00 3 5 50 11 6 2 3.6919355e+00 4 2 2 22 16 2 0.0000000e+00 4 2 2 8 5 2 1.1920929e-06 4 2 2 7 5 2 0.0000000e+00 5 3 3 10 7 2 5.4542014e-08 5 3 3 19 14 2 4.7826476e-10 5 3 3 20 15 2 1.3740234e-11 6 4 4 41 32 2 1.7848865e-14 6 4 4 45 36 2 1.4786386e-13 6 4 4 49 43 4 8.5951308e-16 7 2 2 8 4 1 6.9989924e+00 7 2 2 16 11 1 6.9988756e+00 7 2 2 19 15 1 6.9989395e+00 8 3 15 6 5 1 9.0635955e-02 8 3 15 10 9 1 4.1753497e+00 8 3 15 5 4 3 4.1747766e+00 9 4 11 8 6 1 1.7535927e-02 9 4 11 38 32 1 3.2103930e-02 9 4 11 67 53 1 1.7535923e-02 10 3 16 156 148 2 1.2981203e+01 10 3 16 212 197 5 2.7072710e+01 11 6 31 7 6 1 1.7147580e-01 11 6 31 17 12 2 4.7845893e-02 11 6 31 20 16 2 4.7832731e-02 11 9 31 15 6 2 2.9982859e-03 11 9 31 24 15 2 2.6633304e-03 11 9 31 22 17 2 5.3021852e-03 11 12 31 13 9 2 3.0702035e-04 11 12 31 25 16 2 1.5569972e-01 11 12 31 29 21 2 7.4688956e-02 12 3 10 6 5 2 3.0225415e-08 13 2 10 15 9 1 1.1151854e+01 14 4 20 163 151 1 2.9329004e+02 14 4 20 25 20 1 2.9296634e+02 14 4 20 30 25 1 2.9299112e+02 15 1 8 2 1 1 1.8862375e+00 15 1 8 25 24 1 1.8842816e+00 15 1 8 43 42 1 1.8842816e+00 15 8 8 22 13 2 5.9324905e-02 15 9 9 12 8 2 1.3888700e-07 15 10 10 15 7 1 8.0647901e-02 16 10 10 7 5 3 1.0000138e+00 16 10 10 12 10 2 4.0815039e-06 16 10 10 22 20 2 1.0000000e+00 16 30 30 9 8 2 5.9604645e-07 16 40 40 10 9 2 6.7171022e-06 17 5 33 19 16 3 7.3931883e-03 18 11 65 15 11 3 2.0034409e-01 cminpack-1.3.4/examples/ref/slmsdrvc.ref000644 000765 000765 00000063653 12303616324 020216 0ustar00devernay000000 000000 problem 1 dimensions 5 10 initial l2 norm of the residuals 5.0000000e+00 final l2 norm of the residuals 2.2360678e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -1.0000002e+00 -9.9999988e-01 -9.9999988e-01 -9.9999988e-01 -9.9999988e-01 problem 1 dimensions 5 50 initial l2 norm of the residuals 8.0622559e+00 final l2 norm of the residuals 6.7082019e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 3 final approximate solution -9.9999952e-01 -1.0000005e+00 -1.0000000e+00 -1.0000000e+00 -9.9999964e-01 problem 2 dimensions 5 10 initial l2 norm of the residuals 2.9152188e+02 final l2 norm of the residuals 1.4638501e+00 number of function evaluations 5 number of jacobian evaluations 3 exit parameter 1 final approximate solution 3.0851965e+02 4.1267426e+02 -4.9210529e+02 2.0683719e+02 -9.6951630e+01 problem 2 dimensions 5 50 initial l2 norm of the residuals 3.1016003e+03 final l2 norm of the residuals 3.4826310e+00 number of function evaluations 9 number of jacobian evaluations 3 exit parameter 1 final approximate solution 4.1943604e+02 1.7581781e+02 -2.7622058e+02 8.8408958e+01 -5.9203209e+01 problem 3 dimensions 5 10 initial l2 norm of the residuals 1.2603967e+02 final l2 norm of the residuals 1.9097275e+00 number of function evaluations 3 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.0000000e+00 3.2299553e+01 -1.3648456e+02 8.6257767e+01 1.0000000e+00 problem 3 dimensions 5 50 initial l2 norm of the residuals 1.7489500e+03 final l2 norm of the residuals 3.6917305e+00 number of function evaluations 8 number of jacobian evaluations 3 exit parameter 1 final approximate solution 1.0000000e+00 1.7138905e+02 -2.1971686e+02 7.9100845e+01 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 4.9193501e+00 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 21 number of jacobian evaluations 16 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.3400631e+03 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 7 number of jacobian evaluations 5 exit parameter 4 final approximate solution 1.0000000e+00 1.0000000e+00 problem 4 dimensions 2 2 initial l2 norm of the residuals 1.4300006e+05 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 4 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 5.0000000e+01 final l2 norm of the residuals 4.4930580e-08 number of function evaluations 10 number of jacobian evaluations 7 exit parameter 2 final approximate solution 1.0000000e+00 2.8230716e-09 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 1.0295630e+02 final l2 norm of the residuals 1.1145794e-09 number of function evaluations 19 number of jacobian evaluations 14 exit parameter 2 final approximate solution 1.0000000e+00 -7.0031092e-11 0.0000000e+00 problem 5 dimensions 3 3 initial l2 norm of the residuals 9.9126184e+02 final l2 norm of the residuals 1.1308639e-13 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 2 final approximate solution 1.0000000e+00 7.1054274e-15 0.0000000e+00 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.4662878e+01 final l2 norm of the residuals 2.8699966e-39 number of function evaluations 70 number of jacobian evaluations 67 exit parameter 4 final approximate solution 4.3987462e-20 -4.3987462e-21 1.5360878e-20 1.5360878e-20 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2709838e+03 final l2 norm of the residuals 4.3201266e-16 number of function evaluations 32 number of jacobian evaluations 31 exit parameter 4 final approximate solution 1.1087157e-08 -1.1087157e-09 1.7739458e-09 1.7739457e-09 problem 6 dimensions 4 4 initial l2 norm of the residuals 1.2688791e+05 final l2 norm of the residuals 6.1333960e-17 number of function evaluations 45 number of jacobian evaluations 39 exit parameter 2 final approximate solution 3.4415706e-09 -3.4415706e-10 5.7483118e-10 5.7483118e-10 problem 7 dimensions 2 2 initial l2 norm of the residuals 2.0012497e+01 final l2 norm of the residuals 6.9989629e+00 number of function evaluations 8 number of jacobian evaluations 5 exit parameter 1 final approximate solution 1.1467422e+01 -8.9349121e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.2432834e+04 final l2 norm of the residuals 6.9988751e+00 number of function evaluations 16 number of jacobian evaluations 11 exit parameter 1 final approximate solution 1.1412983e+01 -8.9679766e-01 problem 7 dimensions 2 2 initial l2 norm of the residuals 1.1426455e+07 final l2 norm of the residuals 6.9989057e+00 number of function evaluations 19 number of jacobian evaluations 15 exit parameter 1 final approximate solution 1.1433800e+01 -8.9629221e-01 problem 8 dimensions 3 15 initial l2 norm of the residuals 6.4561362e+00 final l2 norm of the residuals 9.0635970e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 3 final approximate solution 8.2411885e-02 1.1330806e+00 2.3436489e+00 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.6141850e+01 final l2 norm of the residuals 4.1761765e+00 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 1 final approximate solution 8.4089172e-01 -6.1763193e+03 -4.2086387e+03 problem 8 dimensions 3 15 initial l2 norm of the residuals 3.8411469e+02 final l2 norm of the residuals 4.1747694e+00 number of function evaluations 5 number of jacobian evaluations 4 exit parameter 1 final approximate solution 8.4066653e-01 -8.5064220e+06 -8.7856840e+06 problem 9 dimensions 4 11 initial l2 norm of the residuals 7.2891504e-02 final l2 norm of the residuals 1.7536076e-02 number of function evaluations 8 number of jacobian evaluations 6 exit parameter 1 final approximate solution 1.9289610e-01 1.8919730e-01 1.2262843e-01 1.3510448e-01 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9793701e+00 final l2 norm of the residuals 3.2069419e-02 number of function evaluations 45 number of jacobian evaluations 37 exit parameter 1 final approximate solution 1.5689885e+01 -1.3921293e+01 -7.0213147e+02 -4.3772058e+02 problem 9 dimensions 4 11 initial l2 norm of the residuals 2.9959064e+01 final l2 norm of the residuals 4.2497460e-02 number of function evaluations 28 number of jacobian evaluations 20 exit parameter 1 final approximate solution 7.9770422e-01 1.1258904e+03 3.8749358e+03 1.5724391e+03 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1153469e+04 final l2 norm of the residuals 9.4501982e+00 number of function evaluations 121 number of jacobian evaluations 113 exit parameter 2 final approximate solution 5.6615476e-03 6.1736577e+03 3.4496469e+02 problem 10 dimensions 3 16 initial l2 norm of the residuals 4.1682162e+06 final l2 norm of the residuals 9.4068420e+02 number of function evaluations 206 number of jacobian evaluations 162 exit parameter 2 final approximate solution 1.4960986e-13 4.3620285e+04 1.0413533e+03 problem 11 dimensions 6 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 4.7829513e-02 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 1 final approximate solution -1.5785452e-02 1.0124278e+00 -2.3294121e-01 1.2599717e+00 -1.5130415e+00 9.9258274e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.4331255e+03 final l2 norm of the residuals 4.7829743e-02 number of function evaluations 11 number of jacobian evaluations 10 exit parameter 1 final approximate solution -1.5674004e-02 1.0124398e+00 -2.3302841e-01 1.2607979e+00 -1.5142845e+00 9.9333328e-01 problem 11 dimensions 6 31 initial l2 norm of the residuals 6.7425606e+05 final l2 norm of the residuals 4.7829483e-02 number of function evaluations 15 number of jacobian evaluations 14 exit parameter 3 final approximate solution -1.5728218e-02 1.0124344e+00 -2.3298804e-01 1.2604046e+00 -1.5136923e+00 9.9297494e-01 problem 11 dimensions 9 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 1.1828358e-03 number of function evaluations 7 number of jacobian evaluations 6 exit parameter 2 final approximate solution -1.5260997e-05 9.9978966e-01 1.4763309e-02 1.4633828e-01 1.0008550e+00 -2.6178274e+00 4.1045370e+00 -3.1437044e+00 1.0526515e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2088127e+04 final l2 norm of the residuals 1.1821783e-03 number of function evaluations 18 number of jacobian evaluations 14 exit parameter 2 final approximate solution -1.5707890e-05 9.9979013e-01 1.4759362e-02 1.4636689e-01 1.0007401e+00 -2.6176071e+00 4.1043191e+00 -3.1435957e+00 1.0526295e+00 problem 11 dimensions 9 31 initial l2 norm of the residuals 1.2691092e+06 final l2 norm of the residuals 1.1831152e-03 number of function evaluations 18 number of jacobian evaluations 15 exit parameter 3 final approximate solution -1.5323640e-05 9.9978966e-01 1.4769566e-02 1.4627734e-01 1.0011417e+00 -2.6185443e+00 4.1055059e+00 -3.1443701e+00 1.0528333e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 5.4772258e+00 final l2 norm of the residuals 1.8917617e-05 number of function evaluations 14 number of jacobian evaluations 10 exit parameter 2 final approximate solution 2.7236624e-08 1.0000017e+00 -5.7436200e-04 3.4799814e-01 -1.5793957e-01 1.0569109e+00 -3.2540383e+00 7.2908320e+00 -1.0261942e+01 9.0569487e+00 -4.5299549e+00 1.0091665e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 1.9220758e+04 final l2 norm of the residuals 2.0489091e-05 number of function evaluations 23 number of jacobian evaluations 16 exit parameter 2 final approximate solution -1.3459449e-09 1.0000014e+00 -5.4893835e-04 3.4771207e-01 -1.5713821e-01 1.0601681e+00 -3.2817526e+00 7.3718801e+00 -1.0388937e+01 9.1702709e+00 -4.5843325e+00 1.0200843e+00 problem 11 dimensions 12 31 initial l2 norm of the residuals 2.0189180e+06 final l2 norm of the residuals 1.9193252e-05 number of function evaluations 25 number of jacobian evaluations 18 exit parameter 2 final approximate solution -7.2524244e-09 1.0000015e+00 -5.5030826e-04 3.4753999e-01 -1.5410925e-01 1.0391998e+00 -3.2043118e+00 7.2027102e+00 -1.0163090e+01 8.9890957e+00 -4.5040555e+00 1.0049767e+00 problem 12 dimensions 3 10 initial l2 norm of the residuals 3.2111584e+01 final l2 norm of the residuals 0.0000000e+00 number of function evaluations 6 number of jacobian evaluations 5 exit parameter 2 final approximate solution 1.0000000e+00 1.0000000e+01 1.0000000e+00 problem 13 dimensions 2 10 initial l2 norm of the residuals 6.4585655e+01 final l2 norm of the residuals 1.1151857e+01 number of function evaluations 15 number of jacobian evaluations 9 exit parameter 1 final approximate solution 2.5829542e-01 2.5753230e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 2.8154382e+03 final l2 norm of the residuals 2.9332809e+02 number of function evaluations 163 number of jacobian evaluations 153 exit parameter 1 final approximate solution -1.1185437e+01 1.3057540e+01 -3.9446104e-01 2.5670618e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 5.5507331e+05 final l2 norm of the residuals 2.9298209e+02 number of function evaluations 27 number of jacobian evaluations 20 exit parameter 1 final approximate solution -1.1700037e+01 1.3243442e+01 -4.1518396e-01 2.2605659e-01 problem 14 dimensions 4 20 initial l2 norm of the residuals 6.1211256e+07 final l2 norm of the residuals 2.9351437e+02 number of function evaluations 77 number of jacobian evaluations 70 exit parameter 1 final approximate solution -1.1096786e+01 1.3018889e+01 -4.3165925e-01 2.2452404e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.8862381e+00 final l2 norm of the residuals 1.8862381e+00 number of function evaluations 1 number of jacobian evaluations 1 exit parameter 4 final approximate solution 5.0000000e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 5.3833446e+09 final l2 norm of the residuals 1.8842582e+00 number of function evaluations 25 number of jacobian evaluations 24 exit parameter 1 final approximate solution 9.8180389e-01 problem 15 dimensions 1 8 initial l2 norm of the residuals 1.1808874e+18 final l2 norm of the residuals 1.8842576e+00 number of function evaluations 43 number of jacobian evaluations 42 exit parameter 1 final approximate solution 9.8180157e-01 problem 15 dimensions 8 8 initial l2 norm of the residuals 1.9651386e-01 final l2 norm of the residuals 5.9314556e-02 number of function evaluations 24 number of jacobian evaluations 13 exit parameter 2 final approximate solution 4.3417852e-02 1.9331416e-01 2.6631495e-01 4.9977845e-01 5.0022149e-01 7.3368502e-01 8.0668581e-01 9.5658213e-01 problem 15 dimensions 9 9 initial l2 norm of the residuals 1.6994981e-01 final l2 norm of the residuals 1.8384672e-07 number of function evaluations 11 number of jacobian evaluations 8 exit parameter 2 final approximate solution 4.4205341e-02 1.9949065e-01 2.3561911e-01 4.1604692e-01 4.9999997e-01 5.8395314e-01 7.6438087e-01 8.0050933e-01 9.5579463e-01 problem 15 dimensions 10 10 initial l2 norm of the residuals 1.8374783e-01 final l2 norm of the residuals 8.0647521e-02 number of function evaluations 15 number of jacobian evaluations 7 exit parameter 1 final approximate solution 5.9669998e-02 1.6677602e-01 2.3921293e-01 3.9873415e-01 3.9908096e-01 6.0091907e-01 6.0126579e-01 7.6078707e-01 8.3322400e-01 9.4033003e-01 problem 16 dimensions 10 10 initial l2 norm of the residuals 1.6530216e+01 final l2 norm of the residuals 7.3323404e-06 number of function evaluations 13 number of jacobian evaluations 11 exit parameter 2 final approximate solution 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 9.7943157e-01 1.2056828e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656240e+06 final l2 norm of the residuals 2.1490760e-06 number of function evaluations 11 number of jacobian evaluations 6 exit parameter 2 final approximate solution 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 9.7943056e-01 1.2056941e+00 problem 16 dimensions 10 10 initial l2 norm of the residuals 9.7656252e+16 final l2 norm of the residuals 3.2186508e-06 number of function evaluations 27 number of jacobian evaluations 24 exit parameter 2 final approximate solution 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 9.7943068e-01 1.2056929e+00 problem 16 dimensions 30 30 initial l2 norm of the residuals 8.3476044e+01 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 1 final approximate solution 5.8075756e-02 5.8079898e-02 5.8076262e-02 5.8075994e-02 5.8081031e-02 5.8079571e-02 5.8078527e-02 5.8078557e-02 5.8077991e-02 5.8077097e-02 5.8077246e-02 5.8078468e-02 5.8078647e-02 5.8079422e-02 5.8080673e-02 5.8081597e-02 5.8080912e-02 5.8079839e-02 5.8081508e-02 5.8081090e-02 5.8080584e-02 5.8079034e-02 5.8078319e-02 5.8078527e-02 5.8077723e-02 5.8082163e-02 5.8080882e-02 5.8081627e-02 5.8080912e-02 2.9257618e+01 problem 16 dimensions 40 40 initial l2 norm of the residuals 1.2802637e+02 final l2 norm of the residuals 1.0000000e+00 number of function evaluations 5 number of jacobian evaluations 2 exit parameter 1 final approximate solution 1.9025487e-01 1.9025970e-01 1.9025639e-01 1.9025964e-01 1.9025838e-01 1.9025806e-01 1.9025996e-01 1.9025758e-01 1.9025901e-01 1.9025990e-01 1.9026136e-01 1.9026092e-01 1.9026023e-01 1.9026068e-01 1.9026110e-01 1.9026366e-01 1.9026342e-01 1.9026312e-01 1.9026724e-01 1.9026667e-01 1.9026598e-01 1.9026518e-01 1.9026449e-01 1.9026557e-01 1.9026402e-01 1.9026694e-01 1.9026604e-01 1.9026515e-01 1.9026524e-01 1.9026613e-01 1.9026697e-01 1.9026595e-01 1.9026276e-01 1.9026285e-01 1.9026273e-01 1.9026479e-01 1.9026396e-01 1.9026420e-01 1.9026211e-01 3.3389492e+01 problem 17 dimensions 5 33 initial l2 norm of the residuals 9.3756407e-01 final l2 norm of the residuals 7.3924293e-03 number of function evaluations 17 number of jacobian evaluations 14 exit parameter 1 final approximate solution 3.7541005e-01 1.9358462e+00 -1.4646864e+00 1.2867534e-02 2.2122702e-02 problem 18 dimensions 11 65 initial l2 norm of the residuals 1.4468656e+00 final l2 norm of the residuals 2.0034409e-01 number of function evaluations 15 number of jacobian evaluations 11 exit parameter 3 final approximate solution 1.3099747e+00 4.3154839e-01 6.3365942e-01 5.9943390e-01 7.5416678e-01 9.0433097e-01 1.3658432e+00 4.8234982e+00 2.3986933e+00 4.5688639e+00 5.6753392e+00 summary of 53 calls to lmstr1 nprob n m nfev njev info final L2 norm 1 5 10 3 2 3 2.2360678e+00 1 5 50 3 2 3 6.7082019e+00 2 5 10 5 3 1 1.4638501e+00 2 5 50 9 3 1 3.4826310e+00 3 5 10 3 2 1 1.9097275e+00 3 5 50 8 3 1 3.6917305e+00 4 2 2 21 16 4 0.0000000e+00 4 2 2 7 5 4 0.0000000e+00 4 2 2 6 4 2 0.0000000e+00 5 3 3 10 7 2 4.4930580e-08 5 3 3 19 14 2 1.1145794e-09 5 3 3 18 15 2 1.1308639e-13 6 4 4 70 67 4 2.8699966e-39 6 4 4 32 31 4 4.3201266e-16 6 4 4 45 39 2 6.1333960e-17 7 2 2 8 5 1 6.9989629e+00 7 2 2 16 11 1 6.9988751e+00 7 2 2 19 15 1 6.9989057e+00 8 3 15 6 5 3 9.0635970e-02 8 3 15 7 6 1 4.1761765e+00 8 3 15 5 4 1 4.1747694e+00 9 4 11 8 6 1 1.7536076e-02 9 4 11 45 37 1 3.2069419e-02 9 4 11 28 20 1 4.2497460e-02 10 3 16 121 113 2 9.4501982e+00 10 3 16 206 162 2 9.4068420e+02 11 6 31 6 5 1 4.7829513e-02 11 6 31 11 10 1 4.7829743e-02 11 6 31 15 14 3 4.7829483e-02 11 9 31 7 6 2 1.1828358e-03 11 9 31 18 14 2 1.1821783e-03 11 9 31 18 15 3 1.1831152e-03 11 12 31 14 10 2 1.8917617e-05 11 12 31 23 16 2 2.0489091e-05 11 12 31 25 18 2 1.9193252e-05 12 3 10 6 5 2 0.0000000e+00 13 2 10 15 9 1 1.1151857e+01 14 4 20 163 153 1 2.9332809e+02 14 4 20 27 20 1 2.9298209e+02 14 4 20 77 70 1 2.9351437e+02 15 1 8 1 1 4 1.8862381e+00 15 1 8 25 24 1 1.8842582e+00 15 1 8 43 42 1 1.8842576e+00 15 8 8 24 13 2 5.9314556e-02 15 9 9 11 8 2 1.8384672e-07 15 10 10 15 7 1 8.0647521e-02 16 10 10 13 11 2 7.3323404e-06 16 10 10 11 6 2 2.1490760e-06 16 10 10 27 24 2 3.2186508e-06 16 30 30 5 2 1 1.0000000e+00 16 40 40 5 2 1 1.0000000e+00 17 5 33 17 14 1 7.3924293e-03 18 11 65 15 11 3 2.0034409e-01 cminpack-1.3.4/examples/ref/stchkderc.ref000644 000765 000765 00000001451 12225167750 020326 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468976 -2.827562 -3.473582 -4.437612 -6.047661 -9.267761 -18.91806 fvecp - fvec -0.0001790524 -7.963181e-05 -4.768372e-06 5.352497e-05 9.989738e-05 0.0001385212 0.0001702309 0.0001974106 0.0003447533 0.0005407333 0.0008158684 0.001227856 0.001914024 0.003288269 0.007408142 err 0.2581466 0.2248907 0 0.2256959 0.2429258 0.2760358 0.3457333 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/stchkderc_box.ref000644 000765 000765 00000001451 12274440052 021167 0ustar00devernay000000 000000 fvec -0.9829918 -1.111746 -1.214351 -1.306448 -1.372163 -1.434587 -1.486078 -1.518468 -1.820838 -1.987333 -2.364425 -2.925063 -3.862792 -5.738253 -11.35463 fvecp - fvec -0.0002996922 -0.0002846718 -0.0002703667 -0.0002571344 -0.0002450943 -0.0002338886 -0.0002236366 -0.0002140999 -0.0001850128 -0.000146389 -9.250641e-05 -1.072884e-05 0.0001239777 0.000395298 0.001207352 err 0.5400268 0.4820367 0.4575765 0.4514604 0.4589003 0.4841411 0.5469722 1 1 1 1 0 1 1 1 cminpack-1.3.4/examples/ref/stenormc.ref000644 000765 000765 00000000406 12275245051 020201 0ustar00devernay000000 000000 dpmpar(2) = 1.175494e-38, dpmpar(3) = 3.402823e+38 rdwarf = 1.327871072777421e-18, rgiant = 1.844674297419792e+18 norm/rdwarf (naive) = 0.99506002664566 norm/rdwarf (enorm) = 1 norm/agiant (naive) = 1.01806378364563 norm/agiant (enorm) = 0.993795692920685 cminpack-1.3.4/examples/ref/stfdjac2c.ref000644 000765 000765 00000002064 12225167750 020220 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468976 -2.827562 -3.473582 -4.437612 -6.047661 -9.267761 -18.91806 fvecp - fvec -0.0001790524 -7.963181e-05 -4.768372e-06 5.352497e-05 9.989738e-05 0.0001385212 0.0001702309 0.0001974106 0.0003447533 0.0005407333 0.0008158684 0.001227856 0.001914024 0.003288269 0.007408142 errd 1 1 0 1 1 0.9949697 1 1 1 1 1 1 1 1 1 err 1 1 0 1 0.9952511 1 1 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/sthybrd1c.ref000644 000765 000765 00000000436 12225167750 020261 0ustar00devernay000000 000000 final L2 norm of the residuals 3.500863e-05 exit parameter 1 final approximates solution -0.5706489 -0.6816254 -0.7017328 -0.7042154 -0.7013723 -0.6918683 -0.6657927 -0.5960336 -0.4164145 cminpack-1.3.4/examples/ref/sthybrdc.ref000644 000765 000765 00000000521 12225167750 020173 0ustar00devernay000000 000000 final l2 norm of the residuals 3.500863e-05 number of function evaluations 10 exit parameter 1 final approximate solution -0.5706489 -0.6816254 -0.7017328 -0.7042154 -0.7013723 -0.6918683 -0.6657927 -0.5960336 -0.4164145 cminpack-1.3.4/examples/ref/sthybrj1c.ref000644 000765 000765 00000000440 12225167750 020262 0ustar00devernay000000 000000 final l2 norm of the residuals 3.519986e-05 exit parameter 1 final approximate solution -0.5706488 -0.6816254 -0.7017328 -0.7042154 -0.7013724 -0.6918683 -0.6657928 -0.5960336 -0.4164144 cminpack-1.3.4/examples/ref/sthybrjc.ref000644 000765 000765 00000000574 12225167750 020211 0ustar00devernay000000 000000 final l2 norm of the residuals 3.519986e-05 number of function evaluations 7 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.5706488 -0.6816254 -0.7017328 -0.7042154 -0.7013724 -0.6918683 -0.6657928 -0.5960336 -0.4164144 cminpack-1.3.4/examples/ref/sthybrjc_box.ref000644 000765 000765 00000000574 12274440052 021052 0ustar00devernay000000 000000 final l2 norm of the residuals 0.7585269 number of function evaluations 21 number of jacobian evaluations 2 exit parameter 5 final approximate solution -0.4715775 -0.5 -0.6075998 -0.6912393 -0.715058 -0.7148161 -0.6893578 -0.6133261 -0.4219725 cminpack-1.3.4/examples/ref/stlmder1c.ref000644 000765 000765 00000000272 12225167750 020252 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063593 exit parameter 3 final approximate solution 0.08241184 1.13308 2.343649 cminpack-1.3.4/examples/ref/stlmderc.ref000644 000765 000765 00000000705 12274447246 020177 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063593 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 3 final approximate solution 0.08241184 1.13308 2.343649 covariance 0.0001531201 0.00286994 -0.00265666 0.00286994 0.09480933 -0.09098993 -0.00265666 -0.09098993 0.08778726 cminpack-1.3.4/examples/ref/stlmderc_box.ref000644 000765 000765 00000000705 12274447242 021043 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09071382 number of function evaluations 9 number of Jacobian evaluations 8 exit parameter 3 final approximate solution 0.08371091 1.178308 2.3 covariance 6.693124e-05 0.0001068011 0 0.0001068011 0.0004612439 0 0 0 0 cminpack-1.3.4/examples/ref/stlmdif1c.ref000644 000765 000765 00000000266 12225167750 020245 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.0824282 1.133575 2.343179 cminpack-1.3.4/examples/ref/stlmdifc.ref000644 000765 000765 00000000625 12274447234 020165 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 21 exit parameter 1 final approximate solution 0.0824282 1.133575 2.343179 covariance 0.0001531442 0.002870449 -0.002656704 0.002870449 0.09489396 -0.09106711 -0.002656704 -0.09106711 0.08785866 cminpack-1.3.4/examples/ref/stlmstr1c.ref000644 000765 000765 00000000272 12225167750 020310 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063597 exit parameter 3 final approximate solution 0.08241189 1.133081 2.343649 cminpack-1.3.4/examples/ref/stlmstrc.ref000644 000765 000765 00000000705 12274447226 020233 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063597 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 3 final approximate solution 0.08241189 1.133081 2.343649 covariance 0.0001531202 0.002869945 -0.002656665 0.002869945 0.09480961 -0.09099019 -0.002656665 -0.09099019 0.08778751 cminpack-1.3.4/examples/ref/tchkder.ref000644 000765 000765 00000001453 12225167750 020002 0ustar00devernay000000 000000 FVEC -0.1181606D+01 -0.1429655D+01 -0.1606344D+01 -0.1745269D+01 -0.1840654D+01 -0.1921586D+01 -0.1984141D+01 -0.2022537D+01 -0.2468977D+01 -0.2827562D+01 -0.3473582D+01 -0.4437612D+01 -0.6047662D+01 -0.9267761D+01 -0.1891806D+02 FVECP - FVEC -0.7724666D-08 -0.3432406D-08 -0.2034843D-09 0.2313685D-08 0.4331078D-08 0.5984096D-08 0.7363281D-08 0.8531470D-08 0.1488591D-07 0.2335850D-07 0.3522012D-07 0.5301255D-07 0.8266660D-07 0.1419747D-06 0.3198990D-06 ERR 0.1141397D+00 0.9943516D-01 0.9674474D-01 0.9980447D-01 0.1073116D+00 0.1220445D+00 0.1526814D+00 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 cminpack-1.3.4/examples/ref/tchkderc.ref000644 000765 000765 00000001451 12225167750 020143 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468977 -2.827562 -3.473582 -4.437612 -6.047662 -9.267761 -18.91806 fvecp - fvec -7.724666e-09 -3.432406e-09 -2.034843e-10 2.313685e-09 4.331078e-09 5.984096e-09 7.363281e-09 8.53147e-09 1.488591e-08 2.33585e-08 3.522012e-08 5.301255e-08 8.26666e-08 1.419747e-07 3.19899e-07 err 0.1141397 0.09943516 0.09674474 0.09980447 0.1073116 0.1220445 0.1526814 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/tchkderc_box.ref000644 000765 000765 00000001451 12303616324 021004 0ustar00devernay000000 000000 fvec -0.9829917 -1.111746 -1.214351 -1.306448 -1.372163 -1.434587 -1.486078 -1.518468 -1.820838 -1.987333 -2.364425 -2.925063 -3.862792 -5.738252 -11.35463 fvecp - fvec -1.293763e-08 -1.22842e-08 -1.167235e-08 -1.110506e-08 -1.058151e-08 -1.009919e-08 -9.654869e-09 -9.245206e-09 -7.99478e-09 -6.327542e-09 -3.993411e-09 -4.922134e-10 5.343114e-09 1.701377e-08 5.202575e-08 err 0.2393293 0.2130632 0.2026053 0.2000738 0.2031623 0.2144393 0.2422281 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/tenormc.ref000644 000765 000765 00000000406 12275237763 020031 0ustar00devernay000000 000000 dpmpar(2) = 2.225074e-308, dpmpar(3) = 1.797693e+308 rdwarf = 1.826912911925689e-153, rgiant = 1.34078079299426e+153 norm/rdwarf (naive) = 1.00000000001012 norm/rdwarf (enorm) = 1 norm/agiant (naive) = 1.0000000000508 norm/agiant (enorm) = 0.999999999995784 cminpack-1.3.4/examples/ref/tfdjac2c.ref000644 000765 000765 00000002064 12225167750 020035 0ustar00devernay000000 000000 fvec -1.181606 -1.429655 -1.606344 -1.745269 -1.840654 -1.921586 -1.984141 -2.022537 -2.468977 -2.827562 -3.473582 -4.437612 -6.047662 -9.267761 -18.91806 fvecp - fvec -7.724666e-09 -3.432406e-09 -2.034843e-10 2.313685e-09 4.331078e-09 5.984096e-09 7.363281e-09 8.53147e-09 1.488591e-08 2.33585e-08 3.522012e-08 5.301255e-08 8.26666e-08 1.419747e-07 3.19899e-07 errd 1 1 1 1 0.995393 1 1 1 1 1 1 1 1 1 1 err 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 cminpack-1.3.4/examples/ref/thybrd.ref000644 000765 000765 00000000520 12225167750 017644 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 NUMBER OF FUNCTION EVALUATIONS 14 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 cminpack-1.3.4/examples/ref/thybrd1.ref000644 000765 000765 00000000440 12225167750 017726 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 cminpack-1.3.4/examples/ref/thybrd1c.ref000644 000765 000765 00000000436 12225167750 020076 0ustar00devernay000000 000000 final L2 norm of the residuals 1.192636e-08 exit parameter 1 final approximates solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/thybrdc.ref000644 000765 000765 00000000521 12225167750 020010 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 number of function evaluations 14 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/thybrj.ref000644 000765 000765 00000000600 12225167750 017651 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 NUMBER OF FUNCTION EVALUATIONS 11 NUMBER OF JACOBIAN EVALUATIONS 1 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 cminpack-1.3.4/examples/ref/thybrj1.ref000644 000765 000765 00000000440 12225167750 017734 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 cminpack-1.3.4/examples/ref/thybrj1c.ref000644 000765 000765 00000000440 12225167750 020077 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/thybrjc.ref000644 000765 000765 00000000574 12225167750 020026 0ustar00devernay000000 000000 final l2 norm of the residuals 1.192636e-08 number of function evaluations 11 number of jacobian evaluations 1 exit parameter 1 final approximate solution -0.5706545 -0.6816283 -0.7017325 -0.7042129 -0.701369 -0.6918656 -0.665792 -0.5960342 -0.4164121 cminpack-1.3.4/examples/ref/thybrjc_box.ref000644 000765 000765 00000000574 12274205470 020672 0ustar00devernay000000 000000 final l2 norm of the residuals 0.7585268 number of function evaluations 21 number of jacobian evaluations 2 exit parameter 5 final approximate solution -0.4715775 -0.5 -0.6075997 -0.6912395 -0.715058 -0.7148161 -0.689358 -0.613326 -0.4219724 cminpack-1.3.4/examples/ref/tlmder.ref000644 000765 000765 00000000432 12225167750 017641 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 6 NUMBER OF JACOBIAN EVALUATIONS 5 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmder1.ref000644 000765 000765 00000000272 12225167750 017724 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmder1c.ref000644 000765 000765 00000000272 12225167750 020067 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 cminpack-1.3.4/examples/ref/tlmderc.ref000644 000765 000765 00000000705 12274447216 020011 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778727 cminpack-1.3.4/examples/ref/tlmderc_box.ref000644 000765 000765 00000000705 12274447212 020655 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09071386 number of function evaluations 10 number of Jacobian evaluations 9 exit parameter 1 final approximate solution 0.08371095 1.178309 2.3 covariance 0.0001536684 0.002994926 -0 0.002994926 0.1026389 -0 -0 -0 0 cminpack-1.3.4/examples/ref/tlmdif.ref000644 000765 000765 00000000352 12225167750 017632 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 21 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmdif1.ref000644 000765 000765 00000000272 12225167750 017714 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmdif1c.ref000644 000765 000765 00000000266 12225167750 020062 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 cminpack-1.3.4/examples/ref/tlmdifc.ref000644 000765 000765 00000000625 12274447202 017775 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 21 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778728 cminpack-1.3.4/examples/ref/tlmstr.ref000644 000765 000765 00000000432 12225167750 017677 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 6 NUMBER OF JACOBIAN EVALUATIONS 5 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmstr1.ref000644 000765 000765 00000000272 12225167750 017762 0ustar00devernay000000 000000 FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 cminpack-1.3.4/examples/ref/tlmstr1c.ref000644 000765 000765 00000000272 12225167750 020125 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 cminpack-1.3.4/examples/ref/tlmstrc.ref000644 000765 000765 00000000705 12274447171 020047 0ustar00devernay000000 000000 final l2 norm of the residuals 0.09063596 number of function evaluations 6 number of Jacobian evaluations 5 exit parameter 1 final approximate solution 0.08241058 1.133037 2.343695 covariance 0.0001531202 0.002869941 -0.002656662 0.002869941 0.09480935 -0.09098995 -0.002656662 -0.09098995 0.08778727 cminpack-1.3.4/doc/hybrd1_.3000644 000765 000765 00000000022 12225167750 015436 0ustar00devernay000000 000000 .so man3/hybrd_.3 cminpack-1.3.4/doc/hybrd_.3000644 000765 000765 00000021722 12225167750 015367 0ustar00devernay000000 000000 .\" 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 \fBg77\fP version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of \fBg77\fP. .TP Compile with \fBg77\fP. Even if your program is all C code, you should link with \fBg77\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBg77\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). cminpack-1.3.4/doc/hybrd_.html000644 000765 000765 00000027122 12225167750 016171 0ustar00devernay000000 000000 Manpage of HYBRD_

HYBRD_

Section: C Library Functions (3)
Updated: March 8, 2002
Index Return to Main Contents
 

NAME

hybrd_, hybrd1_ - find a zero of a system of nonlinear function  

SYNOPSIS

#include <minpack.h>

void hybrd1_ ( void (*fcn)( int *n, double *x,
double *fvec, int *iflag),
int *n, double *x, double *fvec,
double *tol, int *info, double *wa,
int *lwa);
void hybrd_ ( void (*fcn)( int * n, double *x,
double *fvec, int *iflag),
int *n, double *x, double *fvec,
double *xtol, int *maxfev, int *ml, int *mu,
double *epsfcn, double *diag, int *mode, double *factor, int *nprint, int *info,
int *nfev, double *fjac, int *ldfjac,
double *r, int *lr, double *qtf,
double *wa1, double *wa2, double *wa3, double *wa4);
 

DESCRIPTION

The purpose of hybrd_ is to find a zero of a system of n nonlinear functions in n 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.

hybrd1_ serves the same function but has a simplified calling sequence.
 

Language notes

hybrd_ and hybrd1_ are written in FORTRAN. If calling from C, keep these points in mind:
Name mangling.
With g77 version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of g77.
Compile with g77.
Even if your program is all C code, you should link with g77 so it will pull in the FORTRAN libraries automatically. It's easiest just to use g77 to do all the compiling. (It handles C just fine.)
Call by reference.
All function parameters must be pointers.
Column-major arrays.
Suppose a function returns an array with 5 rows and 3 columns in an array z and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are:

        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]
 

Parameters for both functions

fcn is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, fcn must be declared in an external statement in the user calling program, and should be written as follows:

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

In C, fcn should be written as follows:

  void fcn(int n, double *x, double *fvec, int *iflag)
  {
    /* calculate the functions at x and
       return this vector in fvec. */
  }

The value of iflag should not be changed by fcn unless the user wants to terminate execution of hybrd_. In this case set iflag to a negative integer.

n is a positive integer input variable set to the number of functions and variables.

x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.

fvec is an output array of length n which contains the functions evaluated at the output x.
 

Parameters for hybrd1_

tol is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between x and the solution is at most tol.

info 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.

info = 0 improper input parameters.

info = 1 algorithm estimates that the relative error
           between x and the solution is at most tol.

info = 2 number of calls to fcn has reached or exceeded
           200*(n+1).

info = 3 tol is too small. No further improvement in
           the approximate solution x is possible.

info = 4 iteration is not making good progress.

wa is a work array of length lwa.

lwa is a positive integer input variable not less than (n*(3*n+13))/2.
 

Parameters for hybrd_

xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol.

maxfev is a positive integer input variable. Termination occurs when the number of calls to fcn is at least maxfev by the end of an iteration.

ml 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 ml to at least n - 1.

mu 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 n - 1.

epsfcn 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 epsfcn. If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.

diag is an array of length n. If mode = 1 (see below), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.

mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag. Other values of mode are equivalent to mode = 1.

factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if nonzero, or else to factor itself. In most cases factor should lie in the interval (.1,100.). 100. Is a generally recommended value.

nprint is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with x and fvec available for printing. If nprint is not positive, no special calls of fcn with iflag = 0 are made.

info 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.

info = 0 improper input parameters.

info = 1 relative error between two consecutive iterates
           is at most xtol.

info = 2 number of calls to fcn has reached or exceeded
           maxfev.

info = 3 xtol is too small. No further improvement in
           the approximate solution x is possible.

info = 4 iteration is not making good progress, as
           measured by the improvement from the last
           five jacobian evaluations.

info = 5 iteration is not making good progress, as
           measured by the improvement from the last
           ten iterations.

nfev is an integer output variable set to the number of calls to fcn.

fjac is an output n by n array which contains the orthogonal matrix q produced by the qr factorization of the final approximate jacobian.

ldfjac is a positive integer input variable not less than n which specifies the leading dimension of the array fjac.

r is an output array of length lr which contains the upper triangular matrix produced by the qr factorization of the final approximate Jacobian, stored rowwise.

lr is a positive integer input variable not less than (n*(n+1))/2.

qtf is an output array of length n which contains the vector (q transpose)*fvec.

wa1, wa2, wa3, and wa4 are work arrays of length n.

 

SEE ALSO

hybrj(3), hybrj1(3).

 

AUTHORS

Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
This manual page was written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


 

Index

NAME
SYNOPSIS
DESCRIPTION
Language notes
Parameters for both functions
Parameters for hybrd1_
Parameters for hybrd_
SEE ALSO
AUTHORS

This document was created by man2html, using the manual pages.
Time: 10:19:50 GMT, April 20, 2007 cminpack-1.3.4/doc/hybrj1_.3000644 000765 000765 00000000022 12225167750 015444 0ustar00devernay000000 000000 .so man3/hybrj_.3 cminpack-1.3.4/doc/hybrj_.3000644 000765 000765 00000021464 12225167750 015400 0ustar00devernay000000 000000 .\" 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 *" fjec , .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 *" fjec , .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 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 \fBg77\fP version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of \fBg77\fP. .TP Compile with \fBg77\fP. Even if your program is all C code, you should link with \fBg77\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBg77\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). cminpack-1.3.4/doc/hybrj_.html000644 000765 000765 00000026723 12225167750 016205 0ustar00devernay000000 000000 Manpage of HYBRJ_

HYBRJ_

Section: C Library Functions (3)
Updated: March 8, 2002
Index Return to Main Contents
 

NAME

hybrj_, hybrj1_ - find a zero of a system of nonlinear function  

SYNOPSIS

#include <minpack.h>
void hybrj1_ (void (*fcn)(int *n, double *x, double *fvec, double *fjec, int *ldfjac, int *iflag),
int *n, double *x, double *fvec, double *fjac,
int *ldfjac,
double *tol, int *info, double *wa, int *lwa);

void hybrj_ (void (*fcn)(int *n, double *x, double *fvec, double *fjec, int *ldfjac, int *iflag),
int *n, double *x, double *fvec, double *fjac,
int *ldfjac,
double *xtol, int *maxfev, double *diag, int *mode, double *factor, int *nprint, int *info, int *nfev,
int *njev, double *r, int *lr, double *qtf,
double *wa1, double *wa2, double *wa3, double *wa4);
 

DESCRIPTION

The purpose of hybrj_ is to find a zero of a system of n nonlinear functions in n variables by a modification of the Powell hybrid method. The user must provide a subroutine which calculates the functions and the Jacobian.

hybrj1_ serves the same function but has a simplified calling sequence.
 

Language notes

hybrj_ and hybrj1_ are written in FORTRAN. If calling from C, keep these points in mind:
Name mangling.
With g77 version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of g77.
Compile with g77.
Even if your program is all C code, you should link with g77 so it will pull in the FORTRAN libraries automatically. It's easiest just to use g77 to do all the compiling. (It handles C just fine.)
Call by reference.
All function parameters must be pointers.
Column-major arrays.
Suppose a function returns an array with 5 rows and 3 columns in an array z and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are:

        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]
 

Parameters for both functions

fcn is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, fcn must be declared in an external statement in the user calling program, and should be written as follows:

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

In C, fcn should be written as follows:

  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. */
  }

The value of iflag should not be changed by fcn unless the user wants to terminate execution of hybrj_. In this case set iflag to a negative integer.

n is a positive integer input variable set to the number of functions and variables.

x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.

fjac is an output n by n array which contains the orthogonal matrix q produced by the qr factorization of the final approximate jacobian.

ldfjac is a positive integer input variable not less than n which specifies the leading dimension of the array fjac.

fvec is an output array of length n which contains the functions evaluated at the output x.
 

Parameters for hybrj1_

tol is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between x and the solution is at most tol.

info 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.

info = 0 improper input parameters.

info = 1 algorithm estimates that the relative error
           between x and the solution is at most tol.

info = 2 number of calls to fcn has reached or exceeded
           200*(n+1).

info = 3 tol is too small. No further improvement in
           the approximate solution x is possible.

info = 4 iteration is not making good progress.

wa is a work array of length lwa.

lwa is a positive integer input variable not less than (n*(3*n+13))/2.
 

Parameters for hybrj_

xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol.

maxfev is a positive integer input variable. Termination occurs when the number of calls to fcn is at least maxfev by the end of an iteration.

diag is an array of length n. If mode = 1 (see below), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.

mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag. Other values of mode are equivalent to mode = 1.

factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if nonzero, or else to factor itself. In most cases factor should lie in the interval (.1,100.). 100. Is a generally recommended value.

nprint is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with x and fvec available for printing. If nprint is not positive, no special calls of fcn with iflag = 0 are made.

info 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.

info = 0 improper input parameters.

info = 1 relative error between two consecutive iterates
           is at most xtol.

info = 2 number of calls to fcn has reached or exceeded
           maxfev.

info = 3 xtol is too small. No further improvement in
           the approximate solution x is possible.

info = 4 iteration is not making good progress, as
           measured by the improvement from the last
           five jacobian evaluations.

info = 5 iteration is not making good progress, as
           measured by the improvement from the last
           ten iterations.

nfev is an integer output variable set to the number of calls to fcn.

fjac is an output n by n array which contains the orthogonal matrix q produced by the qr factorization of the final approximate jacobian.

ldfjac is a positive integer input variable not less than n which specifies the leading dimension of the array fjac.

r is an output array of length lr which contains the upper triangular matrix produced by the qr factorization of the final approximate Jacobian, stored rowwise.

lr is a positive integer input variable not less than (n*(n+1))/2.

qtf is an output array of length n which contains the vector (q transpose)*fvec.

wa1, wa2, wa3, and wa4 are work arrays of length n.

 

SEE ALSO

hybrd(3), hybrd1(3).

 

AUTHORS

Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
This manual page was written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


 

Index

NAME
SYNOPSIS
DESCRIPTION
Language notes
Parameters for both functions
Parameters for hybrj1_
Parameters for hybrj_
SEE ALSO
AUTHORS

This document was created by man2html, using the manual pages.
Time: 10:19:50 GMT, April 20, 2007 cminpack-1.3.4/doc/index.html000644 000765 000765 00000051302 12341325455 016023 0ustar00devernay000000 000000 C/C++ Minpack

C/C++ Minpack

What is Minpack?

This is the official description of Minpack, from the original ReadMe file: 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.

The original authors of the FORTRAN version are Jorge More', Burt Garbow, and Ken Hillstrom from Argonne National Laboratory, and the code can be obtained from Netlib.

Minpack is probably the best open-source implementation of the Levenberg-Marquardt algorithm (in fact, it is even better, since it adds to L-M automatic variables scaling). There is another open-source L-M implementation in C/C++, levmar by Manolis Lourakis, but unfortunately is is released under the GPL, which restricts its inclusion in commercial software. Minpack is licensed under a BSD-like license (available in the distribution).

What about CMinpack?

In July 2002 (before levmar), Manolis Lourakis (lourakis at ics forth gr) released a C version of Minpack, called CMinpack, obtained from the FORTRAN version using f2c and some limited manual editing. However, this version had several problems, which came from the FORTRAN version:

  1. All the function prototypes were following the original FORTRAN call conventions, so that all parameters are passed by reference (if a function needs an int parameter, you have to pass a pointer to this int).
  2. There were lots of static variables in the code, thus you could not optimize a function which required calling Minpack to be evaluated (a minimization-of-minimization problem for example): The Minpack code is not reentrant.
  3. If the function to be optimized has to use extra parameters or data (this is the case most of the time), the only way to access them was though global variables, which is very bad, especially if you want to use the same function with different data in different threads: The Minpack code is not MT-Safe.
  4. There was no C/C++ include file.
  5. Examples and tests were missing from the distribution, although there are some FORTRAN examples in the documentation.

Why is C/C++ Minpack better?

I took a dozen of hours to rework all these problems, and came out with a pure C version of Minpack, with has standard (ISO C99) parameters passing, is fully reentrant, multithread-safe, and has a full set of examples and tests:

  1. Input variables are now passed by value, output variables are passed by reference. The keyword "const" is used as much as possible for constant arrays. The return value of each function is now used to get the function status (it was obtained via the IFLAG or INFO parameter in Minpack).
  2. All non-const static variables were removed, and the code was tested after that. Luckily, Minpack didn't use the nastiest feature in FORTRAN: all local variables are static, so that a function can behave differently when you call it several times.
  3. The function to be minimized and all the Minpack functions now take an extra "void*" argument, which can be used to pass any pointer-to-struct or pointer-to-class, and you can put all you extra parameters and data in that struct. Just cast this pointer to the appropriate pointer type in your function, and there they are! There is no need for global variables anymore. Be careful if you access the same object from different threads, though (a solution is to protect this extra data with a mutex).
  4. The Debian project did a C include file for Minpack. It still needed some work (add consts and C++ compatibility), so I did this work, and used the include file for the FORTRAN version as the base for my C/C++ version.
  5. The Debian project also translated all the FORTRAN examples to C. I worked from these to produce examples which also call my C/C++ version of Minpack instead of the FORTRAN version. Also included in the distribution are reference output files produced by the test runs (for comparison).

If you use C/C++ Minpack for a publication, you should cite it as:

@misc{cminpack,
  title={C/C++ Minpack},
  author={Devernay, Fr{\'e}d{\'e}ric},
  year={2007},
  howpublished = "\url{http://devernay.free.fr/hacks/cminpack/}",
}

Distribution

The distribution contains:

  • The CMinpack code, where static and global variables were removed (it is thus reentrant, but not MT-Safe).
  • The C/C++ Minpack code (reentrant and MT-Safe).
  • C and C++-compatible include files for Minpack or CMinpack (minpack.h) and C/C++ Minpack (cminpack.h), and Unix Makefiles.
  • Full original documentation, translated to HTML, and all the examples, tests, and reference test results, so that you can check if the code runs properly on your machine before really using it.
  • The extra covariance function "covar", with sample uses in the tlmder and tlmdir examples. Note that the result of covar has to be scaled by some factor, as shown in the source file examples/tlmderc.c (look for the documentation of the NAG function E04YCF for further explanations).

It is distributed under the original Minpack license (see the file CopyrightMINPACK.txt in the distribution).

Download

GitHub repository: https://github.com/devernay/cminpack

Using CMinpack

The CMinpack calls have the same name as the FORTRAN functions, in lowercase (e.g. lmder(...)). See the links to the documentation below, or take a look at the simple examples in the examples directory of the distribution. The simple examples are named after the function they call: tlmder.c is the simple example for lmder.

If you want to use the single precision CMinpack, you should define __cminpack_float__ before including cminpack.h. __cminpack_half__ has to be defined for the half-precision version (and the code needs to be compiled with a C++ compiler).

The single-precision versions of the functions are prefixed by "s" (as in "slmder(...)"), and the half-precision are prefixed by "h".

CMinpack defines __cminpack_real__ as the floating point type, and the __cminpack_func__() macro can be used to call CMinpack functions independently of the precision used (as in the examples). However, you shouldn't use these macros in your own code, since your code is probably designed for a specific precision, and you should prefer calling directly slmder(...) or slmder(...).

Documentation

Simulating box constraints

Note that box constraints can easily be simulated in C++ Minpack, using a change of variables in the function (that hint was found in the lmfit documentation).

For example, say you want xmin[j] < x[j] < xmax[j], just apply the following change of variable at the beginning of fcn on the variables vector, and also on the computed solution after the optimization was performed:

  for (j = 0; j < 3; ++j) {
    real xmiddle = (xmin[j]+xmax[j])/2.;
    real xwidth = (xmax[j]-xmin[j])/2.;
    real th =  tanh((x[j]-xmiddle)/xwidth);
    x[j] = xmiddle + th * xwidth;
    jacfac[j] = 1. - th * th;
  }

This change of variables preserves the variables scaling, and is almost the identity near the middle of the interval.

Of course, if you use lmder, lmder1, hybrj or hybrj1, the Jacobian must be also consistent with that new function, so the column of the original Jacobian corresponding to x1 must be multiplied by the derivative of the change of variable, i.e jacfac[j].

Similarly, each element of the covariance matrix must be multiplied by jacfac[i]*jacfac[j].

For examples on how to implement this in practice, see the portions of code delimited by "#ifdef BOX_CONSTRAINTS" in the following source files: tlmderc.c, thybrj.c, tchkderc.c.

Equivalence table with other libraries

The following table may be useful if you need to switch to or from another library.

Equivalence table between MINPACK and NAG, NPL, SLATEC, levmar and GSL
MINPACK NAG NPL SLATEC levmar GSL
lmdif E04FCF LSQNDN DNLS1 dlevmar_dif
lmdif1 E04FYF LSNDN1 DNLS1E dlevmar_dif
lmder E04GDF/E04GBF LSQFDN DNLS1 dlevmar_der gsl_multifit_fdfsolver_lmsder
lmder1 E04GZF LSFDN2 DNLS1E dlevmar_der
lmstr * * DNLS1
hybrd C05NCF * DNSQ
hybrd1 C05NBF * DNSQE
hybrj C05PCF * DNSQ
hybrj1 C05PBF * DNSQE
covar E04YCF * DCOV gsl_multifit_covar

Other MINPACK implementations

History

  • 1.3.4 (28/05/2014): Add FindCMinpack.cmake cmake module. If you use the cmake install, finding CMinpack from your CMakeLists.txt (especially on Windows) is as easy as find_package(CMinpack).
  • 1.3.3 (04/02/2014): Add documentation and examples abouts how to add box constraints to the variables. Continuous integration using Travis CI
  • 1.3.2 (27/10/2013): Minor change in the CMake build: also set SOVERSION.
  • 1.3.1 (02/10/2013): Fix CUDA examples compilation, and remove non-free files.
  • 1.3.0 (09/06/2012): Optionally use LAPACK and CBLAS in lmpar, qrfac, and qrsolv. Added "make lapack" to build the LAPACK-based cminpack and "make checklapack" to test it (results of the test may depend on the underlying LAPACK and BLAS implementations). On 64-bits architectures, the preprocessor symbol __LP64__ must be defined (see cminpackP.h) if the LAPACK library uses the LP64 interface (i.e. 32-bits integer, vhereas the ILP interface uses 64 bits integers).
  • 1.2.2 (16/05/2012): Update Makefiles and documentation (see "Using CMinpack" above) for easier building and testing.
  • 1.2.1 (15/05/2012): The library can now be built as double, float or half versions. Standard tests in the "examples" directory can now be lauched using "make check" (to run common tests, including against the float version), "make checkhalf" (to test the half version) and "make checkfail" (to run all the tests, even those that fail).
  • 1.2.0 (14/05/2012): Added original FORTRAN sources for better testing (type "make" in directory fortran, then "make" in examples and follow the instructions). Added driver tests lmsdrv, chkdrv, hyjdrv, hybdrv. Typing "make alltest" in the examples directory will run all possible test combinations (make sure you have gfortran installed).
  • 1.1.5 (04/05/2012): cminpack now works in CUDA, thanks to Jordi Bataller Mascarell, type "make" in the "cuda" subdir (be careful, though: this is a straightforward port from C, and each problem is solved using a single thread). cminpack can now also be compiled with single-precision floating point computation (define __cminpack_real__ to float when compiling and using the library). Fix cmake support for CMINPACK_LIB_INSTALL_DIR. Update the reference files for tests.
  • 1.1.4 (30/10/2011): Translated all the Levenberg-Marquardt code (lmder, lmdif, lmstr, lmder1, lmdif1, lmstr1, lmpar, qrfac, qrsolv, fdjac2, chkder) to use C-style indices.
  • 1.1.3 (16/03/2011): Minor fix: Change non-standard strnstr() to strstr() in genf77tests.c.
  • 1.1.2 (07/01/2011): Fix Windows DLL building (David Graeff) and document covar in cminpack.h.
  • 1.1.1 (04/12/2010): Complete rewrite of the C functions (without trailing underscore in the function name). Using the original FORTRAN code, the original algorithms structure was recovered, and many goto's were converted to if...then...else. The code should now be both more readable and easier to optimize, both for humans and for compilers. Added lmddrv and lmfdrv test drivers, which test a lot of difficult functions (these functions are explained in Testing Unconstrained Optimization Software by Moré et al.). Also added the pkg-config files to the cmake build, as well as an "uninstall" target, contributed by Geoffrey Biggs.
  • 1.0.4 (18/10/2010): Support for shared library building using CMake, thanks to Goeffrey Biggs from AIST and Radu Bogdan Rusu from Willow Garage. Shared libraries can be enabled using cmake options, as in: cmake -DUSE_FPIC=ON -DSHARED_LIBS=ON -DBUILD_EXAMPLES=OFF path_to_sources
  • 1.0.3 (18/03/2010): Added CMake support. XCode build is now Universal (i386+ppc). Added tfdjac2_ and tfdjac2c examples, which test the accuracy of a finite-differences approximation of the Jacobian. Bug fix in tlmstr1 (signaled by Thomas Capricelli).
  • 1.0.2 (27/02/2009): Added Xcode and Visual Studio project files
  • 1.0.1 (17/12/2007): bug fix in covar() and covar_(), the computation of tolr caused a segfault (signaled by Timo Hartmann).
  • 1.0.0 (24/04/2007): Initial revision.

Future work

There is now a very powerful alternative to MINPACK, which is the Ceres Solver. You may want to consider using Ceres for any new project.

The main feature that's missing on cminpack is the possibility to add constraints on variables. Simple boundary constraints should be enough, as implemented in ALGLIB or MPFIT.

levmar also has linear constraints, but they shouldn't be necessary since linear constraints can be changed to box constraints by a simple change of variables. If you really need nonlinear constraints, and no reparameterization of variables (which may be able to linearize these constraints), you should consider using NLopt instead of cminpack.

Please contact me for any suggestion or request.

Frédéric Devernay

Valid XHTML 1.1! Valid CSS! Level Double-A conformance icon, 
          W3C-WAI Web Content Accessibility Guidelines 1.0

cminpack-1.3.4/doc/lmder1_.3000644 000765 000765 00000000022 12225167750 015431 0ustar00devernay000000 000000 .so man3/lmder_.3 cminpack-1.3.4/doc/lmder_.3000644 000765 000765 00000026310 12225167750 015360 0ustar00devernay000000 000000 .\" 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 \fBg77\fP version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of \fBg77\fP. .TP Compile with \fBg77\fP. Even if your program is all C code, you should link with \fBg77\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBg77\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). cminpack-1.3.4/doc/lmder_.html000644 000765 000765 00000035034 12225167750 016165 0ustar00devernay000000 000000 Manpage of LMDER_

LMDER_

Section: C Library Functions (3)
Updated: March 8, 2002
Index Return to Main Contents
 

NAME

lmder_, lmder1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian  

SYNOPSIS

include <minpack.h>
void lmder1_ ( void (*fcn) (int *m, int *n, double *x, double *fvec, double *fjac,
int *ldfjac, int *iflag),
int *m, int * n, double *x, double *fvec, double *fjac, int *ldfjac,
double *tol, int *info, int *iwa, double *wa, int *lwa);
void lmder_ ( void (*fcn)( int *m, int *n, double *x, double *fvec, double *fjac,
int *ldfjac, int *iflag),
int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac,
double *ftol, double *xtol, double *gtol, int *maxfev, double *diag, int *mode,
double *factor, int *nprint, int *info,
int *nfev, int *njev, int *ipvt,
double *qtf, double *wa1, double *wa2, double *wa3, double *wa4 );
 

DESCRIPTION

The purpose of lmder_ is to minimize the sum of the squares of m nonlinear functions in n variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a function which calculates the functions and the Jacobian.

lmder1_ performs the same function as lmder_ but has a simplified calling sequence.

lmstr and lmstr1 also perform the same function but use minimal storage.
 

Language notes

These functions are written in FORTRAN. If calling from C, keep these points in mind:
Name mangling.
With g77 version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of g77.
Compile with g77.
Even if your program is all C code, you should link with g77 so it will pull in the FORTRAN libraries automatically. It's easiest just to use g77 to do all the compiling. (It handles C just fine.)
Call by reference.
All function parameters must be pointers.
Column-major arrays.
Suppose a function returns an array with 5 rows and 3 columns in an array z and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are:

        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]

 

User-supplied Function

fcn is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, fcn must be declared in an external statement in the user calling program, and should be written as follows:

  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

In C, fcn should be written as follows:

  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. */
  }

The value of iflag should not be changed by fcn unless the user wants to terminate execution of lmder_ (or lmder1_). In this case set iflag to a negative integer.
 

Parameters for both lmder_ and lmder1_

m is a positive integer input variable set to the number of functions.

n is a positive integer input variable set to the number of variables. n must not exceed m.

x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.

fvec is an output array of length m which contains the functions evaluated at the output x.

fjac is an output m by n array. The upper n by n submatrix of fjac contains an upper triangular matrix r with diagonal elements of nonincreasing magnitude such that


         t     t           t
        p *(jac *jac)*p = r *r,

where p is a permutation matrix and jac is the final calculated Jacobian. column j of p is column ipvt(j) (see below) of the identity matrix. The lower trapezoidal part of fjac contains information generated during the computation of r.

ldfjac is a positive integer input variable not less than m which specifies the leading dimension of the array fjac.
 

Parameters for lmder1_

tol is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most tol or that the relative error between x and the solution is at most tol.

info 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.


  info = 0  improper input parameters.


  info = 1  algorithm estimates that the relative error in the sum of squares is at most tol.


  info = 2  algorithm estimates that the relative error between x and the solution is at most tol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  fvec is orthogonal to the columns of the Jacobian to machine precision.


  info = 5  number of calls to fcn has reached or exceeded 200*(n+1).


  info = 6  tol is too small. no further reduction in the sum of squares is possible.


  info = 7  tol is too small. no further improvement in the approximate solution x is possible.

iwa is an integer work array of length n.

wa is a work array of length lwa.

lwa is an integer input variable not less than m*n + 5*n + m for lmder1_.
 

Parameters for lmder_

ftol is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares.

xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol. Therefore, xtol measures the relative error desired in the approximate solution.

gtol is a nonnegative input variable. Termination occurs when the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. Therefore, gtol measures the orthogonality desired between the function vector and the columns of the Jacobian.

maxfev is a positive integer input variable. Termination occurs when the number of calls to fcn is at least maxfev by the end of an iteration.

diag is an array of length n. If mode = 1 (see below), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.

mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag. Other values of mode are equivalent to mode = 1.

factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if the latter is nonzero, or else to factor itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value.

nprint is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with x and fvec available for printing. If nprint is not positive, no special calls of fcn with iflag = 0 are made.

info 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.


  info = 0  improper input parameters.


  info = 1  both actual and predicted relative reductions in the sum of squares are at most ftol.


  info = 2  relative error between two consecutive iterates is at most xtol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value.


  info = 5  number of calls to fcn has reached or exceeded maxfev.


  info = 6  ftol is too small. No further reduction in the sum of squares is possible.


  info = 7  xtol is too small. No further improvement in the approximate solution x is possible.


  info = 8 gtol is too small. fvec is orthogonal to the columns of the Jacobian to machine precision.

nfev is an integer output variable set to the number of calls to fcn with iflag = 1.

njev is an integer output variable set to the number of calls to fcn with iflag = 2.

ipvt is an integer output array of length n. ipvt defines a permutation matrix p such that jac*p = q*r, where jac is the final calculated Jacobian, q is orthogonal (not stored), and r is upper triangular with diagonal elements of nonincreasing magnitude. Column j of p is column ipvt(j) of the identity matrix.

qtf is an output array of length n which contains the first n elements of the vector (q transpose)*fvec.

wa1, wa2, and wa3 are work arrays of length n.

wa4 is a work array of length m.
 

SEE ALSO

lmdif(3), lmdif1(3), lmstr(3), lmstr1(3).
 

AUTHORS

Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


 

Index

NAME
SYNOPSIS
DESCRIPTION
Language notes
User-supplied Function
Parameters for both lmder_ and lmder1_
Parameters for lmder1_
Parameters for lmder_
SEE ALSO
AUTHORS

This document was created by man2html, using the manual pages.
Time: 10:19:50 GMT, April 20, 2007 cminpack-1.3.4/doc/lmdif1_.3000644 000765 000765 00000000022 12225167750 015421 0ustar00devernay000000 000000 .so man3/lmdif_.3 cminpack-1.3.4/doc/lmdif_.3000644 000765 000765 00000025271 12225167750 015355 0ustar00devernay000000 000000 .\" 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 \fBg77\fP version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of \fBg77\fP. .TP Compile with \fBg77\fP. Even if your program is all C code, you should link with \fBg77\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBg77\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). cminpack-1.3.4/doc/lmdif_.html000644 000765 000765 00000033737 12225167750 016165 0ustar00devernay000000 000000 Manpage of LMDIF_

LMDIF_

Section: C Library Functions (3)
Updated: March 8, 2002
Index Return to Main Contents
 

NAME

lmdif_, lmdif1_ - minimize the sum of squares of m nonlinear functions  

SYNOPSIS

include <minpack.h>
void lmdif1_ ( void (*fcn)(int *m, int *n, double *x, double *fvec, int *iflag),
int *m, int * n, double *x, double *fvec,
double *tol, int *info, int *iwa, double *wa, int *lwa);
void lmdif_ ( void (*fcn)(int *m, int *n, double *x, double *fvec, int *iflag),
int *m, int *n, double *x, double *fvec,
double *ftol, double *xtol, double *gtol, int *maxfev, double *epsfcn, double *diag, int *mode, double *factor, int *nprint, int *info, int *nfev, double *fjac,
int *ldfjac, int *ipvt, double *qtf,
double *wa1, double *wa2, double *wa3, double *wa4 );
 

DESCRIPTION

The purpose of lmdif_ is to minimize the sum of the squares of m nonlinear functions in n 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.

lmdif1_ serves the same purpose but has a simplified calling sequence.
 

Language notes

These functions are written in FORTRAN. If calling from C, keep these points in mind:
Name mangling.
With g77 version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of g77.
Compile with g77.
Even if your program is all C code, you should link with g77 so it will pull in the FORTRAN libraries automatically. It's easiest just to use g77 to do all the compiling. (It handles C just fine.)
Call by reference.
All function parameters must be pointers.
Column-major arrays.
Suppose a function returns an array with 5 rows and 3 columns in an array z and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are:

        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]

fcn is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, fcn must be declared in an external statement in the user calling program, and should be written as follows:

  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

In C, fcn should be written as follows:

  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] */
  }

The value of iflag should not be changed by fcn unless the user wants to terminate execution of lmdif_ (or lmdif1_). In this case set iflag to a negative integer.

 

Parameters for both lmdif_ and lmdif1_

m is a positive integer input variable set to the number of functions.

n is a positive integer input variable set to the number of variables. n must not exceed m.

x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.

fvec is an output array of length m which contains the functions evaluated at the output x.
 

Parameters for lmdif1_

tol is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most tol or that the relative error between x and the solution is at most tol.

info 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.


  info = 0  improper input parameters.


  info = 1  algorithm estimates that the relative error in the sum of squares is at most tol.


  info = 2  algorithm estimates that the relative error between x and the solution is at most tol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  fvec is orthogonal to the columns of the Jacobian to machine precision.


  info = 5  number of calls to fcn has reached or exceeded 200*(n+1).


  info = 6  tol is too small. no further reduction in the sum of squares is possible.


  info = 7  tol is too small. no further improvement in the approximate solution x is possible.

iwa is an integer work array of length n.

wa is a work array of length lwa.

lwa is an integer input variable not less than m*n + 5*n + m.
 

Parameters for lmdif_

ftol is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares.

xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol. Therefore, xtol measures the relative error desired in the approximate solution.

gtol is a nonnegative input variable. Termination occurs when the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. Therefore, gtol measures the orthogonality desired between the function vector and the columns of the Jacobian.

maxfev is a positive integer input variable. Termination occurs when the number of calls to fcn is at least maxfev by the end of an iteration.

epsfcn 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 epsfcn. If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.

diag is an array of length n. If mode = 1 (see below), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.

mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag. Other values of mode are equivalent to mode = 1.

factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if the latter is nonzero, or else to factor itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value.

nprint is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with x and fvec available for printing. If nprint is not positive, no special calls of fcn with iflag = 0 are made.

info 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.


  info = 0  improper input parameters.


  info = 1  both actual and predicted relative reductions in the sum of squares are at most ftol.


  info = 2  relative error between two consecutive iterates is at most xtol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value.


  info = 5  number of calls to fcn has reached or exceeded maxfev.


  info = 6  ftol is too small. No further reduction in the sum of squares is possible.


  info = 7  xtol is too small. No further improvement in the approximate solution x is possible.


  info = 8 gtol is too small. fvec is orthogonal to the columns of the Jacobian to machine precision.

nfev is an integer output variable set to the number of calls to fcn.

fjac is an output m by n array. The upper n by n submatrix of fjac contains an upper triangular matrix r with diagonal elements of nonincreasing magnitude such that


         t     t           t
        p *(jac *jac)*p = r *r,

where p is a permutation matrix and jac is the final calculated Jacobian. column j of p is column ipvt(j) (see below) of the identity matrix. The lower trapezoidal part of fjac contains information generated during the computation of r.

ldfjac is a positive integer input variable not less than m which specifies the leading dimension of the array fjac.

ipvt is an integer output array of length n. ipvt defines a permutation matrix p such that jac*p = q*r, where jac is the final calculated Jacobian, q is orthogonal (not stored), and r is upper triangular with diagonal elements of nonincreasing magnitude. Column j of p is column ipvt(j) of the identity matrix.

qtf is an output array of length n which contains the first n elements of the vector (q transpose)*fvec.

wa1, wa2, and wa3 are work arrays of length n.

wa4 is a work array of length m.
 

SEE ALSO

lmder(3), lmder1(3), lmstr(3), lmstr1(3).
 

AUTHORS

Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


 

Index

NAME
SYNOPSIS
DESCRIPTION
Language notes
Parameters for both lmdif_ and lmdif1_
Parameters for lmdif1_
Parameters for lmdif_
SEE ALSO
AUTHORS

This document was created by man2html, using the manual pages.
Time: 10:19:50 GMT, April 20, 2007 cminpack-1.3.4/doc/lmstr1_.3000644 000765 000765 00000000022 12225167750 015467 0ustar00devernay000000 000000 .so man3/lmstr_.3 cminpack-1.3.4/doc/lmstr_.3000644 000765 000765 00000026530 12225167750 015422 0ustar00devernay000000 000000 .\" 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 \fBg77\fP version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of \fBg77\fP. .TP Compile with \fBg77\fP. Even if your program is all C code, you should link with \fBg77\fP so it will pull in the FORTRAN libraries automatically. It's easiest just to use \fBg77\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). cminpack-1.3.4/doc/lmstr_.html000644 000765 000765 00000035330 12225167750 016222 0ustar00devernay000000 000000 Manpage of LMSTR_

LMSTR_

Section: C Library Functions (3)
Updated: March 8, 2002
Index Return to Main Contents
 

NAME

lmstr_, lmstr1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage  

SYNOPSIS

include <minpack.h>
void lmstr1_ ( void (*fcn) (int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag),
int *m, int * n, double *x, double *fvec, double *fjac, int *ldfjac,
double *tol, int *info, int *iwa,
double *wa, int *kwa);
void lmstr_ ( void (*fcn)( int *m, int *n, double *x, double *fvec, double *fjrow, int *iflag),
int *m, int *n, double *x, double *fvec, double *fjac, int *ldfjac,
double *ftol, double *xtol, double *gtol,
int *maxfev, double *diag, int *mode, double *factor,
int *nprint, int *info, int *nfev, int *njev,
int *ipvt, double *qtf,
double *wa1, double *wa2, double *wa3, double *wa4 );
 

DESCRIPTION

The purpose of lmstr_ is to minimize the sum of the squares of m nonlinear functions in n 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.

lmstr1_ performs the same function but has a simplified calling sequence.

lmder(3) and lmder1(3) perform the same function but do not attempt to minimize storage.
 

Language notes

These functions are written in FORTRAN. If calling from C, keep these points in mind:
Name mangling.
With g77 version 2.95 or 3.0, all the function names end in an underscore. This may change with future versions of g77.
Compile with g77.
Even if your program is all C code, you should link with g77 so it will pull in the FORTRAN libraries automatically. It's easiest just to use g77 to do all the compiling. (It handles C just fine.)
Call by reference.
All function parameters must be pointers.
Column-major arrays.
Suppose a function returns an array with 5 rows and 3 columns in an array z and in the call you have declared a leading dimension of 7. The FORTRAN and equivalent C references are:

        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]

 

User-supplied Function

fcn is the name of the user-supplied subroutine which calculates the functions. In FORTRAN, fcn must be declared in an external statement in the user calling program, and should be written as follows:

  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

In C, fcn should be written as follows:

  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. */
  }

iflag is an input integer which specifies whether a function value or Jacobian row is to be calculated. The value of iflag should not be changed by fcn unless the user wants to terminate execution of lmstr_ (or lmstr1_). In this case set iflag to a negative integer.
 

Parameters for both lmstr_ and lmstr1_

m is a positive integer input variable set to the number of functions.

n is a positive integer input variable set to the number of variables. n must not exceed m.

x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.

fvec is an output array of length m which contains the functions evaluated at the output x.

fjrow is an output array of length n which is set to one row of the Jacobian evaluated at x.

fjac is an output m by n array. The upper n by n submatrix of fjac contains an upper triangular matrix r with diagonal elements of nonincreasing magnitude such that


         t     t           t
        p *(jac *jac)*p = r *r,

where p is a permutation matrix and jac is the final calculated Jacobian. Column j of p is column ipvt(j) (see below) of the identity matrix. The lower trapezoidal part of fjac contains information generated during the computation of r.

ldfjac is a positive integer input variable not less than m which specifies the leading dimension of the array fjac.
 

Parameters for lmstr1_

tol is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most tol or that the relative error between x and the solution is at most tol.

info 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.


  info = 0  improper input parameters.


  info = 1  algorithm estimates that the relative error in the sum of squares is at most tol.


  info = 2  algorithm estimates that the relative error between x and the solution is at most tol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  fvec is orthogonal to the columns of the Jacobian to machine precision.


  info = 5  number of calls to fcn has reached or exceeded 100*(n+1).


  info = 6  tol is too small. no further reduction in the sum of squares is possible.


  info = 7  tol is too small. no further improvement in the approximate solution x is possible.

wa is a work array of length lwa.

lwa is an integer input variable not less than m*n + 5*n + m for lmder1, or 5*n+m for lmstr1_.
 

Parameters for lmstr_

ftol is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares.

xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol. Therefore, xtol measures the relative error desired in the approximate solution.

gtol is a nonnegative input variable. Termination occurs when the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. Therefore, gtol measures the orthogonality desired between the function vector and the columns of the Jacobian.

maxfev is a positive integer input variable. Termination occurs when the number of calls to fcn is at least maxfev by the end of an iteration.

diag is an array of length n. If mode = 1 (see below), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.

mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag. Other values of mode are equivalent to mode = 1.

factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if the latter is nonzero, or else to factor itself. In most cases factor should lie in the interval (.1,100.). 100. is a generally recommended value.

nprint is an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and immediately prior to return, with x and fvec available for printing. If nprint is not positive, no special calls of fcn with iflag = 0 are made.

info 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.


  info = 0  improper input parameters.


  info = 1  both actual and predicted relative reductions in the sum of squares are at most ftol.


  info = 2  relative error between two consecutive iterates is at most xtol.


  info = 3  conditions for info = 1 and info = 2 both hold.


  info = 4  the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value.


  info = 5  number of calls to fcn has reached or exceeded maxfev.


  info = 6  ftol is too small. No further reduction in the sum of squares is possible.


  info = 7  xtol is too small. No further improvement in the approximate solution x is possible.


  info = 8 gtol is too small. fvec is orthogonal to the columns of the Jacobian to machine precision.

nfev is an integer output variable set to the number of calls to fcn with iflag = 1.

njev is an integer output variable set to the number of calls to fcn with iflag = 2.

ipvt is an integer output array of length n. ipvt defines a permutation matrix p such that jac*p = q*r, where jac is the final calculated Jacobian, q is orthogonal (not stored), and r is upper triangular with diagonal elements of nonincreasing magnitude. Column j of p is column ipvt(j) of the identity matrix.

qtf is an output array of length n which contains the first n elements of the vector (q transpose)*fvec.

wa1, wa2, and wa3 are work arrays of length n.

wa4 is a work array of length m.
 

SEE ALSO

lmdif(3), lmdif1(3), lmder(3), lmder1(3).
 

AUTHORS

Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. This manual page was written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


 

Index

NAME
SYNOPSIS
DESCRIPTION
Language notes
User-supplied Function
Parameters for both lmstr_ and lmstr1_
Parameters for lmstr1_
Parameters for lmstr_
SEE ALSO
AUTHORS

This document was created by man2html, using the manual pages.
Time: 10:19:50 GMT, April 20, 2007 cminpack-1.3.4/doc/man.html000644 000765 000765 00000002062 12225167750 015471 0ustar00devernay000000 000000 MINPACK Manual

MINPACK

Function Index

  • hybrd_, hybrd1_ - find a zero of a system of nonlinear function
  • hybrj_, hybrj1_ - find a zero of a system of nonlinear function
  • lmder_, lmder1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian
  • lmdif_, lmdif1_ - minimize the sum of squares of m nonlinear functions
  • lmstr_, lmstr1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage

AUTHORS

Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. These manual pages were written by Jim Van Zandt <jrv@debian.org>, for the Debian GNU/Linux system (but may be used by others).


This document was created by man2html. cminpack-1.3.4/doc/minpack-documentation.txt000644 000765 000765 00000507022 12225167750 021070 0ustar00devernay000000 000000 Page Documentation for MINPACK subroutine HYBRD1 Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of HYBRD1 is to find a zero of a system of N non- linear functions in N variables by a modification of the Powell hybrid method. This is done by using the more general nonlinear equation solver HYBRD. The user must provide a subroutine which calculates the functions. The Jacobian is then calculated by a forward-difference approximation. 2. Subroutine and type statements. SUBROUTINE HYBRD1(FCN,N,X,FVEC,TOL,INFO,WA,LWA) INTEGER N,INFO,LWA DOUBLE PRECISION TOL DOUBLE PRECISION X(N),FVEC(N),WA(LWA) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to HYBRD1 and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from HYBRD1. FCN is the name of the user-supplied subroutine which calculate the functions. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows 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 The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of HYBRD1. In this case set IFLAG to a negative integer. Page N is a positive integer input variable set to the number of functions and variables. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length N which contains the function evaluated at the output X. TOL is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between X and the solution is at most TOL. Section 4 contains more details about TOL. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Algorithm estimates that the relative error between X and the solution is at most TOL. INFO = 2 Number of calls to FCN has reached or exceeded 200*(N+1). INFO = 3 TOL is too small. No further improvement in the approximate solution X is possible. INFO = 4 Iteration is not making good progress. Sections 4 and 5 contain more details about INFO. WA is a work array of length LWA. LWA is a positive integer input variable not less than (N*(3*N+13))/2. 4. Successful completion. The accuracy of HYBRD1 is controlled by the convergence parame- ter TOL. This parameter is used in a test which makes a compar- ison between the approximation X and a solution XSOL. HYBRD1 terminates when the test is satisfied. If TOL is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then HYBRD1 only attempts to satisfy the test defined by the machine precision. Further progress is not usu- ally possible. Unless high precision solutions are required, the recommended value for TOL is the square root of the machine precision. The test assumes that the functions are reasonably well behaved Page If this condition is not satisfied, then HYBRD1 may incorrectly indicate convergence. The validity of the answer can be checked, for example, by rerunning HYBRD1 with a tighter toler- ance. Convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(X-XSOL) .LE. TOL*ENORM(XSOL). If this condition is satisfied with TOL = 10**(-K), then the larger components of X have K significant decimal digits and INFO is set to 1. There is a danger that the smaller compo- nents of X may have large relative errors, but the fast rate of convergence of HYBRD1 usually avoids this possibility. 5. Unsuccessful completion. Unsuccessful termination of HYBRD1 can be due to improper input parameters, arithmetic interrupts, an excessive number of func- tion evaluations, errors in the functions, or lack of good prog ress. Improper input parameters. INFO is set to 0 if N .LE. 0, or TOL .LT. 0.D0, or LWA .LT. (N*(3*N+13))/2. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by HYBRD1. In this case, it may be possible to remedy the situation by not evalu- ating the functions here, but instead setting the components of FVEC to numbers that exceed those in the initial FVEC, thereby indirectly reducing the step length. The step length can be more directly controlled by using instead HYBRD, which includes in its calling sequence the step-length- governing parameter FACTOR. Excessive number of function evaluations. If the number of calls to FCN reaches 200*(N+1), then this indicates that the routine is converging very slowly as measured by the progress of FVEC, and INFO is set to 2. This situation should be unu- sual because, as indicated below, lack of good progress is usually diagnosed earlier by HYBRD1, causing termination with INFO = 4. Errors in the functions. The choice of step length in the for- ward-difference approximation to the Jacobian assumes that th relative errors in the functions are of the order of the machine precision. If this is not the case, HYBRD1 may fail (usually with INFO = 4). The user should then use HYBRD instead, or one of the programs which require the analytic Jacobian (HYBRJ1 and HYBRJ). Page Lack of good progress. HYBRD1 searches for a zero of the system by minimizing the sum of the squares of the functions. In so doing, it can become trapped in a region where the minimum does not correspond to a zero of the system and, in this situ- ation, the iteration eventually fails to make good progress. In particular, this will happen if the system does not have a zero. If the system has a zero, rerunning HYBRD1 from a dif- ferent starting point may be helpful. 6. Characteristics of the algorithm. HYBRD1 is a modification of the Powell hybrid method. Two of its main characteristics involve the choice of the correction a a convex combination of the Newton and scaled gradient direc- tions, and the updating of the Jacobian by the rank-1 method of Broyden. The choice of the correction guarantees (under reason able conditions) global convergence for starting points far fro the solution and a fast rate of convergence. The Jacobian is approximated by forward differences at the starting point, but forward differences are not used again until the rank-1 method fails to produce satisfactory progress. Timing. The time required by HYBRD1 to solve a given problem depends on N, the behavior of the functions, the accuracy requested, and the starting point. The number of arithmetic operations needed by HYBRD1 is about 11.5*(N**2) to process each call to FCN. Unless FCN can be evaluated quickly, the timing of HYBRD1 will be strongly influenced by the time spent in FCN. Storage. HYBRD1 requires (3*N**2 + 17*N)/2 double precision storage locations, in addition to the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,FDJAC1,HYBRD, QFORM,QRFAC,R1MPYQ,R1UPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD 8. References. M. J. D. Powell, A Hybrid Method for Nonlinear Equations. Numerical Methods for Nonlinear Algebraic Equations, P. Rabinowitz, editor. Gordon and Breach, 1970. 9. Example. Page The problem is to determine the values of x(1), x(2), ..., x(9) which solve the system of tridiagonal equations (3-2*x(1))*x(1) -2*x(2) = -1 -x(i-1) + (3-2*x(i))*x(i) -2*x(i+1) = -1, i=2-8 -x(8) + (3-2*x(9))*x(9) = -1 C ********** C C DRIVER FOR HYBRD1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,INFO,LWA,NWRITE DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(9),FVEC(9),WA(180) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LWA = 180 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL HYBRD1(FCN,N,X,FVEC,TOL,INFO,WA,LWA) FNORM = ENORM(N,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRD1 EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,IFLAG) INTEGER N,IFLAG DOUBLE PRECISION X(N),FVEC(N) C Page C SUBROUTINE FCN FOR HYBRD1 EXAMPLE. C INTEGER K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/ C DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 Page Documentation for MINPACK subroutine HYBRD Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of HYBRD is to find a zero of a system of N non- linear functions in N variables by a modification of the Powell hybrid method. The user must provide a subroutine which calcu- lates the functions. The Jacobian is then calculated by a for- ward-difference approximation. 2. Subroutine and type statements. SUBROUTINE 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) INTEGER N,MAXFEV,ML,MU,MODE,NPRINT,INFO,NFEV,LDFJAC,LR DOUBLE PRECISION XTOL,EPSFCN,FACTOR DOUBLE PRECISION X(N),FVEC(N),DIAG(N),FJAC(LDFJAC,N),R(LR),QTF( * WA1(N),WA2(N),WA3(N),WA4(N) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to HYBRD and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from HYBRD. FCN is the name of the user-supplied subroutine which calculate the functions. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows 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 The value of IFLAG should not be changed by FCN unless the Page user wants to terminate execution of HYBRD. In this case set IFLAG to a negative integer. N is a positive integer input variable set to the number of functions and variables. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length N which contains the function evaluated at the output X. XTOL is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most XTOL. Therefore, XTOL measures the relative error desired in the approximate solution. Section 4 contains more details about XTOL. MAXFEV is a positive integer input variable. Termination occur when the number of calls to FCN is at least MAXFEV by the end of an iteration. ML 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 ML to at least N - 1. MU 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 N - 1. EPSFCN is an input variable used in determining a suitable step for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of EPSFCN. If EPSFCN is less than the machine preci- sion, it is assumed that the relative errors in the functions are of the order of the machine precision. DIAG is an array of length N. If MODE = 1 (see below), DIAG is internally set. If MODE = 2, DIAG must contain positive entries that serve as multiplicative scale factors for the variables. MODE is an integer input variable. If MODE = 1, the variables will be scaled internally. If MODE = 2, the scaling is speci- fied by the input DIAG. Other values of MODE are equivalent to MODE = 1. FACTOR is a positive input variable used in determining the ini- tial step bound. This bound is set to the product of FACTOR and the Euclidean norm of DIAG*X if nonzero, or else to FACTO itself. In most cases FACTOR should lie in the interval (.1,100.). 100. is a generally recommended value. Page NPRINT is an integer input variable that enables controlled printing of iterates if it is positive. In this case, FCN is called with IFLAG = 0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X and FVEC available for printing. If NPRINT is not positive, no special calls of FCN with IFLAG = 0 are made. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Relative error between two consecutive iterates is at most XTOL. INFO = 2 Number of calls to FCN has reached or exceeded MAXFEV. INFO = 3 XTOL is too small. No further improvement in the approximate solution X is possible. INFO = 4 Iteration is not making good progress, as measured by the improvement from the last five Jacobian eval- uations. INFO = 5 Iteration is not making good progress, as measured by the improvement from the last ten iterations. Sections 4 and 5 contain more details about INFO. NFEV is an integer output variable set to the number of calls t FCN. FJAC is an output N by N array which contains the orthogonal matrix Q produced by the QR factorization of the final approx- imate Jacobian. LDFJAC is a positive integer input variable not less than N which specifies the leading dimension of the array FJAC. R is an output array of length LR which contains the upper triangular matrix produced by the QR factorization of the final approximate Jacobian, stored rowwise. LR is a positive integer input variable not less than (N*(N+1))/2. QTF is an output array of length N which contains the vector (Q transpose)*FVEC. WA1, WA2, WA3, and WA4 are work arrays of length N. Page 4. Successful completion. The accuracy of HYBRD is controlled by the convergence parameter XTOL. This parameter is used in a test which makes a comparison between the approximation X and a solution XSOL. HYBRD termi- nates when the test is satisfied. If the convergence parameter is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then HYBRD only attempts to satisfy the test defined by the machine precision. Further progress is not usually possible. The test assumes that the functions are reasonably well behaved If this condition is not satisfied, then HYBRD may incorrectly indicate convergence. The validity of the answer can be checked, for example, by rerunning HYBRD with a tighter toler- ance. Convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z and D is the diagonal matrix whose entries are defined by the array DIAG, then this test attempts to guaran- tee that ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL). If this condition is satisfied with XTOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 1. There is a danger that the smaller compo- nents of D*X may have large relative errors, but the fast rat of convergence of HYBRD usually avoids this possibility. Unless high precision solutions are required, the recommended value for XTOL is the square root of the machine precision. 5. Unsuccessful completion. Unsuccessful termination of HYBRD can be due to improper input parameters, arithmetic interrupts, an excessive number of func- tion evaluations, or lack of good progress. Improper input parameters. INFO is set to 0 if N .LE. 0, or XTOL .LT. 0.D0, or MAXFEV .LE. 0, or ML .LT. 0, or MU .LT. 0, or FACTOR .LE. 0.D0, or LDFJAC .LT. N, or LR .LT. (N*(N+1))/2 Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by HYBRD. In this case, it may be possible to remedy the situation by rerunning HYBRD with a smaller value of FACTOR. Excessive number of function evaluations. A reasonable value for MAXFEV is 200*(N+1). If the number of calls to FCN reaches MAXFEV, then this indicates that the routine is con- verging very slowly as measured by the progress of FVEC, and Page INFO is set to 2. This situation should be unusual because, as indicated below, lack of good progress is usually diagnose earlier by HYBRD, causing termination with INFO = 4 or INFO = 5. Lack of good progress. HYBRD searches for a zero of the system by minimizing the sum of the squares of the functions. In so doing, it can become trapped in a region where the minimum does not correspond to a zero of the system and, in this situ- ation, the iteration eventually fails to make good progress. In particular, this will happen if the system does not have a zero. If the system has a zero, rerunning HYBRD from a dif- ferent starting point may be helpful. 6. Characteristics of the algorithm. HYBRD is a modification of the Powell hybrid method. Two of it main characteristics involve the choice of the correction as a convex combination of the Newton and scaled gradient directions and the updating of the Jacobian by the rank-1 method of Broy- den. The choice of the correction guarantees (under reasonable conditions) global convergence for starting points far from the solution and a fast rate of convergence. The Jacobian is approximated by forward differences at the starting point, but forward differences are not used again until the rank-1 method fails to produce satisfactory progress. Timing. The time required by HYBRD to solve a given problem depends on N, the behavior of the functions, the accuracy requested, and the starting point. The number of arithmetic operations needed by HYBRD is about 11.5*(N**2) to process each call to FCN. Unless FCN can be evaluated quickly, the timing of HYBRD will be strongly influenced by the time spent in FCN. Storage. HYBRD requires (3*N**2 + 17*N)/2 double precision storage locations, in addition to the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,FDJAC1, QFORM,QRFAC,R1MPYQ,R1UPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD 8. References. M. J. D. Powell, A Hybrid Method for Nonlinear Equations. Page Numerical Methods for Nonlinear Algebraic Equations, P. Rabinowitz, editor. Gordon and Breach, 1970. 9. Example. The problem is to determine the values of x(1), x(2), ..., x(9) which solve the system of tridiagonal equations (3-2*x(1))*x(1) -2*x(2) = -1 -x(i-1) + (3-2*x(i))*x(i) -2*x(i+1) = -1, i=2-8 -x(8) + (3-2*x(9))*x(9) = -1 C ********** C C DRIVER FOR HYBRD EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,MAXFEV,ML,MU,MODE,NPRINT,INFO,NFEV,LDFJAC,LR,NWRITE DOUBLE PRECISION XTOL,EPSFCN,FACTOR,FNORM DOUBLE PRECISION X(9),FVEC(9),DIAG(9),FJAC(9,9),R(45),QTF(9), * WA1(9),WA2(9),WA3(9),WA4(9) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LR = 45 C C SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C XTOL = DSQRT(DPMPAR(1)) C MAXFEV = 2000 ML = 1 MU = 1 EPSFCN = 0.D0 MODE = 2 DO 20 J = 1, 9 DIAG(J) = 1.D0 Page 20 CONTINUE FACTOR = 1.D2 NPRINT = 0 C CALL 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) WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRD EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,IFLAG) INTEGER N,IFLAG DOUBLE PRECISION X(N),FVEC(N) C C SUBROUTINE FCN FOR HYBRD EXAMPLE. C INTEGER K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 NUMBER OF FUNCTION EVALUATIONS 14 Page EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 Page Documentation for MINPACK subroutine HYBRJ1 Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of HYBRJ1 is to find a zero of a system of N non- linear functions in N variables by a modification of the Powell hybrid method. This is done by using the more general nonlinear equation solver HYBRJ. The user must provide a subroutine which calculates the functions and the Jacobian. 2. Subroutine and type statements. SUBROUTINE HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA) INTEGER N,LDFJAC,INFO,LWA DOUBLE PRECISION TOL DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N),WA(LWA) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to HYBRJ1 and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from HYBRJ1. FCN is the name of the user-supplied subroutine which calculate the functions and the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows. 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 The value of IFLAG should not be changed by FCN unless the Page user wants to terminate execution of HYBRJ1. In this case set IFLAG to a negative integer. N is a positive integer input variable set to the number of functions and variables. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length N which contains the function evaluated at the output X. FJAC is an output N by N array which contains the orthogonal matrix Q produced by the QR factorization of the final approx- imate Jacobian. Section 6 contains more details about the approximation to the Jacobian. LDFJAC is a positive integer input variable not less than N which specifies the leading dimension of the array FJAC. TOL is a nonnegative input variable. Termination occurs when the algorithm estimates that the relative error between X and the solution is at most TOL. Section 4 contains more details about TOL. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Algorithm estimates that the relative error between X and the solution is at most TOL. INFO = 2 Number of calls to FCN with IFLAG = 1 has reached 100*(N+1). INFO = 3 TOL is too small. No further improvement in the approximate solution X is possible. INFO = 4 Iteration is not making good progress. Sections 4 and 5 contain more details about INFO. WA is a work array of length LWA. LWA is a positive integer input variable not less than (N*(N+13))/2. 4. Successful completion. The accuracy of HYBRJ1 is controlled by the convergence Page parameter TOL. This parameter is used in a test which makes a comparison between the approximation X and a solution XSOL. HYBRJ1 terminates when the test is satisfied. If TOL is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then HYBRJ1 only attempts to satisfy the test defined by the machine precision. Further progress is not usu- ally possible. Unless high precision solutions are required, the recommended value for TOL is the square root of the machine precision. The test assumes that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then HYBRJ1 ma incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning HYBRJ1 with a tighter toler- ance. Convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(X-XSOL) .LE. TOL*ENORM(XSOL). If this condition is satisfied with TOL = 10**(-K), then the larger components of X have K significant decimal digits and INFO is set to 1. There is a danger that the smaller compo- nents of X may have large relative errors, but the fast rate of convergence of HYBRJ1 usually avoids this possibility. 5. Unsuccessful completion. Unsuccessful termination of HYBRJ1 can be due to improper input parameters, arithmetic interrupts, an excessive number of func- tion evaluations, or lack of good progress. Improper input parameters. INFO is set to 0 if N .LE. 0, or LDFJAC .LT. N, or TOL .LT. 0.D0, or LWA .LT. (N*(N+13))/2. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by HYBRJ1. In this case, it may be possible to remedy the situation by not evalu ating the functions here, but instead setting the components of FVEC to numbers that exceed those in the initial FVEC, thereby indirectly reducing the step length. The step length can be more directly controlled by using instead HYBRJ, which includes in its calling sequence the step-length- governing parameter FACTOR. Excessive number of function evaluations. If the number of calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi- cates that the routine is converging very slowly as measured Page by the progress of FVEC, and INFO is set to 2. This situation should be unusual because, as indicated below, lack of good progress is usually diagnosed earlier by HYBRJ1, causing ter- mination with INFO = 4. Lack of good progress. HYBRJ1 searches for a zero of the system by minimizing the sum of the squares of the functions. In so doing, it can become trapped in a region where the minimum does not correspond to a zero of the system and, in this situ- ation, the iteration eventually fails to make good progress. In particular, this will happen if the system does not have a zero. If the system has a zero, rerunning HYBRJ1 from a dif- ferent starting point may be helpful. 6. Characteristics of the algorithm. HYBRJ1 is a modification of the Powell hybrid method. Two of its main characteristics involve the choice of the correction a a convex combination of the Newton and scaled gradient direc- tions, and the updating of the Jacobian by the rank-1 method of Broyden. The choice of the correction guarantees (under reason able conditions) global convergence for starting points far fro the solution and a fast rate of convergence. The Jacobian is calculated at the starting point, but it is not recalculated until the rank-1 method fails to produce satisfactory progress. Timing. The time required by HYBRJ1 to solve a given problem depends on N, the behavior of the functions, the accuracy requested, and the starting point. The number of arithmetic operations needed by HYBRJ1 is about 11.5*(N**2) to process each evaluation of the functions (call to FCN with IFLAG = 1) and 1.3*(N**3) to process each evaluation of the Jacobian (call to FCN with IFLAG = 2). Unless FCN can be evaluated quickly, the timing of HYBRJ1 will be strongly influenced by the time spent in FCN. Storage. HYBRJ1 requires (3*N**2 + 17*N)/2 double precision storage locations, in addition to the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,HYBRJ, QFORM,QRFAC,R1MPYQ,R1UPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD 8. References. Page M. J. D. Powell, A Hybrid Method for Nonlinear Equations. Numerical Methods for Nonlinear Algebraic Equations, P. Rabinowitz, editor. Gordon and Breach, 1970. 9. Example. The problem is to determine the values of x(1), x(2), ..., x(9) which solve the system of tridiagonal equations (3-2*x(1))*x(1) -2*x(2) = -1 -x(i-1) + (3-2*x(i))*x(i) -2*x(i+1) = -1, i=2-8 -x(8) + (3-2*x(9))*x(9) = -1 C ********** C C DRIVER FOR HYBRJ1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,LDFJAC,INFO,LWA,NWRITE DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),WA(99) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LWA = 99 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA) FNORM = ENORM(N,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) Page C C LAST CARD OF DRIVER FOR HYBRJ1 EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR HYBRJ1 EXAMPLE. C INTEGER J,K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE GO TO 50 20 CONTINUE DO 40 K = 1, N DO 30 J = 1, N FJAC(K,J) = ZERO 30 CONTINUE FJAC(K,K) = THREE - FOUR*X(K) IF (K .NE. 1) FJAC(K,K-1) = -ONE IF (K .NE. N) FJAC(K,K+1) = -TWO 40 CONTINUE 50 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 Page Documentation for MINPACK subroutine HYBRJ Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of HYBRJ is to find a zero of a system of N non- linear functions in N variables by a modification of the Powell hybrid method. The user must provide a subroutine which calcu- lates the functions and the Jacobian. 2. Subroutine and type statements. SUBROUTINE HYBRJ(FCN,N,X,FVEC,FJAC,LDFJAC,XTOL,MAXFEV,DIAG, * MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,R,LR,QTF, * WA1,WA2,WA3,WA4) INTEGER N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,LR DOUBLE PRECISION XTOL,FACTOR DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N),DIAG(N),R(LR),QTF( * WA1(N),WA2(N),WA3(N),WA4(N) 3. Parameters. Parameters designated as input parameters must be specified on entry to HYBRJ and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from HYBRJ. FCN is the name of the user-supplied subroutine which calculate the functions and the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows. 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 Page The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of HYBRJ. In this case set IFLAG to a negative integer. N is a positive integer input variable set to the number of functions and variables. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length N which contains the function evaluated at the output X. FJAC is an output N by N array which contains the orthogonal matrix Q produced by the QR factorization of the final approx- imate Jacobian. Section 6 contains more details about the approximation to the Jacobian. LDFJAC is a positive integer input variable not less than N which specifies the leading dimension of the array FJAC. XTOL is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most XTOL. Therefore, XTOL measures the relative error desired in the approximate solution. Section 4 contains more details about XTOL. MAXFEV is a positive integer input variable. Termination occur when the number of calls to FCN with IFLAG = 1 has reached MAXFEV. DIAG is an array of length N. If MODE = 1 (see below), DIAG is internally set. If MODE = 2, DIAG must contain positive entries that serve as multiplicative scale factors for the variables. MODE is an integer input variable. If MODE = 1, the variables will be scaled internally. If MODE = 2, the scaling is speci- fied by the input DIAG. Other values of MODE are equivalent to MODE = 1. FACTOR is a positive input variable used in determining the ini- tial step bound. This bound is set to the product of FACTOR and the Euclidean norm of DIAG*X if nonzero, or else to FACTO itself. In most cases FACTOR should lie in the interval (.1,100.). 100. is a generally recommended value. NPRINT is an integer input variable that enables controlled printing of iterates if it is positive. In this case, FCN is called with IFLAG = 0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X and FVEC available for printing. FVEC and FJAC should not be altered. If NPRINT is not positive, no Page special calls of FCN with IFLAG = 0 are made. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Relative error between two consecutive iterates is at most XTOL. INFO = 2 Number of calls to FCN with IFLAG = 1 has reached MAXFEV. INFO = 3 XTOL is too small. No further improvement in the approximate solution X is possible. INFO = 4 Iteration is not making good progress, as measured by the improvement from the last five Jacobian eval- uations. INFO = 5 Iteration is not making good progress, as measured by the improvement from the last ten iterations. Sections 4 and 5 contain more details about INFO. NFEV is an integer output variable set to the number of calls t FCN with IFLAG = 1. NJEV is an integer output variable set to the number of calls t FCN with IFLAG = 2. R is an output array of length LR which contains the upper triangular matrix produced by the QR factorization of the final approximate Jacobian, stored rowwise. LR is a positive integer input variable not less than (N*(N+1))/2. QTF is an output array of length N which contains the vector (Q transpose)*FVEC. WA1, WA2, WA3, and WA4 are work arrays of length N. 4. Successful completion. The accuracy of HYBRJ is controlled by the convergence parameter XTOL. This parameter is used in a test which makes a comparison between the approximation X and a solution XSOL. HYBRJ termi- nates when the test is satisfied. If the convergence parameter is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then HYBRJ only attempts to satisfy the test defined by the machine precision. Further progress is not Page usually possible. The test assumes that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then HYBRJ may incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning HYBRJ with a tighter toler- ance. Convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z and D is the diagonal matrix whose entries are defined by the array DIAG, then this test attempts to guaran- tee that ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL). If this condition is satisfied with XTOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 1. There is a danger that the smaller compo- nents of D*X may have large relative errors, but the fast rat of convergence of HYBRJ usually avoids this possibility. Unless high precision solutions are required, the recommended value for XTOL is the square root of the machine precision. 5. Unsuccessful completion. Unsuccessful termination of HYBRJ can be due to improper input parameters, arithmetic interrupts, an excessive number of func- tion evaluations, or lack of good progress. Improper input parameters. INFO is set to 0 if N .LE. 0, or LDFJAC .LT. N, or XTOL .LT. 0.D0, or MAXFEV .LE. 0, or FACTOR .LE. 0.D0, or LR .LT. (N*(N+1))/2. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by HYBRJ. In this case, it may be possible to remedy the situation by rerunning HYBRJ with a smaller value of FACTOR. Excessive number of function evaluations. A reasonable value for MAXFEV is 100*(N+1). If the number of calls to FCN with IFLAG = 1 reaches MAXFEV, then this indicates that the routine is converging very slowly as measured by the progress of FVEC and INFO is set to 2. This situation should be unusual because, as indicated below, lack of good progress is usually diagnosed earlier by HYBRJ, causing termination with INFO = 4 or INFO = 5. Lack of good progress. HYBRJ searches for a zero of the system by minimizing the sum of the squares of the functions. In so Page doing, it can become trapped in a region where the minimum does not correspond to a zero of the system and, in this situ- ation, the iteration eventually fails to make good progress. In particular, this will happen if the system does not have a zero. If the system has a zero, rerunning HYBRJ from a dif- ferent starting point may be helpful. 6. Characteristics of the algorithm. HYBRJ is a modification of the Powell hybrid method. Two of it main characteristics involve the choice of the correction as a convex combination of the Newton and scaled gradient directions and the updating of the Jacobian by the rank-1 method of Broy- den. The choice of the correction guarantees (under reasonable conditions) global convergence for starting points far from the solution and a fast rate of convergence. The Jacobian is calcu lated at the starting point, but it is not recalculated until the rank-1 method fails to produce satisfactory progress. Timing. The time required by HYBRJ to solve a given problem depends on N, the behavior of the functions, the accuracy requested, and the starting point. The number of arithmetic operations needed by HYBRJ is about 11.5*(N**2) to process each evaluation of the functions (call to FCN with IFLAG = 1) and 1.3*(N**3) to process each evaluation of the Jacobian (call to FCN with IFLAG = 2). Unless FCN can be evaluated quickly, the timing of HYBRJ will be strongly influenced by the time spent in FCN. Storage. HYBRJ requires (3*N**2 + 17*N)/2 double precision storage locations, in addition to the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DOGLEG,DPMPAR,ENORM, QFORM,QRFAC,R1MPYQ,R1UPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD 8. References. M. J. D. Powell, A Hybrid Method for Nonlinear Equations. Numerical Methods for Nonlinear Algebraic Equations, P. Rabinowitz, editor. Gordon and Breach, 1970. 9. Example. Page The problem is to determine the values of x(1), x(2), ..., x(9) which solve the system of tridiagonal equations (3-2*x(1))*x(1) -2*x(2) = -1 -x(i-1) + (3-2*x(i))*x(i) -2*x(i+1) = -1, i=2-8 -x(8) + (3-2*x(9))*x(9) = -1 C ********** C C DRIVER FOR HYBRJ EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,LR,NWRITE DOUBLE PRECISION XTOL,FACTOR,FNORM DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),DIAG(9),R(45),QTF(9), * WA1(9),WA2(9),WA3(9),WA4(9) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C N = 9 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION. C DO 10 J = 1, 9 X(J) = -1.D0 10 CONTINUE C LDFJAC = 9 LR = 45 C C SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C XTOL = DSQRT(DPMPAR(1)) C MAXFEV = 1000 MODE = 2 DO 20 J = 1, 9 DIAG(J) = 1.D0 20 CONTINUE FACTOR = 1.D2 NPRINT = 0 C CALL 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) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) Page STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR HYBRJ EXAMPLE. C END SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR HYBRJ EXAMPLE. C INTEGER J,K DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .EQ. 2) GO TO 20 DO 10 K = 1, N TEMP = (THREE - TWO*X(K))*X(K) TEMP1 = ZERO IF (K .NE. 1) TEMP1 = X(K-1) TEMP2 = ZERO IF (K .NE. N) TEMP2 = X(K+1) FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE 10 CONTINUE GO TO 50 20 CONTINUE DO 40 K = 1, N DO 30 J = 1, N FJAC(K,J) = ZERO 30 CONTINUE FJAC(K,K) = THREE - FOUR*X(K) IF (K .NE. 1) FJAC(K,K-1) = -ONE IF (K .NE. N) FJAC(K,K+1) = -TWO 40 CONTINUE 50 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. Page FINAL L2 NORM OF THE RESIDUALS 0.1192636D-07 NUMBER OF FUNCTION EVALUATIONS 11 NUMBER OF JACOBIAN EVALUATIONS 1 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION -0.5706545D+00 -0.6816283D+00 -0.7017325D+00 -0.7042129D+00 -0.7013690D+00 -0.6918656D+00 -0.6657920D+00 -0.5960342D+00 -0.4164121D+00 Page Documentation for MINPACK subroutine LMDER1 Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMDER1 is to minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm. This is done by using the more general least-squares solver LMDER. The user must provide a subroutine which calculates the functions and the Jacobian. 2. Subroutine and type statements. SUBROUTINE LMDER1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) INTEGER M,N,LDFJAC,INFO,LWA INTEGER IPVT(N) DOUBLE PRECISION TOL DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),WA(LWA) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to LMDER1 and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMDER1. FCN is the name of the user-supplied subroutine which calculate the functions and the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows. SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,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 Page The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMDER1. In this case set IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. FJAC is an output M by N array. The upper N by N submatrix of FJAC contains an upper triangular matrix R with diagonal ele- ments of nonincreasing magnitude such that T T T P *(JAC *JAC)*P = R *R, where P is a permutation matrix and JAC is the final calcu- lated Jacobian. Column j of P is column IPVT(j) (see below) of the identity matrix. The lower trapezoidal part of FJAC contains information generated during the computation of R. LDFJAC is a positive integer input variable not less than M which specifies the leading dimension of the array FJAC. TOL is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most TOL or that the relative error between X and the solution is at most TOL. Section 4 contain more details about TOL. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Algorithm estimates that the relative error in the sum of squares is at most TOL. INFO = 2 Algorithm estimates that the relative error between X and the solution is at most TOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 FVEC is orthogonal to the columns of the Jacobian t machine precision. Page INFO = 5 Number of calls to FCN with IFLAG = 1 has reached 100*(N+1). INFO = 6 TOL is too small. No further reduction in the sum of squares is possible. INFO = 7 TOL is too small. No further improvement in the approximate solution X is possible. Sections 4 and 5 contain more details about INFO. IPVT is an integer output array of length N. IPVT defines a permutation matrix P such that JAC*P = Q*R, where JAC is the final calculated Jacobian, Q is orthogonal (not stored), and is upper triangular with diagonal elements of nonincreasing magnitude. Column j of P is column IPVT(j) of the identity matrix. WA is a work array of length LWA. LWA is a positive integer input variable not less than 5*N+M. 4. Successful completion. The accuracy of LMDER1 is controlled by the convergence parame- ter TOL. This parameter is used in tests which make three type of comparisons between the approximation X and a solution XSOL. LMDER1 terminates when any of the tests is satisfied. If TOL i less than the machine precision (as defined by the MINPACK func- tion DPMPAR(1)), then LMDER1 only attempts to satisfy the test defined by the machine precision. Further progress is not usu- ally possible. Unless high precision solutions are required, the recommended value for TOL is the square root of the machine precision. The tests assume that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then LMDER1 ma incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning LMDER1 with a tighter toler- ance. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with TOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an INFO is set to 1 (or to 3 if the second test is also Page satisfied). Second convergence test. If D is a diagonal matrix (implicitly generated by LMDER1) whose entries contain scale factors for the variables, then this test attempts to guarantee that ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL). If this condition is satisfied with TOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but the choice of D is such that the accuracy of the components of X is usually related t their sensitivity. Third convergence test. This test is satisfied when FVEC is orthogonal to the columns of the Jacobian to machine preci- sion. There is no clear relationship between this test and the accuracy of LMDER1, and furthermore, the test is equally well satisfied at other critical points, namely maximizers an saddle points. Therefore, termination caused by this test (INFO = 4) should be examined carefully. 5. Unsuccessful completion. Unsuccessful termination of LMDER1 can be due to improper input parameters, arithmetic interrupts, or an excessive number of function evaluations. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or LDFJAC .LT. M, or TOL .LT. 0.D0, or LWA .LT. 5*N+M. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMDER1. In this case, it may be possible to remedy the situation by not evalu- ating the functions here, but instead setting the components of FVEC to numbers that exceed those in the initial FVEC, thereby indirectly reducing the step length. The step length can be more directly controlled by using instead LMDER, which includes in its calling sequence the step-length- governing parameter FACTOR. Excessive number of function evaluations. If the number of calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi- cates that the routine is converging very slowly as measured by the progress of FVEC, and INFO is set to 5. In this case, it may be helpful to restart LMDER1, thereby forcing it to disregard old (and possibly harmful) information. Page 6. Characteristics of the algorithm. LMDER1 is a modification of the Levenberg-Marquardt algorithm. Two of its main characteristics involve the proper use of implicitly scaled variables and an optimal choice for the cor- rection. The use of implicitly scaled variables achieves scale invariance of LMDER1 and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from th solution and a fast rate of convergence for problems with small residuals. Timing. The time required by LMDER1 to solve a given problem depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMDER1 is about N**3 to process each evaluation of the functions (call to FCN with IFLAG = 1) and M*(N**2) to process each evaluation of the Jacobian (call to FCN with IFLAG = 2). Unless FCN can be evaluated quickly, the timing of LMDER1 will be strongly influenced by the time spent in FCN. Storage. LMDER1 requires M*N + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,LMDER,LMPAR,QRFAC,QRSOLV FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data Page y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMDER1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE INTEGER IPVT(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),WA(30) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 LWA = 30 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMDER1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDER1 EXAMPLE. C Page END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR LMDER1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine LMDER Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMDER is to minimize the sum of the squares of M nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a subrou- tine which calculates the functions and the Jacobian. 2. Subroutine and type statements. SUBROUTINE LMDER(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) INTEGER M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV INTEGER IPVT(N) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),DIAG(N),QTF(N), * WA1(N),WA2(N),WA3(N),WA4(M) 3. Parameters. Parameters designated as input parameters must be specified on entry to LMDER and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMDER. FCN is the name of the user-supplied subroutine which calculate the functions and the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows. SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,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 Page The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMDER. In this case set IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. FJAC is an output M by N array. The upper N by N submatrix of FJAC contains an upper triangular matrix R with diagonal ele- ments of nonincreasing magnitude such that T T T P *(JAC *JAC)*P = R *R, where P is a permutation matrix and JAC is the final calcu- lated Jacobian. Column j of P is column IPVT(j) (see below) of the identity matrix. The lower trapezoidal part of FJAC contains information generated during the computation of R. LDFJAC is a positive integer input variable not less than M which specifies the leading dimension of the array FJAC. FTOL is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most FTOL. Therefore, FTOL measures the relative error desired in the sum of squares. Section 4 con- tains more details about FTOL. XTOL is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most XTOL. Therefore, XTOL measures the relative error desired in the approximate solution. Section 4 contains more details about XTOL. GTOL is a nonnegative input variable. Termination occurs when the cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. Therefore, GTOL measures the orthogonality desired between the function vector and the columns of the Jacobian. Section 4 contains more details about GTOL. MAXFEV is a positive integer input variable. Termination occur when the number of calls to FCN with IFLAG = 1 has reached MAXFEV. Page DIAG is an array of length N. If MODE = 1 (see below), DIAG is internally set. If MODE = 2, DIAG must contain positive entries that serve as multiplicative scale factors for the variables. MODE is an integer input variable. If MODE = 1, the variables will be scaled internally. If MODE = 2, the scaling is speci- fied by the input DIAG. Other values of MODE are equivalent to MODE = 1. FACTOR is a positive input variable used in determining the ini- tial step bound. This bound is set to the product of FACTOR and the Euclidean norm of DIAG*X if nonzero, or else to FACTO itself. In most cases FACTOR should lie in the interval (.1,100.). 100. is a generally recommended value. NPRINT is an integer input variable that enables controlled printing of iterates if it is positive. In this case, FCN is called with IFLAG = 0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X, FVEC, and FJAC available for printing. FVEC and FJAC should not be altered. If NPRINT is not posi- tive, no special calls of FCN with IFLAG = 0 are made. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Both actual and predicted relative reductions in th sum of squares are at most FTOL. INFO = 2 Relative error between two consecutive iterates is at most XTOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 The cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. INFO = 5 Number of calls to FCN with IFLAG = 1 has reached MAXFEV. INFO = 6 FTOL is too small. No further reduction in the sum of squares is possible. INFO = 7 XTOL is too small. No further improvement in the approximate solution X is possible. INFO = 8 GTOL is too small. FVEC is orthogonal to the columns of the Jacobian to machine precision. Sections 4 and 5 contain more details about INFO. Page NFEV is an integer output variable set to the number of calls t FCN with IFLAG = 1. NJEV is an integer output variable set to the number of calls t FCN with IFLAG = 2. IPVT is an integer output array of length N. IPVT defines a permutation matrix P such that JAC*P = Q*R, where JAC is the final calculated Jacobian, Q is orthogonal (not stored), and is upper triangular with diagonal elements of nonincreasing magnitude. Column j of P is column IPVT(j) of the identity matrix. QTF is an output array of length N which contains the first N elements of the vector (Q transpose)*FVEC. WA1, WA2, and WA3 are work arrays of length N. WA4 is a work array of length M. 4. Successful completion. The accuracy of LMDER is controlled by the convergence parame- ters FTOL, XTOL, and GTOL. These parameters are used in tests which make three types of comparisons between the approximation X and a solution XSOL. LMDER terminates when any of the tests is satisfied. If any of the convergence parameters is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then LMDER only attempts to satisfy the test define by the machine precision. Further progress is not usually pos- sible. The tests assume that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then LMDER may incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning LMDER with tighter toler- ances. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with FTOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an INFO is set to 1 (or to 3 if the second test is also satis- fied). Unless high precision solutions are required, the recommended value for FTOL is the square root of the machine precision. Page Second convergence test. If D is the diagonal matrix whose entries are defined by the array DIAG, then this test attempt to guarantee that ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL). If this condition is satisfied with XTOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but if MODE = 1, then the accuracy of the components of X is usually related to their sensitivity. Unless high precision solutions are required, the recommended value for XTOL is the square root of the machine precision. Third convergence test. This test is satisfied when the cosine of the angle between FVEC and any column of the Jacobian at X is at most GTOL in absolute value. There is no clear rela- tionship between this test and the accuracy of LMDER, and furthermore, the test is equally well satisfied at other crit- ical points, namely maximizers and saddle points. Therefore, termination caused by this test (INFO = 4) should be examined carefully. The recommended value for GTOL is zero. 5. Unsuccessful completion. Unsuccessful termination of LMDER can be due to improper input parameters, arithmetic interrupts, or an excessive number of function evaluations. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or LDFJAC .LT. M, or FTOL .LT. 0.D0, or XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or FACTOR .LE. 0.D0. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMDER. In this case, it may be possible to remedy the situation by rerunning LMDER with a smaller value of FACTOR. Excessive number of function evaluations. A reasonable value for MAXFEV is 100*(N+1). If the number of calls to FCN with IFLAG = 1 reaches MAXFEV, then this indicates that the routine is converging very slowly as measured by the progress of FVEC and INFO is set to 5. In this case, it may be helpful to restart LMDER with MODE set to 1. 6. Characteristics of the algorithm. LMDER is a modification of the Levenberg-Marquardt algorithm. Page Two of its main characteristics involve the proper use of implicitly scaled variables (if MODE = 1) and an optimal choice for the correction. The use of implicitly scaled variables achieves scale invariance of LMDER and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from the solution and a fast rate of convergence for prob- lems with small residuals. Timing. The time required by LMDER to solve a given problem depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMDER is about N**3 to process each evaluation of the functions (call to FCN with IFLAG = 1) and M*(N**2) to process each evaluation of the Jacobian (call to FCN with IFLAG = 2). Unless FCN can be evaluated quickly, th timing of LMDER will be strongly influenced by the time spent in FCN. Storage. LMDER requires M*N + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,LMPAR,QRFAC,QRSOLV FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), Page where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMDER EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),DIAG(3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 400 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMDER(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // Page * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDER EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR LMDER EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Page Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 6 NUMBER OF JACOBIAN EVALUATIONS 5 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine LMSTR1 Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMSTR1 is to minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm which uses minimal storage. This is done by using the more general least-squares solver LMSTR. The user must provide a subroutine which calculates the func- tions and the rows of the Jacobian. 2. Subroutine and type statements. SUBROUTINE LMSTR1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) INTEGER M,N,LDFJAC,INFO,LWA INTEGER IPVT(N) DOUBLE PRECISION TOL DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),WA(LWA) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to LMSTR1 and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMSTR1. FCN is the name of the user-supplied subroutine which calculate the functions and the rows of the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program and should be written as follows. 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. IF IFLAG = I CALCULATE THE (I-1)-ST ROW OF THE JACOBIAN AT X AND RETURN THIS VECTOR IN FJROW. ---------- RETURN Page END The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMSTR1. In this case set IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. FJAC is an output N by N array. The upper triangle of FJAC con tains an upper triangular matrix R such that T T T P *(JAC *JAC)*P = R *R, where P is a permutation matrix and JAC is the final calcu- lated Jacobian. Column j of P is column IPVT(j) (see below) of the identity matrix. The lower triangular part of FJAC contains information generated during the computation of R. LDFJAC is a positive integer input variable not less than N which specifies the leading dimension of the array FJAC. TOL is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most TOL or that the relative error between X and the solution is at most TOL. Section 4 contain more details about TOL. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Algorithm estimates that the relative error in the sum of squares is at most TOL. INFO = 2 Algorithm estimates that the relative error between X and the solution is at most TOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 FVEC is orthogonal to the columns of the Jacobian t Page machine precision. INFO = 5 Number of calls to FCN with IFLAG = 1 has reached 100*(N+1). INFO = 6 TOL is too small. No further reduction in the sum of squares is possible. INFO = 7 TOL is too small. No further improvement in the approximate solution X is possible. Sections 4 and 5 contain more details about INFO. IPVT is an integer output array of length N. IPVT defines a permutation matrix P such that JAC*P = Q*R, where JAC is the final calculated Jacobian, Q is orthogonal (not stored), and is upper triangular. Column j of P is column IPVT(j) of the identity matrix. WA is a work array of length LWA. LWA is a positive integer input variable not less than 5*N+M. 4. Successful completion. The accuracy of LMSTR1 is controlled by the convergence parame- ter TOL. This parameter is used in tests which make three type of comparisons between the approximation X and a solution XSOL. LMSTR1 terminates when any of the tests is satisfied. If TOL i less than the machine precision (as defined by the MINPACK func- tion DPMPAR(1)), then LMSTR1 only attempts to satisfy the test defined by the machine precision. Further progress is not usu- ally possible. Unless high precision solutions are required, the recommended value for TOL is the square root of the machine precision. The tests assume that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then LMSTR1 ma incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning LMSTR1 with a tighter toler- ance. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with TOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an Page INFO is set to 1 (or to 3 if the second test is also satis- fied). Second convergence test. If D is a diagonal matrix (implicitly generated by LMSTR1) whose entries contain scale factors for the variables, then this test attempts to guarantee that ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL). If this condition is satisfied with TOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but the choice of D is such that the accuracy of the components of X is usually related t their sensitivity. Third convergence test. This test is satisfied when FVEC is orthogonal to the columns of the Jacobian to machine preci- sion. There is no clear relationship between this test and the accuracy of LMSTR1, and furthermore, the test is equally well satisfied at other critical points, namely maximizers an saddle points. Therefore, termination caused by this test (INFO = 4) should be examined carefully. 5. Unsuccessful completion. Unsuccessful termination of LMSTR1 can be due to improper input parameters, arithmetic interrupts, or an excessive number of function evaluations. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or LDFJAC .LT. N, or TOL .LT. 0.D0, or LWA .LT. 5*N+M. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMSTR1. In this case, it may be possible to remedy the situation by not evalu- ating the functions here, but instead setting the components of FVEC to numbers that exceed those in the initial FVEC, thereby indirectly reducing the step length. The step length can be more directly controlled by using instead LMSTR, which includes in its calling sequence the step-length- governing parameter FACTOR. Excessive number of function evaluations. If the number of calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi- cates that the routine is converging very slowly as measured by the progress of FVEC, and INFO is set to 5. In this case, it may be helpful to restart LMSTR1, thereby forcing it to disregard old (and possibly harmful) information. Page 6. Characteristics of the algorithm. LMSTR1 is a modification of the Levenberg-Marquardt algorithm. Two of its main characteristics involve the proper use of implicitly scaled variables and an optimal choice for the cor- rection. The use of implicitly scaled variables achieves scale invariance of LMSTR1 and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from th solution and a fast rate of convergence for problems with small residuals. Timing. The time required by LMSTR1 to solve a given problem depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMSTR1 is about N**3 to process each evaluation of the functions (call to FCN with IFLAG = 1) and 1.5*(N**2) to process each row of the Jacobian (call to FCN with IFLAG .GE. 2). Unless FCN can be evaluated quickly, the timing of LMSTR1 will be strongly influenced by the time spent in FCN. Storage. LMSTR1 requires N**2 + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,LMSTR,LMPAR,QRFAC,QRSOLV, RWUPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 Page to the data y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMSTR1 EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE INTEGER IPVT(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),WA(30) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 3 LWA = 30 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMSTR1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL, * INFO,IPVT,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C Page C LAST CARD OF DRIVER FOR LMSTR1 EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJROW(N) C C SUBROUTINE FCN FOR LMSTR1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .GE. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE I = IFLAG - 1 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJROW(1) = -1.D0 FJROW(2) = TMP1*TMP2/TMP4 FJROW(3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine LMSTR Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMSTR is to minimize the sum of the squares of M nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm which uses minimal storage. The user must provide a subroutine which calculates the functions and the rows of the Jacobian. 2. Subroutine and type statements. SUBROUTINE LMSTR(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) INTEGER M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV INTEGER IPVT(N) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),DIAG(N),QTF(N), * WA1(N),WA2(N),WA3(N),WA4(M) 3. Parameters. Parameters designated as input parameters must be specified on entry to LMSTR and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMSTR. FCN is the name of the user-supplied subroutine which calculate the functions and the rows of the Jacobian. FCN must be declared in an EXTERNAL statement in the user calling program and should be written as follows. 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. IF IFLAG = I CALCULATE THE (I-1)-ST ROW OF THE JACOBIAN AT X AND RETURN THIS VECTOR IN FJROW. ---------- RETURN Page END The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMSTR. In this case set IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. FJAC is an output N by N array. The upper triangle of FJAC con tains an upper triangular matrix R such that T T T P *(JAC *JAC)*P = R *R, where P is a permutation matrix and JAC is the final calcu- lated Jacobian. Column j of P is column IPVT(j) (see below) of the identity matrix. The lower triangular part of FJAC contains information generated during the computation of R. LDFJAC is a positive integer input variable not less than N which specifies the leading dimension of the array FJAC. FTOL is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most FTOL. Therefore, FTOL measures the relative error desired in the sum of squares. Section 4 con- tains more details about FTOL. XTOL is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most XTOL. Therefore, XTOL measures the relative error desired in the approximate solution. Section 4 contains more details about XTOL. GTOL is a nonnegative input variable. Termination occurs when the cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. Therefore, GTOL measures the orthogonality desired between the function vector and the columns of the Jacobian. Section 4 contains more details about GTOL. MAXFEV is a positive integer input variable. Termination occur when the number of calls to FCN with IFLAG = 1 has reached Page MAXFEV. DIAG is an array of length N. If MODE = 1 (see below), DIAG is internally set. If MODE = 2, DIAG must contain positive entries that serve as multiplicative scale factors for the variables. MODE is an integer input variable. If MODE = 1, the variables will be scaled internally. If MODE = 2, the scaling is speci- fied by the input DIAG. Other values of MODE are equivalent to MODE = 1. FACTOR is a positive input variable used in determining the ini- tial step bound. This bound is set to the product of FACTOR and the Euclidean norm of DIAG*X if nonzero, or else to FACTO itself. In most cases FACTOR should lie in the interval (.1,100.). 100. is a generally recommended value. NPRINT is an integer input variable that enables controlled printing of iterates if it is positive. In this case, FCN is called with IFLAG = 0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X and FVEC available for printing. If NPRINT is not positive, no special calls of FCN with IFLAG = 0 are made. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Both actual and predicted relative reductions in th sum of squares are at most FTOL. INFO = 2 Relative error between two consecutive iterates is at most XTOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 The cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. INFO = 5 Number of calls to FCN with IFLAG = 1 has reached MAXFEV. INFO = 6 FTOL is too small. No further reduction in the sum of squares is possible. INFO = 7 XTOL is too small. No further improvement in the approximate solution X is possible. INFO = 8 GTOL is too small. FVEC is orthogonal to the columns of the Jacobian to machine precision. Page Sections 4 and 5 contain more details about INFO. NFEV is an integer output variable set to the number of calls t FCN with IFLAG = 1. NJEV is an integer output variable set to the number of calls t FCN with IFLAG = 2. IPVT is an integer output array of length N. IPVT defines a permutation matrix P such that JAC*P = Q*R, where JAC is the final calculated Jacobian, Q is orthogonal (not stored), and is upper triangular. Column j of P is column IPVT(j) of the identity matrix. QTF is an output array of length N which contains the first N elements of the vector (Q transpose)*FVEC. WA1, WA2, and WA3 are work arrays of length N. WA4 is a work array of length M. 4. Successful completion. The accuracy of LMSTR is controlled by the convergence parame- ters FTOL, XTOL, and GTOL. These parameters are used in tests which make three types of comparisons between the approximation X and a solution XSOL. LMSTR terminates when any of the tests is satisfied. If any of the convergence parameters is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then LMSTR only attempts to satisfy the test define by the machine precision. Further progress is not usually pos- sible. The tests assume that the functions and the Jacobian are coded consistently, and that the functions are reasonably well behaved. If these conditions are not satisfied, then LMSTR may incorrectly indicate convergence. The coding of the Jacobian can be checked by the MINPACK subroutine CHKDER. If the Jaco- bian is coded correctly, then the validity of the answer can be checked, for example, by rerunning LMSTR with tighter toler- ances. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with FTOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an INFO is set to 1 (or to 3 if the second test is also satis- fied). Unless high precision solutions are required, the recommended value for FTOL is the square root of the machine Page precision. Second convergence test. If D is the diagonal matrix whose entries are defined by the array DIAG, then this test attempt to guarantee that ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL). If this condition is satisfied with XTOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but if MODE = 1, then the accuracy of the components of X is usually related to their sensitivity. Unless high precision solutions are required, the recommended value for XTOL is the square root of the machine precision. Third convergence test. This test is satisfied when the cosine of the angle between FVEC and any column of the Jacobian at X is at most GTOL in absolute value. There is no clear rela- tionship between this test and the accuracy of LMSTR, and furthermore, the test is equally well satisfied at other crit- ical points, namely maximizers and saddle points. Therefore, termination caused by this test (INFO = 4) should be examined carefully. The recommended value for GTOL is zero. 5. Unsuccessful completion. Unsuccessful termination of LMSTR can be due to improper input parameters, arithmetic interrupts, or an excessive number of function evaluations. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or LDFJAC .LT. N, or FTOL .LT. 0.D0, or XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or FACTOR .LE. 0.D0. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMSTR. In this case, it may be possible to remedy the situation by rerunning LMSTR with a smaller value of FACTOR. Excessive number of function evaluations. A reasonable value for MAXFEV is 100*(N+1). If the number of calls to FCN with IFLAG = 1 reaches MAXFEV, then this indicates that the routine is converging very slowly as measured by the progress of FVEC and INFO is set to 5. In this case, it may be helpful to restart LMSTR with MODE set to 1. 6. Characteristics of the algorithm. Page LMSTR is a modification of the Levenberg-Marquardt algorithm. Two of its main characteristics involve the proper use of implicitly scaled variables (if MODE = 1) and an optimal choice for the correction. The use of implicitly scaled variables achieves scale invariance of LMSTR and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from the solution and a fast rate of convergence for prob- lems with small residuals. Timing. The time required by LMSTR to solve a given problem depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMSTR is about N**3 to process each evaluation of the functions (call to FCN with IFLAG = 1) and 1.5*(N**2) to process each row of the Jacobian (call to FCN with IFLAG .GE. 2). Unless FCN can be evaluated quickly, the timing of LMSTR will be strongly influenced by the time spent in FCN. Storage. LMSTR requires N**2 + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,LMPAR,QRFAC,QRSOLV,RWUPDT FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), Page where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMSTR EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),DIAG(3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 3 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 400 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMSTR(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL, * MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV, * IPVT,QTF,WA1,WA2,WA3,WA4) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // Page * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMSTR EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJROW(N) C C SUBROUTINE FCN FOR LMSTR EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE IF (IFLAG .GE. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE I = IFLAG - 1 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJROW(1) = -1.D0 FJROW(2) = TMP1*TMP2/TMP4 FJROW(3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Page Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 6 NUMBER OF JACOBIAN EVALUATIONS 5 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241058D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine LMDIF1 Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMDIF1 is to minimize the sum of the squares of nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm. This is done by using the more general least-squares solver LMDIF. The user must provide a subroutine which calculates the functions. The Jacobian is the calculated by a forward-difference approximation. 2. Subroutine and type statements. SUBROUTINE LMDIF1(FCN,M,N,X,FVEC,TOL,INFO,IWA,WA,LWA) INTEGER M,N,INFO,LWA INTEGER IWA(N) DOUBLE PRECISION TOL DOUBLE PRECISION X(N),FVEC(M),WA(LWA) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to LMDIF1 and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMDIF1. FCN is the name of the user-supplied subroutine which calculate the functions. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows 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 The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMDIF1. In this case set Page IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. TOL is a nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most TOL or that the relative error between X and the solution is at most TOL. Section 4 contain more details about TOL. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Algorithm estimates that the relative error in the sum of squares is at most TOL. INFO = 2 Algorithm estimates that the relative error between X and the solution is at most TOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 FVEC is orthogonal to the columns of the Jacobian t machine precision. INFO = 5 Number of calls to FCN has reached or exceeded 200*(N+1). INFO = 6 TOL is too small. No further reduction in the sum of squares is possible. INFO = 7 TOL is too small. No further improvement in the approximate solution X is possible. Sections 4 and 5 contain more details about INFO. IWA is an integer work array of length N. WA is a work array of length LWA. LWA is a positive integer input variable not less than Page M*N+5*N+M. 4. Successful completion. The accuracy of LMDIF1 is controlled by the convergence parame- ter TOL. This parameter is used in tests which make three type of comparisons between the approximation X and a solution XSOL. LMDIF1 terminates when any of the tests is satisfied. If TOL i less than the machine precision (as defined by the MINPACK func- tion DPMPAR(1)), then LMDIF1 only attempts to satisfy the test defined by the machine precision. Further progress is not usu- ally possible. Unless high precision solutions are required, the recommended value for TOL is the square root of the machine precision. The tests assume that the functions are reasonably well behaved If this condition is not satisfied, then LMDIF1 may incorrectly indicate convergence. The validity of the answer can be checked, for example, by rerunning LMDIF1 with a tighter toler- ance. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with TOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an INFO is set to 1 (or to 3 if the second test is also satis- fied). Second convergence test. If D is a diagonal matrix (implicitly generated by LMDIF1) whose entries contain scale factors for the variables, then this test attempts to guarantee that ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL). If this condition is satisfied with TOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but the choice of D is such that the accuracy of the components of X is usually related t their sensitivity. Third convergence test. This test is satisfied when FVEC is orthogonal to the columns of the Jacobian to machine preci- sion. There is no clear relationship between this test and the accuracy of LMDIF1, and furthermore, the test is equally well satisfied at other critical points, namely maximizers an saddle points. Also, errors in the functions (see below) may result in the test being satisfied at a point not close to th Page minimum. Therefore, termination caused by this test (INFO = 4) should be examined carefully. 5. Unsuccessful completion. Unsuccessful termination of LMDIF1 can be due to improper input parameters, arithmetic interrupts, an excessive number of func- tion evaluations, or errors in the functions. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or TOL .LT. 0.D0, or LWA .LT. M*N+5*N+M. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMDIF1. In this case, it may be possible to remedy the situation by not evalu- ating the functions here, but instead setting the components of FVEC to numbers that exceed those in the initial FVEC, thereby indirectly reducing the step length. The step length can be more directly controlled by using instead LMDIF, which includes in its calling sequence the step-length-governing parameter FACTOR. Excessive number of function evaluations. If the number of calls to FCN reaches 200*(N+1), then this indicates that the routine is converging very slowly as measured by the progress of FVEC, and INFO is set to 5. In this case, it may be help- ful to restart LMDIF1, thereby forcing it to disregard old (and possibly harmful) information. Errors in the functions. The choice of step length in the for- ward-difference approximation to the Jacobian assumes that th relative errors in the functions are of the order of the machine precision. If this is not the case, LMDIF1 may fail (usually with INFO = 4). The user should then use LMDIF instead, or one of the programs which require the analytic Jacobian (LMDER1 and LMDER). 6. Characteristics of the algorithm. LMDIF1 is a modification of the Levenberg-Marquardt algorithm. Two of its main characteristics involve the proper use of implicitly scaled variables and an optimal choice for the cor- rection. The use of implicitly scaled variables achieves scale invariance of LMDIF1 and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from th solution and a fast rate of convergence for problems with small residuals. Timing. The time required by LMDIF1 to solve a given problem Page depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMDIF1 is about N**3 to process each evaluation of the functions (one call to FCN) and M*(N**2) to process each approximation to the Jacobian (N calls to FCN). Unless FCN can be evaluated quickly, the tim- ing of LMDIF1 will be strongly influenced by the time spent i FCN. Storage. LMDIF1 requires M*N + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,FDJAC2,LMDIF,LMPAR, QRFAC,QRSOLV FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMDIF1 EXAMPLE. C DOUBLE PRECISION VERSION C Page C ********** INTEGER J,M,N,INFO,LWA,NWRITE INTEGER IWA(3) DOUBLE PRECISION TOL,FNORM DOUBLE PRECISION X(3),FVEC(15),WA(75) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LWA = 75 C C SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION. C UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED, C THIS IS THE RECOMMENDED SETTING. C TOL = DSQRT(DPMPAR(1)) C CALL LMDIF1(FCN,M,N,X,FVEC,TOL,INFO,IWA,WA,LWA) FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDIF1 EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M) C C SUBROUTINE FCN FOR LMDIF1 EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C Page DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION 0.8241057D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine LMDIF Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of LMDIF is to minimize the sum of the squares of M nonlinear functions in N variables by a modification of the Levenberg-Marquardt algorithm. The user must provide a subrou- tine which calculates the functions. The Jacobian is then cal- culated by a forward-difference approximation. 2. Subroutine and type statements. SUBROUTINE LMDIF(FCN,M,N,X,FVEC,FTOL,XTOL,GTOL,MAXFEV,EPSFCN, * DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC, * IPVT,QTF,WA1,WA2,WA3,WA4) INTEGER M,N,MAXFEV,MODE,NPRINT,INFO,NFEV,LDFJAC INTEGER IPVT(N) DOUBLE PRECISION FTOL,XTOL,GTOL,EPSFCN,FACTOR DOUBLE PRECISION X(N),FVEC(M),DIAG(N),FJAC(LDFJAC,N),QTF(N), * WA1(N),WA2(N),WA3(N),WA4(M) EXTERNAL FCN 3. Parameters. Parameters designated as input parameters must be specified on entry to LMDIF and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from LMDIF. FCN is the name of the user-supplied subroutine which calculate the functions. FCN must be declared in an EXTERNAL statement in the user calling program, and should be written as follows 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 Page The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMDIF. In this case set IFLAG to a negative integer. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. N must not exceed M. X is an array of length N. On input X must contain an initial estimate of the solution vector. On output X contains the final estimate of the solution vector. FVEC is an output array of length M which contains the function evaluated at the output X. FTOL is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most FTOL. Therefore, FTOL measures the relative error desired in the sum of squares. Section 4 con- tains more details about FTOL. XTOL is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most XTOL. Therefore, XTOL measures the relative error desired in the approximate solution. Section 4 contains more details about XTOL. GTOL is a nonnegative input variable. Termination occurs when the cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. Therefore, GTOL measures the orthogonality desired between the function vector and the columns of the Jacobian. Section 4 contains more details about GTOL. MAXFEV is a positive integer input variable. Termination occur when the number of calls to FCN is at least MAXFEV by the end of an iteration. EPSFCN is an input variable used in determining a suitable step for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of EPSFCN. If EPSFCN is less than the machine preci- sion, it is assumed that the relative errors in the functions are of the order of the machine precision. DIAG is an array of length N. If MODE = 1 (see below), DIAG is internally set. If MODE = 2, DIAG must contain positive entries that serve as multiplicative scale factors for the variables. MODE is an integer input variable. If MODE = 1, the variables will be scaled internally. If MODE = 2, the scaling is Page specified by the input DIAG. Other values of MODE are equiva- lent to MODE = 1. FACTOR is a positive input variable used in determining the ini- tial step bound. This bound is set to the product of FACTOR and the Euclidean norm of DIAG*X if nonzero, or else to FACTO itself. In most cases FACTOR should lie in the interval (.1,100.). 100. is a generally recommended value. NPRINT is an integer input variable that enables controlled printing of iterates if it is positive. In this case, FCN is called with IFLAG = 0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X and FVEC available for printing. If NPRINT is not positive, no special calls of FCN with IFLAG = 0 are made. INFO 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. INFO = 0 Improper input parameters. INFO = 1 Both actual and predicted relative reductions in th sum of squares are at most FTOL. INFO = 2 Relative error between two consecutive iterates is at most XTOL. INFO = 3 Conditions for INFO = 1 and INFO = 2 both hold. INFO = 4 The cosine of the angle between FVEC and any column of the Jacobian is at most GTOL in absolute value. INFO = 5 Number of calls to FCN has reached or exceeded MAXFEV. INFO = 6 FTOL is too small. No further reduction in the sum of squares is possible. INFO = 7 XTOL is too small. No further improvement in the approximate solution X is possible. INFO = 8 GTOL is too small. FVEC is orthogonal to the columns of the Jacobian to machine precision. Sections 4 and 5 contain more details about INFO. NFEV is an integer output variable set to the number of calls t FCN. FJAC is an output M by N array. The upper N by N submatrix of FJAC contains an upper triangular matrix R with diagonal ele- ments of nonincreasing magnitude such that Page T T T P *(JAC *JAC)*P = R *R, where P is a permutation matrix and JAC is the final calcu- lated Jacobian. Column j of P is column IPVT(j) (see below) of the identity matrix. The lower trapezoidal part of FJAC contains information generated during the computation of R. LDFJAC is a positive integer input variable not less than M which specifies the leading dimension of the array FJAC. IPVT is an integer output array of length N. IPVT defines a permutation matrix P such that JAC*P = Q*R, where JAC is the final calculated Jacobian, Q is orthogonal (not stored), and is upper triangular with diagonal elements of nonincreasing magnitude. Column j of P is column IPVT(j) of the identity matrix. QTF is an output array of length N which contains the first N elements of the vector (Q transpose)*FVEC. WA1, WA2, and WA3 are work arrays of length N. WA4 is a work array of length M. 4. Successful completion. The accuracy of LMDIF is controlled by the convergence parame- ters FTOL, XTOL, and GTOL. These parameters are used in tests which make three types of comparisons between the approximation X and a solution XSOL. LMDIF terminates when any of the tests is satisfied. If any of the convergence parameters is less than the machine precision (as defined by the MINPACK function DPMPAR(1)), then LMDIF only attempts to satisfy the test define by the machine precision. Further progress is not usually pos- sible. The tests assume that the functions are reasonably well behaved If this condition is not satisfied, then LMDIF may incorrectly indicate convergence. The validity of the answer can be checked, for example, by rerunning LMDIF with tighter toler- ances. First convergence test. If ENORM(Z) denotes the Euclidean norm of a vector Z, then this test attempts to guarantee that ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS), where FVECS denotes the functions evaluated at XSOL. If this condition is satisfied with FTOL = 10**(-K), then the final residual norm ENORM(FVEC) has K significant decimal digits an INFO is set to 1 (or to 3 if the second test is also satis- fied). Unless high precision solutions are required, the Page recommended value for FTOL is the square root of the machine precision. Second convergence test. If D is the diagonal matrix whose entries are defined by the array DIAG, then this test attempt to guarantee that ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL). If this condition is satisfied with XTOL = 10**(-K), then the larger components of D*X have K significant decimal digits an INFO is set to 2 (or to 3 if the first test is also satis- fied). There is a danger that the smaller components of D*X may have large relative errors, but if MODE = 1, then the accuracy of the components of X is usually related to their sensitivity. Unless high precision solutions are required, the recommended value for XTOL is the square root of the machine precision. Third convergence test. This test is satisfied when the cosine of the angle between FVEC and any column of the Jacobian at X is at most GTOL in absolute value. There is no clear rela- tionship between this test and the accuracy of LMDIF, and furthermore, the test is equally well satisfied at other crit- ical points, namely maximizers and saddle points. Therefore, termination caused by this test (INFO = 4) should be examined carefully. The recommended value for GTOL is zero. 5. Unsuccessful completion. Unsuccessful termination of LMDIF can be due to improper input parameters, arithmetic interrupts, or an excessive number of function evaluations. Improper input parameters. INFO is set to 0 if N .LE. 0, or M .LT. N, or LDFJAC .LT. M, or FTOL .LT. 0.D0, or XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or FACTOR .LE. 0.D0. Arithmetic interrupts. If these interrupts occur in the FCN subroutine during an early stage of the computation, they may be caused by an unacceptable choice of X by LMDIF. In this case, it may be possible to remedy the situation by rerunning LMDIF with a smaller value of FACTOR. Excessive number of function evaluations. A reasonable value for MAXFEV is 200*(N+1). If the number of calls to FCN reaches MAXFEV, then this indicates that the routine is con- verging very slowly as measured by the progress of FVEC, and INFO is set to 5. In this case, it may be helpful to restart LMDIF with MODE set to 1. Page 6. Characteristics of the algorithm. LMDIF is a modification of the Levenberg-Marquardt algorithm. Two of its main characteristics involve the proper use of implicitly scaled variables (if MODE = 1) and an optimal choice for the correction. The use of implicitly scaled variables achieves scale invariance of LMDIF and limits the size of the correction in any direction where the functions are changing rapidly. The optimal choice of the correction guarantees (under reasonable conditions) global convergence from starting points far from the solution and a fast rate of convergence for prob- lems with small residuals. Timing. The time required by LMDIF to solve a given problem depends on M and N, the behavior of the functions, the accu- racy requested, and the starting point. The number of arith- metic operations needed by LMDIF is about N**3 to process each evaluation of the functions (one call to FCN) and M*(N**2) to process each approximation to the Jacobian (N calls to FCN). Unless FCN can be evaluated quickly, the timing of LMDIF will be strongly influenced by the time spent in FCN. Storage. LMDIF requires M*N + 2*M + 6*N double precision sto- rage locations and N integer storage locations, in addition t the storage required by the program. There are no internally declared storage arrays. 7. Subprograms required. USER-supplied ...... FCN MINPACK-supplied ... DPMPAR,ENORM,FDJAC2,LMPAR,QRFAC,QRSOLV FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD 8. References. Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation and Theory. Numerical Analysis, G. A. Watson, editor. Lecture Notes in Mathematics 630, Springer-Verlag, 1977. 9. Example. The problem is to determine the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data Page y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). C ********** C C DRIVER FOR LMDIF EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER J,M,N,MAXFEV,MODE,NPRINT,INFO,NFEV,LDFJAC,NWRITE INTEGER IPVT(3) DOUBLE PRECISION FTOL,XTOL,GTOL,EPSFCN,FACTOR,FNORM DOUBLE PRECISION X(3),FVEC(15),DIAG(3),FJAC(15,3),QTF(3), * WA1(3),WA2(3),WA3(3),WA4(15) DOUBLE PRECISION ENORM,DPMPAR EXTERNAL FCN C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT. C X(1) = 1.D0 X(2) = 1.D0 X(3) = 1.D0 C LDFJAC = 15 C C SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION C AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE C REQUIRED, THESE ARE THE RECOMMENDED SETTINGS. C FTOL = DSQRT(DPMPAR(1)) XTOL = DSQRT(DPMPAR(1)) GTOL = 0.D0 C MAXFEV = 800 EPSFCN = 0.D0 MODE = 1 FACTOR = 1.D2 NPRINT = 0 C CALL LMDIF(FCN,M,N,X,FVEC,FTOL,XTOL,GTOL,MAXFEV,EPSFCN, * DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC, * IPVT,QTF,WA1,WA2,WA3,WA4) Page FNORM = ENORM(M,FVEC) WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N) STOP 1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 // * 5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 // * 5X,15H EXIT PARAMETER,16X,I10 // * 5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7) C C LAST CARD OF DRIVER FOR LMDIF EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,IFLAG) INTEGER M,N,IFLAG DOUBLE PRECISION X(N),FVEC(M) C C SUBROUTINE FCN FOR LMDIF EXAMPLE. C INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .NE. 0) GO TO 5 C C INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE. C RETURN 5 CONTINUE DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be slightly different. FINAL L2 NORM OF THE RESIDUALS 0.9063596D-01 NUMBER OF FUNCTION EVALUATIONS 21 EXIT PARAMETER 1 FINAL APPROXIMATE SOLUTION Page 0.8241057D-01 0.1133037D+01 0.2343695D+01 Page Documentation for MINPACK subroutine CHKDER Double precision version Argonne National Laboratory Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More March 1980 1. Purpose. The purpose of CHKDER is to check the gradients of M nonlinear functions in N variables, evaluated at a point X, for consis- tency with the functions themselves. The user must call CHKDER twice, first with MODE = 1 and then with MODE = 2. 2. Subroutine and type statements. SUBROUTINE CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR) INTEGER M,N,LDFJAC,MODE DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),XP(N),FVECP(M), * ERR(M) 3. Parameters. Parameters designated as input parameters must be specified on entry to CHKDER and are not changed on exit, while parameters designated as output parameters need not be specified on entry and are set to appropriate values on exit from CHKDER. M is a positive integer input variable set to the number of functions. N is a positive integer input variable set to the number of variables. X is an input array of length N. FVEC is an array of length M. On input when MODE = 2, FVEC must contain the functions evaluated at X. FJAC is an M by N array. On input when MODE = 2, the rows of FJAC must contain the gradients of the respective functions evaluated at X. LDFJAC is a positive integer input variable not less than M which specifies the leading dimension of the array FJAC. XP is an array of length N. On output when MODE = 1, XP is set to a neighboring point of X. Page FVECP is an array of length M. On input when MODE = 2, FVECP must contain the functions evaluated at XP. MODE is an integer input variable set to 1 on the first call an 2 on the second. Other values of MODE are equivalent to MODE = 1. ERR is an array of length M. On output when MODE = 2, ERR con- tains measures of correctness of the respective gradients. I there is no severe loss of significance, then if ERR(I) is 1. the I-th gradient is correct, while if ERR(I) is 0.0 the I-th gradient is incorrect. For values of ERR between 0.0 and 1.0 the categorization is less certain. In general, a value of ERR(I) greater than 0.5 indicates that the I-th gradient is probably correct, while a value of ERR(I) less than 0.5 indi- cates that the I-th gradient is probably incorrect. 4. Successful completion. CHKDER usually guarantees that if ERR(I) is 1.0, then the I-th gradient at X is consistent with the I-th function. This sug- gests that the input X be such that consistency of the gradient at X implies consistency of the gradient at all points of inter est. If all the components of X are distinct and the fractional part of each one has two nonzero digits, then X is likely to be a satisfactory choice. If ERR(I) is not 1.0 but is greater than 0.5, then the I-th gra- dient is probably consistent with the I-th function (the more s the larger ERR(I) is), but the conditions for ERR(I) to be 1.0 have not been completely satisfied. In this case, it is recom- mended that CHKDER be rerun with other input values of X. If ERR(I) is always greater than 0.5, then the I-th gradient is consistent with the I-th function. 5. Unsuccessful completion. CHKDER does not perform reliably if cancellation or rounding errors cause a severe loss of significance in the evaluation of a function. Therefore, none of the components of X should be unusually small (in particular, zero) or any other value which may cause loss of significance. The relative differences between corresponding elements of FVECP and FVEC should be at least two orders of magnitude greater than the machine precision (as defined by the MINPACK function DPMPAR(1)). If there is a severe loss of significance in the evaluation of the I-th func- tion, then ERR(I) may be 0.0 and yet the I-th gradient could be correct. If ERR(I) is not 0.0 but is less than 0.5, then the I-th gra- dient is probably not consistent with the I-th function (the more so the smaller ERR(I) is), but the conditions for ERR(I) t Page be 0.0 have not been completely satisfied. In this case, it is recommended that CHKDER be rerun with other input values of X. If ERR(I) is always less than 0.5 and if there is no severe loss of significance, then the I-th gradient is not consistent with the I-th function. 6. Characteristics of the algorithm. CHKDER checks the I-th gradient for consistency with the I-th function by computing a forward-difference approximation along suitably chosen direction and comparing this approximation with the user-supplied gradient along the same direction. The prin- cipal characteristic of CHKDER is its invariance to changes in scale of the variables or functions. Timing. The time required by CHKDER depends only on M and N. The number of arithmetic operations needed by CHKDER is about N when MODE = 1 and M*N when MODE = 2. Storage. CHKDER requires M*N + 3*M + 2*N double precision stor- age locations, in addition to the storage required by the pro gram. There are no internally declared storage arrays. 7. Subprograms required. MINPACK-supplied ... DPMPAR FORTRAN-supplied ... DABS,DLOG10,DSQRT 8. References. None. 9. Example. This example checks the Jacobian matrix for the problem that determines the values of x(1), x(2), and x(3) which provide the best fit (in the least squares sense) of x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)), i = 1, 15 to the data y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39, 0.37,0.58,0.73,0.96,1.34,2.10,4.39), where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)). The i-th component of FVEC is thus defined by y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))). Page C ********** C C DRIVER FOR CHKDER EXAMPLE. C DOUBLE PRECISION VERSION C C ********** INTEGER I,M,N,LDFJAC,MODE,NWRITE DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),XP(3),FVECP(15), * ERR(15) C C LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6. C DATA NWRITE /6/ C M = 15 N = 3 C C THE FOLLOWING VALUES SHOULD BE SUITABLE FOR C CHECKING THE JACOBIAN MATRIX. C X(1) = 9.2D-1 X(2) = 1.3D-1 X(3) = 5.4D-1 C LDFJAC = 15 C MODE = 1 CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR) MODE = 2 CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,1) CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,2) CALL FCN(M,N,XP,FVECP,FJAC,LDFJAC,1) CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR) C DO 10 I = 1, M FVECP(I) = FVECP(I) - FVEC(I) 10 CONTINUE WRITE (NWRITE,1000) (FVEC(I),I=1,M) WRITE (NWRITE,2000) (FVECP(I),I=1,M) WRITE (NWRITE,3000) (ERR(I),I=1,M) STOP 1000 FORMAT (/5X,5H FVEC // (5X,3D15.7)) 2000 FORMAT (/5X,13H FVECP - FVEC // (5X,3D15.7)) 3000 FORMAT (/5X,4H ERR // (5X,3D15.7)) C C LAST CARD OF DRIVER FOR CHKDER EXAMPLE. C END SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG) INTEGER M,N,LDFJAC,IFLAG DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N) C C SUBROUTINE FCN FOR CHKDER EXAMPLE. C Page INTEGER I DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4 DOUBLE PRECISION Y(15) DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8), * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15) * /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1, * 3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/ C IF (IFLAG .EQ. 2) GO TO 20 DO 10 I = 1, 15 TMP1 = I TMP2 = 16 - I TMP3 = TMP1 IF (I .GT. 8) TMP3 = TMP2 FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3)) 10 CONTINUE GO TO 40 20 CONTINUE DO 30 I = 1, 15 TMP1 = I TMP2 = 16 - I C C ERROR INTRODUCED INTO NEXT STATEMENT FOR ILLUSTRATION. C CORRECTED STATEMENT SHOULD READ TMP3 = TMP1 . C TMP3 = TMP2 IF (I .GT. 8) TMP3 = TMP2 TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2 FJAC(I,1) = -1.D0 FJAC(I,2) = TMP1*TMP2/TMP4 FJAC(I,3) = TMP1*TMP3/TMP4 30 CONTINUE 40 CONTINUE RETURN C C LAST CARD OF SUBROUTINE FCN. C END Results obtained with different compilers or machines may be different. In particular, the differences FVECP - FVEC are machine dependent. FVEC -0.1181606D+01 -0.1429655D+01 -0.1606344D+01 -0.1745269D+01 -0.1840654D+01 -0.1921586D+01 -0.1984141D+01 -0.2022537D+01 -0.2468977D+01 -0.2827562D+01 -0.3473582D+01 -0.4437612D+01 -0.6047662D+01 -0.9267761D+01 -0.1891806D+02 FVECP - FVEC -0.7724666D-08 -0.3432405D-08 -0.2034843D-09 Page 0.2313685D-08 0.4331078D-08 0.5984096D-08 0.7363281D-08 0.8531470D-08 0.1488591D-07 0.2335850D-07 0.3522012D-07 0.5301255D-07 0.8266660D-07 0.1419747D-06 0.3198990D-06 ERR 0.1141397D+00 0.9943516D-01 0.9674474D-01 0.9980447D-01 0.1073116D+00 0.1220445D+00 0.1526814D+00 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 0.1000000D+01 cminpack-1.3.4/cuda/chkder.cu000644 000765 000765 00000000150 12225167750 015764 0ustar00devernay000000 000000 #ifndef CHKDER_CU_INCLUDED #define CHKDER_CU_INCLUDED #include "dpmpar.cu" #include #endif cminpack-1.3.4/cuda/covar.cu000644 000765 000765 00000000120 12225167750 015633 0ustar00devernay000000 000000 #ifndef COVAR_CU_INCLUDED #define COVAR_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/covar1.cu000644 000765 000765 00000000123 12225167750 015717 0ustar00devernay000000 000000 #ifndef COVAR1_CU_INCLUDED #define COVAR1_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/dogleg.cu000644 000765 000765 00000000174 12225167750 015773 0ustar00devernay000000 000000 #ifndef DOGLEG_CU_INCLUDED #define DOGLEG_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include #endif cminpack-1.3.4/cuda/dpmpar.cu000644 000765 000765 00000000123 12225167750 016007 0ustar00devernay000000 000000 #ifndef DPMPAR_CU_INCLUDED #define DPMPAR_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/enorm.cu000644 000765 000765 00000000145 12225167750 015650 0ustar00devernay000000 000000 #ifndef ENORM_CU_INCLUDED #define ENORM_CU_INCLUDED #include "dpmpar.cu" #include #endif cminpack-1.3.4/cuda/examples/000755 000765 000765 00000000000 12225167750 016015 5ustar00devernay000000 000000 cminpack-1.3.4/cuda/fdjac1.cu000644 000765 000765 00000000150 12225167750 015654 0ustar00devernay000000 000000 #ifndef FDJAC1_CU_INCLUDED #define FDJAC1_CU_INCLUDED #include "dpmpar.cu" #include #endif cminpack-1.3.4/cuda/fdjac2.cu000644 000765 000765 00000000150 12225167750 015655 0ustar00devernay000000 000000 #ifndef FDJAC2_CU_INCLUDED #define FDJAC2_CU_INCLUDED #include "dpmpar.cu" #include #endif cminpack-1.3.4/cuda/hybrd.cu000644 000765 000765 00000000365 12225167750 015644 0ustar00devernay000000 000000 #ifndef HYBRD_CU_INCLUDED #define HYBRD_CU_INCLUDED #include "dogleg.cu" #include "dpmpar.cu" #include "enorm.cu" #include "fdjac1.cu" #include "qform.cu" #include "qrfac.cu" #include "r1mpyq.cu" #include "r1updt.cu" #include #endif cminpack-1.3.4/cuda/hybrd1.cu000644 000765 000765 00000000147 12225167750 015723 0ustar00devernay000000 000000 #ifndef HYBRD1_CU_INCLUDED #define HYBRD1_CU_INCLUDED #include "hybrd.cu" #include #endif cminpack-1.3.4/cuda/hybrj.cu000644 000765 000765 00000000340 12225167750 015643 0ustar00devernay000000 000000 #ifndef HYBRJ_CU_INCLUDED #define HYBRJ_CU_INCLUDED #include "dogleg.cu" #include "dpmpar.cu" #include "enorm.cu" #include "qform.cu" #include "qrfac.cu" #include "r1mpyq.cu" #include "r1updt.cu" #include #endif cminpack-1.3.4/cuda/hybrj1.cu000644 000765 000765 00000000147 12225167750 015731 0ustar00devernay000000 000000 #ifndef HYBRJ1_CU_INCLUDED #define HYBRJ1_CU_INCLUDED #include "hybrj.cu" #include #endif cminpack-1.3.4/cuda/lmder.cu000644 000765 000765 00000000241 12225167750 015630 0ustar00devernay000000 000000 #ifndef LMDER_CU_INCLUDED #define LMDER_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include "lmpar.cu" #include "qrfac.cu" #include #endif cminpack-1.3.4/cuda/lmder1.cu000644 000765 000765 00000000147 12225167750 015716 0ustar00devernay000000 000000 #ifndef LMDER1_CU_INCLUDED #define LMDER1_CU_INCLUDED #include "lmder.cu" #include #endif cminpack-1.3.4/cuda/lmdif.cu000644 000765 000765 00000000266 12225167750 015627 0ustar00devernay000000 000000 #ifndef LMDIF_CU_INCLUDED #define LMDIF_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include "fdjac2.cu" #include "lmpar.cu" #include "qrfac.cu" #include #endif cminpack-1.3.4/cuda/lmdif1.cu000644 000765 000765 00000000147 12225167750 015706 0ustar00devernay000000 000000 #ifndef LMDIF1_CU_INCLUDED #define LMDIF1_CU_INCLUDED #include "lmdif.cu" #include #endif cminpack-1.3.4/cuda/lmpar.cu000644 000765 000765 00000000216 12225167750 015642 0ustar00devernay000000 000000 #ifndef LMPAR_CU_INCLUDED #define LMPAR_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include "qrsolv.cu" #include #endif cminpack-1.3.4/cuda/lmstr.cu000644 000765 000765 00000000266 12225167750 015675 0ustar00devernay000000 000000 #ifndef LMSTR_CU_INCLUDED #define LMSTR_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include "lmpar.cu" #include "qrfac.cu" #include "rwupdt.cu" #include #endif cminpack-1.3.4/cuda/lmstr1.cu000644 000765 000765 00000000147 12225167750 015754 0ustar00devernay000000 000000 #ifndef LMSTR1_CU_INCLUDED #define LMSTR1_CU_INCLUDED #include "lmstr.cu" #include #endif cminpack-1.3.4/cuda/Makefile000644 000765 000765 00000000751 12225167750 015642 0ustar00devernay000000 000000 CC=nvcc CFLAGS= --compile -I.. SOURCES = $(wildcard *.cu) OBJECTS = $(SOURCES:.cu=.o) all: libcuminpack.a libcuminpack.a: $(OBJECTS) @echo " **************************** " @echo " making compiling and library for testing " @echo " (cuda needs __device__ source code compiled inline with kernel) " @echo " **************************** " ar r $@ $(OBJECTS); ranlib $@ %.o: %.cu @echo " compiling for testing " ${CC} ${CFLAGS} -o $@ $< clean: rm -f *.o libcuminpack.a *~ #*# cminpack-1.3.4/cuda/qform.cu000644 000765 000765 00000000120 12225167750 015645 0ustar00devernay000000 000000 #ifndef QFORM_CU_INCLUDED #define QFORM_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/qrfac.cu000644 000765 000765 00000000171 12225167750 015623 0ustar00devernay000000 000000 #ifndef QRFAC_CU_INCLUDED #define QRFAC_CU_INCLUDED #include "dpmpar.cu" #include "enorm.cu" #include #endif cminpack-1.3.4/cuda/qrsolv.cu000644 000765 000765 00000000123 12225167750 016052 0ustar00devernay000000 000000 #ifndef QRSOLV_CU_INCLUDED #define QRSOLV_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/r1mpyq.cu000644 000765 000765 00000000123 12225167750 015755 0ustar00devernay000000 000000 #ifndef R1MPYQ_CU_INCLUDED #define R1MPYQ_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/r1updt.cu000644 000765 000765 00000000150 12225167750 015743 0ustar00devernay000000 000000 #ifndef R1UPDT_CU_INCLUDED #define R1UPDT_CU_INCLUDED #include "dpmpar.cu" #include #endif cminpack-1.3.4/cuda/rwupdt.cu000644 000765 000765 00000000123 12225167750 016051 0ustar00devernay000000 000000 #ifndef RWUPDT_CU_INCLUDED #define RWUPDT_CU_INCLUDED #include #endif cminpack-1.3.4/cuda/examples/leeme.txt000755 000765 000765 00000001023 12225167750 017644 0ustar00devernay000000 000000 man nvcc --gpu-name __CUDACC__ and __CUDA_ARCH__. (http://forums.nvidia.com/index.php?showtopic=149501) http://developer.download.nvidia.com/compute/cuda/4_0/toolkit/docs/CUDA_C_Programming_Guide.pdf Function Pointers Function pointers to __global__ functions are supported in host code, but not in device code. Function pointers to __device__ functions are only supported in device code compiled for devices of compute capability 2.x. It is not allowed to take the address of a __device__ function in host code. cminpack-1.3.4/cuda/examples/Makefile000755 000765 000765 00000000415 12225167750 017460 0ustar00devernay000000 000000 SOURCES = $(wildcard t*.cu) TEST_PROGRAMS = $(SOURCES:.cu=) CC=nvcc CFLAGS= -I.. -I../.. all: @echo make cudatest, make clean @echo $(TEST_PROGRAMS) cudatest: clean $(TEST_PROGRAMS) %:%.cu $(CC) $(CFLAGS) -o $@ $< clean: rm -f *.o run.* $(TEST_PROGRAMS) cminpack-1.3.4/cuda/examples/tlmderc.cu000755 000765 000765 00000022543 12225167750 020011 0ustar00devernay000000 000000 /* -*- mode: c++ -*- */ /* ------------------------------ */ /* driver for lmder example. */ /* ------------------------------ */ #include #include #include #include #include #include #define real __cminpack_real__ #define cutilSafeCall(err) __cudaSafeCall (err, __FILE__, __LINE__) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { if( cudaSuccess != err) { fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n", file, line, cudaGetErrorString( err) ); exit(-1); } } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- const unsigned int NUM_OBSERVATIONS = 15; // m const unsigned int NUM_PARAMS = 3; // 3 = n //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // fixed arrangement of threads to be run // const unsigned int NUM_THREADS = 2048; const unsigned int NUM_THREADS_PER_BLOCK = 128; const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK; //-------------------------------------------------------------------------- // // the struct for returning results from the GPU // typedef struct { real fnorm; int nfev; int njev; int info; int rankJ; real solution[NUM_PARAMS]; real covar[NUM_PARAMS][NUM_PARAMS]; } ResultType; //-------------------------------------------------------------------------- // the cost function //-------------------------------------------------------------------------- __cminpack_attr__ /* __device__ */ int fcnder_mn( void *p, int m, int n, const real *x, real *fvec, real *fjac, int ldfjac, int iflag) { /* subroutine fcn for lmder example. */ int i; real tmp1, tmp2, tmp3, tmp4; real y[NUM_OBSERVATIONS]={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 0; } if (iflag != 2) { for (i = 1; i <= NUM_OBSERVATIONS; i++) { tmp1 = i; tmp2 = (NUM_OBSERVATIONS+1) - 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)); } // for } else { for (i=1; i<=NUM_OBSERVATIONS; i++) { tmp1 = i; tmp2 = (NUM_OBSERVATIONS+1) - 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; } // for } // if return 0; } //-------------------------------------------------------------------------- // the kernel in the GPU //-------------------------------------------------------------------------- __global__ void mainKernel(ResultType pResults[]) { int ldfjac, maxfev, mode, nprint, info, nfev, njev; int ipvt[NUM_PARAMS]; real ftol, xtol, gtol, factor, fnorm; real x[NUM_PARAMS], fvec[NUM_OBSERVATIONS], diag[NUM_PARAMS], fjac[NUM_OBSERVATIONS*NUM_PARAMS], qtf[NUM_PARAMS], wa1[NUM_PARAMS], wa2[NUM_PARAMS], wa3[NUM_PARAMS], wa4[NUM_OBSERVATIONS]; int k; // m = NUM_OBSERVATIONS; // n = NUM_PARAMS; /* the following starting values provide a rough fit. */ x[1-1] = 1.; x[2-1] = 1.; x[3-1] = 1.; ldfjac = NUM_OBSERVATIONS; /* 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(__cminpack_func__(dpmpar)(1)); xtol = sqrt(__cminpack_func__(dpmpar)(1)); gtol = 0.; maxfev = 400; mode = 1; factor = 1.e2; nprint = 0; // ------------------------------- // call lmder, enorm, and covar1 // ------------------------------- info = __cminpack_func__(lmder)(__cminpack_param_fcnder_mn__ 0, NUM_OBSERVATIONS, NUM_PARAMS, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, diag, mode, factor, nprint, &nfev, &njev, ipvt, qtf, wa1, wa2, wa3, wa4); fnorm = __cminpack_func__(enorm)(NUM_OBSERVATIONS, fvec); // NOTE: REMOVED THE TEST OF ORIGINAL MINPACK covar routine /* test covar1, which also estimates the rank of the Jacobian */ ftol = __cminpack_func__(dpmpar)(1); k = __cminpack_func__(covar1)(NUM_OBSERVATIONS, NUM_PARAMS, fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1); // ---------------------------------- // save the results in global memory // ---------------------------------- int threadId = (blockIdx.x * blockDim.x) + threadIdx.x; pResults[threadId].fnorm = fnorm; pResults[threadId].nfev = nfev; pResults[threadId].njev = njev; pResults[threadId].info = info; for (int j=1; j<=NUM_PARAMS; j++) { pResults[threadId].solution[j-1] = x[j-1]; } for (int i=1; i<=NUM_PARAMS; i++) { for (int j=1; j<=NUM_PARAMS; j++) { pResults[threadId].covar[i-1][j-1] = fjac[(i-1)*ldfjac+j-1]; } // for } // for pResults[threadId].rankJ = (k != 0 ? k : NUM_PARAMS); } // () //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- int main (int argc, char** argv) { fprintf (stderr, "\ntlmder starts ! \n"); // ............................................................... // choose the fastest GPU device // ............................................................... unsigned int GPU_ID = 1; // unsigned int GPU_ID = cutGetMaxGflopsDeviceId() ; cudaSetDevice(GPU_ID); fprintf (stderr, " CUDA device chosen = %d \n", GPU_ID); // ....................................................... // get memory in the GPU to store the results // ....................................................... ResultType * results_GPU = 0; cutilSafeCall(cudaMalloc( &results_GPU, NUM_THREADS * sizeof(ResultType) )); // ....................................................... // get memory in the CPU to store the results // ....................................................... ResultType * results_CPU = 0; cutilSafeCall(cudaMallocHost( &results_CPU, NUM_THREADS * sizeof(ResultType) )); // ....................................................... // launch the kernel // ....................................................... fprintf (stderr, " \nlaunching the kernel num. blocks = %d, threads per block = %d\n total threads = %d\n\n", NUM_BLOCKS, NUM_THREADS_PER_BLOCK, NUM_THREADS); mainKernel<<>> ( results_GPU ); // ....................................................... // wait for termination // ....................................................... cudaThreadSynchronize(); fprintf (stderr, " GPU processing done \n\n"); // ....................................................... // copy back to CPU the results // ....................................................... cutilSafeCall(cudaMemcpy( results_CPU, results_GPU, NUM_THREADS * sizeof(ResultType), cudaMemcpyDeviceToHost )); // ....................................................... // check all the threads computed the same results // ....................................................... bool ok = true; for (unsigned int i = 1; i #include #include #include #include #define real __cminpack_real__ #define cutilSafeCall(err) __cudaSafeCall (err, __FILE__, __LINE__) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { if( cudaSuccess != err) { fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n", file, line, cudaGetErrorString( err) ); exit(-1); } } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- const unsigned int NUM_OBSERVATIONS = 15; // m const unsigned int NUM_PARAMS = 3; // 3 = n //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // fixed arrangement of threads to be run // const unsigned int NUM_THREADS = 2048; const unsigned int NUM_THREADS_PER_BLOCK = 128; const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK; //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // the struct for returning results from the GPU // typedef struct { real fnorm; int info; real solution[NUM_PARAMS]; } ResultType; //-------------------------------------------------------------------------- // the cost function //-------------------------------------------------------------------------- __cminpack_attr__ /* __device__ */ int fcn_mn(void *p, int m, int n, const real *x, real *fvec, int iflag) { /* subroutine fcn for lmdif example. */ int i; real tmp1, tmp2, tmp3; real y[NUM_OBSERVATIONS]={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}; for (i = 0; i < NUM_OBSERVATIONS; i++) { tmp1 = i+1; tmp2 = NUM_OBSERVATIONS - i; tmp3 = tmp1; if (i >= 8) tmp3 = tmp2; fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); } // for return 0; } //-------------------------------------------------------------------------- // the kernel in the GPU //-------------------------------------------------------------------------- __global__ void mainKernel(ResultType pResults[]) { int info, lwa, iwa[NUM_PARAMS]; real tol, fnorm, x[NUM_PARAMS], fvec[NUM_OBSERVATIONS], wa[75]; // m = 15 = NUM_OBSERVATIONS; // n = 3 = NUM_PARAMS; /* the following starting values provide a rough fit. */ x[0] = 1.; x[1] = 1.; x[2] = 1.; 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(__cminpack_func__(dpmpar)(1)); // ------------------------------- // call lmdif, and enorm // ------------------------------- info = __cminpack_func__(lmdif1)(__cminpack_param_fcn_mn__ 0, NUM_OBSERVATIONS, NUM_PARAMS, x, fvec, tol, iwa, wa, lwa); fnorm = __cminpack_func__(enorm)(NUM_OBSERVATIONS, fvec); // ---------------------------------- // save the results in global memory // ---------------------------------- int threadId = (blockIdx.x * blockDim.x) + threadIdx.x; pResults[threadId].fnorm = fnorm; pResults[threadId].info = info; for (int j=0; j>> ( results_GPU ); // ....................................................... // wait for termination // ....................................................... cudaThreadSynchronize(); fprintf (stderr, " GPU processing done \n\n"); // ....................................................... // copy back to CPU the results // ....................................................... cutilSafeCall( cudaMemcpy( results_CPU, results_GPU, NUM_THREADS * sizeof(ResultType), cudaMemcpyDeviceToHost ) ); // ....................................................... // check all the threads computed the same results // ....................................................... bool ok = true; for (unsigned int i = 1; i #include #include #include #include #include #define real __cminpack_real__ #define cutilSafeCall(err) __cudaSafeCall (err, __FILE__, __LINE__) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { if( cudaSuccess != err) { fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n", file, line, cudaGetErrorString( err) ); exit(-1); } } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- const unsigned int NUM_OBSERVATIONS = 15; // m const unsigned int NUM_PARAMS = 3; // 3 = n //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // fixed arrangement of threads to be run // const unsigned int NUM_THREADS = 2048; const unsigned int NUM_THREADS_PER_BLOCK = 128; const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK; //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // the struct for returning results from the GPU // // #define ALIGN 16 // #pragma pack(16) // float rankJ; // __align__(2*sizeof(float)) // __align__(ALIGN) // float covar[NUM_PARAMS][NUM_PARAMS]; typedef struct { real fnorm; int nfev; int info; int rankJ; real solution[NUM_PARAMS]; real covar[NUM_PARAMS][NUM_PARAMS]; } ResultType; //-------------------------------------------------------------------------- // the cost function //-------------------------------------------------------------------------- __cminpack_attr__ /* __device__ */ int fcn_mn(void *p, int m, int n, const real *x, real *fvec, int iflag) { /* subroutine fcn for lmdif example. */ int i; real tmp1, tmp2, tmp3; real y[NUM_OBSERVATIONS]={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 0; } for (i = 1; i <= NUM_OBSERVATIONS; i++) { tmp1 = i; tmp2 = (NUM_OBSERVATIONS+1) - 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 0; } //-------------------------------------------------------------------------- // a test kernel for cheking the return of results //-------------------------------------------------------------------------- __global__ void test_mainKernel(ResultType * pResults) { int threadId = (blockIdx.x * blockDim.x) + threadIdx.x; pResults[threadId].fnorm = 13.13; pResults[threadId].nfev = 144; pResults[threadId].info = -1234; for (int j=0; j>> ( results_GPU ); // ....................................................... // wait for termination // ....................................................... cudaThreadSynchronize(); fprintf (stderr, " GPU processing done \n\n"); // ....................................................... // copy back to CPU the results // ....................................................... cutilSafeCall( cudaMemcpy( results_CPU, results_GPU, NUM_THREADS * sizeof(ResultType), cudaMemcpyDeviceToHost ) ); // ....................................................... // check all the threads computed the same results // ....................................................... bool ok = true; for (unsigned int i = 1; i