2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-15 13:12:19 +00:00

Improved error messages and added tentative fixes for HP Tru64: the compiler appears to store constants that should underflow to zero as a small non-zero values which messes up the logic used in the test cases.

[SVN r40963]
This commit is contained in:
John Maddock
2007-11-09 11:01:45 +00:00
parent 40b2cc0967
commit bf1404a2df
3 changed files with 50 additions and 11 deletions

View File

@@ -143,6 +143,19 @@ void expected_results()
".*", // test data group
".*", 200000, 100000); // test function
//
// HP Tru64:
// Extended exponent range of long double
// causes more extreme test cases to be executed:
//
add_expected_result(
"HP Tru64.*", // compiler
".*", // stdlib
".*", // platform
"long double", // test type(s)
".*", // test data group
".*", 200000, 100000); // test function
//
// Catch all cases come last:
//

View File

@@ -185,6 +185,19 @@ void expected_results()
<< BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
}
#define BOOST_CHECK_CLOSE_EX(a, b, prec, i) \
{\
unsigned int failures = boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed;\
BOOST_CHECK_CLOSE(a, b, prec); \
if(failures != boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed)\
{\
std::cerr << "Failure was at row " << i << std::endl;\
std::cerr << std::setprecision(35); \
std::cerr << "{ " << data[i][0] << " , " << data[i][1] << " , " << data[i][2];\
std::cerr << " , " << data[i][3] << " , " << data[i][4] << " , " << data[i][5] << " } " << std::endl;\
}\
}
template <class T>
void do_test_gamma_2(const T& data, const char* type_name, const char* test_name)
{
@@ -227,7 +240,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name
&& (fabs(data[i][5]) > 2 * boost::math::tools::min_value<double>()))
{
value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);
BOOST_CHECK_CLOSE(data[i][1], inv, precision);
BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);
}
else if(1 == data[i][5])
BOOST_CHECK_EQUAL(boost::math::gamma_p_inv(data[i][0], data[i][5]), boost::math::tools::max_value<value_type>());
@@ -236,24 +249,24 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name
// not enough bits in our input to get back to x, but we should be in
// the same ball park:
value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);
BOOST_CHECK_CLOSE(data[i][1], inv, 100000);
BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100000, i);
}
if(data[i][3] == 0)
BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), boost::math::tools::max_value<value_type>());
else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) >= boost::math::tools::min_value<value_type>()))
else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>()))
{
value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);
BOOST_CHECK_CLOSE(data[i][1], inv, precision);
BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);
}
else if(1 == data[i][3])
BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), value_type(0));
else
else if(fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>())
{
// not enough bits in our input to get back to x, but we should be in
// the same ball park:
value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);
BOOST_CHECK_CLOSE(data[i][1], inv, 100);
BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100, i);
}
}
std::cout << std::endl;

View File

@@ -111,6 +111,19 @@ void expected_results()
<< BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
}
#define BOOST_CHECK_CLOSE_EX(a, b, prec, i) \
{\
unsigned int failures = boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed;\
BOOST_CHECK_CLOSE(a, b, prec); \
if(failures != boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed)\
{\
std::cerr << "Failure was at row " << i << std::endl;\
std::cerr << std::setprecision(35); \
std::cerr << "{ " << data[i][0] << " , " << data[i][1] << " , " << data[i][2];\
std::cerr << " , " << data[i][3] << " , " << data[i][4] << " , " << data[i][5] << " } " << std::endl;\
}\
}
template <class T>
void do_test_gamma_2(const T& data, const char* type_name, const char* test_name)
{
@@ -151,7 +164,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name
else if((1 - data[i][5] > 0.001) && (fabs(data[i][5]) >= boost::math::tools::min_value<value_type>()))
{
value_type inv = boost::math::gamma_p_inva(data[i][1], data[i][5]);
BOOST_CHECK_CLOSE(data[i][0], inv, precision);
BOOST_CHECK_CLOSE_EX(data[i][0], inv, precision, i);
}
else if(1 == data[i][5])
BOOST_CHECK_EQUAL(boost::math::gamma_p_inva(data[i][1], data[i][5]), boost::math::tools::min_value<value_type>());
@@ -160,7 +173,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name
// not enough bits in our input to get back to x, but we should be in
// the same ball park:
value_type inv = boost::math::gamma_p_inva(data[i][1], data[i][5]);
BOOST_CHECK_CLOSE(data[i][0], inv, 100);
BOOST_CHECK_CLOSE_EX(data[i][0], inv, 100, i);
}
if(data[i][3] == 0)
@@ -170,16 +183,16 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name
&& (fabs(data[i][3]) > 2 * boost::math::tools::min_value<double>()))
{
value_type inv = boost::math::gamma_q_inva(data[i][1], data[i][3]);
BOOST_CHECK_CLOSE(data[i][0], inv, precision);
BOOST_CHECK_CLOSE_EX(data[i][0], inv, precision, i);
}
else if(1 == data[i][3])
BOOST_CHECK_EQUAL(boost::math::gamma_q_inva(data[i][1], data[i][3]), boost::math::tools::max_value<value_type>());
else
else if(data[i][3] > 2 * boost::math::tools::min_value<value_type>())
{
// not enough bits in our input to get back to x, but we should be in
// the same ball park:
value_type inv = boost::math::gamma_q_inva(data[i][1], data[i][3]);
BOOST_CHECK_CLOSE(data[i][0], inv, 100);
BOOST_CHECK_CLOSE_EX(data[i][0], inv, 100, i);
}
}
std::cout << std::endl;