From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../math_toolkit/pol_ref/assert_undefined.html | 102 +++ .../math_toolkit/pol_ref/discrete_quant_ref.html | 252 +++++++ .../pol_ref/error_handling_policies.html | 773 +++++++++++++++++++++ .../math_toolkit/pol_ref/internal_promotion.html | 150 ++++ .../html/math_toolkit/pol_ref/iteration_pol.html | 67 ++ .../html/math_toolkit/pol_ref/namespace_pol.html | 157 +++++ .../doc/html/math_toolkit/pol_ref/pol_ref_ref.html | 258 +++++++ .../html/math_toolkit/pol_ref/policy_defaults.html | 258 +++++++ .../html/math_toolkit/pol_ref/precision_pol.html | 110 +++ 9 files changed, 2127 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/assert_undefined.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/discrete_quant_ref.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/error_handling_policies.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/internal_promotion.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/iteration_pol.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/namespace_pol.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/pol_ref_ref.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/policy_defaults.html create mode 100644 boost/libs/math/doc/html/math_toolkit/pol_ref/precision_pol.html (limited to 'boost/libs/math/doc/html/math_toolkit/pol_ref') diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/assert_undefined.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/assert_undefined.html new file mode 100644 index 00000000..54506078 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/assert_undefined.html @@ -0,0 +1,102 @@ + + + +Mathematically Undefined Function Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ There are some functions that are generic (they are present for all the statistical + distributions supported) but which may be mathematically undefined for certain + distributions, but defined for others. +

+

+ For example, the Cauchy distribution does not have a meaningful mean, so + what should +

+
mean(cauchy<>());
+
+

+ return, and should such an expression even compile at all? +

+

+ The default behaviour is for all such functions to not compile at all - in + fact they will raise a static + assertion - but by changing the policy we can have them return the + result of a domain error instead (which may well throw an exception, depending + on the error handling policy). +

+

+ This behaviour is controlled by the assert_undefined<> policy: +

+
namespace boost{ namespace math{ namespace policies {
+
+template <bool b>
+class assert_undefined;
+
+}}} //namespaces
+
+

+ For example: +

+
#include <boost/math/distributions/cauchy.hpp>
+
+using namespace boost::math::policies;
+using namespace boost::math;
+
+// This will not compile, cauchy has no mean!
+double m1 = mean(cauchy());
+
+// This will compile, but raises a domain error!
+double m2 = mean(cauchy_distribution<double, policy<assert_undefined<false> > >());
+
+

+ policy<assert_undefined<false> + behaviour can also be obtained by defining the macro +

+
#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
+
+

+ at the head of the file - see Using + Macros to Change the Policy Defaults. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/discrete_quant_ref.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/discrete_quant_ref.html new file mode 100644 index 00000000..2d8a6364 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/discrete_quant_ref.html @@ -0,0 +1,252 @@ + + + +Discrete Quantile Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ If a statistical distribution is discrete then the random + variable can only have integer values - this leaves us with a problem when + calculating quantiles - we can either ignore the discreteness of the distribution + and return a real value, or we can round to an integer. As it happens, computing + integer values can be substantially faster than calculating a real value, + so there are definite advantages to returning an integer, but we do then + need to decide how best to round the result. The discrete_quantile + policy defines how discrete quantiles work, and how integer results are rounded: +

+
enum discrete_quantile_policy_type
+{
+   real,
+   integer_round_outwards, // default
+   integer_round_inwards,
+   integer_round_down,
+   integer_round_up,
+   integer_round_nearest
+};
+
+template <discrete_quantile_policy_type>
+struct discrete_quantile;
+
+

+ The values that discrete_quantile + can take have the following meanings: +

+
+ + real +
+

+ Ignores the discreteness of the distribution, and returns a real-valued result. + For example: +

+
#include <boost/math/distributions/negative_binomial.hpp>
+using boost::math::negative_binomial_distribution;
+
+using namespace boost::math::policies;
+
+typedef negative_binomial_distribution<
+      double,
+      policy<discrete_quantile<real> >
+   > dist_type;
+
+// Lower 5% quantile:
+double x = quantile(dist_type(20, 0.3), 0.05);
+// Upper 95% quantile:
+double y = quantile(complement(dist_type(20, 0.3), 0.05));
+
+

+ Results in x = + 27.3898 and y + = 68.1584. +

+
+ + integer_round_outwards +
+

+ This is the default policy: an integer value is returned so that: +

+
    +
  • + Lower quantiles (where the probability is less than 0.5) are rounded + down. +
  • +
  • + Upper quantiles (where the probability is greater than 0.5) are rounded + up. +
  • +
+

