2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-28 07:22:12 +00:00

Merge branch 'cstdfloat' of https://github.com/boostorg/math into cstdfloat

This commit is contained in:
ckormanyos
2014-02-18 23:08:02 +01:00
2 changed files with 4 additions and 3 deletions

View File

@@ -139,7 +139,7 @@ T gamma_imp(T z, const Policy& pol, const Lanczos& l)
result = gamma_imp(T(-z), pol, l) * sinpx(z);
BOOST_MATH_INSTRUMENT_VARIABLE(result);
if((fabs(result) < 1) && (tools::max_value<T>() * fabs(result) < boost::math::constants::pi<T>()))
return policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
return -boost::math::sign(result) * policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
result = -boost::math::constants::pi<T>() / result;
if(result == 0)
return policies::raise_underflow_error<T>(function, "Result of tgamma is too small to represent.", pol);
@@ -178,13 +178,13 @@ T gamma_imp(T z, const Policy& pol, const Lanczos& l)
// we're going to overflow unless this is done with care:
BOOST_MATH_INSTRUMENT_VARIABLE(zgh);
if(lzgh * z / 2 > tools::log_max_value<T>())
return policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
return boost::math::sign(result) * policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
T hp = pow(zgh, (z / 2) - T(0.25));
BOOST_MATH_INSTRUMENT_VARIABLE(hp);
result *= hp / exp(zgh);
BOOST_MATH_INSTRUMENT_VARIABLE(result);
if(tools::max_value<T>() / hp < result)
return policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
return boost::math::sign(result) * policies::raise_overflow_error<T>(function, "Result of tgamma is too large to represent.", pol);
result *= hp;
BOOST_MATH_INSTRUMENT_VARIABLE(result);
}

View File

@@ -167,6 +167,7 @@ void test_gamma(T, const char* name)
template <class T>
void test_spots(T)
{
BOOST_MATH_STD_USING
//
// basic sanity checks, tolerance is 50 epsilon expressed as a percentage:
//