Home | Libraries | People | FAQ | More |
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 | |
---|---|
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 | |
---|---|
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.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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.
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.
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.
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
.
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.
Determines how many series iterations a special function is permitted to perform before it gives up and returns an evaluation_error: Defaults to 1000000.
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.
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.