Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Large numbers in F90
@ 1998-02-11  5:00 Jeffrey J. Potoff
  1998-02-12  5:00 ` Pierre Asselin
  0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey J. Potoff @ 1998-02-11  5:00 UTC (permalink / raw)



I have a Fortran 90 code where on occasion I need to take the
exponential of some large numbers (500+).  As you can imagine,
the result is a floating point overflow with real*8.  I was able
to avoid the floating overflow by going real*16, but now the 
code is incredibly slow.  Why is this ?  Is there anyway to gain
some speed or am I doomed ?  Here is the section of code if anyone 
has any ideas for restructuring it.  'prob' can be around 700 
at times, which is causing the problems.  I have a hack that 
may work, but I'd like to avoid it.

Thanks,
	Jeff


  do kfile = 1,nfiles
    weight(kfile) = 0.0
    do ifile = 1,nfiles      
      do i=1,nentry(ifile)
        y = 0.0
        do jfile = 1,nfiles      
          prob = -(beta(jfile)-beta(kfile))*e(i,ifile) +&
          (beta(jfile)*mu1(jfile)-beta(kfile)*mu1(kfile))*n1(i,ifile) +&
          (beta(jfile)*mu2(jfile)-beta(kfile)*mu2(kfile))*n2(i,ifile)
                
          y = y+nentry(jfile)*exp(prob-log(oldweight(jfile))) 
        enddo
        weight(kfile) = weight(kfile)+1./y      
      enddo
    enddo
    val = abs(weight(kfile)/oldweight(kfile)-1.)
    if (val.gt.maxd) maxd=val
  enddo



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Large numbers in F90
  1998-02-11  5:00 Large numbers in F90 Jeffrey J. Potoff
@ 1998-02-12  5:00 ` Pierre Asselin
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre Asselin @ 1998-02-12  5:00 UTC (permalink / raw)



"Jeffrey J. Potoff" <jpotoff@rhea.umd.edu> writes:

>I have a Fortran 90 code where on occasion I need to take the
>exponential of some large numbers (500+).  As you can imagine,
>the result is a floating point overflow with real*8.

That's normal.

>I was able
>to avoid the floating overflow by going real*16, but now the 
>code is incredibly slow.

That's normal.  The real*16 gives you the extra dynamic range of a
longer exponent, but also the extra accuracy of a longer mantissa.
Your code works that much harder to compute exponentials to that
accuracy.

Go back to the math behind the code, factor out the exponent offset
analytically, and re-code.

-- 
--Pierre Asselin, Westminster, Colorado
  lpa@netcom.com
  pa@verano.sba.ca.us



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-02-12  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-11  5:00 Large numbers in F90 Jeffrey J. Potoff
1998-02-12  5:00 ` Pierre Asselin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox