1,2c1,4 < FUNCTION ADDLN(ALN,BLN) ! Bernd Berg, Aug 20 2003. < C Given ln(A) and ln(B), the function returns ln(C) with C=A+B. --- > program addln_test ! Bernd Berg, August 21 2003. > C > C Illustrates and tests addln.f and addln2.f using random numbers. > C 5,8c7,51 < ADDLN=MAX(ALN,BLN)+LOG(ONE+EXP(-ABS(ALN-BLN))) < RETURN < END < --- > parameter(iuo=6,iud=10,iseed1=1,iseed2=0,npri=14,ndat=14) > c > call rmaset(iuo,iud,iseed1,iseed2,'no_file') > write(iuo,'(/," npri,ndat =",2i10)') npri,ndat > c > write(iuo,'(/," addln2.f:",/)') > c=rmafun() > do idat=1,ndat > a=c > b=rmafun() > c=a+b > aln=log(a) > bln=log(b) > cln=addln_cut(aln,bln) > c cln=addln(aln,bln) > cc=exp(cln) > if(idat.le.npri) > & write(iuo,'(" idat,a,b,c,c:",i5,4f12.6)') idat,a,b,c,cc > end do > write(iuo,'(" Last c,c:",2g16.7)') c,cc > c > write(iuo,'(/," addln2.f:",/)') > c=rmafun() > do idat=1,ndat > if(c.gt.zero) then > a=c > b=rmafun() > isgn=-1 > else > a=-c > b=rmafun() > isgn=+1 > end if > c=a+isgn*b > aln=log(a) > bln=log(b) > call addln2(aln,bln,cln,isgn) > cc=isgn*exp(cln) > if(idat.le.npri) > & write(iuo,'(" idat,a,b,c,c:",i5,4f12.6)') idat,a,b,c,cc > end do > write(iuo,'(" Last c,c:",2g16.7)') c,cc > c > stop > end 9a53,58 > include '../../Libs/Fortran/addln.f' > include '../../Libs/Fortran/addln_cut.f' > include '../../Libs/Fortran/addln2.f' > include '../../Libs/Fortran/rmaset.f' > include '../../Libs/Fortran/ranmar.f' > include '../../Libs/Fortran/rmafun.f'