You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When checking input arguments, it's common to want min <= max. If this statement is not true, the program needs to error. One way to make sure the statement is true is to assert that it is true. E.g., with:
BOOST_MATH_ASSERT(min <= max);
A common way of checking the assertion that min <= max in the Boost codebase is to use the construction:
if (min > max) {
returnpolicies::raise_evaluation_error(function, "assertion min <= max failed (first arg=%1%)", min, boost::math::policies::policy<>());
}
The first approach has three advantages over the second approach:
gives x0 = nan, even though the lower bound is inf.
NOTE:
The six comparison operators are: ==, <, <=, >, >=, and !=. For all comparison operators besides !=, if one or both of the arguments are nan, the result is false according to the IEEE standard.
The text was updated successfully, but these errors were encountered:
The issue with assertions is that they are debug only, once the program is built with -D_NDEBUG=1 they disappear.
The six comparison operators are: ==, <, <=, >, >=, and !=. For all comparison operators besides !=, if one or both of the arguments are nan, the result is false according to the IEEE standard.
True, however it is common for programs to be compiled with options (often the default for release builds) where the NaN's are assumed to simply not exist and these assumptions no longer hold. Besides which if(!(min < max)) would have the same logic as your assertion.
When checking input arguments, it's common to want
min <= max
. If this statement is not true, the program needs to error. One way to make sure the statement is true is to assert that it is true. E.g., with:BOOST_MATH_ASSERT(min <= max);
A common way of checking the assertion that
min <= max
in the Boost codebase is to use the construction:The first approach has three advantages over the second approach:
nan
. E.g.,gives
x0 = nan
, even though the lower bound isinf
.NOTE:
The six comparison operators are:
==
,<
,<=
,>
,>=
, and!=
. For all comparison operators besides!=
, if one or both of the arguments arenan
, the result isfalse
according to the IEEE standard.The text was updated successfully, but these errors were encountered: