⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minpack-documentation.txt

📁 该程序实现了非线性最小二乘问题和非线性方程组的解法
💻 TXT
📖 第 1 页 / 共 5 页
字号:
        (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 in

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -