|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76095 - trunk/boost/math/special_functions/detail
From: john_at_[hidden]
Date: 2011-12-21 11:58:37
Author: johnmaddock
Date: 2011-12-21 11:58:36 EST (Wed, 21 Dec 2011)
New Revision: 76095
URL: http://svn.boost.org/trac/boost/changeset/76095
Log:
Change overflow tests to not generate an infinity.
Fixes #6307.
Text files modified:
trunk/boost/math/special_functions/detail/bessel_jn.hpp | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
Modified: trunk/boost/math/special_functions/detail/bessel_jn.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_jn.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_jn.hpp 2011-12-21 11:58:36 EST (Wed, 21 Dec 2011)
@@ -72,7 +72,10 @@
for (int k = 1; k < n; k++)
{
T fact = 2 * k / x;
- if((tools::max_value<T>() - fabs(prev)) / fabs(fact) < fabs(current))
+ //
+ // rescale if we would overflow or underflow:
+ //
+ if((fabs(fact) > 1) && ((tools::max_value<T>() - fabs(prev)) / fabs(fact) < fabs(current)))
{
scale /= current;
prev /= current;
@@ -97,7 +100,7 @@
for (int k = n; k > 0; k--)
{
T fact = 2 * k / x;
- if((tools::max_value<T>() - fabs(prev)) / fact < fabs(current))
+ if((fabs(fact) > 1) && ((tools::max_value<T>() - fabs(prev)) / fabs(fact) < fabs(current)))
{
prev /= current;
scale /= current;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk