I would like to make the following suggestions to fix this and other similar problems in TMath.h ... the functions I've "fixed" are those that are not internally protected against numerical overflow in intermediate calculations, but whose final results should be representable. I've put the code at the following URL so as to shorten this message: http://g2pc1.bu.edu/~krlynch/rootpatch/TMath.cxx.new ... I have tested all this suggested code, although not extensively. In the regions where the current TMath functions are safe, these replacements behave similarly; they also work in regions where the current functions fail, including the region where Ken Bloom reported the problem, for instance: root [2] TMath::Poisson(170,70) Error: Symbol inf is not defined in current scope FILE: LINE:0 (Double_t)inf *** Interpreter error recovered *** root [3] TMathnew::Poisson(170,70) (Double_t)2.54255920378495108e-24 root [4] TMath::Poisson(10,5) (Double_t)1.81327887078059496e-02 root [5] TMathnew::Poisson(10,5) (Double_t)1.81327887078059427e-02 In this file, I've "fixed" the functions hypot, TMath::ASinH, TMath::ACosH, TMath::Normalize, and TMath::Poisson (although, except for Poisson, there likely won't ever be problems with the current code). Feel free to use any or all of this code as you see fit... >>On Mon, 26 Apr 2004, Rene Brun wrote: >> >> >>>Ken, >>> >>>I will be happy to add any suggestion you might have to protect the code >>>against the case you mention. >>> >>>Rene Brun >>> >>>On >>>Mon, 26 Apr 2004, Ken Bloom wrote: >>> >>> >>>>Dear ROOTers, >>>> >>>> I'm using ROOT 3.05/07, and am getting non-numerical results out of >>>>the TMath::Poisson function, under what I admit are extreme conditions: >>>> >>>>root [2] TMath::Poisson(170,70) >>>>Error: Symbol inf is not defined in current scope FILE: LINE:0 >>>>(Double_t)inf >>>>*** Interpreter error recovered *** >>>> >>>>Yes, I know that the result should be a very tiny number, but I would prefer >>>>that I get 0.0 (or its moral equivalent) rather than something I can't do math >>>>with. Can you recommend a protection against this? Thanks, best wishes. >>>> >>>> Ken Bloom -- ------------------------------------------------------------------------------- Kevin Lynch voice: (617) 353-6025 Physics Department Fax: (617) 353-9393 Boston University office: PRB-361 590 Commonwealth Ave. e-mail: krlynch@bu.edu Boston, MA 02215 USA http://budoe.bu.edu/~krlynch -------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET