Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56647 - trunk/libs/math/performance
From: john_at_[hidden]
Date: 2009-10-08 05:54:56


Author: johnmaddock
Date: 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
New Revision: 56647
URL: http://svn.boost.org/trac/boost/changeset/56647

Log:
Added more performance tests along with comparisons to the DCDFLIB.
Added:
   trunk/libs/math/performance/test_beta.cpp (contents, props changed)
   trunk/libs/math/performance/test_expm1_log1p.cpp (contents, props changed)
Text files modified:
   trunk/libs/math/performance/distributions.cpp | 287 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/math/performance/test_erf.cpp | 27 +++
   trunk/libs/math/performance/test_gamma.cpp | 66 +++++++++
   trunk/libs/math/performance/test_ibeta.cpp | 37 +++++
   trunk/libs/math/performance/test_igamma.cpp | 22 ---
   5 files changed, 417 insertions(+), 22 deletions(-)

Modified: trunk/libs/math/performance/distributions.cpp
==============================================================================
--- trunk/libs/math/performance/distributions.cpp (original)
+++ trunk/libs/math/performance/distributions.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -651,3 +651,290 @@
 
 #endif
 
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+void cdfbeta( int *which, double *p, double *q, double *x, double *a, double *b, int *status, double *bound)
+{
+ double y = 1 - *x;
+ cdfbet(which, p, q, x, &y, a, b, status, bound);
+}
+
+void cdfbinomial( int *which, double *p, double *q, double *x, double *a, double *b, int *status, double *bound)
+{
+ double y = 1 - *x;
+ double cb = 1 - *b;
+ cdfbet(which, p, q, x, a, b, &cb, status, bound);
+}
+
+void cdfnegative_binomial( int *which, double *p, double *q, double *x, double *a, double *b, int *status, double *bound)
+{
+ double y = 1 - *x;
+ double cb = 1 - *b;
+ cdfnbn(which, p, q, x, a, b, &cb, status, bound);
+}
+
+void cdfchi_squared( int *which, double *p, double *q, double *x, double *a, int *status, double *bound)
+{
+ cdfchi(which, p, q, x, a, status, bound);
+}
+
+void cdfnon_central_chi_squared( int *which, double *p, double *q, double *x, double *a, double *b, int *status, double *bound)
+{
+ cdfchn(which, p, q, x, a, b, status, bound);
+}
+
+namespace boost{ namespace math{
+
+ template <class T = double> struct f_distribution : public fisher_f_distribution<T>
+ { f_distribution(T a, T b) : fisher_f_distribution(a, b) {} };
+ template <class T = double>
+ struct fnc_distribution : public non_central_f_distribution<T>
+ { fnc_distribution(T a, T b, T c) : non_central_f_distribution(a, b, c) {} };
+ template <class T = double> struct gam_distribution : public gamma_distribution<T>
+ { gam_distribution(T a, T b) : gamma_distribution(a, b) {} };
+ template <class T = double> struct nor_distribution : public normal_distribution<T>
+ { nor_distribution(T a, T b) : normal_distribution(a, b) {} };
+ template <class T = double> struct poi_distribution : public poisson_distribution<T>
+ { poi_distribution(T a) : poisson_distribution(a) {} };
+ template <class T = double> struct t_distribution : public students_t_distribution<T>
+ { t_distribution(T a) : students_t_distribution(a) {} };
+
+ template <class T>
+ T cdf(const f_distribution<T>& d, const T& r){ return cdf(static_cast<fisher_f_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const f_distribution<T>& d, const T& r){ return quantile(static_cast<fisher_f_distribution<T> >(d), r); }
+ template <class T>
+ T cdf(const fnc_distribution<T>& d, const T& r){ return cdf(static_cast<non_central_f_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const fnc_distribution<T>& d, const T& r){ return quantile(static_cast<non_central_f_distribution<T> >(d), r); }
+ template <class T>
+ T cdf(const gam_distribution<T>& d, const T& r){ return cdf(static_cast<gamma_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const gam_distribution<T>& d, const T& r){ return quantile(static_cast<gamma_distribution<T> >(d), r); }
+ template <class T>
+ T cdf(const nor_distribution<T>& d, const T& r){ return cdf(static_cast<normal_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const nor_distribution<T>& d, const T& r){ return quantile(static_cast<normal_distribution<T> >(d), r); }
+ template <class T>
+ T cdf(const poi_distribution<T>& d, const T& r){ return cdf(static_cast<poisson_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const poi_distribution<T>& d, const T& r){ return quantile(static_cast<poisson_distribution<T> >(d), r); }
+ template <class T>
+ T cdf(const t_distribution<T>& d, const T& r){ return cdf(static_cast<students_t_distribution<T> >(d), r); }
+ template <class T>
+ T quantile(const t_distribution<T>& d, const T& r){ return quantile(static_cast<students_t_distribution<T> >(d), r); }
+
+}}
+
+bool check_near(double a, double b)
+{
+ bool r = ((fabs(a) <= 1e-7) || (fabs(b) <= 1e-7)) ? (fabs(a-b) < 1e-7) : fabs((a - b) / a) < 1e-5;
+ return r;
+}
+
+#define BOOST_MATH_DCD_DISTRIBUTION3_TEST(name, param1_table, param2_table, param3_table, random_variable_table, probability_table) \
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist, name), "dist-" BOOST_STRINGIZE(name) "-dcd-cdf")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned b_size = sizeof(param2_table)/sizeof(param2_table[0]);\
+ unsigned c_size = sizeof(param3_table)/sizeof(param3_table[0]);\
+ unsigned d_size = sizeof(random_variable_table)/sizeof(random_variable_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned j = 0; j < b_size; ++j)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ for(unsigned l = 0; l < d_size; ++l)\
+ {\
+ int which = 1;\
+ double p; double q; \
+ double rv = random_variable_table[l];\
+ double a = param1_table[i];\
+ double b = param2_table[j];\
+ double c = param3_table[k];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &b, &c, &status, &bound);\
+ result += p;\
+ BOOST_ASSERT(\
+ (status != 0) || check_near(p, \
+ cdf(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i], param2_table[j], param3_table[k]), random_variable_table[l])\
+ ));\
+ }\
+ }\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * b_size * c_size * d_size);\
+ }\
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist_quant, name), "dist-" BOOST_STRINGIZE(name) "-dcd-quantile")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned b_size = sizeof(param2_table)/sizeof(param2_table[0]);\
+ unsigned c_size = sizeof(param3_table)/sizeof(param3_table[0]);\
+ unsigned d_size = sizeof(probability_table)/sizeof(probability_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned j = 0; j < b_size; ++j)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ for(unsigned l = 0; l < d_size; ++l)\
+ {\
+ int which = 2;\
+ double p = probability_table[l];\
+ double q = 1 - p; \
+ double rv;\
+ double a = param1_table[i];\
+ double b = param2_table[j];\
+ double c = param3_table[k];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &b, &c, &status, &bound);\
+ result += rv;\
+ BOOST_ASSERT((status != 0) || (p > 0.99) || check_near(rv, quantile(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i], param2_table[j], param3_table[k]), probability_table[l])));\
+ }\
+ }\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * b_size * c_size * d_size);\
+ }
+
+#define BOOST_MATH_DCD_DISTRIBUTION2_TEST(name, param1_table, param2_table, random_variable_table, probability_table) \
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist, name), "dist-" BOOST_STRINGIZE(name) "-dcd-cdf")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned b_size = sizeof(param2_table)/sizeof(param2_table[0]);\
+ unsigned c_size = sizeof(random_variable_table)/sizeof(random_variable_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned j = 0; j < b_size; ++j)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ int which = 1;\
+ double p; double q; \
+ double rv = random_variable_table[k];\
+ double a = param1_table[i];\
+ double b = param2_table[j];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &b, &status, &bound);\
+ result += p;\
+ BOOST_ASSERT((status != 0) || check_near(p, cdf(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i], param2_table[j]), random_variable_table[k])));\
+ }\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * b_size * c_size);\
+ }\
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist_quant, name), "dist-" BOOST_STRINGIZE(name) "-dcd-quantile")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned b_size = sizeof(param2_table)/sizeof(param2_table[0]);\
+ unsigned c_size = sizeof(probability_table)/sizeof(probability_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned j = 0; j < b_size; ++j)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ int which = 2;\
+ double p = probability_table[k];\
+ double q = 1 - p; \
+ double rv;\
+ double a = param1_table[i];\
+ double b = param2_table[j];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &b, &status, &bound);\
+ result += rv;\
+ BOOST_ASSERT((status != 0) || (p > 0.99) || check_near(rv, quantile(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i], param2_table[j]), probability_table[k])));\
+ }\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * b_size * c_size);\
+ }
+
+#define BOOST_MATH_DCD_DISTRIBUTION1_TEST(name, param1_table, random_variable_table, probability_table) \
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist, name), "dist-" BOOST_STRINGIZE(name) "-dcd-cdf")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned c_size = sizeof(random_variable_table)/sizeof(random_variable_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ int which = 1;\
+ double p; double q; \
+ double rv = random_variable_table[k];\
+ double a = param1_table[i];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &status, &bound);\
+ result += p;\
+ BOOST_ASSERT((status != 0) || check_near(p, cdf(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i]), random_variable_table[k])));\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * c_size);\
+ }\
+ BOOST_MATH_PERFORMANCE_TEST(BOOST_JOIN(dcd_dist_quant, name), "dist-" BOOST_STRINGIZE(name) "-dcd-quantile")\
+ {\
+ double result = 0;\
+ unsigned a_size = sizeof(param1_table)/sizeof(param1_table[0]);\
+ unsigned c_size = sizeof(probability_table)/sizeof(probability_table[0]);\
+ \
+ for(unsigned i = 0; i < a_size; ++i)\
+ {\
+ for(unsigned k = 0; k < c_size; ++k)\
+ {\
+ int which = 2;\
+ double p = probability_table[k];\
+ double q = 1 - p; \
+ double rv;\
+ double a = param1_table[i];\
+ int status = 0;\
+ double bound = 0;\
+ BOOST_JOIN(cdf, name)(&which, &p, &q, &rv, &a, &status, &bound);\
+ result += rv;\
+ BOOST_ASSERT((status != 0) || (p > 0.99) || check_near(rv, quantile(boost::math:: BOOST_JOIN(name, _distribution) <>(param1_table[i]), probability_table[k])));\
+ }\
+ }\
+ \
+ consume_result(result);\
+ set_call_count(a_size * c_size);\
+ }
+
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(beta, probabilities, probabilities, probabilities, probabilities) // ??
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(binomial, int_values, probabilities, int_values, probabilities) // OK ish
+BOOST_MATH_DCD_DISTRIBUTION1_TEST(chi_squared, int_values, real_values, probabilities) // OK
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(non_central_chi_squared, int_values, int_values, real_values, probabilities) // Error rates quite high for DCD version?
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(f, int_values, int_values, real_values, probabilities) // OK
+BOOST_MATH_DCD_DISTRIBUTION3_TEST(fnc, int_values, int_values, real_values, real_values, probabilities) // Error rates quite high for DCD version?
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(gam, real_values, real_values, real_values, probabilities) // ??
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(negative_binomial, int_values, probabilities, int_values, probabilities) // OK
+BOOST_MATH_DCD_DISTRIBUTION2_TEST(nor, real_values, real_values, real_values, probabilities) // OK
+BOOST_MATH_DCD_DISTRIBUTION1_TEST(poi, real_values, int_values, probabilities) // OK
+BOOST_MATH_DCD_DISTRIBUTION1_TEST(t, int_values, real_values, probabilities) // OK
+
+#endif

