Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80117 - trunk/boost/math/distributions/detail
From: pbristow_at_[hidden]
Date: 2012-08-21 13:37:21


Author: pbristow
Date: 2012-08-21 13:37:20 EDT (Tue, 21 Aug 2012)
New Revision: 80117
URL: http://svn.boost.org/trac/boost/changeset/80117

Log:
Added df >0 and infinite test, used by students t and non-central t.
Text files modified:
   trunk/boost/math/distributions/detail/common_error_handling.hpp | 20 +++++++++++++++++---
   1 files changed, 17 insertions(+), 3 deletions(-)

Modified: trunk/boost/math/distributions/detail/common_error_handling.hpp
==============================================================================
--- trunk/boost/math/distributions/detail/common_error_handling.hpp (original)
+++ trunk/boost/math/distributions/detail/common_error_handling.hpp 2012-08-21 13:37:20 EDT (Tue, 21 Aug 2012)
@@ -1,5 +1,5 @@
 // Copyright John Maddock 2006, 2007.
-// Copyright Paul A. Bristow 2006, 2007.
+// Copyright Paul A. Bristow 2006, 2007, 2012.
 
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
@@ -12,7 +12,7 @@
 #include <boost/math/policies/error_handling.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
 // using boost::math::isfinite;
-
+// using boost::math::isnan;
 
 namespace boost{ namespace math{ namespace detail
 {
@@ -32,7 +32,7 @@
 
 template <class RealType, class Policy>
 inline bool check_df(const char* function, RealType const& df, RealType* result, const Policy& pol)
-{
+{ // df > 0 but NOT +infinity allowed.
    if((df <= 0) || !(boost::math::isfinite)(df))
    {
       *result = policies::raise_domain_error<RealType>(
@@ -44,6 +44,20 @@
 }
 
 template <class RealType, class Policy>
+inline bool check_df_gt0_to_inf(const char* function, RealType const& df, RealType* result, const Policy& pol)
+{ // df > 0 or +infinity are allowed.
+ if( (df <= 0) || (boost::math::isnan)(df) )
+ { // is bad df <= 0 or NaN or -infinity.
+ *result = policies::raise_domain_error<RealType>(
+ function,
+ "Degrees of freedom argument is %1%, but must be > 0 !", df, pol);
+ return false;
+ }
+ return true;
+} // check_df_gt0_to_inf
+
+
+template <class RealType, class Policy>
 inline bool check_scale(
       const char* function,
       RealType scale,


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