[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] Bug in vegas.c
From: |
David Zaslavsky |
Subject: |
Re: [Bug-gsl] Bug in vegas.c |
Date: |
Mon, 23 Mar 2015 22:27:11 +0800 |
Sure, attached is the simplest program I can get to demonstrate the nan
result (on my computer - perhaps this is hardware-dependent). It took me a
little while to come up with it, as the bug seems somewhat difficult to
trigger. Hopefully this helps.
:) David
On Sat, Mar 21, 2015 at 11:17 PM, Patrick Alken <address@hidden>
wrote:
> Thanks for the report David. Do you have a simple program which
> demonstrates the bug?
>
> Patrick
>
> On 03/21/2015 01:59 AM, David Zaslavsky wrote:
> > I'm fairly sure I've identified a small bug in the VEGAS implementation:
> in
> > lines 280-283 of vegas.c on the master branch,
> >
> > if (var > 0) { wgt = 1.0 / var; }
> >
> > very small but nonzero values of var (like 1e-322) will cause wgt to be
> set
> > to inf, and that in turn causes gsl_monte_vegas_integrate to return nan.
> > The logical fix seems to be to treat any value of var satisfying
> > 1.0/var==inf as zero, i.e.
> >
> > - if (var > 0)
> > + if (var > 0 && gsl_finite(1.0 / var))
> >
> > I don't know if that would break anything else, but I can't imagine how.
> > Thoughts?
> >
> > I can send a proper patch file if desired (it's on my other computer).
> >
> > :) David
> >
>
>
>
gsl_vegas_bug_demo.c
Description: Text Data