Added: trunk/libs/math/performance/test_beta.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/math/performance/test_beta.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -0,0 +1,67 @@
+// Copyright John Maddock 2009.
+// 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)
+
+#include "required_defines.hpp"
+
+#include "performance_measure.hpp"
+
+#include <boost/math/special_functions/beta.hpp>
+#include <boost/array.hpp>
+
+#define T double
+# include "../test/beta_small_data.ipp"
+# include "../test/beta_med_data.ipp"
+# include "../test/beta_exp_data.ipp"
+
+template <std::size_t N>
+double beta_evaluate2(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ result += boost::math::beta(data[i][0], data[i][1]);
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(beta_test, "beta")
+{
+ double result = beta_evaluate2(beta_small_data);
+ result += beta_evaluate2(beta_med_data);
+ result += beta_evaluate2(beta_exp_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(beta_small_data)
+ + sizeof(beta_med_data)
+ + sizeof(beta_exp_data)) / sizeof(beta_exp_data[0]));
+}
+
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+template <std::size_t N>
+double beta_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ result += ::beta(data[i][0], data[i][1]);
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(beta_test_dcd, "beta-dcd")
+{
+ double result = beta_evaluate2_dcd(beta_small_data);
+ result += beta_evaluate2_dcd(beta_med_data);
+ result += beta_evaluate2_dcd(beta_exp_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(beta_small_data)
+ + sizeof(beta_med_data)
+ + sizeof(beta_exp_data)) / sizeof(beta_exp_data[0]));
+}
+
+#endif
+
+

Modified: trunk/libs/math/performance/test_erf.cpp
==============================================================================
--- trunk/libs/math/performance/test_erf.cpp (original)
+++ trunk/libs/math/performance/test_erf.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -107,3 +107,30 @@
 #endif
 
 
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+template <std::size_t N>
+double erf_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double x = data[i][0];
+ result += error_f(&x);
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(erf_test_dcd, "erf-dcd")
+{
+ double result = erf_evaluate2_dcd(erf_data);
+ result += erf_evaluate2_dcd(erf_large_data);
+ result += erf_evaluate2_dcd(erf_small_data);
+
+ consume_result(result);
+ set_call_count((sizeof(erf_data) + sizeof(erf_large_data) + sizeof(erf_small_data)) / sizeof(erf_data[0]));
+}
+
+#endif
+

Added: trunk/libs/math/performance/test_expm1_log1p.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/math/performance/test_expm1_log1p.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -0,0 +1,100 @@
+// Copyright John Maddock 2009.
+// 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)
+
+#include "required_defines.hpp"
+
+#include "performance_measure.hpp"
+
+#include <boost/math/special_functions/log1p.hpp>
+#include <boost/math/special_functions/expm1.hpp>
+#include <boost/array.hpp>
+
+#define T double
+# include "../test/log1p_expm1_data.ipp"
+
+template <std::size_t N>
+double log1p_evaluate2(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ result += boost::math::log1p(data[i][0]);
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(log1p_test, "log1p")
+{
+ double result = log1p_evaluate2(log1p_expm1_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(log1p_expm1_data)) / sizeof(log1p_expm1_data[0]));
+}
+
+template <std::size_t N>
+double expm1_evaluate2(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ result += boost::math::expm1(data[i][0]);
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(expm1_test, "expm1")
+{
+ double result = expm1_evaluate2(log1p_expm1_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(log1p_expm1_data)) / sizeof(log1p_expm1_data[0]));
+}
+
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+template <std::size_t N>
+double log1p_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double t = data[i][0];
+ result += ::alnrel(&t);
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(log1p_test_dcd, "log1p-dcd")
+{
+ double result = log1p_evaluate2_dcd(log1p_expm1_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(log1p_expm1_data)) / sizeof(log1p_expm1_data[0]));
+}
+
+template <std::size_t N>
+double expm1_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double t = data[i][0];
+ result += ::dexpm1(&t);
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(expm1_test_dcd, "expm1-dcd")
+{
+ double result = expm1_evaluate2_dcd(log1p_expm1_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(log1p_expm1_data)) / sizeof(log1p_expm1_data[0]));
+}
+
+#endif
+
+

Modified: trunk/libs/math/performance/test_gamma.cpp
==============================================================================
--- trunk/libs/math/performance/test_gamma.cpp (original)
+++ trunk/libs/math/performance/test_gamma.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -198,3 +198,69 @@
 
 #endif
 
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+template <std::size_t N>
+double gamma_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double x = data[i][0];
+ result += gamma_x(&x);
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(gamma_test_dcd, "gamma-dcd")
+{
+ double result = gamma_evaluate2_dcd(factorials);
+ result += gamma_evaluate2_dcd(near_1);
+ result += gamma_evaluate2_dcd(near_2);
+ result += gamma_evaluate2_dcd(near_0);
+ result += gamma_evaluate2_dcd(near_m10);
+ result += gamma_evaluate2_dcd(near_m55);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(factorials)
+ + sizeof(near_1)
+ + sizeof(near_2)
+ + sizeof(near_0)
+ + sizeof(near_m10)
+ + sizeof(near_m55)) / sizeof(factorials[0]));
+}
+
+template <std::size_t N>
+double lgamma_evaluate2_dcd(const boost::array<boost::array<T, 3>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double x = data[i][0];
+ result += gamma_log(&x);
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(lgamma_test_dcd, "lgamma-dcd")
+{
+ double result = lgamma_evaluate2_dcd(factorials);
+ result += lgamma_evaluate2_dcd(near_1);
+ result += lgamma_evaluate2_dcd(near_2);
+ result += lgamma_evaluate2_dcd(near_0);
+ result += lgamma_evaluate2_dcd(near_m10);
+ result += lgamma_evaluate2_dcd(near_m55);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(factorials)
+ + sizeof(near_1)
+ + sizeof(near_2)
+ + sizeof(near_0)
+ + sizeof(near_m10)
+ + sizeof(near_m55)) / sizeof(factorials[0]));
+}
+
+#endif
\ No newline at end of file

