Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78063 - sandbox/math/boost/math/special_functions
From: john_at_[hidden]
Date: 2012-04-18 07:25:16


Author: johnmaddock
Date: 2012-04-18 07:25:15 EDT (Wed, 18 Apr 2012)
New Revision: 78063
URL: http://svn.boost.org/trac/boost/changeset/78063

Log:
Add some special case handling.
Text files modified:
   sandbox/math/boost/math/special_functions/owens_t.hpp | 32 ++++++++++++++++++++++++++------
   1 files changed, 26 insertions(+), 6 deletions(-)

Modified: sandbox/math/boost/math/special_functions/owens_t.hpp
==============================================================================
--- sandbox/math/boost/math/special_functions/owens_t.hpp (original)
+++ sandbox/math/boost/math/special_functions/owens_t.hpp 2012-04-18 07:25:15 EDT (Wed, 18 Apr 2012)
@@ -638,10 +638,27 @@
          template<typename RealType, typename Policy>
          inline RealType owens_t_dispatch(const RealType h, const RealType a, const RealType ah, const Policy& pol)
          {
- static const unsigned short meth[] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5, 6}; // 18 entries
- //static const unsigned short ord[] = {2, 3, 4, 5, 7, 10, 12, 18, 10, 20, 30, 20, 4, 7, 8, 20, 13, 0}; // 18 entries
-
- RealType val = 0; // avoid compiler warnings, 0 will be overwritten in any case
+ BOOST_MATH_STD_USING
+ //
+ // Handle some special cases first, these are from
+ // page 1077 of Owen's original paper:
+ //
+ if(h == 0)
+ {
+ return atan(a) * constants::one_div_two_pi<RealType>();
+ }
+ if(a == 0)
+ {
+ return 0;
+ }
+ if(a == 1)
+ {
+ return owens_t_znorm2(RealType(-h)) * owens_t_znorm2(h) / 2;
+ }
+ if(a >= tools::max_value<RealType>())
+ {
+ return owens_t_znorm2(RealType(fabs(h)));
+ }
 
             if(policies::digits<RealType, Policy>() > 64)
             {
@@ -649,8 +666,7 @@
                try
                {
                   typedef boost::math::policies::normalise<Policy, boost::math::policies::evaluation_error<> >::type forwarding_policy;
- val = owens_t_T1_accelerated(h, a, forwarding_policy());
- return val;
+ return owens_t_T1_accelerated(h, a, forwarding_policy());
                }
                catch(const boost::math::evaluation_error&)
                {
@@ -659,6 +675,10 @@
             }
 
 
+ static const unsigned short meth[] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5, 6}; // 18 entries
+ //static const unsigned short ord[] = {2, 3, 4, 5, 7, 10, 12, 18, 10, 20, 30, 20, 4, 7, 8, 20, 13, 0}; // 18 entries
+
+ RealType val = 0; // avoid compiler warnings, 0 will be overwritten in any case
             const unsigned short icode = owens_t_compute_code(h, a);
             const unsigned short m = owens_t_get_order(icode, val /* just a dummy for the type */, pol);
 


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