...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Most of the time you can just ignore the policy framework.
*The defaults for the various policies are as follows, if these work OK for you then you can stop reading now!
Throws a std::domain_error
exception.
Occurs when a function is evaluated at a pole: throws a std::domain_error
exception.
Throws a std::overflow_error
exception.
Ignores the underflow, and returns zero.
Ignores the fact that the result is denormalised, and returns it.
Throws a boost::math::rounding_error
exception.
Throws a boost::math::evaluation_error
exception.
Returns a result that depends on the function where the error occurred.
Does occur by default - gives full float precision results.
Does occur by default if long double offers more precision than double.
By default uses an approximation that will result in the lowest level of error for the type of the result.
The quantile function will by default return an integer result that has been rounded outwards. That is to say lower quantiles (where the probability is less than 0.5) are rounded downward, and upper quantiles (where the probability is greater than 0.5) are rounded upwards. This behaviour ensures that if an X% quantile is requested, then at least the requested coverage will be present in the central region, and no more than the requested coverage will be present in the tails.
This behaviour can be changed so that the quantile functions are rounded differently, or even return a real-valued result using Policies. It is strongly recommended that you read the tutorial Understanding Quantiles of Discrete Distributions before using the quantile function on a discrete distribution. The reference docs describe how to change the rounding policy for these distributions.
What's more, if you define your own policy type, then it automatically inherits the defaults for any policies not explicitly set, so given:
using namespace boost::math::policies; // // Define a policy that sets ::errno on overflow, and does // not promote double to long double internally: // typedef policy<domain_error<errno_on_error>, promote_double<false> > mypolicy;
then mypolicy
defines a
policy where only the overflow error handling and double
-promotion
policies differ from the defaults.