+ This is normally the safest rounding policy, since it ensures that both one + and two sided intervals are guaranteed to have at least + the requested coverage. For example: +

+
#include <boost/math/distributions/negative_binomial.hpp>
+using boost::math::negative_binomial;
+
+// Use the default rounding policy integer_round_outwards.
+// Lower quantile rounded down:
+double x = quantile(negative_binomial(20, 0.3), 0.05); // rounded up 27 from 27.3898
+// Upper quantile rounded up:
+double y = quantile(complement(negative_binomial(20, 0.3), 0.05)); // rounded down to 69 from 68.1584
+
+

+ Results in x = + 27 (rounded down from 27.3898) and + y = + 69 (rounded up from 68.1584). +

+

+ The variables x and y are now defined so that: +

+
cdf(negative_binomial(20), x) <= 0.05
+cdf(negative_binomial(20), y) >= 0.95
+
+

+ In other words we guarantee at least 90% coverage in the central + region overall, and also no more than 5% coverage in + each tail. +

+
+ + integer_round_inwards +
+

+ This is the opposite of integer_round_outwards: an integer + value is returned so that: +

+
    +
  • + Lower quantiles (where the probability is less than 0.5) are rounded + up. +
  • +
  • + Upper quantiles (where the probability is greater than 0.5) are rounded + down. +
  • +
+

+ For example: +

+
#include <boost/math/distributions/negative_binomial.hpp>
+using boost::math::negative_binomial_distribution;
+
+using namespace boost::math::policies;
+
+typedef negative_binomial_distribution<
+      double,
+      policy<discrete_quantile<integer_round_inwards> >
+   > dist_type;
+
+// Lower quantile rounded up:
+double x = quantile(dist_type(20, 0.3), 0.05); // 28 rounded up from 27.3898
+// Upper quantile rounded down:
+double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68 rounded down from 68.1584
+
+

+ Results in x = + 28 (rounded up from 27.3898) and y = 68 + (rounded down from 68.1584). +

+

+ The variables x and y are now defined so that: +

+
cdf(negative_binomial(20), x) >= 0.05
+cdf(negative_binomial(20), y) <= 0.95
+
+

+ In other words we guarantee at no more than 90% coverage in the + central region overall, and also at least 5% coverage + in each tail. +

+
+ + integer_round_down +
+

+ Always rounds down to an integer value, no matter whether it's an upper or + a lower quantile. +

+
+ + integer_round_up +
+

+ Always rounds up to an integer value, no matter whether it's an upper or + a lower quantile. +

+
+ + integer_round_nearest +
+

+ Always rounds to the nearest integer value, no matter whether it's an upper + or a lower quantile. This will produce the requested coverage in + the average case, but for any specific example may results in + either significantly more or less coverage than the requested amount. For + example: +

+

+ For example: +

+
#include <boost/math/distributions/negative_binomial.hpp>
+using boost::math::negative_binomial_distribution;
+
+using namespace boost::math::policies;
+
+typedef negative_binomial_distribution<
+      double,
+      policy<discrete_quantile<integer_round_nearest> >
+   > dist_type;
+
+// Lower quantile rounded (down) to nearest:
+double x = quantile(dist_type(20, 0.3), 0.05); // 27
+// Upper quantile rounded (down) to nearest:
+double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68
+
+

+ Results in x = + 27 (rounded from 27.3898) and y = 68 + (rounded from 68.1584). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/error_handling_policies.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/error_handling_policies.html new file mode 100644 index 00000000..685334d9 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/error_handling_policies.html @@ -0,0 +1,773 @@ + + + +Error Handling Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ There are two orthogonal aspects to error handling: +

+
    +
  • + What to do (if anything) with the error. +
  • +
  • + What kind of error is being raised. +
  • +
+
+ + Available + Actions When an Error is Raised +
+

+ What to do with the error is encapsulated by an enumerated type: +

+
namespace boost { namespace math { namespace policies {
+
+enum error_policy_type
+{
+   throw_on_error = 0, // throw an exception.
+   errno_on_error = 1, // set ::errno & return 0, NaN, infinity or best guess.
+   ignore_error = 2, // return 0, NaN, infinity or best guess.
+   user_error = 3  // call a user-defined error handler.
+};
+
+}}} // namespaces
+
+

+ The various enumerated values have the following meanings: +

+
+ + throw_on_error +
+

+ Will throw one of the following exceptions, depending upon the type of the + error: +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Error Type +

+
+

+ Exception +

+
+

+ Domain Error +

+
+

+ std::domain_error +

+
+

+ Pole Error +

+
+

+ std::domain_error +

+
+

+ Overflow Error +

+
+

+ std::overflow_error +

+
+

+ Underflow Error +

+
+

+ std::underflow_error +

+
+

