|
Boost-Commit : |
From: pbristow_at_[hidden]
Date: 2008-03-10 13:53:15
Author: pbristow
Date: 2008-03-10 13:53:15 EDT (Mon, 10 Mar 2008)
New Revision: 43551
URL: http://svn.boost.org/trac/boost/changeset/43551
Log:
Changed logic of error as suggested by johneddy101_at_[hidden] similar to uniform
Text files modified:
sandbox/math_toolkit/boost/math/distributions/triangular.hpp | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
Modified: sandbox/math_toolkit/boost/math/distributions/triangular.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/triangular.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/triangular.hpp 2008-03-10 13:53:15 EDT (Mon, 10 Mar 2008)
@@ -106,12 +106,21 @@
RealType upper,
RealType* result, const Policy& pol)
{
- if(check_triangular_lower(function, lower, result, pol)
- && check_triangular_mode(function, mode, result, pol)
- && check_triangular_upper(function, upper, result, pol)
- && (lower < upper) // lower == upper NOT useful.
- )
- {
+ if ((check_triangular_lower(function, lower, result, pol) == false)
+ || (check_triangular_mode(function, mode, result, pol) == false)
+ || (check_triangular_upper(function, upper, result, pol) == false))
+ { // Some parameter not finite.
+ return false;
+ }
+ else if (lower >= upper) // lower == upper NOT useful.
+ { // lower >= upper.
+ *result = policies::raise_domain_error<RealType>(
+ function,
+ "lower parameter is %1%, but must be less than upper!", lower, pol);
+ return false;
+ }
+ else
+ { // Check lower <= mode <= upper.
if (mode < lower)
{
*result = policies::raise_domain_error<RealType>(
@@ -119,21 +128,14 @@
"mode parameter is %1%, but must be >= than lower!", lower, pol);
return false;
}
- if (mode > upper )
+ if (mode > upper)
{
*result = policies::raise_domain_error<RealType>(
function,
"mode parameter is %1%, but must be <= than upper!", upper, pol);
return false;
}
- return true;
- }
- else
- { // upper and lower have each been checked before, so must be lower >= upper.
- *result = policies::raise_domain_error<RealType>(
- function,
- "lower parameter is %1%, but must be less than upper!", lower, pol);
- return false;
+ return true; // All OK.
}
} // bool check_triangular
} // namespace detail
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