diff --git a/include/boost/math/special_functions/owens_t.hpp b/include/boost/math/special_functions/owens_t.hpp index cca1c75a1..25ff43f0b 100644 --- a/include/boost/math/special_functions/owens_t.hpp +++ b/include/boost/math/special_functions/owens_t.hpp @@ -49,19 +49,19 @@ namespace boost namespace detail { // owens_t_znorm1(x) = P(-oo - inline RealType owens_t_znorm1(const RealType x) + template + inline RealType owens_t_znorm1(const RealType x, const Policy& pol) { using namespace boost::math::constants; - return boost::math::erf(x*one_div_root_two())*half(); + return boost::math::erf(x*one_div_root_two(), pol)*half(); } // RealType owens_t_znorm1(const RealType x) // owens_t_znorm2(x) = P(x<=Z - inline RealType owens_t_znorm2(const RealType x) + template + inline RealType owens_t_znorm2(const RealType x, const Policy& pol) { using namespace boost::math::constants; - return boost::math::erfc(x*one_div_root_two())*half(); + return boost::math::erfc(x*one_div_root_two(), pol)*half(); } // RealType owens_t_znorm2(const RealType x) // Auxiliary function, it computes an array key that is used to determine @@ -193,7 +193,7 @@ namespace boost // compute the value of Owen's T function with method T2 from the reference paper template - inline RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah, const Policy&, const boost::false_type&) + inline RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah, const Policy& pol, const boost::false_type&) { BOOST_MATH_STD_USING using namespace boost::math::constants; @@ -206,7 +206,7 @@ namespace boost unsigned short ii = 1; RealType val = 0; RealType vi = a * exp( -ah*ah*half() ) * one_div_root_two_pi(); - RealType z = owens_t_znorm1(ah)/h; + RealType z = owens_t_znorm1(ah, pol)/h; while( true ) { @@ -225,8 +225,8 @@ namespace boost } // RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah) // compute the value of Owen's T function with method T3 from the reference paper - template - inline RealType owens_t_T3_imp(const RealType h, const RealType a, const RealType ah, const boost::integral_constant&) + template + inline RealType owens_t_T3_imp(const RealType h, const RealType a, const RealType ah, const boost::integral_constant&, const Policy& pol) { BOOST_MATH_STD_USING using namespace boost::math::constants; @@ -255,7 +255,7 @@ namespace boost RealType ii = 1; unsigned short i = 0; RealType vi = a * exp( -ah*ah*half() ) * one_div_root_two_pi(); - RealType zi = owens_t_znorm1(ah)/h; + RealType zi = owens_t_znorm1(ah, pol)/h; RealType val = 0; while( true ) @@ -277,8 +277,8 @@ namespace boost } // RealType owens_t_T3(const RealType h, const RealType a, const RealType ah) // compute the value of Owen's T function with method T3 from the reference paper - template - inline RealType owens_t_T3_imp(const RealType h, const RealType a, const RealType ah, const boost::integral_constant&) + template + inline RealType owens_t_T3_imp(const RealType h, const RealType a, const RealType ah, const boost::integral_constant&, const Policy& pol) { BOOST_MATH_STD_USING using namespace boost::math::constants; @@ -327,7 +327,7 @@ namespace boost RealType ii = 1; unsigned short i = 0; RealType vi = a * exp( -ah*ah*half() ) * one_div_root_two_pi(); - RealType zi = owens_t_znorm1(ah)/h; + RealType zi = owens_t_znorm1(ah, pol)/h; RealType val = 0; while( true ) @@ -349,7 +349,7 @@ namespace boost } // RealType owens_t_T3(const RealType h, const RealType a, const RealType ah) template - inline RealType owens_t_T3(const RealType h, const RealType a, const RealType ah, const Policy&) + inline RealType owens_t_T3(const RealType h, const RealType a, const RealType ah, const Policy& pol) { typedef typename policies::precision::type precision_type; typedef boost::integral_constant tag_type; - return owens_t_T3_imp(h, a, ah, tag_type()); + return owens_t_T3_imp(h, a, ah, tag_type(), pol); } // compute the value of Owen's T function with method T4 from the reference paper @@ -521,13 +521,13 @@ namespace boost // compute the value of Owen's T function with method T6 from the reference paper - template - inline RealType owens_t_T6(const RealType h, const RealType a) + template + inline RealType owens_t_T6(const RealType h, const RealType a, const Policy& pol) { BOOST_MATH_STD_USING using namespace boost::math::constants; - const RealType normh = owens_t_znorm2( h ); + const RealType normh = owens_t_znorm2(h, pol); const RealType y = static_cast(1) - a; const RealType r = atan2(y, static_cast(1 + a) ); @@ -621,7 +621,7 @@ namespace boost } template - inline RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah, const Policy&, const boost::true_type&) + inline RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah, const Policy& pol, const boost::true_type&) { BOOST_MATH_STD_USING using namespace boost::math::constants; @@ -634,7 +634,7 @@ namespace boost unsigned short ii = 1; RealType val = 0; RealType vi = a * exp( -ah*ah*half() ) / root_two_pi(); - RealType z = owens_t_znorm1(ah)/h; + RealType z = owens_t_znorm1(ah, pol)/h; RealType last_z = fabs(z); RealType lim = policies::get_epsilon(); @@ -660,7 +660,7 @@ namespace boost } // RealType owens_t_T2(const RealType h, const RealType a, const unsigned short m, const RealType ah) template - inline std::pair owens_t_T2_accelerated(const RealType h, const RealType a, const RealType ah, const Policy&) + inline std::pair owens_t_T2_accelerated(const RealType h, const RealType a, const RealType ah, const Policy& pol) { // // This is the same series as T2, but with acceleration applied. @@ -678,7 +678,7 @@ namespace boost unsigned short ii = 1; RealType val = 0; RealType vi = a * exp( -ah*ah*half() ) / root_two_pi(); - RealType z = boost::math::detail::owens_t_znorm1(ah)/h; + RealType z = boost::math::detail::owens_t_znorm1(ah, pol)/h; RealType last_z = fabs(z); // @@ -794,11 +794,11 @@ namespace boost } if(a == 1) { - return owens_t_znorm2(RealType(-h)) * owens_t_znorm2(h) / 2; + return owens_t_znorm2(RealType(-h), pol) * owens_t_znorm2(h, pol) / 2; } if(a >= tools::max_value()) { - return owens_t_znorm2(RealType(fabs(h))); + return owens_t_znorm2(RealType(fabs(h)), pol); } RealType val = 0; // avoid compiler warnings, 0 will be overwritten in any case const unsigned short icode = owens_t_compute_code(h, a); @@ -826,7 +826,7 @@ namespace boost val = owens_t_T5(h,a, pol); break; case 6: // T6 - val = owens_t_T6(h,a); + val = owens_t_T6(h,a, pol); break; default: BOOST_THROW_EXCEPTION(std::logic_error("selection routine in Owen's T function failed")); @@ -853,11 +853,11 @@ namespace boost } if(a == 1) { - return owens_t_znorm2(RealType(-h)) * owens_t_znorm2(h) / 2; + return owens_t_znorm2(RealType(-h), pol) * owens_t_znorm2(h, pol) / 2; } if(a >= tools::max_value()) { - return owens_t_znorm2(RealType(fabs(h))); + return owens_t_znorm2(RealType(fabs(h)), pol); } // Attempt arbitrary precision code, this will throw if it goes wrong: typedef typename boost::math::policies::normalise >::type forwarding_policy; @@ -1003,15 +1003,15 @@ namespace boost { if( h <= 0.67 ) { - const RealType normh = owens_t_znorm1(h); - const RealType normah = owens_t_znorm1(fabs_ah); + const RealType normh = owens_t_znorm1(h, pol); + const RealType normah = owens_t_znorm1(fabs_ah, pol); val = static_cast(1)/static_cast(4) - normh*normah - owens_t_dispatch(fabs_ah, static_cast(1 / fabs_a), h, pol); } // if( h <= 0.67 ) else { - const RealType normh = detail::owens_t_znorm2(h); - const RealType normah = detail::owens_t_znorm2(fabs_ah); + const RealType normh = detail::owens_t_znorm2(h, pol); + const RealType normah = detail::owens_t_znorm2(fabs_ah, pol); val = constants::half()*(normh+normah) - normh*normah - owens_t_dispatch(fabs_ah, static_cast(1 / fabs_a), h, pol); } // else [if( h <= 0.67 )] diff --git a/test/owens_t_T7.hpp b/test/owens_t_T7.hpp index b3ad30dd6..bd5227d58 100644 --- a/test/owens_t_T7.hpp +++ b/test/owens_t_T7.hpp @@ -151,7 +151,7 @@ namespace boost // compute Owen's T function, T(h,a), for arbitrary values of h and a template - inline RealType owens_t_T7(RealType h, RealType a, const Policy&) + inline RealType owens_t_T7(RealType h, RealType a, const Policy& pol) { BOOST_MATH_STD_USING // exploit that T(-h,a) == T(h,a) @@ -174,15 +174,15 @@ namespace boost { if( h <= 0.67 ) { - const RealType normh = owens_t_znorm1(h); - const RealType normah = owens_t_znorm1(fabs_ah); + const RealType normh = owens_t_znorm1(h, pol); + const RealType normah = owens_t_znorm1(fabs_ah, pol); val = static_cast(1)/static_cast(4) - normh*normah - compute_owens_t_T7(fabs_ah, static_cast(1 / fabs_a)); } // if( h <= 0.67 ) else { - const RealType normh = owens_t_znorm2(h); - const RealType normah = owens_t_znorm2(fabs_ah); + const RealType normh = owens_t_znorm2(h, pol); + const RealType normah = owens_t_znorm2(fabs_ah, pol); val = constants::half()*(normh+normah) - normh*normah - compute_owens_t_T7(fabs_ah, static_cast(1 / fabs_a)); } // else [if( h <= 0.67 )]