+ Denorm Error +

+
+

+ std::underflow_error +

+
+

+ Evaluation Error +

+
+

+ boost::math::evaluation_error +

+
+

+ Indeterminate Result Error +

+
+

+ std::domain_error +

+
+
+ + errno_on_error +
+

+ Will set global ::errno + ::errno + to one of the following values depending upon the error type (often EDOM + = 33 and ERANGE = 34), and then return the same value as if the error had + been ignored: +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Error Type +

+
+

+ errno value +

+
+

+ Domain Error +

+
+

+ EDOM +

+
+

+ Pole Error +

+
+

+ EDOM +

+
+

+ Overflow Error +

+
+

+ ERANGE +

+
+

+ Underflow Error +

+
+

+ ERANGE +

+
+

+ Denorm Error +

+
+

+ ERANGE +

+
+

+ Evaluation Error +

+
+

+ EDOM +

+
+

+ Indeterminate Result Error +

+
+

+ EDOM +

+
+
+ + ignore_error +
+

+ Will return one of the values below depending on the error type (::errno + is NOT changed):: +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Error Type +

+
+

+ Returned Value +

+
+

+ Domain Error +

+
+

+ std::numeric_limits<T>::quiet_NaN() +

+
+

+ Pole Error +

+
+

+ std::numeric_limits<T>::quiet_NaN() +

+
+

+ Overflow Error +

+
+

+ std::numeric_limits<T>::infinity() +

+
+

+ Underflow Error +

+
+

+ 0 +

+
+

+ Denorm Error +

+
+

+ The denormalised value. +

+
+

+ Evaluation Error +

+
+

+ The best guess (perhaps NaN) as to the result: which may be significantly + in error. +

+
+

+ Indeterminate Result Error +

+
+

+ Depends on the function where the error occurred +

+
+
+ + user_error +
+

+ Will call a user defined error handler: these are forward declared in boost/math/policies/error_handling.hpp, + but the actual definitions must be provided by the user: +

+
namespace boost{ namespace math{ namespace policies{
+
+template <class T>
+T user_domain_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_pole_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_overflow_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_underflow_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_denorm_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_rounding_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_evaluation_error(const char* function, const char* message, const T& val);
+
+template <class T>
+T user_indeterminate_result_error(const char* function, const char* message, const T& val);
+
+}}} // namespaces
+
+

+ Note that the strings function and message + may contain "%1%" format specifiers designed to be used in conjunction + with Boost.Format. If these strings are to be presented to the program's + end-user then the "%1%" format specifier should be replaced with + the name of type T in the function string, and if there + is a %1% specifier in the message string then it should + be replaced with the value of val. +

+

+ There is more information on user-defined error handlers in the tutorial + here. +

+
+ + Kinds + of Error Raised +
+

+ There are six kinds of error reported by this library, which are summarised + in the following table: +

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Error Type +

+
+

+ Policy Class +

+
+

+ Description +

+
+

+ Domain Error +

+
+

+ boost::math::policies::domain_error<action> +

+
+

+ Raised when more or more arguments are outside the defined range + of the function. +

+

+ Defaults to boost::math::policies::domain_error<throw_on_error> +

+

+ When the action is set to throw_on_error then + throws std::domain_error +

+
+

+ Pole Error +

+
+

+ boost::math::policies::pole_error<action> +

+
+

+ Raised when more or more arguments would cause the function to + be evaluated at a pole. +

+

+ Defaults to boost::math::policies::pole_error<throw_on_error> +

+

+ When the action is throw_on_error then throw + a std::domain_error +

+
+

+ Overflow Error +

+
+

+ boost::math::policies::overflow_error<action> +

+
+

+ Raised when the result of the function is outside the representable + range of the floating point type used. +

+

+ Defaults to boost::math::policies::overflow_error<throw_on_error>. +

+

+ When the action is throw_on_error then throws + a std::overflow_error. +

+
+

+ Underflow Error +

+
+

+ boost::math::policies::underflow_error<action> +

+
+

+ Raised when the result of the function is too small to be represented + in the floating point type used. +

+

+ Defaults to boost::math::policies::underflow_error<ignore_error> +

+

+ When the specified action is throw_on_error + then throws a std::underflow_error +

+
+

+ Denorm Error +

+
+

+ boost::math::policies::denorm_error<action> +

+
+

+ Raised when the result of the function is a denormalised value. +

+

+ Defaults to boost::math::policies::denorm_error<ignore_error> +

+

+ When the action is throw_on_error then throws + a std::underflow_error +

+
+

+ Rounding Error +

+
+

+ boost::math::policies::rounding_error<action> +

+
+

+ Raised When one of the rounding functions round, + trunc or modf is called with + an argument that has no integer representation, or is too large + to be represented in the result type +

+

+ Defaults to boost::math::policies::rounding_error<throw_on_error> +

+

+ When the action is throw_on_error then throws + boost::math::rounding_error +

+
+

+ Evaluation Error +

+
+

+ boost::math::policies::evaluation_error<action> +

+
+

+ Raised when the result of the function is well defined and finite, + but we were unable to compute it. Typically this occurs when an + iterative method fails to converge. Of course ideally this error + should never be raised: feel free to report it as a bug if it is! +

+

+ Defaults to boost::math::policies::evaluation_error<throw_on_error> +

+

+ When the action is throw_on_error then throws + boost::math::evaluation_error +

+
+

+ Indeterminate Result Error +

+
+

+ boost::math::policies::indeterminate_result_error<action> +

+
+

+ Raised when the result of a function is not defined for the values + that were passed to it. +

+

+ Defaults to boost::math::policies::indeterminate_result_error<ignore_error> +

+

+ When the action is throw_on_error then throws + std::domain_error +

+
+
+ + Examples +
+

+ Suppose we want a call to tgamma + to behave in a C-compatible way and set global ::errno rather than throw an exception, we + can achieve this at the call site using: +

+
#include <boost/math/special_functions/gamma.hpp>
+using boost::math::tgamma;
+
+//using namespace boost::math::policies; may also be convenient.
+using boost::math::policies::policy;
+using boost::math::policies::evaluation_error;
+using boost::math::policies::domain_error;
+using boost::math::policies::overflow_error;
+using boost::math::policies::domain_error;
+using boost::math::policies::pole_error;
+using boost::math::policies::errno_on_error;
+
+// Define a policy:
+typedef policy<
+  domain_error<errno_on_error>,
+  pole_error<errno_on_error>,
+  overflow_error<errno_on_error>,
+  evaluation_error<errno_on_error>
+> my_policy;
+
+double my_value = 0.; // 
+
+// Call the function applying my_policy:
+double t1 = tgamma(my_value, my_policy());
+
+// Alternatively (and equivalently) we could use helpful function
+// make_policy and define everything at the call site:
+double t2 = tgamma(my_value,
+  make_policy(
+    domain_error<errno_on_error>(),
+    pole_error<errno_on_error>(),
+    overflow_error<errno_on_error>(),
+    evaluation_error<errno_on_error>() )
+  );
+
+

+ Suppose we want a statistical distribution to return infinities, rather than + throw exceptions, then we can use: +

+
#include <boost/math/distributions/normal.hpp>
+using boost::math::normal_distribution;
+
+using namespace boost::math::policies;
+
+// Define a specific policy:
+typedef policy<
+      overflow_error<ignore_error>
+      > my_policy;
+
+// Define the distribution, using my_policy:
+typedef normal_distribution<double, my_policy> my_norm;
+
+// Construct a my_norm distribution, using default mean and standard deviation,
+// and get a 0.05 or 5% quantile:
+double q = quantile(my_norm(), 0.05); // = -1.64485
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/internal_promotion.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/internal_promotion.html new file mode 100644 index 00000000..efadea7b --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/internal_promotion.html @@ -0,0 +1,150 @@ + + + +Internal Floating-point Promotion Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Normally when evaluating a function at say float + precision, maximal accuracy is assured by conducting the calculation at + double precision internally, + and then rounding the result. There are two policies that control whether + internal promotion to a higher precision floating-point type takes place, + or not: +

+
++++ + + + + + + + + + + + + + + +
+

+ Policy +

+
+

+ Meaning +

+
+

+ boost::math::policies::promote_float<B> +

+
+

+ Indicates whether float + arguments should be promoted to double + precision internally: defaults to boost::math::policies::promote_float<true> +

+
+

+ boost::math::policies::promote_double<B> +

+
+

+ Indicates whether double + arguments should be promoted to long + double precision internally: + defaults to boost::math::policies::promote_double<true> +

+
+
+ + Examples +
+

+ Suppose we want tgamma to + be evaluated without internal promotion to long + double, then we could use: +

+
#include <boost/math/special_functions/gamma.hpp>
+
+using namespace boost::math::policies;
+using boost::math::tgamma;
+
+// Define a new policy *not* internally promoting RealType to double:
+typedef policy<
+      promote_double<false>
+      > my_policy;
+
+// Call the function, applying the new policy:
+double t1 = tgamma(some_value, my_policy());
+
+// Alternatively we could use helper function make_policy,
+// and concisely define everything at the call site:
+double t2 = tgamma(some_value, make_policy(promote_double<false>()));
+
+

+ Alternatively, suppose we want a distribution to perform calculations without + promoting float to double, then we could use: +

+
#include <boost/math/distributions/normal.hpp>
+using boost::math::normal_distribution;
+
+using namespace boost::math::policies;
+
+// Define a policy:
+typedef policy<
+      promote_float<false>
+      > my_policy;
+
+// Define the new normal distribution using my_policy:
+typedef normal_distribution<float, my_policy> my_norm;
+
+// Get a quantile:
+float q = quantile(my_norm(), 0.05f);
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/iteration_pol.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/iteration_pol.html new file mode 100644 index 00000000..c37b4924 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/iteration_pol.html @@ -0,0 +1,67 @@ + + + +Iteration Limits Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ There are two policies that effect the iterative algorithms used to implement + the special functions in this library: +

+
template <unsigned long limit = BOOST_MATH_MAX_SERIES_ITERATION_POLICY>
+class max_series_iterations;
+
+template <unsigned long limit = BOOST_MATH_MAX_ROOT_ITERATION_POLICY>
+class max_root_iterations;
+
+

+ The class max_series_iterations + determines the maximum number of iterations permitted in a series evaluation, + before the special function gives up and returns the result of evaluation_error. +

+

+ The class max_root_iterations + determines the maximum number of iterations permitted in a root-finding algorithm + before the special function gives up and returns the result of evaluation_error. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/namespace_pol.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/namespace_pol.html new file mode 100644 index 00000000..031797af --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/namespace_pol.html @@ -0,0 +1,157 @@ + + + +Setting Polices at Namespace Scope + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Sometimes what you really want to do is bring all the special functions, + or all the distributions into a specific namespace-scope, along with a specific + policy to use with them. There are two macros defined to assist with that: +

+
BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(Policy)
+
+

+ and: +

+
BOOST_MATH_DECLARE_DISTRIBUTIONS(Type, Policy)
+
+

+ You can use either of these macros after including any special function or + distribution header. For example: +

+
#include <boost/math/special_functions/gamma.hpp>
+//using boost::math::tgamma;
+// Need not declare using boost::math::tgamma here,
+// because will define tgamma in myspace using macro below.
+
+namespace myspace
+{
+  using namespace boost::math::policies;
+
+  // Define a policy that does not throw on overflow:
+  typedef policy<overflow_error<errno_on_error> > my_policy;
+
+  // Define the special functions in this scope to use the policy:   
+  BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(my_policy)
+}
+
+// Now we can use myspace::tgamma etc.
+// They will automatically use "my_policy":
+//
+double t = myspace::tgamma(30.0); // Will *not* throw on overflow,
+// despite the large value of factorial 30 = 265252859812191058636308480000000
+// unlike default policy boost::math::tgamma;
+
+

+ In this example, using BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS results in a + set of thin inline forwarding functions being defined: +

+
template <class T>
+inline T tgamma(T a){ return ::boost::math::tgamma(a, mypolicy()); }
+
+template <class T>
+inline T lgamma(T a) ( return ::boost::math::lgamma(a, mypolicy()); }
+
+

+ and so on. Note that while a forwarding function is defined for all the special + functions, however, unless you include the specific header for the special + function you use (or boost/math/special_functions.hpp to include everything), + you will get linker errors from functions that are forward declared, but + not defined. +

+

+ We can do the same thing with the distributions, but this time we need to + specify the floating-point type to use: +

+
#include <boost/math/distributions/cauchy.hpp>
+
+namespace myspace
+{ // using namespace boost::math::policies; // May be convenient in myspace.
+
+  // Define a policy called my_policy to use.
+  using boost::math::policies::policy;
+
+// In this case we want all the distribution accessor functions to compile,
+// even if they are mathematically undefined, so
+// make the policy assert_undefined.
+  using boost::math::policies::assert_undefined;
+
+typedef policy<assert_undefined<false> > my_policy;
+
+// Finally apply this policy to type double.
+BOOST_MATH_DECLARE_DISTRIBUTIONS(double, my_policy)
+} // namespace myspace
+
+// Now we can use myspace::cauchy etc, which will use policy
+// myspace::mypolicy:
+//
+// This compiles but throws a domain error exception at runtime.
+// Caution! If you omit the try'n'catch blocks, 
+// it will just silently terminate, giving no clues as to why! 
+// So try'n'catch blocks are very strongly recommended.
+
+void test_cauchy()
+{
+   try
+   {
+      double d = mean(myspace::cauchy());  // Cauchy does not have a mean!
+   }
+   catch(const std::domain_error& e)
+   {
+      cout << e.what() << endl;
+   }
+}
+
+

+ In this example the result of BOOST_MATH_DECLARE_DISTRIBUTIONS is to declare + a typedef for each distribution like this: +

+
typedef boost::math::cauchy_distribution<double, my_policy> cauchy;
+tyepdef boost::math::gamma_distribution<double, my_policy> gamma;
+
+

+ and so on. The name given to each typedef is the name of the distribution + with the "_distribution" suffix removed. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/pol_ref_ref.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/pol_ref_ref.html new file mode 100644 index 00000000..82e03d8f --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/pol_ref_ref.html @@ -0,0 +1,258 @@ + + + +Policy Class Reference + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ There's very little to say here, the policy + class is just a rag-bag compile-time container for a collection of policies: +

+
#include <boost/math/policies/policy.hpp>
+
namespace boost{
+namespace math{
+namespace policies
+
+template <class A1 = default_policy,
+          class A2 = default_policy,
+          class A3 = default_policy,
+          class A4 = default_policy,
+          class A5 = default_policy,
+          class A6 = default_policy,
+          class A7 = default_policy,
+          class A8 = default_policy,
+          class A9 = default_policy,
+          class A10 = default_policy,
+          class A11 = default_policy,
+          class A12 = default_policy,
+          class A13 = default_policy>
+struct policy
+{
+public:
+   typedef computed-from-template-arguments domain_error_type;
+   typedef computed-from-template-arguments pole_error_type;
+   typedef computed-from-template-arguments overflow_error_type;
+   typedef computed-from-template-arguments underflow_error_type;
+   typedef computed-from-template-arguments denorm_error_type;
+   typedef computed-from-template-arguments rounding_error_type;
+   typedef computed-from-template-arguments evaluation_error_type;
+   typedef computed-from-template-arguments indeterminate_result_error_type;
+   typedef computed-from-template-arguments precision_type;
+   typedef computed-from-template-arguments promote_float_type;
+   typedef computed-from-template-arguments promote_double_type;
+   typedef computed-from-template-arguments discrete_quantile_type;
+   typedef computed-from-template-arguments assert_undefined_type;
+};
+
+template <...argument list...>
+typename normalise<policy<>, A1>::type make_policy(...argument list..);
+
+template <class Policy,
+          class A1 = default_policy,
+          class A2 = default_policy,
+          class A3 = default_policy,
+          class A4 = default_policy,
+          class A5 = default_policy,
+          class A6 = default_policy,
+          class A7 = default_policy,
+          class A8 = default_policy,
+          class A9 = default_policy,
+          class A10 = default_policy,
+          class A11 = default_policy,
+          class A12 = default_policy,
+          class A13 = default_policy>
+struct normalise
+{
+   typedef computed-from-template-arguments type;
+};
+
+

+ The member typedefs of class policy + are intended for internal use but are documented briefly here for the sake + of completeness. +

+
policy<...>::domain_error_type
+
+

+ Specifies how domain errors are handled, will be an instance of boost::math::policies::domain_error<> + with the template argument to domain_error + one of the error_policy_type + enumerated values. +

+
policy<...>::pole_error_type
+
+

+ Specifies how pole-errors are handled, will be an instance of boost::math::policies::pole_error<> + with the template argument to pole_error + one of the error_policy_type + enumerated values. +

+
policy<...>::overflow_error_type
+
+

+ Specifies how overflow errors are handled, will be an instance of boost::math::policies::overflow_error<> + with the template argument to overflow_error + one of the error_policy_type + enumerated values. +

+
policy<...>::underflow_error_type
+
+

+ Specifies how underflow errors are handled, will be an instance of boost::math::policies::underflow_error<> + with the template argument to underflow_error + one of the error_policy_type + enumerated values. +

+
policy<...>::denorm_error_type
+
+

+ Specifies how denorm errors are handled, will be an instance of boost::math::policies::denorm_error<> + with the template argument to denorm_error + one of the error_policy_type + enumerated values. +

+
policy<...>::rounding_error_type
+
+

+ Specifies how rounding errors are handled, will be an instance of boost::math::policies::rounding_error<> + with the template argument to rounding_error + one of the error_policy_type + enumerated values. +

+
policy<...>::evaluation_error_type
+
+

+ Specifies how evaluation errors are handled, will be an instance of boost::math::policies::evaluation_error<> + with the template argument to evaluation_error + one of the error_policy_type + enumerated values. +

+
policy<...>::indeterminate_error_type
+
+

+ Specifies how indeterminate result errors are handled, will be an instance + of boost::math::policies::indeterminate_result_error<> + with the template argument to indeterminate_result_error + one of the error_policy_type + enumerated values. +

+
policy<...>::precision_type
+
+

+ Specifies the internal precision to use in binary digits (uses zero to represent + whatever the default precision is). Will be an instance of boost::math::policies::digits2<N> which + in turn inherits from boost::mpl::int_<N>. +

+
policy<...>::promote_float_type
+
+

+ Specifies whether or not to promote float + arguments to double precision + internally. Will be an instance of boost::math::policies::promote_float<B> + which in turn inherits from boost::mpl::bool_<B>. +

+
policy<...>::promote_double_type
+
+

+ Specifies whether or not to promote double + arguments to long double + precision internally. Will be an instance of boost::math::policies::promote_float<B> + which in turn inherits from boost::mpl::bool_<B>. +

+
policy<...>::discrete_quantile_type
+
+

+ Specifies how discrete quantiles are evaluated, will be an instance of boost::math::policies::discrete_quantile<> + instantiated with one of the discrete_quantile_policy_type + enumerated type. +

+
policy<...>::assert_undefined_type
+
+

+ Specifies whether mathematically-undefined properties are asserted as compile-time + errors, or treated as runtime errors instead. Will be an instance of boost::math::policies::assert_undefined<B> which + in turn inherits from boost::math::mpl::bool_<B>. +

+
template <...argument list...>
+typename normalise<policy<>, A1>::type make_policy(...argument list..);
+
+

+ make_policy is a helper function + that converts a list of policies into a normalised policy + class. +

+
template <class Policy,
+          class A1 = default_policy,
+          class A2 = default_policy,
+          class A3 = default_policy,
+          class A4 = default_policy,
+          class A5 = default_policy,
+          class A6 = default_policy,
+          class A7 = default_policy,
+          class A8 = default_policy,
+          class A9 = default_policy,
+          class A10 = default_policy,
+          class A11 = default_policy,
+          class A12 = default_policy,
+          class A13 = default_policy>
+struct normalise
+{
+   typedef computed-from-template-arguments type;
+};
+
+

+ The normalise class template + converts one instantiation of the policy + class into a normalised form. This is used internally to reduce code bloat: + so that instantiating a special function on policy<A,B> or + policy<B,A> actually both generate the same code + internally. +

+

+ Further more, normalise can + be used to combine a policy with one or more policies: for example many of + the special functions will use this to set policies which they don't make + use of to their default values, before forwarding to the actual implementation. + In this way code bloat is reduced, since the actual implementation depends + only on the policy types that they actually use. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/policy_defaults.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/policy_defaults.html new file mode 100644 index 00000000..0fdecbb3 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/policy_defaults.html @@ -0,0 +1,258 @@ + + + +Using Macros to Change the Policy Defaults + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ You can use the various macros below to change any (or all) of the policies. +

+

+ You can make a local change by placing a macro definition before + a function or distribution #include. +

+
+ + + + + +
[Caution]Caution

+ There is a danger of One-Definition-Rule violations if you add ad-hoc macros + to more than one source files: these must be set the same in every translation unit. +

+
+ + + + + +
[Caution]Caution

+ If you place it after the #include it will have no effect, (and it will + affect only any other following #includes). This is probably not what you + intend! +

+

+ If you want to alter the defaults for any or all of the policies for all functions and distributions, installation-wide, + then you can do so by defining various macros in boost/math/tools/user.hpp. +

+
+ + BOOST_MATH_DOMAIN_ERROR_POLICY +
+

+ Defines what happens when a domain error occurs, if not defined then defaults + to throw_on_error, but can + be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_POLE_ERROR_POLICY +
+

+ Defines what happens when a pole error occurs, if not defined then defaults + to throw_on_error, but can + be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_OVERFLOW_ERROR_POLICY +
+

+ Defines what happens when an overflow error occurs, if not defined then defaults + to throw_on_error, but can + be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_ROUNDING_ERROR_POLICY +
+

+ Defines what happens when a rounding error occurs, if not defined then defaults + to throw_on_error, but can + be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_EVALUATION_ERROR_POLICY +
+

+ Defines what happens when an internal evaluation error occurs, if not defined + then defaults to throw_on_error, + but can be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_UNDERFLOW_ERROR_POLICY +
+

+ Defines what happens when an overflow error occurs, if not defined then defaults + to ignore_error, but can + be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_DENORM_ERROR_POLICY +
+

+ Defines what happens when a denormalisation error occurs, if not defined + then defaults to ignore_error, + but can be set to any of the enumerated actions for error handing: throw_on_error, errno_on_error, + ignore_error or user_error. +

+
+ + BOOST_MATH_INDETERMINATE_RESULT_ERROR_POLICY +
+

+ Defines what happens when the result is indeterminate, but where there is + none the less a convention for the result. If not defined then defaults to + ignore_error, but can be + set to any of the enumerated actions for error handing: throw_on_error, + errno_on_error, ignore_error or user_error. +

+
+ + BOOST_MATH_DIGITS10_POLICY +
+

+ Defines how many decimal digits to use in internal computations: defaults + to 0 - meaning use all available + digits - but can be set to some other decimal value. Since setting this is + likely to have a substantial impact on accuracy, it's not generally recommended + that you change this from the default. +

+
+ + BOOST_MATH_PROMOTE_FLOAT_POLICY +
+

+ Determines whether float types + get promoted to double internally + to ensure maximum precision in the result, defaults to true, + but can be set to false to turn + promotion of float's off. +

+
+ + BOOST_MATH_PROMOTE_DOUBLE_POLICY +
+

+ Determines whether double types + get promoted to long double + internally to ensure maximum precision in the result, defaults to true, but can be set to false + to turn promotion of double's + off. +

+
+ + BOOST_MATH_DISCRETE_QUANTILE_POLICY +
+

+ Determines how discrete quantiles return their results: either as an integer, + or as a real value, can be set to one of the enumerated values: real, integer_round_outwards, + integer_round_inwards, integer_round_down, integer_round_up, + integer_round_nearest. Defaults + to integer_round_outwards. +

+
+ + BOOST_MATH_ASSERT_UNDEFINED_POLICY +
+

+ Determines whether functions that are mathematically undefined for a specific + distribution compile or raise a static (i.e. compile-time) assertion. Defaults + to true: meaning that any mathematically + undefined function will not compile. When set to false + then the function will compile but return the result of a domain error: this + can be useful for some generic code, that needs to work with all distributions + and determine at runtime whether or not a particular property is well defined. +

+
+ + BOOST_MATH_MAX_SERIES_ITERATION_POLICY +
+

+ Determines how many series iterations a special function is permitted to + perform before it gives up and returns an evaluation_error: + Defaults to 1000000. +

+
+ + BOOST_MATH_MAX_ROOT_ITERATION_POLICY +
+

+ Determines how many root-finding iterations a special function is permitted + to perform before it gives up and returns an evaluation_error: + Defaults to 200. +

+
+ + Example +
+

+ Suppose we want overflow errors to set ::errno and return an infinity, discrete + quantiles to return a real-valued result (rather than round to integer), + and for mathematically undefined functions to compile, but return a domain + error. Then we could add the following to boost/math/tools/user.hpp: +

+
#define BOOST_MATH_OVERFLOW_ERROR_POLICY errno_on_error
+#define BOOST_MATH_DISCRETE_QUANTILE_POLICY real
+#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
+
+

+ or we could place these definitions before +

+
#include <boost/math/distributions/normal.hpp>
+  using boost::math::normal_distribution;
+
+

+ in a source .cpp file. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/pol_ref/precision_pol.html b/boost/libs/math/doc/html/math_toolkit/pol_ref/precision_pol.html new file mode 100644 index 00000000..45143151 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/pol_ref/precision_pol.html @@ -0,0 +1,110 @@ + + + +Precision Policies + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ There are two equivalent policies that effect the working precision + used to calculate results, these policies both default to 0 - meaning calculate + to the maximum precision available in the type being used - but can be set + to other values to cause lower levels of precision to be used. One might + want to trade precision for evaluation speed. +

+
namespace boost{ namespace math{ namespace policies{
+
+template <int N>
+digits10;
+
+template <int N>
+digits2;
+
+}}} // namespaces
+
+

+ As you would expect, digits10 specifies the number of + decimal digits to use, and digits2 the number of binary + digits. Internally, whichever is used, the precision is always converted + to binary digits. +

+

+ These policies are specified at compile-time, because many of the special + functions use compile-time-dispatch to select which approximation to use + based on the precision requested and the numeric type being used. +

+

+ For example we could calculate tgamma + to approximately 5 decimal digits using: +

+
#include <boost/math/special_functions/gamma.hpp>
+using boost::math::tgamma;
+using boost::math::policies::policy;
+using boost::math::policies::digits10;
+
+typedef policy<digits10<5> > my_pol_5; // Define a new, non-default, policy
+// to calculate tgamma to accuracy of approximately 5 decimal digits.
+
+

+ Or again using helper function make_policy: +

+
#include <boost/math/special_functions/gamma.hpp>
+using boost::math::tgamma;
+
+using namespace boost::math::policies;
+
+double t = tgamma(12, policy<digits10<5> >());  // Concise make_policy.
+
+

+ And for a quantile of a distribution to approximately 25-bit precision: +

+
#include <boost/math/distributions/normal.hpp>
+using boost::math::normal_distribution;
+
+using namespace boost::math::policies;
+
+const int bits = 25; // approximate precision.
+
+double q = quantile(
+      normal_distribution<double, policy<digits2<bits> > >(),
+      0.05); // 5% quantile.
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3