|
Boost-Commit : |
From: pbristow_at_[hidden]
Date: 2007-09-12 05:40:10
Author: pbristow
Date: 2007-09-12 05:40:10 EDT (Wed, 12 Sep 2007)
New Revision: 39209
URL: http://svn.boost.org/trac/boost/changeset/39209
Log:
added check location and check_x (random deviate)
and changed check scale to not permit 0
Text files modified:
sandbox/math_toolkit/boost/math/distributions/detail/common_error_handling.hpp | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
Modified: sandbox/math_toolkit/boost/math/distributions/detail/common_error_handling.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/detail/common_error_handling.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/detail/common_error_handling.hpp 2007-09-12 05:40:10 EDT (Wed, 12 Sep 2007)
@@ -11,6 +11,7 @@
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
+// using boost::math::isfinite;
namespace boost{ namespace math{ namespace detail
{
@@ -48,8 +49,8 @@
RealType* result,
const Policy& pol)
{
- if((scale < 0) || !(boost::math::isfinite)(scale))
- {
+ if((scale <= 0) || !(boost::math::isfinite)(scale))
+ { // Assume scale == 0 is NOT valid for any distribution.
*result = policies::raise_domain_error<RealType>(
function,
"Scale parameter is %1%, but must be > 0 !", scale, pol);
@@ -58,6 +59,41 @@
return true;
}
+template <class RealType, class Policy>
+inline bool check_location(
+ const char* function,
+ RealType location,
+ RealType* result,
+ const Policy& pol)
+{
+ if(!(boost::math::isfinite)(location))
+ {
+ *result = policies::raise_domain_error<RealType>(
+ function,
+ "Location parameter is %1%, but must be finite!", location, pol);
+ return false;
+ }
+ return true;
+}
+
+template <class RealType, class Policy>
+inline bool check_x(
+ const char* function,
+ RealType location,
+ RealType* result,
+ const Policy& pol)
+{
+ if(!(boost::math::isfinite)(location))
+ {
+ *result = policies::raise_domain_error<RealType>(
+ function,
+ "Random variate x is %1%, but must be finite!", location, pol);
+ return false;
+ }
+ return true;
+}
+
+
} // namespace detail
} // namespace math
} // namespace boost
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