dqelg.f

Go to the documentation of this file.
00001       SUBROUTINE DQELG(N,EPSTAB,RESULT,ABSERR,RES3LA,NRES)
00002 C***BEGIN PROLOGUE  DQELG
00003 C***REFER TO  DQAGIE,DQAGOE,DQAGPE,DQAGSE
00004 C***ROUTINES CALLED  D1MACH
00005 C***REVISION DATE  830518   (YYMMDD)
00006 C***KEYWORDS  EPSILON ALGORITHM, CONVERGENCE ACCELERATION,
00007 C             EXTRAPOLATION
00008 C***AUTHOR  PIESSENS,ROBERT,APPL. MATH. & PROGR. DIV. - K.U.LEUVEN
00009 C           DE DONCKER,ELISE,APPL. MATH & PROGR. DIV. - K.U.LEUVEN
00010 C***PURPOSE  THE ROUTINE DETERMINES THE LIMIT OF A GIVEN SEQUENCE OF
00011 C            APPROXIMATIONS, BY MEANS OF THE EPSILON ALGORITHM OF
00012 C            P.WYNN. AN ESTIMATE OF THE ABSOLUTE ERROR IS ALSO GIVEN.
00013 C            THE CONDENSED EPSILON TABLE IS COMPUTED. ONLY THOSE
00014 C            ELEMENTS NEEDED FOR THE COMPUTATION OF THE NEXT DIAGONAL
00015 C            ARE PRESERVED.
00016 C***DESCRIPTION
00017 C
00018 C           EPSILON ALGORITHM
00019 C           STANDARD FORTRAN SUBROUTINE
00020 C           DOUBLE PRECISION VERSION
00021 C
00022 C           PARAMETERS
00023 C              N      - INTEGER
00024 C                       EPSTAB(N) CONTAINS THE NEW ELEMENT IN THE
00025 C                       FIRST COLUMN OF THE EPSILON TABLE.
00026 C
00027 C              EPSTAB - DOUBLE PRECISION
00028 C                       VECTOR OF DIMENSION 52 CONTAINING THE ELEMENTS
00029 C                       OF THE TWO LOWER DIAGONALS OF THE TRIANGULAR
00030 C                       EPSILON TABLE. THE ELEMENTS ARE NUMBERED
00031 C                       STARTING AT THE RIGHT-HAND CORNER OF THE
00032 C                       TRIANGLE.
00033 C
00034 C              RESULT - DOUBLE PRECISION
00035 C                       RESULTING APPROXIMATION TO THE INTEGRAL
00036 C
00037 C              ABSERR - DOUBLE PRECISION
00038 C                       ESTIMATE OF THE ABSOLUTE ERROR COMPUTED FROM
00039 C                       RESULT AND THE 3 PREVIOUS RESULTS
00040 C
00041 C              RES3LA - DOUBLE PRECISION
00042 C                       VECTOR OF DIMENSION 3 CONTAINING THE LAST 3
00043 C                       RESULTS
00044 C
00045 C              NRES   - INTEGER
00046 C                       NUMBER OF CALLS TO THE ROUTINE
00047 C                       (SHOULD BE ZERO AT FIRST CALL)
00048 C
00049 C***END PROLOGUE  DQELG
00050 C
00051       DOUBLE PRECISION ABSERR,DABS,DELTA1,DELTA2,DELTA3,DMAX1,D1MACH,
00052      *  EPMACH,EPSINF,EPSTAB,ERROR,ERR1,ERR2,ERR3,E0,E1,E1ABS,E2,E3,
00053      *  OFLOW,RES,RESULT,RES3LA,SS,TOL1,TOL2,TOL3
00054       INTEGER I,IB,IB2,IE,INDX,K1,K2,K3,LIMEXP,N,NEWELM,NRES,NUM
00055       DIMENSION EPSTAB(52),RES3LA(3)
00056 C
00057 C           LIST OF MAJOR VARIABLES
00058 C           -----------------------
00059 C
00060 C           E0     - THE 4 ELEMENTS ON WHICH THE COMPUTATION OF A NEW
00061 C           E1       ELEMENT IN THE EPSILON TABLE IS BASED
00062 C           E2
00063 C           E3                 E0
00064 C                        E3    E1    NEW
00065 C                              E2
00066 C           NEWELM - NUMBER OF ELEMENTS TO BE COMPUTED IN THE NEW
00067 C                    DIAGONAL
00068 C           ERROR  - ERROR = ABS(E1-E0)+ABS(E2-E1)+ABS(NEW-E2)
00069 C           RESULT - THE ELEMENT IN THE NEW DIAGONAL WITH LEAST VALUE
00070 C                    OF ERROR
00071 C
00072 C           MACHINE DEPENDENT CONSTANTS
00073 C           ---------------------------
00074 C
00075 C           EPMACH IS THE LARGEST RELATIVE SPACING.
00076 C           OFLOW IS THE LARGEST POSITIVE MAGNITUDE.
00077 C           LIMEXP IS THE MAXIMUM NUMBER OF ELEMENTS THE EPSILON
00078 C           TABLE CAN CONTAIN. IF THIS NUMBER IS REACHED, THE UPPER
00079 C           DIAGONAL OF THE EPSILON TABLE IS DELETED.
00080 C
00081 C***FIRST EXECUTABLE STATEMENT  DQELG
00082       EPMACH = D1MACH(4)
00083       OFLOW = D1MACH(2)
00084       NRES = NRES+1
00085       ABSERR = OFLOW
00086       RESULT = EPSTAB(N)
00087       IF(N.LT.3) GO TO 100
00088       LIMEXP = 50
00089       EPSTAB(N+2) = EPSTAB(N)
00090       NEWELM = (N-1)/2
00091       EPSTAB(N) = OFLOW
00092       NUM = N
00093       K1 = N
00094       DO 40 I = 1,NEWELM
00095         K2 = K1-1
00096         K3 = K1-2
00097         RES = EPSTAB(K1+2)
00098         E0 = EPSTAB(K3)
00099         E1 = EPSTAB(K2)
00100         E2 = RES
00101         E1ABS = DABS(E1)
00102         DELTA2 = E2-E1
00103         ERR2 = DABS(DELTA2)
00104         TOL2 = DMAX1(DABS(E2),E1ABS)*EPMACH
00105         DELTA3 = E1-E0
00106         ERR3 = DABS(DELTA3)
00107         TOL3 = DMAX1(E1ABS,DABS(E0))*EPMACH
00108         IF(ERR2.GT.TOL2.OR.ERR3.GT.TOL3) GO TO 10
00109 C
00110 C           IF E0, E1 AND E2 ARE EQUAL TO WITHIN MACHINE
00111 C           ACCURACY, CONVERGENCE IS ASSUMED.
00112 C           RESULT = E2
00113 C           ABSERR = ABS(E1-E0)+ABS(E2-E1)
00114 C
00115         RESULT = RES
00116         ABSERR = ERR2+ERR3
00117 C ***JUMP OUT OF DO-LOOP
00118         GO TO 100
00119    10   E3 = EPSTAB(K1)
00120         EPSTAB(K1) = E1
00121         DELTA1 = E1-E3
00122         ERR1 = DABS(DELTA1)
00123         TOL1 = DMAX1(E1ABS,DABS(E3))*EPMACH
00124 C
00125 C           IF TWO ELEMENTS ARE VERY CLOSE TO EACH OTHER, OMIT
00126 C           A PART OF THE TABLE BY ADJUSTING THE VALUE OF N
00127 C
00128         IF(ERR1.LE.TOL1.OR.ERR2.LE.TOL2.OR.ERR3.LE.TOL3) GO TO 20
00129         SS = 0.1D+01/DELTA1+0.1D+01/DELTA2-0.1D+01/DELTA3
00130         EPSINF = DABS(SS*E1)
00131 C
00132 C           TEST TO DETECT IRREGULAR BEHAVIOUR IN THE TABLE, AND
00133 C           EVENTUALLY OMIT A PART OF THE TABLE ADJUSTING THE VALUE
00134 C           OF N.
00135 C
00136         IF(EPSINF.GT.0.1D-03) GO TO 30
00137    20   N = I+I-1
00138 C ***JUMP OUT OF DO-LOOP
00139         GO TO 50
00140 C
00141 C           COMPUTE A NEW ELEMENT AND EVENTUALLY ADJUST
00142 C           THE VALUE OF RESULT.
00143 C
00144    30   RES = E1+0.1D+01/SS
00145         EPSTAB(K1) = RES
00146         K1 = K1-2
00147         ERROR = ERR2+DABS(RES-E2)+ERR3
00148         IF(ERROR.GT.ABSERR) GO TO 40
00149         ABSERR = ERROR
00150         RESULT = RES
00151    40 CONTINUE
00152 C
00153 C           SHIFT THE TABLE.
00154 C
00155    50 IF(N.EQ.LIMEXP) N = 2*(LIMEXP/2)-1
00156       IB = 1
00157       IF((NUM/2)*2.EQ.NUM) IB = 2
00158       IE = NEWELM+1
00159       DO 60 I=1,IE
00160         IB2 = IB+2
00161         EPSTAB(IB) = EPSTAB(IB2)
00162         IB = IB2
00163    60 CONTINUE
00164       IF(NUM.EQ.N) GO TO 80
00165       INDX = NUM-N+1
00166       DO 70 I = 1,N
00167         EPSTAB(I)= EPSTAB(INDX)
00168         INDX = INDX+1
00169    70 CONTINUE
00170    80 IF(NRES.GE.4) GO TO 90
00171       RES3LA(NRES) = RESULT
00172       ABSERR = OFLOW
00173       GO TO 100
00174 C
00175 C           COMPUTE ERROR ESTIMATE
00176 C
00177    90 ABSERR = DABS(RESULT-RES3LA(3))+DABS(RESULT-RES3LA(2))
00178      *  +DABS(RESULT-RES3LA(1))
00179       RES3LA(1) = RES3LA(2)
00180       RES3LA(2) = RES3LA(3)
00181       RES3LA(3) = RESULT
00182   100 ABSERR = DMAX1(ABSERR,0.5D+01*EPMACH*DABS(RESULT))
00183       RETURN
00184       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines