File indexing completed on 2024-04-06 12:13:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 subroutine vegas(fxn,ndim,ncall,itmx,nprn)
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 implicit double precision(a-h,o-z)
0026 implicit integer (i-n)
0027
0028
0029 parameter (maxnup=500)
0030 common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
0031 &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
0032 &vtimup(maxnup),spinup(maxnup)
0033 save /hepeup/
0034
0035 #include "invegas.h"
0036 #include "bcvegpy_set_par.inc"
0037
0038
0039 common/grade/xi(NVEGBIN,10)
0040 common/ptpass/ptmin,ptmax,crossmax,etamin,etamax,
0041 & smin,smax,ymin,ymax,psetamin,psetamax
0042 common/vegcross/vegsec,vegerr,iveggrade
0043
0044
0045 dimension x(10),xin(NVEGBIN),r(NVEGBIN),ia(10),d(NVEGBIN,10)
0046
0047
0048 alph=1.50d0
0049
0050 nd=NVEGBIN
0051
0052
0053
0054 si =0.0d0
0055 si2 =0.0d0
0056 swgt =0.0d0
0057 schi =0.0d0
0058 scalls=0.0d0
0059 calls =ncall
0060 xnd =nd
0061 ndm =nd-1
0062
0063
0064
0065 if(iveggrade.eq.0) then
0066 rc=1.0d0/xnd
0067 do 7 j=1,ndim
0068 xi(nd,j)=1.0d0
0069 dr=0.0d0
0070 do 7 i=1,ndm
0071 dr=dr+rc
0072 xi(i,j)=dr
0073 7 continue
0074 end if
0075
0076
0077
0078
0079 do 1000 it=1,itmx
0080
0081
0082
0083
0084
0085
0086
0087
0088 ti =0.0d0
0089 sfun2=0.0d0
0090 do 10 j=1,ndim
0091 do 10 i=1,nd
0092 d(i,j)=0.0d0
0093 10 continue
0094 do 11 jj=1,ncall
0095 call generand(ndim,xnd,x,ia,wgt)
0096 call phpoint(x,wt)
0097 if(wt.lt.1.0d-15) then
0098 tempfxn=0.0d0
0099 else
0100 tempfxn=fxn(x,wt)*wgt
0101 end if
0102
0103 if(tempfxn.gt.crossmax) then
0104 crossmax=tempfxn
0105 end if
0106 fun=tempfxn/calls
0107 fun2=fun*fun
0108 weight=wgt/calls
0109 ti=ti+fun
0110 sfun2=sfun2+fun2
0111 do j=1,ndim
0112 iaj=ia(j)
0113 d(iaj,j)=d(iaj,j)+fun2
0114 end do
0115 11 continue
0116
0117
0118
0119 ti2=ti*ti
0120 tsi=dsqrt((sfun2*calls-ti2)/(calls-1.0d0))
0121 wgta=ti2/tsi**2
0122 si=si+ti*wgta
0123 si2=si2+ti2
0124 swgt=swgt+wgta
0125 schi=schi+ti2*wgta
0126 scalls=scalls+calls
0127 avgi=si/swgt
0128 sd=swgt*it/si2
0129 chi2a=0.0d0
0130 if(it.gt.1)chi2a=sd*(schi/swgt-avgi*avgi)/(it-1)
0131 sd=1.0d0/dsqrt(sd)
0132 err=sd*100.0d0/avgi
0133
0134
0135
0136 vegsec=avgi !pb
0137 vegerr=err
0138
0139
0140
0141
0142 if(nprn.ge.2) then
0143 print 201,it,avgi,sd,err
0144 write(3,201) it,avgi,sd,err
0145
0146
0147
0148 end if
0149
0150
0151
0152 201 format('iter.no',i3,' acc.result(pb)==>',g14.5,'+/-',g10.4,
0153 . '... % err=',g10.2)
0154
0155
0156
0157
0158
0159
0160 do 23 j=1,ndim
0161 xo=d(1,j)
0162 xn=d(2,j)
0163 d(1,j)=(xo+xn)/2.0d0
0164 x(j)=d(1,j)
0165 do 22 i=2,ndm
0166 d(i,j)=xo+xn
0167 xo=xn
0168 xn=d(i+1,j)
0169 d(i,j)=(d(i,j)+xn)/3.0d0
0170 x(j)=x(j)+d(i,j)
0171 22 continue
0172 d(nd,j)=(xn+xo)/2.0d0
0173 x(j)=x(j)+d(nd,j)
0174 23 continue
0175
0176
0177
0178 do 28 j=1,ndim
0179 rc=0.0d0
0180 do i=1,nd
0181 r(i)=0.0d0
0182 if(d(i,j).le.0.) go to 224
0183 xo=x(j)/d(i,j)
0184 r(i)=((xo-1.0d0)/xo/dlog(xo))**alph
0185 224 rc=rc+r(i)
0186 end do
0187
0188
0189
0190 rc=rc/xnd
0191 kk=0
0192 xn=0.0d0
0193 dr=0.0d0
0194 i=0
0195 25 kk=kk+1
0196 dr=dr+r(kk)
0197 xo=xn
0198 xn=xi(kk,j)
0199 26 if(rc.gt.dr) go to 25
0200 i=i+1
0201 dr=dr-rc
0202 xin(i)=xn-(xn-xo)*dr/r(kk)
0203 if(i.lt.ndm) go to 26
0204 do i=1,ndm
0205 xi(i,j)=xin(i)
0206 end do
0207 xi(nd,j)=1.0d0
0208 28 continue
0209 1000 continue
0210
0211 return
0212 end
0213
0214
0215 subroutine generand(ndim,xnd,x,ia,weight)
0216 implicit double precision(a-h,o-z)
0217 implicit integer (i-n)
0218
0219 #include "invegas.h"
0220 #include "bcvegpy_set_par.inc"
0221
0222 common/grade/xi(NVEGBIN,10)
0223 dimension ia(10),x(10),randx(10)
0224
0225
0226 common/subopen/subfactor,subenergy,isubonly
0227
0228 weight=1.0d0
0229
0230 call randa(ndim,randx)
0231
0232
0233
0234 do 15 j=1,ndim
0235 xn=randx(j)*xnd+1.0d0
0236 ia(j)=xn
0237 xim1=0.0d0
0238 if(ia(j).gt.1) xim1=xi(ia(j)-1,j)
0239 xo=xi(ia(j),j)-xim1
0240 x(j)=xim1+(xn-ia(j))*xo
0241 weight=weight*xo*xnd
0242 15 continue
0243
0244 if(isubonly.eq.1) then
0245 x(6)=subfactor
0246 x(7)=subfactor
0247 end if
0248
0249 return
0250 end
0251
0252
0253
0254 subroutine randa(n,randx)
0255 implicit double precision(a-h,o-z)
0256 implicit integer (i-n)
0257 dimension randx(n)
0258
0259 do i=1,n
0260 randx(i)=pyr(0)
0261 end do
0262
0263 return
0264 end