| [f,a,b,omega,integr,epsabs,epsrel,limit,icall,maxp1,result,abserr,neval,ier,last,alist,blist,rlist,elist,iord,nnlog,momcom,chebmo]=dqawoe(f,a,b,omega,integr,epsabs,epsrel,limit,icall,maxp1,result,abserr,neval,ier,last,alist,blist,rlist,elist,iord,nnlog,mo |
function [f,a,b,omega,integr,epsabs,epsrel,limit,icall,maxp1,result,abserr,neval,ier,last,alist,blist,rlist,elist,iord,nnlog,momcom,chebmo]=dqawoe(f,a,b,omega,integr,epsabs,epsrel,limit,icall,maxp1,result,abserr,neval,ier,last,alist,blist,rlist,elist,iord,nnlog,momcom,chebmo);
%***BEGIN PROLOGUE DQAWOE
%***PURPOSE Calculate an approximation to a given definite integral
% I = Integral of F(X)*W(X) over (A,B), where
% W(X) = COS(OMEGA*X)
% or W(X)=SIN(OMEGA*X),
% hopefully satisfying the following claim for accuracy
% ABS(I-RESULT).LE.MAX(EPSABS,EPSREL*ABS(I)).
%***LIBRARY SLATEC (QUADPACK)
%***CATEGORY H2A2A1
%***TYPE doubleprecision (QAWOE-S, DQAWOE-D)
%***KEYWORDS AUTOMATIC INTEGRATOR, CLENSHAW-CURTIS METHOD,
% EXTRAPOLATION, GLOBALLY ADAPTIVE,
% INTEGRAND WITH OSCILLATORY COS OR SIN FACTOR, QUADPACK,
% QUADRATURE, SPECIAL-PURPOSE
%***AUTHOR Piessens, Robert
% Applied Mathematics and Programming Division
% K. U. Leuven
% de Doncker, Elise
% Applied Mathematics and Programming Division
% K. U. Leuven
%***DESCRIPTION
%
% Computation of Oscillatory integrals
% Standard fortran subroutine
% doubleprecision version
%
% PARAMETERS
% ON ENTRY
% F - doubleprecision
% function subprogram defining the integrand
% function F(X). The actual name for F needs to be
% declared E X T E R N A L in the driver program.
%
% A - doubleprecision
% Lower limit of integration
%
% B - doubleprecision
% Upper limit of integration
%
% OMEGA - doubleprecision
% Parameter in the integrand weight function
%
% INTEGR - Integer
% Indicates which of the WEIGHT functions is to be
% used
% INTEGR = 1 W(X) = COS(OMEGA*X)
% INTEGR = 2 W(X) = SIN(OMEGA*X)
% If INTEGR.NE.1 and INTEGR.NE.2, the routine
% will end with IER = 6.
%
% EPSABS - doubleprecision
% Absolute accuracy requested
% EPSREL - doubleprecision
% Relative accuracy requested
% If EPSABS.LE.0
% and EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28),
% the routine will end with IER = 6.
%
% LIMIT - Integer
% Gives an upper bound on the number of subdivisions
% in the partition of (A,B), LIMIT.GE.1.
%
% ICALL - Integer
% If DQAWOE is to be used only once, ICALL must
% be set to 1. Assume that during this call, the
% Chebyshev moments (for CLENSHAW-CURTIS integration
% of degree 24) have been computed for intervals of
% lengths (ABS(B-A))*2**(-L), L=0,1,2,...MOMCOM-1.
% If ICALL.GT.1 this means that DQAWOE has been
% called twice or more on intervals of the same
% length ABS(B-A). The Chebyshev moments already
% computed are then re-used in subsequent calls.
% If ICALL.LT.1, the routine will end with IER = 6.
%
% MAXP1 - Integer
% Gives an upper bound on the number of Chebyshev
% moments which can be stored, i.e. for the
% intervals of lengths ABS(B-A)*2**(-L),
% L=0,1, ..., MAXP1-2, MAXP1.GE.1.
% If MAXP1.LT.1, the routine will end with IER = 6.
%
% ON RETURN
% RESULT - doubleprecision
% Approximation to the integral
%
% ABSERR - doubleprecision
% Estimate of the modulus of the absolute error,
% which should equal or exceed ABS(I-RESULT)
%
% NEVAL - Integer
% Number of integrand evaluations
%
% IER - Integer
% IER = 0 Normal and reliable termination of the
% routine. It is assumed that the
% requested accuracy has been achieved.
% - IER.GT.0 Abnormal termination of the routine.
% The estimates for integral and error are
% less reliable. It is assumed that the
% requested accuracy has not been achieved.
% ERROR MESSAGES
% IER = 1 Maximum number of subdivisions allowed
% has been achieved. One can allow more
% subdivisions by increasing the value of
% LIMIT (and taking according dimension
% adjustments into account). However, if
% this yields no improvement it is advised
% to analyze the integrand, in order to
% determine the integration difficulties.
% If the position of a local difficulty can
% be determined (e.g. SINGULARITY,
% DISCONTINUITY within the interval) one
% will probably gain from splitting up the
% interval at this point and calling the
% integrator on the subranges. If possible,
% an appropriate special-purpose integrator
% should be used which is designed for
% handling the type of difficulty involved.
% = 2 The occurrence of roundoff error is
% detected, which prevents the requested
% tolerance from being achieved.
% The error may be under-estimated.
% = 3 Extremely bad integrand behaviour occurs
% at some points of the integration
% interval.
% = 4 The algorithm does not converge.
% Roundoff error is detected in the
% extrapolation table.
% It is presumed that the requested
% tolerance cannot be achieved due to
% roundoff in the extrapolation table,
% and that the returned result is the
% best which can be obtained.
% = 5 The integral is probably divergent, or
% slowly convergent. It must be noted that
% divergence can occur with any other value
% of IER.GT.0.
% = 6 The input is invalid, because
% (EPSABS.LE.0 and
% EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28))
% or (INTEGR.NE.1 and INTEGR.NE.2) or
% ICALL.LT.1 or MAXP1.LT.1.
% RESULT, ABSERR, NEVAL, LAST, RLIST(1),
% ELIST(1), IORD(1) and NNLOG(1) are set
% to ZERO. ALIST(1) and BLIST(1) are set
% to A and B respectively.
%
% LAST - Integer
% On return, LAST equals the number of
% subintervals produces in the subdivision
% process, which determines the number of
% significant elements actually in the
% WORK ARRAYS.
% ALIST - doubleprecision
% Vector of dimension at least LIMIT, the first
% LAST elements of which are the left
% end points of the subintervals in the partition
% of the given integration range (A,B)
%
% BLIST - doubleprecision
% Vector of dimension at least LIMIT, the first
% LAST elements of which are the right
% end points of the subintervals in the partition
% of the given integration range (A,B)
%
% RLIST - doubleprecision
% Vector of dimension at least LIMIT, the first
% LAST elements of which are the integral
% approximations on the subintervals
%
% ELIST - doubleprecision
% Vector of dimension at least LIMIT, the first
% LAST elements of which are the moduli of the
% absolute error estimates on the subintervals
%
% IORD - Integer
% Vector of dimension at least LIMIT, the first K
% elements of which are pointers to the error
% estimates over the subintervals,
% such that ELIST(IORD(1)), ...,
% ELIST(IORD(K)) form a decreasing sequence, with
% K = LAST if LAST.LE.(LIMIT/2+2), and
% K = LIMIT+1-LAST otherwise.
%
% NNLOG - Integer
% Vector of dimension at least LIMIT, containing the
% subdivision levels of the subintervals, i.e.
% IWORK(I) = L means that the subinterval
% numbered I is of length ABS(B-A)*2**(1-L)
%
% ON ENTRY AND RETURN
% MOMCOM - Integer
% Indicating that the Chebyshev moments
% have been computed for intervals of lengths
% (ABS(B-A))*2**(-L), L=0,1,2, ..., MOMCOM-1,
% MOMCOM.LT.MAXP1
%
% CHEBMO - doubleprecision
% Array of dimension (MAXP1,25) containing the
% Chebyshev moments
%
%***REFERENCES (NONE)
%***ROUTINES CALLED D1MACH, DQC25F, DQELG, DQPSRT
%***REVISION HISTORY (YYMMDD)
% 800101 DATE WRITTEN
% 890531 Changed all specific intrinsics to generic. (WRB)
% 890831 Modified array declarations. (WRB)
% 890831 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
%***end PROLOGUE DQAWOE
%
persistent a1 a2 abseps area area1 area12 area2 b1 b2 correc defab1 defab2 defabs domega dres epmach erlarg erlast errbnd errmax erro12 error1 error2 errsum ertest extall extrap gt gt2 id ierro iroff1 iroff2 iroff3 jupbnd k ksgn ktmin maxerr nev noext nres nrmax nrmom numrl2 oflow res3la resabs reseps rlist2 small uflow width ;
if isempty(abseps), abseps=0; end;
if isempty(area), area=0; end;
if isempty(area1), area1=0; end;
if isempty(area12), area12=0; end;
if isempty(area2), area2=0; end;
if isempty(a1), a1=0; end;
if isempty(a2), a2=0; end;
if isempty(b1), b1=0; end;
if isempty(b2), b2=0; end;
if isempty(correc), correc=0; end;
if isempty(defab1), defab1=0; end;
if isempty(defab2), defab2=0; end;
if isempty(defabs), defabs=0; end;
if isempty(domega), domega=0; end;
if isempty(dres), dres=0; end;
if isempty(epmach), epmach=0; end;
if isempty(erlarg), erlarg=0; end;
if isempty(erlast), erlast=0; end;
if isempty(errbnd), errbnd=0; end;
if isempty(errmax), errmax=0; end;
if isempty(error1), error1=0; end;
if isempty(erro12), erro12=0; end;
if isempty(error2), error2=0; end;
if isempty(errsum), errsum=0; end;
if isempty(ertest), ertest=0; end;
if isempty(oflow), oflow=0; end;
if isempty(resabs), resabs=0; end;
if isempty(reseps), reseps=0; end;
if isempty(res3la), res3la=zeros(1,3); end;
if isempty(rlist2), rlist2=zeros(1,52); end;
if isempty(small), small=0; end;
if isempty(uflow), uflow=0; end;
if isempty(width), width=0; end;
if isempty(id), id=0; end;
if isempty(ierro), ierro=0; end;
if isempty(iroff1), iroff1=0; end;
if isempty(iroff2), iroff2=0; end;
if isempty(iroff3), iroff3=0; end;
if isempty(jupbnd), jupbnd=0; end;
if isempty(k), k=0; end;
if isempty(ksgn), ksgn=0; end;
if isempty(ktmin), ktmin=0; end;
if isempty(maxerr), maxerr=0; end;
if isempty(nev), nev=0; end;
if isempty(nres), nres=0; end;
if isempty(nrmax), nrmax=0; end;
if isempty(nrmom), nrmom=0; end;
if isempty(numrl2), numrl2=0; end;
if isempty(gt), gt=zeros(1,3); end;
if isempty(gt2), gt2=0; end;
if isempty(extrap), extrap=false; end;
if isempty(noext), noext=false; end;
if isempty(extall), extall=false; end;
%
alist_shape=size(alist);alist=reshape(alist,1,[]);
blist_shape=size(blist);blist=reshape(blist,1,[]);
rlist_shape=size(rlist);rlist=reshape(rlist,1,[]);
elist_shape=size(elist);elist=reshape(elist,1,[]);
iord_shape=size(iord);iord=reshape(iord,1,[]);
chebmo_orig=chebmo;chebmo_shape=[maxp1,25];chebmo=reshape([chebmo_orig(1:min(prod(chebmo_shape),numel(chebmo_orig))),zeros(1,max(0,prod(chebmo_shape)-numel(chebmo_orig)))],chebmo_shape);
nnlog_shape=size(nnlog);nnlog=reshape(nnlog,1,[]);
%
%
% THE DIMENSION OF RLIST2 IS DETERMINED BY THE VALUE OF
% LIMEXP IN SUBROUTINE DQELG (RLIST2 SHOULD BE OF
% DIMENSION (LIMEXP+2) AT LEAST).
%
% LIST OF MAJOR VARIABLES
% -----------------------
%
% ALIST - LIST OF LEFT END POINTS OF ALL SUBINTERVALS
% CONSIDERED UP TO NOW
% BLIST - LIST OF RIGHT END POINTS OF ALL SUBINTERVALS
% CONSIDERED UP TO NOW
% RLIST(I) - APPROXIMATION TO THE INTEGRAL OVER
% (ALIST(I),BLIST(I))
% RLIST2 - ARRAY OF DIMENSION AT LEAST LIMEXP+2
% CONTAINING THE PART OF THE EPSILON TABLE
% WHICH IS STILL NEEDED FOR FURTHER COMPUTATIONS
% ELIST(I) - ERROR ESTIMATE APPLYING TO RLIST(I)
% MAXERR - POINTER TO THE INTERVAL WITH LARGEST
% ERROR ESTIMATE
% ERRMAX - ELIST(MAXERR)
% ERLAST - ERROR ON THE INTERVAL CURRENTLY SUBDIVIDED
% AREA - SUM OF THE INTEGRALS OVER THE SUBINTERVALS
% ERRSUM - SUM OF THE ERRORS OVER THE SUBINTERVALS
% ERRBND - REQUESTED ACCURACY MAX(EPSABS,EPSREL*
% ABS(RESULT))
% *****1 - VARIABLE FOR THE LEFT SUBINTERVAL
% *****2 - VARIABLE FOR THE RIGHT SUBINTERVAL
% LAST - INDEX FOR SUBDIVISION
% NRES - NUMBER OF CALLS TO THE EXTRAPOLATION ROUTINE
% NUMRL2 - NUMBER OF ELEMENTS IN RLIST2. IF AN APPROPRIATE
% APPROXIMATION TO THE COMPOUNDED INTEGRAL HAS
% BEEN OBTAINED IT IS PUT IN RLIST2(NUMRL2) AFTER
% NUMRL2 HAS BEEN INCREASED BY ONE
% SMALL - LENGTH OF THE SMALLEST INTERVAL CONSIDERED
% UP TO NOW, MULTIPLIED BY 1.5
% ERLARG - SUM OF THE ERRORS OVER THE INTERVALS LARGER
% THAN THE SMALLEST INTERVAL CONSIDERED UP TO NOW
% EXTRAP - LOGICAL VARIABLE DENOTING THAT THE ROUTINE IS
% ATTEMPTING TO PERFORM EXTRAPOLATION, I.E. BEFORE
% SUBDIVIDING THE SMALLEST INTERVAL WE TRY TO
% DECREASE THE VALUE OF ERLARG
% NOEXT - LOGICAL VARIABLE DENOTING THAT EXTRAPOLATION
% IS NO LONGER ALLOWED (truemlv VALUE)
%
% MACHINE DEPENDENT CONSTANTS
% ---------------------------
%
% EPMACH IS THE LARGEST RELATIVE SPACING.
% UFLOW IS THE SMALLEST POSITIVE MAGNITUDE.
% OFLOW IS THE LARGEST POSITIVE MAGNITUDE.
%
%***FIRST EXECUTABLE STATEMENT DQAWOE
gt(:)=0;
gt2=0;
[epmach ]=d1mach(4);
%
% TEST ON VALIDITY OF PARAMETERS
% ------------------------------
%
ier = 0;
neval = 0;
last = 0;
result = 0.0d+00;
abserr = 0.0d+00;
alist(1) = a;
blist(1) = b;
rlist(1) = 0.0d+00;
elist(1) = 0.0d+00;
iord(1) = 0;
nnlog(1) = 0;
if((integr~=1 && integr~=2) ||(epsabs<=0.0d+00 && epsrel<max(0.5d+02.*epmach,0.5d-28))|| icall<1 || maxp1<1 )
ier = 6;
end;
if( ier~=6 )
%
% FIRST APPROXIMATION TO THE INTEGRAL
% -----------------------------------
%
domega = abs(omega);
nrmom = 0;
if( icall<=1 )
momcom = 0;
end;
[f,a,b,domega,integr,nrmom,maxp1,dumvar8,result,abserr,neval,defabs,resabs,momcom,chebmo]=dqc25f(f,a,b,domega,integr,nrmom,maxp1,0,result,abserr,neval,defabs,resabs,momcom,chebmo);
%
% TEST ON ACCURACY.
%
dres = abs(result);
errbnd = max(epsabs,epsrel.*dres);
rlist(1) = result;
elist(1) = abserr;
iord(1) = 1;
if( abserr<=0.1d+03.*epmach.*defabs && abserr>errbnd )
ier = 2;
end;
if( limit==1 )
ier = 1;
end;
while (1);
if( ier~=0 || abserr<=errbnd )
if( integr==2 && omega<0.0d+00 )
result = -result;
end;
alist_shape=zeros(alist_shape);alist_shape(:)=alist(1:numel(alist_shape));alist=alist_shape;
blist_shape=zeros(blist_shape);blist_shape(:)=blist(1:numel(blist_shape));blist=blist_shape;
rlist_shape=zeros(rlist_shape);rlist_shape(:)=rlist(1:numel(rlist_shape));rlist=rlist_shape;
elist_shape=zeros(elist_shape);elist_shape(:)=elist(1:numel(elist_shape));elist=elist_shape;
iord_shape=zeros(iord_shape);iord_shape(:)=iord(1:numel(iord_shape));iord=iord_shape;
chebmo_orig(1:prod(chebmo_shape))=chebmo;chebmo=chebmo_orig;
nnlog_shape=zeros(nnlog_shape);nnlog_shape(:)=nnlog(1:numel(nnlog_shape));nnlog=nnlog_shape;
return;
else;
%
% INITIALIZATIONS
% ---------------
%
[uflow ]=d1mach(1);
[oflow ]=d1mach(2);
errmax = abserr;
maxerr = 1;
area = result;
errsum = abserr;
abserr = oflow;
nrmax = 1;
extrap = false;
noext = false;
ierro = 0;
iroff1 = 0;
iroff2 = 0;
iroff3 = 0;
ktmin = 0;
small = abs(b-a).*0.75d+00;
nres = 0;
numrl2 = 0;
extall = false;
if( 0.5d+00.*abs(b-a).*domega<=0.2d+01 )
numrl2 = 1;
extall = true;
rlist2(1) = result;
end;
if( 0.25d+00.*abs(b-a).*domega<=0.2d+01 )
extall = true;
end;
ksgn = -1;
if( dres>=(0.1d+01-0.5d+02.*epmach).*defabs )
ksgn = 1;
end;
%
% MAIN DO-LOOP
% ------------
%
for last = 2 : limit;
gt(:)=0;
%
% BISECT THE SUBINTERVAL WITH THE NRMAX-TH LARGEST
% ERROR ESTIMATE.
%
nrmom = fix(nnlog(maxerr) + 1);
a1 = alist(maxerr);
b1 = 0.5d+00.*(alist(maxerr)+blist(maxerr));
a2 = b1;
b2 = blist(maxerr);
erlast = errmax;
[f,a1,b1,domega,integr,nrmom,maxp1,dumvar8,area1,error1,nev,resabs,defab1,momcom,chebmo]=dqc25f(f,a1,b1,domega,integr,nrmom,maxp1,0,area1,error1,nev,resabs,defab1,momcom,chebmo);
neval = fix(neval + nev);
[f,a2,b2,domega,integr,nrmom,maxp1,dumvar8,area2,error2,nev,resabs,defab2,momcom,chebmo]=dqc25f(f,a2,b2,domega,integr,nrmom,maxp1,1,area2,error2,nev,resabs,defab2,momcom,chebmo);
neval = fix(neval + nev);
%
% IMPROVE PREVIOUS APPROXIMATIONS TO INTEGRAL
% AND ERROR AND TEST FOR ACCURACY.
%
area12 = area1 + area2;
erro12 = error1 + error2;
errsum = errsum + erro12 - errmax;
area = area + area12 - rlist(maxerr);
if( defab1~=error1 && defab2~=error2 )
if( abs(rlist(maxerr)-area12)<=0.1d-04.*abs(area12) &&erro12>=0.99d+00.*errmax )
if( extrap )
iroff2 = fix(iroff2 + 1);
end;
if( ~extrap )
iroff1 = fix(iroff1 + 1);
end;
end;
if( last>10 && erro12>errmax )
iroff3 = fix(iroff3 + 1);
end;
end;
rlist(maxerr) = area1;
rlist(last) = area2;
nnlog(maxerr) = fix(nrmom);
nnlog(last) = fix(nrmom);
errbnd = max(epsabs,epsrel.*abs(area));
%
% TEST FOR ROUNDOFF ERROR AND EVENTUALLY SET ERROR FLAG.
%
if( iroff1+iroff2>=10 || iroff3>=20 )
ier = 2;
end;
if( iroff2>=5 )
ierro = 3;
end;
%
% SET ERROR FLAG IN THE CASE THAT THE NUMBER OF
% SUBINTERVALS EQUALS LIMIT.
%
if( last==limit )
ier = 1;
end;
%
% SET ERROR FLAG IN THE CASE OF BAD INTEGRAND BEHAVIOUR
% AT A POINT OF THE INTEGRATION RANGE.
%
if( max(abs(a1),abs(b2))<=(0.1d+01+0.1d+03.*epmach).*(abs(a2)+0.1d+04.*uflow) )
ier = 4;
end;
%
% APPEND THE NEWLY-CREATED INTERVALS TO THE LIST.
%
if( error2>error1 )
alist(maxerr) = a2;
alist(last) = a1;
blist(last) = b1;
rlist(maxerr) = area2;
rlist(last) = area1;
elist(maxerr) = error2;
elist(last) = error1;
else;
alist(last) = a2;
blist(maxerr) = b1;
blist(last) = b2;
elist(maxerr) = error1;
elist(last) = error2;
end;
%
% CALL SUBROUTINE DQPSRT TO MAINTAIN THE DESCENDING ORDERING
% IN THE LIST OF ERROR ESTIMATES AND SELECT THE SUBINTERVAL
% WITH NRMAX-TH LARGEST ERROR ESTIMATE (TO BISECTED NEXT).
%
[limit,last,maxerr,errmax,elist,iord,nrmax]=dqpsrt(limit,last,maxerr,errmax,elist,iord,nrmax);
% ***JUMP OUT OF DO-LOOP
if( errsum<=errbnd )
gt2=1;
break;
end;
if( ier~=0 )
break;
end;
if( last==2 && extall )
small = small.*0.5d+00;
numrl2 = fix(numrl2 + 1);
rlist2(numrl2) = area;
else;
if( noext )
continue;
end;
if( extall )
erlarg = erlarg - erlast;
if( abs(b1-a1)>small )
erlarg = erlarg + erro12;
end;
if( extrap )
gt(1)=1;
end;
end;
%
% TEST WHETHER THE INTERVAL TO BE BISECTED NEXT IS THE
% SMALLEST INTERVAL.
%
if(gt(1)==0)
width = abs(blist(maxerr)-alist(maxerr));
if( width>small )
continue;
end;
if( extall )
extrap = true;
nrmax = 2;
else;
%
% TEST WHETHER WE CAN START WITH THE EXTRAPOLATION PROCEDURE
% (WE DO THIS IF WE INTEGRATE OVER THE NEXT INTERVAL WITH
% use OF A GAUSS-KRONROD RULE - SEE SUBROUTINE DQC25F).
%
small = small.*0.5d+00;
if( 0.25d+00.*width.*domega>0.2d+01 )
continue;
end;
extall = true;
gt(2)=1;
end;
end;
gt(1)=0;
if(gt(2)==0)
if( ierro~=3 && erlarg>ertest )
%
% THE SMALLEST INTERVAL HAS THE LARGEST ERROR.
% BEFORE BISECTING DECREASE THE SUM OF THE ERRORS OVER
% THE LARGER INTERVALS (ERLARG) AND PERFORM EXTRAPOLATION.
%
jupbnd = fix(last);
if( last>(fix(limit./2)+2) )
jupbnd = fix(limit + 3 - last);
end;
id = fix(nrmax);
for k = id : jupbnd;
maxerr = fix(iord(nrmax));
errmax = elist(maxerr);
if( abs(blist(maxerr)-alist(maxerr))>small )
gt(3)=1;
break;
end;
nrmax = fix(nrmax + 1);
end;
if(gt(3)==1)
continue;
end;
end;
%
% PERFORM EXTRAPOLATION.
%
numrl2 = fix(numrl2 + 1);
rlist2(numrl2) = area;
if( numrl2>=3 )
[numrl2,rlist2,reseps,abseps,res3la,nres]=dqelg(numrl2,rlist2,reseps,abseps,res3la,nres);
ktmin = fix(ktmin + 1);
if( ktmin>5 && abserr<0.1d-02.*errsum )
ier = 5;
end;
if( abseps<abserr )
ktmin = 0;
abserr = abseps;
result = reseps;
correc = erlarg;
ertest = max(epsabs,epsrel.*abs(reseps));
% ***JUMP OUT OF DO-LOOP
if( abserr<=ertest )
break;
end;
end;
%
% PREPARE BISECTION OF THE SMALLEST INTERVAL.
%
if( numrl2==1 )
noext = true;
end;
if( ier==5 )
break;
end;
end;
maxerr = fix(iord(1));
errmax = elist(maxerr);
nrmax = 1;
extrap = false;
small = small.*0.5d+00;
erlarg = errsum;
continue;
end;
gt(2)=0;
end;
ertest = errbnd;
erlarg = errsum;
end;
if(gt2==1)
break;
end;
%
% SET THE FINAL RESULT.
% ---------------------
%
if( abserr~=oflow && nres~=0 )
if( ier+ierro~=0 )
if( ierro==3 )
abserr = abserr + correc;
end;
if( ier==0 )
ier = 3;
end;
if( result==0.0d+00 || area==0.0d+00 )
if( abserr>errsum )
break;
end;
if( area==0.0d+00 )
if( ier>2 )
ier = fix(ier - 1);
end;
if( integr==2 && omega<0.0d+00 )
result = -result;
end;
alist_shape=zeros(alist_shape);alist_shape(:)=alist(1:numel(alist_shape));alist=alist_shape;
blist_shape=zeros(blist_shape);blist_shape(:)=blist(1:numel(blist_shape));blist=blist_shape;
rlist_shape=zeros(rlist_shape);rlist_shape(:)=rlist(1:numel(rlist_shape));rlist=rlist_shape;
elist_shape=zeros(elist_shape);elist_shape(:)=elist(1:numel(elist_shape));elist=elist_shape;
iord_shape=zeros(iord_shape);iord_shape(:)=iord(1:numel(iord_shape));iord=iord_shape;
chebmo_orig(1:prod(chebmo_shape))=chebmo;chebmo=chebmo_orig;
nnlog_shape=zeros(nnlog_shape);nnlog_shape(:)=nnlog(1:numel(nnlog_shape));nnlog=nnlog_shape;
return;
end;
elseif( abserr./abs(result)>errsum./abs(area) ) ;
break;
end;
end;
%
% TEST ON DIVERGENCE.
%
if( ksgn~=(-1) || max(abs(result),abs(area))>defabs.*0.1d-01 )
if( 0.1d-01>(result./area) ||(result./area)>0.1d+03 ||errsum>=abs(area) )
ier = 6;
end;
end;
if( ier>2 )
ier = fix(ier - 1);
end;
if( integr==2 && omega<0.0d+00 )
result = -result;
end;
alist_shape=zeros(alist_shape);alist_shape(:)=alist(1:numel(alist_shape));alist=alist_shape;
blist_shape=zeros(blist_shape);blist_shape(:)=blist(1:numel(blist_shape));blist=blist_shape;
rlist_shape=zeros(rlist_shape);rlist_shape(:)=rlist(1:numel(rlist_shape));rlist=rlist_shape;
elist_shape=zeros(elist_shape);elist_shape(:)=elist(1:numel(elist_shape));elist=elist_shape;
iord_shape=zeros(iord_shape);iord_shape(:)=iord(1:numel(iord_shape));iord=iord_shape;
chebmo_orig(1:prod(chebmo_shape))=chebmo;chebmo=chebmo_orig;
nnlog_shape=zeros(nnlog_shape);nnlog_shape(:)=nnlog(1:numel(nnlog_shape));nnlog=nnlog_shape;
return;
end;
end;
break;
end;
%
% COMPUTE GLOBAL INTEGRAL SUM.
%
result = 0.0d+00;
for k = 1 : last;
result = result + rlist(k);
end; k = fix(last+1);
abserr = errsum;
if( ier>2 )
ier = fix(ier - 1);
end;
if( integr==2 && omega<0.0d+00 )
result = -result;
end;
end;
alist_shape=zeros(alist_shape);alist_shape(:)=alist(1:numel(alist_shape));alist=alist_shape;
blist_shape=zeros(blist_shape);blist_shape(:)=blist(1:numel(blist_shape));blist=blist_shape;
rlist_shape=zeros(rlist_shape);rlist_shape(:)=rlist(1:numel(rlist_shape));rlist=rlist_shape;
elist_shape=zeros(elist_shape);elist_shape(:)=elist(1:numel(elist_shape));elist=elist_shape;
iord_shape=zeros(iord_shape);iord_shape(:)=iord(1:numel(iord_shape));iord=iord_shape;
chebmo_orig(1:prod(chebmo_shape))=chebmo;chebmo=chebmo_orig;
nnlog_shape=zeros(nnlog_shape);nnlog_shape(:)=nnlog(1:numel(nnlog_shape));nnlog=nnlog_shape;
end %subroutine dqawoe
%DECK DQAWO
|
|