2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

[distributions] Hyper-Exponential: registered tests and fixed some test-related issue.

This commit is contained in:
sguazt
2014-08-22 16:37:35 +02:00
parent 144db22c2f
commit 3621b083e2
3 changed files with 36 additions and 8 deletions

View File

@@ -68,12 +68,12 @@ template <typename T>
bool iszero(T x)
{
#ifdef FP_ZERO
return boost::math::fpclassify(x) == FP_ZERO;
return (boost::math::fpclassify)(x) == FP_ZERO;
// Alternatively, we could use std::fpclassify (but this is available from ISO C99)
//return std::fpclassify(x) == FP_ZERO;
#else
return = ((x < 0) ? bool(-x < (std::numeric_limits<T>::min)())
: bool(+x < (std::numeric_limits<T>::min)()));
return ((x < 0) ? bool(-x < (std::numeric_limits<T>::min)())
: bool(+x < (std::numeric_limits<T>::min)()));
#endif // FP_ZERO
}
@@ -112,7 +112,7 @@ bool check_probabilities(char const* function, std::vector<RealT> const& probabi
{
if (probabilities[i] < 0
|| probabilities[i] > 1
|| !boost::math::isfinite(probabilities[i]))
|| !(boost::math::isfinite)(probabilities[i]))
{
*presult = policies::raise_domain_error<RealT>(function,
"The elements of parameter \"probabilities\" must be >= 0 and <= 1, but at least one of them was: %1%.",
@@ -142,7 +142,7 @@ bool check_rates(char const* function, std::vector<RealT> const& rates, RealT* p
for (std::size_t i = 0; i < n; ++i)
{
if (rates[i] <= 0
|| !boost::math::isfinite(rates[i]))
|| !(boost::math::isfinite)(rates[i]))
{
*presult = policies::raise_domain_error<RealT>(function,
"The elements of parameter \"rates\" must be > 0, but at least one of them is: %1%.",
@@ -173,7 +173,7 @@ bool check_dist(char const* function, std::vector<RealT> const& probabilities, s
template <typename RealT, typename PolicyT>
bool check_x(char const* function, RealT x, RealT* presult, PolicyT const& pol)
{
if (x < 0 || boost::math::isnan(x))
if (x < 0 || (boost::math::isnan)(x))
{
*presult = policies::raise_domain_error<RealT>(function, "The random variable must be >= 0, but is: %1%.", x, pol);
return false;
@@ -184,7 +184,7 @@ bool check_x(char const* function, RealT x, RealT* presult, PolicyT const& pol)
template <typename RealT, typename PolicyT>
bool check_probability(char const* function, RealT p, RealT* presult, PolicyT const& pol)
{
if (p < 0 || p > 1 || boost::math::isnan(p))
if (p < 0 || p > 1 || (boost::math::isnan)(p))
{
*presult = policies::raise_domain_error<RealT>(function, "The probability be >= 0 and <= 1, but is: %1%.", p, pol);
return false;
@@ -470,7 +470,7 @@ RealT variance(hyperexponential_distribution<RealT, PolicyT> const& dist)
result += probs[i]/(rates[i]*rates[i]);
}
const RealT mean = mean(dist);
const RealT mean = boost::math::mean(dist);
result = 2.0*result-mean*mean;

View File

@@ -211,6 +211,7 @@ run test_gamma_dist.cpp pch ../../test/build//boost_unit_test_framework ;
run test_geometric.cpp ../../test/build//boost_unit_test_framework ;
run test_hankel.cpp ../../test/build//boost_unit_test_framework ;
run test_hermite.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ;
run test_hyperexponential_dist.cpp ../../test/build//boost_unit_test_framework ;
run test_hypergeometric_dist.cpp ../../test/build//boost_unit_test_framework
: # command line
: # input files
@@ -746,6 +747,7 @@ run compile_test/dist_fisher_f_incl_test.cpp compile_test_main ;
run compile_test/dist_gamma_incl_test.cpp compile_test_main ;
run compile_test/dist_inv_gamma_incl_test.cpp compile_test_main ;
run compile_test/dist_inv_chi_sq_incl_test.cpp compile_test_main ;
run compile_test/dist_hyperexponential_incl_test.cpp compile_test_main ;
run compile_test/dist_hypergeo_incl_test.cpp compile_test_main ;
run compile_test/dist_laplace_incl_test.cpp compile_test_main ;
run compile_test/dist_logistic_incl_test.cpp compile_test_main ;

View File

@@ -0,0 +1,26 @@
// Copyright 2014 Marco Guazzone (marco.guazzone@gmail.com)
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Basic sanity check that header <boost/math/distributions/hyperexponential.hpp>
// #includes all the files that it needs to.
//
#include <boost/math/distributions/hyperexponential.hpp>
//
// Note this header includes no other headers, this is
// important if this test is to be meaningful:
//
#include "test_compile_result.hpp"
void compile_and_link_test()
{
TEST_DIST_FUNC(hyperexponential)
}
template class boost::math::hyperexponential_distribution<float, boost::math::policies::policy<> >;
template class boost::math::hyperexponential_distribution<double, boost::math::policies::policy<> >;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
template class boost::math::hyperexponential_distribution<long double, boost::math::policies::policy<> >;
#endif