Modified: trunk/libs/math/performance/test_ibeta.cpp
==============================================================================
--- trunk/libs/math/performance/test_ibeta.cpp (original)
+++ trunk/libs/math/performance/test_ibeta.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -189,3 +189,40 @@
 
 #endif
 
+#ifdef TEST_DCDFLIB
+#include <dcdflib.h>
+
+template <std::size_t N>
+double ibeta_evaluate2_dcd(const boost::array<boost::array<T, 7>, N>& data)
+{
+ double result = 0;
+ for(unsigned i = 0; i < N; ++i)
+ {
+ double a = data[i][0];
+ double b = data[i][1];
+ double x = data[i][2];
+ double y = 1 - x;
+ double w, w1;
+ int ierr;
+ beta_inc (&a, &b, &x, &y, &w, &w1, &ierr);
+ result += w;
+ }
+ return result;
+}
+
+BOOST_MATH_PERFORMANCE_TEST(ibeta_test_dcd, "ibeta-dcd")
+{
+ double result = ibeta_evaluate2_dcd(ibeta_data);
+ result += ibeta_evaluate2_dcd(ibeta_int_data);
+ result += ibeta_evaluate2_dcd(ibeta_large_data);
+ result += ibeta_evaluate2_dcd(ibeta_small_data);
+
+ consume_result(result);
+ set_call_count(
+ (sizeof(ibeta_data)
+ + sizeof(ibeta_int_data)
+ + sizeof(ibeta_large_data)
+ + sizeof(ibeta_small_data)) / sizeof(ibeta_data[0]));
+}
+
+#endif
\ No newline at end of file

Modified: trunk/libs/math/performance/test_igamma.cpp
==============================================================================
--- trunk/libs/math/performance/test_igamma.cpp (original)
+++ trunk/libs/math/performance/test_igamma.cpp 2009-10-08 05:54:54 EDT (Thu, 08 Oct 2009)
@@ -287,25 +287,3 @@
 
 #endif
 
-double x = 0.165048161769598689119220580323599278926849365234375e-11;
-double y = 0.165048164480104120332981665342231281101703643798828125e-13;
-
-BOOST_MATH_PERFORMANCE_TEST(igamma_scrap, "igamma_scrap")
-{
- //double result = boost::math::gamma_q(x, y);
- double result = igamma_evaluate2(igamma_small_data);
- //result += dcd::gamma_p(x, y);
-
- consume_result(result);
- set_call_count(1);
-}
-
-BOOST_MATH_PERFORMANCE_TEST(igamma_scrap, "igamma_scrap-dcd")
-{
- //double result = dcd::gamma_q(x, y);
- double result = igamma_evaluate2_dcd(igamma_small_data);
-
- consume_result(result);
- set_call_count(1);
-}
-


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