mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Fix eol-style and mime-types
[SVN r7564]
This commit is contained in:
@@ -1,54 +1,54 @@
|
||||
[section:NAG_library Comparison with C, R, FORTRAN-style Free Functions]
|
||||
|
||||
|
||||
You are probably familiar with a statistics library that has free functions,
|
||||
for example the classic [@http://nag.com/numeric/CL/CLdescription.asp NAG C library]
|
||||
and matching [@http://nag.com/numeric/FL/FLdescription.asp NAG FORTRAN Library],
|
||||
[@http://office.microsoft.com/en-us/excel/HP052090051033.aspx Microsoft Excel BINOMDIST(number_s,trials,probability_s,cumulative)],
|
||||
[@http://www.r-project.org/ R], [@http://www.ptc.com/products/mathcad/mathcad14/mathcad_func_chart.htm MathCAD pbinom]
|
||||
and many others.
|
||||
|
||||
If so, you may find 'Distributions as Objects' unfamiliar, if not alien.
|
||||
|
||||
However, *do not panic*, both definition and usage are not really very different.
|
||||
|
||||
A very simple example of generating the same values for the binomial distribution follows.
|
||||
(If you find slightly different values, the Boost C++ version, using double or better,
|
||||
is very likely to be the more accurate.
|
||||
Of course, accuracy is not usually a concern for most applications of this function).
|
||||
|
||||
The [@http://www.nag.co.uk/numeric/cl/manual/pdf/G01/g01bjc.pdf NAG function specification] is
|
||||
|
||||
void nag_binomial_dist(Integer n, double p, Integer k,
|
||||
double *plek, double *pgtk, double *peqk, NagError *fail)
|
||||
|
||||
and is called
|
||||
|
||||
g01bjc(n, p, k, &plek, &pgtk, &peqk, NAGERR_DEFAULT);
|
||||
|
||||
The equivalent using this Boost C++ library is:
|
||||
|
||||
using namespace boost::math; // Using declaration avoids very long names.
|
||||
|
||||
binomial my_dist(4, 0.5); // c.f. NAG n = 4, p = 0.5
|
||||
|
||||
and values can be output thus:
|
||||
|
||||
cout
|
||||
<< my_dist.trials() << " " // Echo the NAG input n = 4 trials.
|
||||
<< my_dist.success_fraction() << " " // Echo the NAG input p = 0.5
|
||||
<< cdf(my_dist, 2) << " " // NAG plek with k = 2
|
||||
<< cdf(complement(my_dist, 2)) << " " // NAG pgtk with k = 2
|
||||
<< pdf(my_dist, 2) << endl; // NAG peqk with k = 2
|
||||
|
||||
|
||||
`cdf(dist, k)` is equivalent to NAG library `plek`, lower tail probability of <= k
|
||||
|
||||
`cdf(complement(dist, k))` is equivalent to NAG library `pgtk`, upper tail probability of > k
|
||||
|
||||
`pdf(dist, k)` is equivalent to NAG library `peqk`, point probability of == k
|
||||
|
||||
See [@../../example/binomial_example3.cpp binomial_example3.cpp] for details.
|
||||
|
||||
[endsect][/ section:NAG_library Comparison with C, R, FORTRAN-style Free Functions]
|
||||
|
||||
[section:NAG_library Comparison with C, R, FORTRAN-style Free Functions]
|
||||
|
||||
|
||||
You are probably familiar with a statistics library that has free functions,
|
||||
for example the classic [@http://nag.com/numeric/CL/CLdescription.asp NAG C library]
|
||||
and matching [@http://nag.com/numeric/FL/FLdescription.asp NAG FORTRAN Library],
|
||||
[@http://office.microsoft.com/en-us/excel/HP052090051033.aspx Microsoft Excel BINOMDIST(number_s,trials,probability_s,cumulative)],
|
||||
[@http://www.r-project.org/ R], [@http://www.ptc.com/products/mathcad/mathcad14/mathcad_func_chart.htm MathCAD pbinom]
|
||||
and many others.
|
||||
|
||||
If so, you may find 'Distributions as Objects' unfamiliar, if not alien.
|
||||
|
||||
However, *do not panic*, both definition and usage are not really very different.
|
||||
|
||||
A very simple example of generating the same values for the binomial distribution follows.
|
||||
(If you find slightly different values, the Boost C++ version, using double or better,
|
||||
is very likely to be the more accurate.
|
||||
Of course, accuracy is not usually a concern for most applications of this function).
|
||||
|
||||
The [@http://www.nag.co.uk/numeric/cl/manual/pdf/G01/g01bjc.pdf NAG function specification] is
|
||||
|
||||
void nag_binomial_dist(Integer n, double p, Integer k,
|
||||
double *plek, double *pgtk, double *peqk, NagError *fail)
|
||||
|
||||
and is called
|
||||
|
||||
g01bjc(n, p, k, &plek, &pgtk, &peqk, NAGERR_DEFAULT);
|
||||
|
||||
The equivalent using this Boost C++ library is:
|
||||
|
||||
using namespace boost::math; // Using declaration avoids very long names.
|
||||
|
||||
binomial my_dist(4, 0.5); // c.f. NAG n = 4, p = 0.5
|
||||
|
||||
and values can be output thus:
|
||||
|
||||
cout
|
||||
<< my_dist.trials() << " " // Echo the NAG input n = 4 trials.
|
||||
<< my_dist.success_fraction() << " " // Echo the NAG input p = 0.5
|
||||
<< cdf(my_dist, 2) << " " // NAG plek with k = 2
|
||||
<< cdf(complement(my_dist, 2)) << " " // NAG pgtk with k = 2
|
||||
<< pdf(my_dist, 2) << endl; // NAG peqk with k = 2
|
||||
|
||||
|
||||
`cdf(dist, k)` is equivalent to NAG library `plek`, lower tail probability of <= k
|
||||
|
||||
`cdf(complement(dist, k))` is equivalent to NAG library `pgtk`, upper tail probability of > k
|
||||
|
||||
`pdf(dist, k)` is equivalent to NAG library `peqk`, point probability of == k
|
||||
|
||||
See [@../../example/binomial_example3.cpp binomial_example3.cpp] for details.
|
||||
|
||||
[endsect][/ section:NAG_library Comparison with C, R, FORTRAN-style Free Functions]
|
||||
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
[/ Symbols and accented letters from Latin-1]
|
||||
[/ File Latin1_symbols.qbk]
|
||||
[/ http://www.htmlhelp.com/reference/html40/entities/latin1.html ]
|
||||
[/ based on table Copyright </copyright.html> 1998-2006 Liam Quinn.]
|
||||
[/ Glyphs <http://www.unicode.org/charts/> of the characters ]
|
||||
[/ are available at the Unicode Consortium <http://www.unicode.org/>. ]
|
||||
|
||||
[template nbsp[]''' '''] [/ no-break space = non-breaking space]
|
||||
[template iexcl[]'''¡'''] [/ inverted exclamation mark ]
|
||||
[template cent[]'''¢'''] [/ cent sign ]
|
||||
[template pound[]'''£'''] [/ pound sign ]
|
||||
[template curren[]'''¤'''] [/ currency sign ]
|
||||
[template yen[]'''¥'''] [/ yen sign = yuan sign ]
|
||||
[template brvbar[]'''¦'''] [/ broken vertical bar ]
|
||||
[template sectsign[]'''§'''] [/ section sign ]
|
||||
[template uml[]'''¨'''] [/ diaeresis ]
|
||||
[template copy[]'''©'''] [/ copyright ]
|
||||
[template ordf[]'''ª'''] [/ feminine ordinal indicator ]
|
||||
[template laquo[]'''«'''] [/ left-pointing double angle quotation mark = left pointing guillemet ]
|
||||
[template not[]'''¬'''] [/ not sign ]
|
||||
[template shy[]'''­'''] [/ soft hyphen = discretionary hyphen ]
|
||||
[template reg[]'''®'''] [/ registered sign = registered trade mark sign ]
|
||||
[template macron[]'''¯'''] [/ macron = spacing macron = overline = APL overbar ]
|
||||
[template deg[]'''°'''] [/ degree sign ]
|
||||
[template plusmn[]'''±'''] [/ plus-minus sign = plus-or-minus sign ]
|
||||
[template sup2[]'''²'''] [/ superscript two = superscript digit two = squared ]
|
||||
[template cubed[]'''³'''] [/ superscript three = superscript digit three = cubed ]
|
||||
[template acute[]'''´'''] [/ acute accent = spacing acute ]
|
||||
[template micro[]'''µ'''] [/ micro sign ]
|
||||
[template para[]'''¶'''] [/ pilcrow sign = paragraph sign ]
|
||||
[template middot[]'''·'''] [/ middle dot = Georgian comma = Greek middle dot ]
|
||||
[template cedil[]'''¸'''] [/ cedilla = spacing cedilla ]
|
||||
[template sup1[]'''¹'''] [/ superscript one = superscript digit one ]
|
||||
[template ordm[]'''º'''] [/ masculine ordinal indicator ]
|
||||
[template raquo[]'''»'''] [/ right-pointing double angle quotation mark = right pointing guillemet ]
|
||||
[template frac14[]'''¼'''] [/ vulgar fraction one quarter = fraction one quarter ]
|
||||
[template frac12[]'''½'''] [/ vulgar fraction one half = fraction one half ]
|
||||
[template frac34[]'''¾'''] [/vulgar fraction three quarters = fraction three quarters ]
|
||||
[template iquest[]'''¿'''] [/ inverted question mark = turned question mark ]
|
||||
[template Agrave[]'''À'''] [/ Latin capital letter A with grave = Latin capital letter A grave ]
|
||||
[template Aacute[]'''Á'''] [/ Latin capital letter A with acute = Latin capital letter A acute ]
|
||||
[template Acirc[]'''Â'''] [/ Latin capital letter A with circumflex ]
|
||||
[template Atilde[]'''Ã'''] [/Latin capital letter A with tilde ]
|
||||
[template Auml[]'''Ä'''] [/ Latin capital letter A with diaeresis ]
|
||||
[template Aring[]'''Å'''] [/ Latin capital letter A with ring above = Latin capital letter A ring ]
|
||||
[template AElig[]'''Æ'''] [/ Latin capital letter AE = Latin capital ligature AE ]
|
||||
[template Ccedil[]'''Ç'''] [/ Latin capital letter C with cedilla ]
|
||||
[template Egrave[]'''È'''] [/ Latin capital letter E with grave ]
|
||||
[template Eacute[]'''É'''] [/ Latin capital letter E with acute ]
|
||||
[template Ecirc[]'''Ê'''] [/ Latin capital letter E with circumflex ]
|
||||
[template Euml[]'''Ë'''] [/ Latin capital letter E with diaeresis ]
|
||||
[template Igrave[]'''Ì'''] [/ Latin capital letter I with grave ]
|
||||
[template Iacute[]'''Í'''] [/ Latin capital letter I with acute ]
|
||||
[template Icirc[]'''Î'''] [/ Latin capital letter I with circumflex ]
|
||||
[template Iuml[]'''Ï'''] [/ Latin capital letter I with diaeresis ]
|
||||
[template ETH[]'''Ð'''] [/ Latin capital letter ETH ]
|
||||
[template Ntilde[]'''Ñ'''] [/ Latin capital letter N with tilde ]
|
||||
[template Ograve[]'''Ò'''] [/ Latin capital letter O with grave]
|
||||
[template Oacute[]'''Ó'''] [/ Latin capital letter O with acute ]
|
||||
[template Ocirc[]'''Ô'''] [/ Latin capital letter O with circumflex ]
|
||||
[template Otilde[]'''Õ'''] [/ Latin capital letter O with tilde ]
|
||||
[template Ouml[]'''Ö'''] [/ Latin capital letter O with diaeresis ]
|
||||
[template times[]'''×'''] [/ multiplication sign ]
|
||||
[template Oslash[]'''Ø'''] [/ Latin capital letter O with stroke = Latin capital letter O slash ]
|
||||
[template Ugrave[]'''Ù'''] [/ Latin capital letter U with grave ]
|
||||
[template Uacute[]'''Ú'''] [/ Latin capital letter U with acute ]
|
||||
[template Ucirc[]'''Û'''] [/ Latin capital letter U with circumflex ]
|
||||
[template Uuml[]'''Ü'''] [/ Latin capital letter U with diaeresis ]
|
||||
[template Yacute[]'''Ý'''] [/ Latin capital letter Y with acute ]
|
||||
[template THORN[]'''Þ'''] [/ Latin capital letter THORN ]
|
||||
[template szlig[]'''ß'''] [/ Latin small letter sharp s = ess-zed ]
|
||||
[template agrave[]'''à'''] [/ Latin small letter a with grave = Latin small letter a grave ]
|
||||
[template aacute[]'''á'''] [/ Latin small letter a with acute ]
|
||||
[template acirc[]'''â'''] [/ Latin small letter a with circumflex ]
|
||||
[template atilde[]'''ã'''] [/ Latin small letter a with tilde ]
|
||||
[template auml[]'''ä'''] [/ Latin small letter a with diaeresis ]
|
||||
[template aring[]'''å'''] [/ Latin small letter a with ring above = Latin small letter a ring ]
|
||||
[template aelig[]'''æ'''] [/ Latin small letter ae = Latin small ligature ae ]
|
||||
[template ccedil[]'''ç'''] [/ Latin small letter c with cedilla ]
|
||||
[template egrave[]'''è'''] [/ Latin small letter e with grave ]
|
||||
[template eacute[]'''é'''] [/ Latin small letter e with acute ]
|
||||
[template ecirc[]'''ê'''] [/ Latin small letter e with circumflex ]
|
||||
[template euml[]'''ë'''] [/ Latin small letter e with diaeresis ]
|
||||
[template igrave[]'''ì'''] [/ Latin small letter i with grave ]
|
||||
[template iacute[]'''í'''] [/ Latin small letter i with acute ]
|
||||
[template icirc[]'''î'''] [/ Latin small letter i with circumflex ]
|
||||
[template iuml[]'''ï'''] [/ Latin small letter i with diaeresis ]
|
||||
[template eth[]'''ð'''] [/ Latin small letter eth ]
|
||||
[template ntilde[]'''ñ'''] [/ Latin small letter n with tilde ]
|
||||
[template ograve[]'''ò'''] [/Latin small letter o with grave ]
|
||||
[template oacute[]'''ó'''] [/ Latin small letter o with acute ]
|
||||
[template ocirc[]'''ô'''] [/ Latin small letter o with circumflex ]
|
||||
[template otilde[]'''õ'''] [/ Latin small letter o with tilde ]
|
||||
[template ouml[]'''ö'''] [/ Latin small letter o with diaeresis ]
|
||||
[template divide[]'''÷'''] [/ division sign ]
|
||||
[template oslash[]'''ø'''] [/ Latin small letter o with stroke = Latin small letter o slash ]
|
||||
[template ugrave[]'''ù'''] [/ Latin small letter u with grave ]
|
||||
[template uacute[]'''ú'''] [/ Latin small letter u with acute ]
|
||||
[template ucirc[]'''û'''] [/ Latin small letter u with circumflex ]
|
||||
[template uuml[]'''ü'''] [/ Latin small letter u with diaeresis ]
|
||||
[template yacute[]'''ý'''] [/ Latin small letter y with acute ]
|
||||
[template thorn[]'''þ'''] [/ Latin small letter thorn ]
|
||||
[template yuml[]'''ÿ'''] [/ Latin small letter y with diaeresis ]
|
||||
|
||||
[/ File Latin1_symbols.qbk
|
||||
Copyright 2007 Paul A. Bristow.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[/ Symbols and accented letters from Latin-1]
|
||||
[/ File Latin1_symbols.qbk]
|
||||
[/ http://www.htmlhelp.com/reference/html40/entities/latin1.html ]
|
||||
[/ based on table Copyright </copyright.html> 1998-2006 Liam Quinn.]
|
||||
[/ Glyphs <http://www.unicode.org/charts/> of the characters ]
|
||||
[/ are available at the Unicode Consortium <http://www.unicode.org/>. ]
|
||||
|
||||
[template nbsp[]''' '''] [/ no-break space = non-breaking space]
|
||||
[template iexcl[]'''¡'''] [/ inverted exclamation mark ]
|
||||
[template cent[]'''¢'''] [/ cent sign ]
|
||||
[template pound[]'''£'''] [/ pound sign ]
|
||||
[template curren[]'''¤'''] [/ currency sign ]
|
||||
[template yen[]'''¥'''] [/ yen sign = yuan sign ]
|
||||
[template brvbar[]'''¦'''] [/ broken vertical bar ]
|
||||
[template sectsign[]'''§'''] [/ section sign ]
|
||||
[template uml[]'''¨'''] [/ diaeresis ]
|
||||
[template copy[]'''©'''] [/ copyright ]
|
||||
[template ordf[]'''ª'''] [/ feminine ordinal indicator ]
|
||||
[template laquo[]'''«'''] [/ left-pointing double angle quotation mark = left pointing guillemet ]
|
||||
[template not[]'''¬'''] [/ not sign ]
|
||||
[template shy[]'''­'''] [/ soft hyphen = discretionary hyphen ]
|
||||
[template reg[]'''®'''] [/ registered sign = registered trade mark sign ]
|
||||
[template macron[]'''¯'''] [/ macron = spacing macron = overline = APL overbar ]
|
||||
[template deg[]'''°'''] [/ degree sign ]
|
||||
[template plusmn[]'''±'''] [/ plus-minus sign = plus-or-minus sign ]
|
||||
[template sup2[]'''²'''] [/ superscript two = superscript digit two = squared ]
|
||||
[template cubed[]'''³'''] [/ superscript three = superscript digit three = cubed ]
|
||||
[template acute[]'''´'''] [/ acute accent = spacing acute ]
|
||||
[template micro[]'''µ'''] [/ micro sign ]
|
||||
[template para[]'''¶'''] [/ pilcrow sign = paragraph sign ]
|
||||
[template middot[]'''·'''] [/ middle dot = Georgian comma = Greek middle dot ]
|
||||
[template cedil[]'''¸'''] [/ cedilla = spacing cedilla ]
|
||||
[template sup1[]'''¹'''] [/ superscript one = superscript digit one ]
|
||||
[template ordm[]'''º'''] [/ masculine ordinal indicator ]
|
||||
[template raquo[]'''»'''] [/ right-pointing double angle quotation mark = right pointing guillemet ]
|
||||
[template frac14[]'''¼'''] [/ vulgar fraction one quarter = fraction one quarter ]
|
||||
[template frac12[]'''½'''] [/ vulgar fraction one half = fraction one half ]
|
||||
[template frac34[]'''¾'''] [/vulgar fraction three quarters = fraction three quarters ]
|
||||
[template iquest[]'''¿'''] [/ inverted question mark = turned question mark ]
|
||||
[template Agrave[]'''À'''] [/ Latin capital letter A with grave = Latin capital letter A grave ]
|
||||
[template Aacute[]'''Á'''] [/ Latin capital letter A with acute = Latin capital letter A acute ]
|
||||
[template Acirc[]'''Â'''] [/ Latin capital letter A with circumflex ]
|
||||
[template Atilde[]'''Ã'''] [/Latin capital letter A with tilde ]
|
||||
[template Auml[]'''Ä'''] [/ Latin capital letter A with diaeresis ]
|
||||
[template Aring[]'''Å'''] [/ Latin capital letter A with ring above = Latin capital letter A ring ]
|
||||
[template AElig[]'''Æ'''] [/ Latin capital letter AE = Latin capital ligature AE ]
|
||||
[template Ccedil[]'''Ç'''] [/ Latin capital letter C with cedilla ]
|
||||
[template Egrave[]'''È'''] [/ Latin capital letter E with grave ]
|
||||
[template Eacute[]'''É'''] [/ Latin capital letter E with acute ]
|
||||
[template Ecirc[]'''Ê'''] [/ Latin capital letter E with circumflex ]
|
||||
[template Euml[]'''Ë'''] [/ Latin capital letter E with diaeresis ]
|
||||
[template Igrave[]'''Ì'''] [/ Latin capital letter I with grave ]
|
||||
[template Iacute[]'''Í'''] [/ Latin capital letter I with acute ]
|
||||
[template Icirc[]'''Î'''] [/ Latin capital letter I with circumflex ]
|
||||
[template Iuml[]'''Ï'''] [/ Latin capital letter I with diaeresis ]
|
||||
[template ETH[]'''Ð'''] [/ Latin capital letter ETH ]
|
||||
[template Ntilde[]'''Ñ'''] [/ Latin capital letter N with tilde ]
|
||||
[template Ograve[]'''Ò'''] [/ Latin capital letter O with grave]
|
||||
[template Oacute[]'''Ó'''] [/ Latin capital letter O with acute ]
|
||||
[template Ocirc[]'''Ô'''] [/ Latin capital letter O with circumflex ]
|
||||
[template Otilde[]'''Õ'''] [/ Latin capital letter O with tilde ]
|
||||
[template Ouml[]'''Ö'''] [/ Latin capital letter O with diaeresis ]
|
||||
[template times[]'''×'''] [/ multiplication sign ]
|
||||
[template Oslash[]'''Ø'''] [/ Latin capital letter O with stroke = Latin capital letter O slash ]
|
||||
[template Ugrave[]'''Ù'''] [/ Latin capital letter U with grave ]
|
||||
[template Uacute[]'''Ú'''] [/ Latin capital letter U with acute ]
|
||||
[template Ucirc[]'''Û'''] [/ Latin capital letter U with circumflex ]
|
||||
[template Uuml[]'''Ü'''] [/ Latin capital letter U with diaeresis ]
|
||||
[template Yacute[]'''Ý'''] [/ Latin capital letter Y with acute ]
|
||||
[template THORN[]'''Þ'''] [/ Latin capital letter THORN ]
|
||||
[template szlig[]'''ß'''] [/ Latin small letter sharp s = ess-zed ]
|
||||
[template agrave[]'''à'''] [/ Latin small letter a with grave = Latin small letter a grave ]
|
||||
[template aacute[]'''á'''] [/ Latin small letter a with acute ]
|
||||
[template acirc[]'''â'''] [/ Latin small letter a with circumflex ]
|
||||
[template atilde[]'''ã'''] [/ Latin small letter a with tilde ]
|
||||
[template auml[]'''ä'''] [/ Latin small letter a with diaeresis ]
|
||||
[template aring[]'''å'''] [/ Latin small letter a with ring above = Latin small letter a ring ]
|
||||
[template aelig[]'''æ'''] [/ Latin small letter ae = Latin small ligature ae ]
|
||||
[template ccedil[]'''ç'''] [/ Latin small letter c with cedilla ]
|
||||
[template egrave[]'''è'''] [/ Latin small letter e with grave ]
|
||||
[template eacute[]'''é'''] [/ Latin small letter e with acute ]
|
||||
[template ecirc[]'''ê'''] [/ Latin small letter e with circumflex ]
|
||||
[template euml[]'''ë'''] [/ Latin small letter e with diaeresis ]
|
||||
[template igrave[]'''ì'''] [/ Latin small letter i with grave ]
|
||||
[template iacute[]'''í'''] [/ Latin small letter i with acute ]
|
||||
[template icirc[]'''î'''] [/ Latin small letter i with circumflex ]
|
||||
[template iuml[]'''ï'''] [/ Latin small letter i with diaeresis ]
|
||||
[template eth[]'''ð'''] [/ Latin small letter eth ]
|
||||
[template ntilde[]'''ñ'''] [/ Latin small letter n with tilde ]
|
||||
[template ograve[]'''ò'''] [/Latin small letter o with grave ]
|
||||
[template oacute[]'''ó'''] [/ Latin small letter o with acute ]
|
||||
[template ocirc[]'''ô'''] [/ Latin small letter o with circumflex ]
|
||||
[template otilde[]'''õ'''] [/ Latin small letter o with tilde ]
|
||||
[template ouml[]'''ö'''] [/ Latin small letter o with diaeresis ]
|
||||
[template divide[]'''÷'''] [/ division sign ]
|
||||
[template oslash[]'''ø'''] [/ Latin small letter o with stroke = Latin small letter o slash ]
|
||||
[template ugrave[]'''ù'''] [/ Latin small letter u with grave ]
|
||||
[template uacute[]'''ú'''] [/ Latin small letter u with acute ]
|
||||
[template ucirc[]'''û'''] [/ Latin small letter u with circumflex ]
|
||||
[template uuml[]'''ü'''] [/ Latin small letter u with diaeresis ]
|
||||
[template yacute[]'''ý'''] [/ Latin small letter y with acute ]
|
||||
[template thorn[]'''þ'''] [/ Latin small letter thorn ]
|
||||
[template yuml[]'''ÿ'''] [/ Latin small letter y with diaeresis ]
|
||||
|
||||
[/ File Latin1_symbols.qbk
|
||||
Copyright 2007 Paul A. Bristow.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
]
|
||||
[authors [Maddock, John], [Bristow, Paul A.], [Holin, Hubert], [Zhang, Xiaogang]]
|
||||
[category math]
|
||||
[/last-revision $Date$]
|
||||
[/last-revision $Date: 2007-07-26 08:50:29 -0400 (Thu, 26 Jul 2007) $]
|
||||
]
|
||||
|
||||
[include HTML4_symbols.qbk] [/ just for testing]
|
||||
|
||||
1876
doc/policy.qbk
1876
doc/policy.qbk
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,27 @@
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
#define BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
|
||||
#include <boost/math/distributions/bernoulli.hpp>
|
||||
#include <boost/math/distributions/beta.hpp>
|
||||
#include <boost/math/distributions/binomial.hpp>
|
||||
#include <boost/math/distributions/cauchy.hpp>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <boost/math/distributions/complement.hpp>
|
||||
#include <boost/math/distributions/exponential.hpp>
|
||||
#include <boost/math/distributions/extreme_value.hpp>
|
||||
#include <boost/math/distributions/fisher_f.hpp>
|
||||
#include <boost/math/distributions/gamma.hpp>
|
||||
#include <boost/math/distributions/lognormal.hpp>
|
||||
#include <boost/math/distributions/negative_binomial.hpp>
|
||||
#include <boost/math/distributions/normal.hpp>
|
||||
#include <boost/math/distributions/pareto.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
#include <boost/math/distributions/rayleigh.hpp>
|
||||
#include <boost/math/distributions/students_t.hpp>
|
||||
#include <boost/math/distributions/triangular.hpp>
|
||||
#include <boost/math/distributions/uniform.hpp>
|
||||
#include <boost/math/distributions/weibull.hpp>
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
#define BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
|
||||
#include <boost/math/distributions/bernoulli.hpp>
|
||||
#include <boost/math/distributions/beta.hpp>
|
||||
#include <boost/math/distributions/binomial.hpp>
|
||||
#include <boost/math/distributions/cauchy.hpp>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <boost/math/distributions/complement.hpp>
|
||||
#include <boost/math/distributions/exponential.hpp>
|
||||
#include <boost/math/distributions/extreme_value.hpp>
|
||||
#include <boost/math/distributions/fisher_f.hpp>
|
||||
#include <boost/math/distributions/gamma.hpp>
|
||||
#include <boost/math/distributions/lognormal.hpp>
|
||||
#include <boost/math/distributions/negative_binomial.hpp>
|
||||
#include <boost/math/distributions/normal.hpp>
|
||||
#include <boost/math/distributions/pareto.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
#include <boost/math/distributions/rayleigh.hpp>
|
||||
#include <boost/math/distributions/students_t.hpp>
|
||||
#include <boost/math/distributions/triangular.hpp>
|
||||
#include <boost/math/distributions/uniform.hpp>
|
||||
#include <boost/math/distributions/weibull.hpp>
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_HPP
|
||||
|
||||
|
||||
@@ -1,480 +1,480 @@
|
||||
// Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
#define BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost{ namespace math{ namespace detail{
|
||||
|
||||
//
|
||||
// Functor for root finding algorithm:
|
||||
//
|
||||
template <class Dist>
|
||||
struct distribution_quantile_finder
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
typedef typename Dist::policy_type policy_type;
|
||||
|
||||
distribution_quantile_finder(const Dist d, value_type p, value_type q)
|
||||
: dist(d), target(p < q ? p : q), comp(p < q ? false : true) {}
|
||||
|
||||
value_type operator()(value_type const& x)
|
||||
{
|
||||
return comp ? target - cdf(complement(dist, x)) : cdf(dist, x) - target;
|
||||
}
|
||||
|
||||
private:
|
||||
Dist dist;
|
||||
value_type target;
|
||||
bool comp;
|
||||
};
|
||||
//
|
||||
// The purpose of adjust_bounds, is to toggle the last bit of the
|
||||
// range so that both ends round to the same integer, if possible.
|
||||
// If they do both round the same then we terminate the search
|
||||
// for the root *very* quickly when finding an integer result.
|
||||
// At the point that this function is called we know that "a" is
|
||||
// below the root and "b" above it, so this change can not result
|
||||
// in the root no longer being bracketed.
|
||||
//
|
||||
template <class Real, class Tol>
|
||||
void adjust_bounds(Real& a, Real& b, Tol const& tol){}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_floor const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
b -= tools::epsilon<Real>() * b;
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_ceil const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
a += tools::epsilon<Real>() * a;
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_nearest_integer const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
a += tools::epsilon<Real>() * a;
|
||||
b -= tools::epsilon<Real>() * b;
|
||||
}
|
||||
//
|
||||
// This is where all the work is done:
|
||||
//
|
||||
template <class Dist, class Tolerance>
|
||||
typename Dist::value_type
|
||||
do_inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
typename Dist::value_type guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
typename Dist::value_type adder,
|
||||
const Tolerance& tol,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
typedef typename Dist::policy_type policy_type;
|
||||
|
||||
static const char* function = "boost::math::do_inverse_discrete_quantile<%1%>";
|
||||
|
||||
using namespace std;
|
||||
|
||||
distribution_quantile_finder<Dist> f(dist, p, q);
|
||||
//
|
||||
// Max bounds of the distribution:
|
||||
//
|
||||
value_type min_bound, max_bound;
|
||||
std::tr1::tie(min_bound, max_bound) = support(dist);
|
||||
|
||||
if(guess > max_bound)
|
||||
guess = max_bound;
|
||||
if(guess < min_bound)
|
||||
guess = min_bound;
|
||||
|
||||
value_type fa = f(guess);
|
||||
boost::uintmax_t count = max_iter - 1;
|
||||
value_type fb(fa), a(guess), b;
|
||||
|
||||
if(fa == 0)
|
||||
return guess;
|
||||
|
||||
//
|
||||
// For small expected results, just use a linear search:
|
||||
//
|
||||
if(guess < 10)
|
||||
{
|
||||
b = a;
|
||||
while((a < 10) && (fa * fb >= 0))
|
||||
{
|
||||
if(fb <= 0)
|
||||
{
|
||||
a = b;
|
||||
b = a + 1;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
fb = f(b);
|
||||
--count;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = a;
|
||||
a = (std::max)(b - 1, value_type(0));
|
||||
if(a < min_bound)
|
||||
a = min_bound;
|
||||
fa = f(a);
|
||||
--count;
|
||||
if(fa == 0)
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Try and bracket using a couple of additions first,
|
||||
// we're assuming that "guess" is likely to be accurate
|
||||
// to the nearest int or so:
|
||||
//
|
||||
else if(adder != 0)
|
||||
{
|
||||
//
|
||||
// If we're looking for a large result, then bump "adder" up
|
||||
// by a bit to increase our chances of bracketing the root:
|
||||
//
|
||||
//adder = (std::max)(adder, 0.001f * guess);
|
||||
if(fa < 0)
|
||||
{
|
||||
b = a + adder;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = (std::max)(a - adder, value_type(0));
|
||||
if(b < min_bound)
|
||||
b = min_bound;
|
||||
}
|
||||
fb = f(b);
|
||||
--count;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
if(count && (fa * fb >= 0))
|
||||
{
|
||||
//
|
||||
// We didn't bracket the root, try
|
||||
// once more:
|
||||
//
|
||||
a = b;
|
||||
fa = fb;
|
||||
if(fa < 0)
|
||||
{
|
||||
b = a + adder;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = (std::max)(a - adder, value_type(0));
|
||||
if(b < min_bound)
|
||||
b = min_bound;
|
||||
}
|
||||
fb = f(b);
|
||||
--count;
|
||||
}
|
||||
if(a > b)
|
||||
{
|
||||
using std::swap;
|
||||
swap(a, b);
|
||||
swap(fa, fb);
|
||||
}
|
||||
}
|
||||
//
|
||||
// If the root hasn't been bracketed yet, try again
|
||||
// using the multiplier this time:
|
||||
//
|
||||
if(sign(fb) == sign(fa))
|
||||
{
|
||||
if(fa < 0)
|
||||
{
|
||||
//
|
||||
// Zero is to the right of x2, so walk upwards
|
||||
// until we find it:
|
||||
//
|
||||
while(sign(fb) == sign(fa))
|
||||
{
|
||||
if(count == 0)
|
||||
policy::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, policy_type());
|
||||
a = b;
|
||||
fa = fb;
|
||||
b *= multiplier;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
fb = f(b);
|
||||
--count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Zero is to the left of a, so walk downwards
|
||||
// until we find it:
|
||||
//
|
||||
while(sign(fb) == sign(fa))
|
||||
{
|
||||
if(fabs(a) < tools::min_value<value_type>())
|
||||
{
|
||||
// Escape route just in case the answer is zero!
|
||||
max_iter -= count;
|
||||
max_iter += 1;
|
||||
return 0;
|
||||
}
|
||||
if(count == 0)
|
||||
policy::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", a, policy_type());
|
||||
b = a;
|
||||
fb = fa;
|
||||
a /= multiplier;
|
||||
if(a < min_bound)
|
||||
a = min_bound;
|
||||
fa = f(a);
|
||||
--count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count);
|
||||
}
|
||||
}
|
||||
}
|
||||
max_iter -= count;
|
||||
if(fa == 0)
|
||||
return a;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
//
|
||||
// Adjust bounds so that if we're looking for an integer
|
||||
// result, then both ends round the same way:
|
||||
//
|
||||
adjust_bounds(a, b, tol);
|
||||
//
|
||||
// We don't want zero or denorm lower bounds:
|
||||
//
|
||||
if(a < tools::min_value<value_type>())
|
||||
a = tools::min_value<value_type>();
|
||||
//
|
||||
// Go ahead and find the root:
|
||||
//
|
||||
std::pair<value_type, value_type> r = toms748_solve(f, a, b, fa, fb, tol, count, policy_type());
|
||||
max_iter += count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("max_iter = " << max_iter << " count = " << count);
|
||||
return (r.first + r.second) / 2;
|
||||
}
|
||||
//
|
||||
// Now finally are the public API functions.
|
||||
// There is one overload for each policy,
|
||||
// each one is responsible for selecting the correct
|
||||
// termination condition, and rounding the result
|
||||
// to an int where required.
|
||||
//
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::real>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
guess,
|
||||
multiplier,
|
||||
adder,
|
||||
tools::eps_tolerance<typename Dist::value_type>(policy::digits<typename Dist::value_type, typename Dist::policy_type>()),
|
||||
max_iter);
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_outside>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// What happens next depends on whether we're looking for an
|
||||
// upper or lower quantile:
|
||||
//
|
||||
if(p < 0.5f)
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
// else:
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_inside>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// What happens next depends on whether we're looking for an
|
||||
// upper or lower quantile:
|
||||
//
|
||||
if(p < 0.5f)
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
// else:
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_below>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_above>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_nearest>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// Note that we adjust the guess to the nearest half-integer:
|
||||
// this increase the chances that we will bracket the root
|
||||
// with two results that both round to the same integer quickly.
|
||||
//
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 0.5f ? value_type(1.5f) : floor(guess + 0.5f) + 0.5f),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_nearest_integer(),
|
||||
max_iter) + 0.5f);
|
||||
}
|
||||
|
||||
}}} // namespaces
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
|
||||
// Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
#define BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost{ namespace math{ namespace detail{
|
||||
|
||||
//
|
||||
// Functor for root finding algorithm:
|
||||
//
|
||||
template <class Dist>
|
||||
struct distribution_quantile_finder
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
typedef typename Dist::policy_type policy_type;
|
||||
|
||||
distribution_quantile_finder(const Dist d, value_type p, value_type q)
|
||||
: dist(d), target(p < q ? p : q), comp(p < q ? false : true) {}
|
||||
|
||||
value_type operator()(value_type const& x)
|
||||
{
|
||||
return comp ? target - cdf(complement(dist, x)) : cdf(dist, x) - target;
|
||||
}
|
||||
|
||||
private:
|
||||
Dist dist;
|
||||
value_type target;
|
||||
bool comp;
|
||||
};
|
||||
//
|
||||
// The purpose of adjust_bounds, is to toggle the last bit of the
|
||||
// range so that both ends round to the same integer, if possible.
|
||||
// If they do both round the same then we terminate the search
|
||||
// for the root *very* quickly when finding an integer result.
|
||||
// At the point that this function is called we know that "a" is
|
||||
// below the root and "b" above it, so this change can not result
|
||||
// in the root no longer being bracketed.
|
||||
//
|
||||
template <class Real, class Tol>
|
||||
void adjust_bounds(Real& a, Real& b, Tol const& tol){}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_floor const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
b -= tools::epsilon<Real>() * b;
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_ceil const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
a += tools::epsilon<Real>() * a;
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
void adjust_bounds(Real& a, Real& b, tools::equal_nearest_integer const& tol)
|
||||
{
|
||||
using namespace std;
|
||||
a += tools::epsilon<Real>() * a;
|
||||
b -= tools::epsilon<Real>() * b;
|
||||
}
|
||||
//
|
||||
// This is where all the work is done:
|
||||
//
|
||||
template <class Dist, class Tolerance>
|
||||
typename Dist::value_type
|
||||
do_inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
typename Dist::value_type guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
typename Dist::value_type adder,
|
||||
const Tolerance& tol,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
typedef typename Dist::policy_type policy_type;
|
||||
|
||||
static const char* function = "boost::math::do_inverse_discrete_quantile<%1%>";
|
||||
|
||||
using namespace std;
|
||||
|
||||
distribution_quantile_finder<Dist> f(dist, p, q);
|
||||
//
|
||||
// Max bounds of the distribution:
|
||||
//
|
||||
value_type min_bound, max_bound;
|
||||
std::tr1::tie(min_bound, max_bound) = support(dist);
|
||||
|
||||
if(guess > max_bound)
|
||||
guess = max_bound;
|
||||
if(guess < min_bound)
|
||||
guess = min_bound;
|
||||
|
||||
value_type fa = f(guess);
|
||||
boost::uintmax_t count = max_iter - 1;
|
||||
value_type fb(fa), a(guess), b;
|
||||
|
||||
if(fa == 0)
|
||||
return guess;
|
||||
|
||||
//
|
||||
// For small expected results, just use a linear search:
|
||||
//
|
||||
if(guess < 10)
|
||||
{
|
||||
b = a;
|
||||
while((a < 10) && (fa * fb >= 0))
|
||||
{
|
||||
if(fb <= 0)
|
||||
{
|
||||
a = b;
|
||||
b = a + 1;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
fb = f(b);
|
||||
--count;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = a;
|
||||
a = (std::max)(b - 1, value_type(0));
|
||||
if(a < min_bound)
|
||||
a = min_bound;
|
||||
fa = f(a);
|
||||
--count;
|
||||
if(fa == 0)
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Try and bracket using a couple of additions first,
|
||||
// we're assuming that "guess" is likely to be accurate
|
||||
// to the nearest int or so:
|
||||
//
|
||||
else if(adder != 0)
|
||||
{
|
||||
//
|
||||
// If we're looking for a large result, then bump "adder" up
|
||||
// by a bit to increase our chances of bracketing the root:
|
||||
//
|
||||
//adder = (std::max)(adder, 0.001f * guess);
|
||||
if(fa < 0)
|
||||
{
|
||||
b = a + adder;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = (std::max)(a - adder, value_type(0));
|
||||
if(b < min_bound)
|
||||
b = min_bound;
|
||||
}
|
||||
fb = f(b);
|
||||
--count;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
if(count && (fa * fb >= 0))
|
||||
{
|
||||
//
|
||||
// We didn't bracket the root, try
|
||||
// once more:
|
||||
//
|
||||
a = b;
|
||||
fa = fb;
|
||||
if(fa < 0)
|
||||
{
|
||||
b = a + adder;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = (std::max)(a - adder, value_type(0));
|
||||
if(b < min_bound)
|
||||
b = min_bound;
|
||||
}
|
||||
fb = f(b);
|
||||
--count;
|
||||
}
|
||||
if(a > b)
|
||||
{
|
||||
using std::swap;
|
||||
swap(a, b);
|
||||
swap(fa, fb);
|
||||
}
|
||||
}
|
||||
//
|
||||
// If the root hasn't been bracketed yet, try again
|
||||
// using the multiplier this time:
|
||||
//
|
||||
if(sign(fb) == sign(fa))
|
||||
{
|
||||
if(fa < 0)
|
||||
{
|
||||
//
|
||||
// Zero is to the right of x2, so walk upwards
|
||||
// until we find it:
|
||||
//
|
||||
while(sign(fb) == sign(fa))
|
||||
{
|
||||
if(count == 0)
|
||||
policy::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, policy_type());
|
||||
a = b;
|
||||
fa = fb;
|
||||
b *= multiplier;
|
||||
if(b > max_bound)
|
||||
b = max_bound;
|
||||
fb = f(b);
|
||||
--count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Zero is to the left of a, so walk downwards
|
||||
// until we find it:
|
||||
//
|
||||
while(sign(fb) == sign(fa))
|
||||
{
|
||||
if(fabs(a) < tools::min_value<value_type>())
|
||||
{
|
||||
// Escape route just in case the answer is zero!
|
||||
max_iter -= count;
|
||||
max_iter += 1;
|
||||
return 0;
|
||||
}
|
||||
if(count == 0)
|
||||
policy::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", a, policy_type());
|
||||
b = a;
|
||||
fb = fa;
|
||||
a /= multiplier;
|
||||
if(a < min_bound)
|
||||
a = min_bound;
|
||||
fa = f(a);
|
||||
--count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count);
|
||||
}
|
||||
}
|
||||
}
|
||||
max_iter -= count;
|
||||
if(fa == 0)
|
||||
return a;
|
||||
if(fb == 0)
|
||||
return b;
|
||||
//
|
||||
// Adjust bounds so that if we're looking for an integer
|
||||
// result, then both ends round the same way:
|
||||
//
|
||||
adjust_bounds(a, b, tol);
|
||||
//
|
||||
// We don't want zero or denorm lower bounds:
|
||||
//
|
||||
if(a < tools::min_value<value_type>())
|
||||
a = tools::min_value<value_type>();
|
||||
//
|
||||
// Go ahead and find the root:
|
||||
//
|
||||
std::pair<value_type, value_type> r = toms748_solve(f, a, b, fa, fb, tol, count, policy_type());
|
||||
max_iter += count;
|
||||
BOOST_MATH_INSTRUMENT_CODE("max_iter = " << max_iter << " count = " << count);
|
||||
return (r.first + r.second) / 2;
|
||||
}
|
||||
//
|
||||
// Now finally are the public API functions.
|
||||
// There is one overload for each policy,
|
||||
// each one is responsible for selecting the correct
|
||||
// termination condition, and rounding the result
|
||||
// to an int where required.
|
||||
//
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::real>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
guess,
|
||||
multiplier,
|
||||
adder,
|
||||
tools::eps_tolerance<typename Dist::value_type>(policy::digits<typename Dist::value_type, typename Dist::policy_type>()),
|
||||
max_iter);
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_outside>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// What happens next depends on whether we're looking for an
|
||||
// upper or lower quantile:
|
||||
//
|
||||
if(p < 0.5f)
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
// else:
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_inside>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// What happens next depends on whether we're looking for an
|
||||
// upper or lower quantile:
|
||||
//
|
||||
if(p < 0.5f)
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
// else:
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_below>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 1 ? value_type(1) : floor(guess)),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_floor(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_above>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
return ceil(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
ceil(guess),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_ceil(),
|
||||
max_iter));
|
||||
}
|
||||
|
||||
template <class Dist>
|
||||
inline typename Dist::value_type
|
||||
inverse_discrete_quantile(
|
||||
const Dist& dist,
|
||||
const typename Dist::value_type& p,
|
||||
const typename Dist::value_type& q,
|
||||
const typename Dist::value_type& guess,
|
||||
const typename Dist::value_type& multiplier,
|
||||
const typename Dist::value_type& adder,
|
||||
const policy::discrete_quantile<policy::integer_nearest>&,
|
||||
boost::uintmax_t& max_iter)
|
||||
{
|
||||
typedef typename Dist::value_type value_type;
|
||||
using namespace std;
|
||||
if(p <= pdf(dist, 0))
|
||||
return 0;
|
||||
//
|
||||
// Note that we adjust the guess to the nearest half-integer:
|
||||
// this increase the chances that we will bracket the root
|
||||
// with two results that both round to the same integer quickly.
|
||||
//
|
||||
return floor(do_inverse_discrete_quantile(
|
||||
dist,
|
||||
p,
|
||||
q,
|
||||
(guess < 0.5f ? value_type(1.5f) : floor(guess + 0.5f) + 0.5f),
|
||||
multiplier,
|
||||
adder,
|
||||
tools::equal_nearest_integer(),
|
||||
max_iter) + 0.5f);
|
||||
}
|
||||
|
||||
}}} // namespaces
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_DETAIL_INV_DISCRETE_QUANTILE
|
||||
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
// Copyright Paul A. Bristow 2007.
|
||||
// Copyright John Maddock 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
#define BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class bernoulli_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class beta_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class binomial_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class cauchy_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class chi_squared_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class exponential_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class extreme_value_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class fisher_f_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class gamma_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class lognormal_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class negative_binomial_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class normal_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class pareto_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class poisson_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class rayleigh_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class students_t_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class triangular_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class uniform_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class weibull_distribution;
|
||||
|
||||
}} // namespaces
|
||||
|
||||
#define BOOST_MATH_DECLARE_DISTRIBUTIONS(Type, Policy)\
|
||||
typedef boost::math::bernoulli_distribution<Type, Policy> bernoulli;\
|
||||
typedef boost::math::beta_distribution<Type, Policy> beta;\
|
||||
typedef boost::math::binomial_distribution<Type, Policy> binomial;\
|
||||
typedef boost::math::cauchy_distribution<Type, Policy> cauchy;\
|
||||
typedef boost::math::chi_squared_distribution<Type, Policy> chi_squared;\
|
||||
typedef boost::math::exponential_distribution<Type, Policy> exponential;\
|
||||
typedef boost::math::extreme_value_distribution<Type, Policy> extreme_value;\
|
||||
typedef boost::math::fisher_f_distribution<Type, Policy> fisher_f;\
|
||||
typedef boost::math::gamma_distribution<Type, Policy> gamma;\
|
||||
typedef boost::math::lognormal_distribution<Type, Policy> lognormal;\
|
||||
typedef boost::math::negative_binomial_distribution<Type, Policy> negative_binomial;\
|
||||
typedef boost::math::normal_distribution<Type, Policy> normal;\
|
||||
typedef boost::math::pareto_distribution<Type, Policy> pareto;\
|
||||
typedef boost::math::poisson_distribution<Type, Policy> poisson;\
|
||||
typedef boost::math::rayleigh_distribution<Type, Policy> rayleigh;\
|
||||
typedef boost::math::students_t_distribution<Type, Policy> students_t;\
|
||||
typedef boost::math::triangular_distribution<Type, Policy> triangular;\
|
||||
typedef boost::math::uniform_distribution<Type, Policy> uniform;\
|
||||
typedef boost::math::weibull_distribution<Type, Policy> weibull;\
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
// Copyright Paul A. Bristow 2007.
|
||||
// Copyright John Maddock 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
#define BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class bernoulli_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class beta_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class binomial_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class cauchy_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class chi_squared_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class exponential_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class extreme_value_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class fisher_f_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class gamma_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class lognormal_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class negative_binomial_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class normal_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class pareto_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class poisson_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class rayleigh_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class students_t_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class triangular_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class uniform_distribution;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
class weibull_distribution;
|
||||
|
||||
}} // namespaces
|
||||
|
||||
#define BOOST_MATH_DECLARE_DISTRIBUTIONS(Type, Policy)\
|
||||
typedef boost::math::bernoulli_distribution<Type, Policy> bernoulli;\
|
||||
typedef boost::math::beta_distribution<Type, Policy> beta;\
|
||||
typedef boost::math::binomial_distribution<Type, Policy> binomial;\
|
||||
typedef boost::math::cauchy_distribution<Type, Policy> cauchy;\
|
||||
typedef boost::math::chi_squared_distribution<Type, Policy> chi_squared;\
|
||||
typedef boost::math::exponential_distribution<Type, Policy> exponential;\
|
||||
typedef boost::math::extreme_value_distribution<Type, Policy> extreme_value;\
|
||||
typedef boost::math::fisher_f_distribution<Type, Policy> fisher_f;\
|
||||
typedef boost::math::gamma_distribution<Type, Policy> gamma;\
|
||||
typedef boost::math::lognormal_distribution<Type, Policy> lognormal;\
|
||||
typedef boost::math::negative_binomial_distribution<Type, Policy> negative_binomial;\
|
||||
typedef boost::math::normal_distribution<Type, Policy> normal;\
|
||||
typedef boost::math::pareto_distribution<Type, Policy> pareto;\
|
||||
typedef boost::math::poisson_distribution<Type, Policy> poisson;\
|
||||
typedef boost::math::rayleigh_distribution<Type, Policy> rayleigh;\
|
||||
typedef boost::math::students_t_distribution<Type, Policy> students_t;\
|
||||
typedef boost::math::triangular_distribution<Type, Policy> triangular;\
|
||||
typedef boost::math::uniform_distribution<Type, Policy> uniform;\
|
||||
typedef boost::math::weibull_distribution<Type, Policy> weibull;\
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_FWD_HPP
|
||||
|
||||
@@ -1,499 +1,499 @@
|
||||
// Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
#define BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <boost/math/tools/config.hpp>
|
||||
#include <boost/math/policy/policy.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push) // Quiet warnings in boost/format.hpp
|
||||
# pragma warning(disable: 4996) // _SCL_SECURE_NO_DEPRECATE
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated.
|
||||
#endif
|
||||
#include <boost/format.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
class evaluation_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
evaluation_error(const std::string& s) : std::runtime_error(s){}
|
||||
};
|
||||
|
||||
namespace policy{
|
||||
//
|
||||
// Forward declarations of user error handlers,
|
||||
// it's up to the user to provide the definition of these:
|
||||
//
|
||||
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_evaluation_error(const char* function, const char* message, const T& val);
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class E, class T>
|
||||
void raise_error(const char* function, const char* message)
|
||||
{
|
||||
if(function == 0)
|
||||
function = "Unknown function";
|
||||
if(message == 0)
|
||||
message = "Cause unknown";
|
||||
|
||||
std::string msg("Error in function ");
|
||||
msg += (boost::format(function) % typeid(T).name()).str();
|
||||
msg += ": ";
|
||||
msg += message;
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
template <class E, class T>
|
||||
void raise_error(const char* function, const char* message, const T& val)
|
||||
{
|
||||
if(function == 0)
|
||||
function = "Unknown function";
|
||||
if(message == 0)
|
||||
message = "Cause unknown";
|
||||
|
||||
std::string msg("Error in function ");
|
||||
msg += (boost::format(function) % typeid(T).name()).str();
|
||||
msg += ": ";
|
||||
msg += message;
|
||||
|
||||
int prec = 2 + (boost::math::policy::digits<T, boost::math::policy::policy<> >() * 30103UL) / 100000UL;
|
||||
msg = (boost::format(msg) % boost::io::group(std::setprecision(prec), val)).str();
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::domain_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = EDOM;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_domain_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
return boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::throw_on_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
return ::boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::ignore_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
return ::boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::errno_on_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_pole_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow");
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_overflow_error(function, message, std::numeric_limits<T>::infinity());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "numeric underflow");
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_underflow_error(function, message, T(0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "denormalised result");
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_denorm_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<boost::math::evaluation_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = EDOM;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_evaluation_error(function, message, val);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::domain_error_type policy_type;
|
||||
return detail::raise_domain_error(
|
||||
function, message ? message : "Domain Error evaluating function at %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::pole_error_type policy_type;
|
||||
return detail::raise_pole_error(
|
||||
function, message ? message : "Evaluation of function at pole %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_overflow_error(const char* function, const char* message, const Policy&)
|
||||
{
|
||||
typedef typename Policy::overflow_error_type policy_type;
|
||||
return detail::raise_overflow_error<T>(
|
||||
function, message ? message : "Overflow Error",
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_underflow_error(const char* function, const char* message, const Policy&)
|
||||
{
|
||||
typedef typename Policy::underflow_error_type policy_type;
|
||||
return detail::raise_underflow_error<T>(
|
||||
function, message ? message : "Underflow Error",
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::denorm_error_type policy_type;
|
||||
return detail::raise_denorm_error<T>(
|
||||
function, message ? message : "Denorm Error",
|
||||
val,
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::evaluation_error_type policy_type;
|
||||
return detail::raise_evaluation_error(
|
||||
function, message ? message : "Internal Evaluation Error, best value so far was %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
//
|
||||
// checked_narrowing_cast:
|
||||
//
|
||||
namespace detail{
|
||||
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_overflow(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
using namespace std;
|
||||
if(fabs(val) > tools::max_value<R>())
|
||||
{
|
||||
*result = static_cast<R>(raise_overflow_error<R>(function, 0, pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_underflow(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
if((val != 0) && (static_cast<R>(val) == 0))
|
||||
{
|
||||
*result = static_cast<R>(raise_underflow_error<R>(function, 0, pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_denorm(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
using namespace std;
|
||||
if((fabs(val) < static_cast<T>(tools::min_value<R>())) && (static_cast<R>(val) != 0))
|
||||
{
|
||||
*result = static_cast<R>(raise_denorm_error<R>(function, 0, static_cast<R>(val), pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class R, class T>
|
||||
inline bool check_overflow(T val, R* result, const char* function, const overflow_error<ignore_error>&){ return false; }
|
||||
template <class R, class T>
|
||||
inline bool check_underflow(T val, R* result, const char* function, const underflow_error<ignore_error>&){ return false; }
|
||||
template <class R, class T>
|
||||
inline bool check_denorm(T val, R* result, const char* function, const denorm_error<ignore_error>&){ return false; }
|
||||
|
||||
}
|
||||
|
||||
template <class R, class Policy, class T>
|
||||
inline R checked_narrowing_cast(T val, const char* function)
|
||||
{
|
||||
typedef typename Policy::overflow_error_type overflow_type;
|
||||
typedef typename Policy::underflow_error_type underflow_type;
|
||||
typedef typename Policy::denorm_error_type denorm_type;
|
||||
//
|
||||
// Most of what follows will evaluate to a no-op:
|
||||
//
|
||||
R result;
|
||||
if(detail::check_overflow<R>(val, &result, function, overflow_type()))
|
||||
return result;
|
||||
if(detail::check_underflow<R>(val, &result, function, underflow_type()))
|
||||
return result;
|
||||
if(detail::check_denorm<R>(val, &result, function, denorm_type()))
|
||||
return result;
|
||||
|
||||
return static_cast<R>(val);
|
||||
}
|
||||
|
||||
template <class Policy>
|
||||
inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
|
||||
{
|
||||
if(max_iter >= BOOST_MATH_MAX_ITER)
|
||||
raise_evaluation_error<boost::uintmax_t>(
|
||||
function,
|
||||
"Series evaluation exceeded %1% iterations, giving up now.", max_iter, pol);
|
||||
}
|
||||
|
||||
} //namespace policy
|
||||
|
||||
}} // namespaces boost/math
|
||||
|
||||
#endif // BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
|
||||
// Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
#define BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <boost/math/tools/config.hpp>
|
||||
#include <boost/math/policy/policy.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push) // Quiet warnings in boost/format.hpp
|
||||
# pragma warning(disable: 4996) // _SCL_SECURE_NO_DEPRECATE
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated.
|
||||
#endif
|
||||
#include <boost/format.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
class evaluation_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
evaluation_error(const std::string& s) : std::runtime_error(s){}
|
||||
};
|
||||
|
||||
namespace policy{
|
||||
//
|
||||
// Forward declarations of user error handlers,
|
||||
// it's up to the user to provide the definition of these:
|
||||
//
|
||||
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_evaluation_error(const char* function, const char* message, const T& val);
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class E, class T>
|
||||
void raise_error(const char* function, const char* message)
|
||||
{
|
||||
if(function == 0)
|
||||
function = "Unknown function";
|
||||
if(message == 0)
|
||||
message = "Cause unknown";
|
||||
|
||||
std::string msg("Error in function ");
|
||||
msg += (boost::format(function) % typeid(T).name()).str();
|
||||
msg += ": ";
|
||||
msg += message;
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
template <class E, class T>
|
||||
void raise_error(const char* function, const char* message, const T& val)
|
||||
{
|
||||
if(function == 0)
|
||||
function = "Unknown function";
|
||||
if(message == 0)
|
||||
message = "Cause unknown";
|
||||
|
||||
std::string msg("Error in function ");
|
||||
msg += (boost::format(function) % typeid(T).name()).str();
|
||||
msg += ": ";
|
||||
msg += message;
|
||||
|
||||
int prec = 2 + (boost::math::policy::digits<T, boost::math::policy::policy<> >() * 30103UL) / 100000UL;
|
||||
msg = (boost::format(msg) % boost::io::group(std::setprecision(prec), val)).str();
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::domain_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = EDOM;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::domain_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_domain_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
return boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::throw_on_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
return ::boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::ignore_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
return ::boost::math::policy::detail::raise_domain_error(function, message, val, ::boost::math::policy::domain_error< ::boost::math::policy::errno_on_error>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::pole_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_pole_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow");
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::overflow_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_overflow_error(function, message, std::numeric_limits<T>::infinity());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "numeric underflow");
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_underflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policy::underflow_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_underflow_error(function, message, T(0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "denormalised result");
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_denorm_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::denorm_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_denorm_error(function, message, val);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::throw_on_error>&)
|
||||
{
|
||||
raise_error<boost::math::evaluation_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::ignore_error>&)
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::errno_on_error>&)
|
||||
{
|
||||
errno = EDOM;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return val;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_evaluation_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
const ::boost::math::policy::evaluation_error< ::boost::math::policy::user_error>&)
|
||||
{
|
||||
return user_evaluation_error(function, message, val);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::domain_error_type policy_type;
|
||||
return detail::raise_domain_error(
|
||||
function, message ? message : "Domain Error evaluating function at %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::pole_error_type policy_type;
|
||||
return detail::raise_pole_error(
|
||||
function, message ? message : "Evaluation of function at pole %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_overflow_error(const char* function, const char* message, const Policy&)
|
||||
{
|
||||
typedef typename Policy::overflow_error_type policy_type;
|
||||
return detail::raise_overflow_error<T>(
|
||||
function, message ? message : "Overflow Error",
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_underflow_error(const char* function, const char* message, const Policy&)
|
||||
{
|
||||
typedef typename Policy::underflow_error_type policy_type;
|
||||
return detail::raise_underflow_error<T>(
|
||||
function, message ? message : "Underflow Error",
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::denorm_error_type policy_type;
|
||||
return detail::raise_denorm_error<T>(
|
||||
function, message ? message : "Denorm Error",
|
||||
val,
|
||||
policy_type());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&)
|
||||
{
|
||||
typedef typename Policy::evaluation_error_type policy_type;
|
||||
return detail::raise_evaluation_error(
|
||||
function, message ? message : "Internal Evaluation Error, best value so far was %1%",
|
||||
val, policy_type());
|
||||
}
|
||||
|
||||
//
|
||||
// checked_narrowing_cast:
|
||||
//
|
||||
namespace detail{
|
||||
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_overflow(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
using namespace std;
|
||||
if(fabs(val) > tools::max_value<R>())
|
||||
{
|
||||
*result = static_cast<R>(raise_overflow_error<R>(function, 0, pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_underflow(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
if((val != 0) && (static_cast<R>(val) == 0))
|
||||
{
|
||||
*result = static_cast<R>(raise_underflow_error<R>(function, 0, pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <class R, class T, class Policy>
|
||||
inline bool check_denorm(T val, R* result, const char* function, const Policy& pol)
|
||||
{
|
||||
using namespace std;
|
||||
if((fabs(val) < static_cast<T>(tools::min_value<R>())) && (static_cast<R>(val) != 0))
|
||||
{
|
||||
*result = static_cast<R>(raise_denorm_error<R>(function, 0, static_cast<R>(val), pol));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class R, class T>
|
||||
inline bool check_overflow(T val, R* result, const char* function, const overflow_error<ignore_error>&){ return false; }
|
||||
template <class R, class T>
|
||||
inline bool check_underflow(T val, R* result, const char* function, const underflow_error<ignore_error>&){ return false; }
|
||||
template <class R, class T>
|
||||
inline bool check_denorm(T val, R* result, const char* function, const denorm_error<ignore_error>&){ return false; }
|
||||
|
||||
}
|
||||
|
||||
template <class R, class Policy, class T>
|
||||
inline R checked_narrowing_cast(T val, const char* function)
|
||||
{
|
||||
typedef typename Policy::overflow_error_type overflow_type;
|
||||
typedef typename Policy::underflow_error_type underflow_type;
|
||||
typedef typename Policy::denorm_error_type denorm_type;
|
||||
//
|
||||
// Most of what follows will evaluate to a no-op:
|
||||
//
|
||||
R result;
|
||||
if(detail::check_overflow<R>(val, &result, function, overflow_type()))
|
||||
return result;
|
||||
if(detail::check_underflow<R>(val, &result, function, underflow_type()))
|
||||
return result;
|
||||
if(detail::check_denorm<R>(val, &result, function, denorm_type()))
|
||||
return result;
|
||||
|
||||
return static_cast<R>(val);
|
||||
}
|
||||
|
||||
template <class Policy>
|
||||
inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
|
||||
{
|
||||
if(max_iter >= BOOST_MATH_MAX_ITER)
|
||||
raise_evaluation_error<boost::uintmax_t>(
|
||||
function,
|
||||
"Series evaluation exceeded %1% iterations, giving up now.", max_iter, pol);
|
||||
}
|
||||
|
||||
} //namespace policy
|
||||
|
||||
}} // namespaces boost/math
|
||||
|
||||
#endif // BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,42 +1,42 @@
|
||||
|
||||
#ifndef BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
#define BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
|
||||
#include <boost/math/special_functions/acosh.hpp>
|
||||
#include <boost/math/special_functions/asinh.hpp>
|
||||
#include <boost/math/special_functions/atanh.hpp>
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#include <boost/math/special_functions/beta.hpp>
|
||||
#include <boost/math/special_functions/binomial.hpp>
|
||||
#include <boost/math/special_functions/cbrt.hpp>
|
||||
#include <boost/math/special_functions/cos_pi.hpp>
|
||||
#include <boost/math/special_functions/digamma.hpp>
|
||||
#include <boost/math/special_functions/ellint_1.hpp>
|
||||
#include <boost/math/special_functions/ellint_2.hpp>
|
||||
#include <boost/math/special_functions/ellint_3.hpp>
|
||||
#include <boost/math/special_functions/ellint_rc.hpp>
|
||||
#include <boost/math/special_functions/ellint_rd.hpp>
|
||||
#include <boost/math/special_functions/ellint_rf.hpp>
|
||||
#include <boost/math/special_functions/ellint_rj.hpp>
|
||||
#include <boost/math/special_functions/erf.hpp>
|
||||
#include <boost/math/special_functions/expm1.hpp>
|
||||
#include <boost/math/special_functions/factorials.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
#include <boost/math/special_functions/hermite.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
#include <boost/math/special_functions/laguerre.hpp>
|
||||
#include <boost/math/special_functions/lanczos.hpp>
|
||||
#include <boost/math/special_functions/legendre.hpp>
|
||||
#include <boost/math/special_functions/log1p.hpp>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/powm1.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
#include <boost/math/special_functions/sin_pi.hpp>
|
||||
#include <boost/math/special_functions/sinc.hpp>
|
||||
#include <boost/math/special_functions/sinhc.hpp>
|
||||
#include <boost/math/special_functions/spherical_harmonic.hpp>
|
||||
#include <boost/math/special_functions/sqrt1pm1.hpp>
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
|
||||
|
||||
#ifndef BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
#define BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
|
||||
#include <boost/math/special_functions/acosh.hpp>
|
||||
#include <boost/math/special_functions/asinh.hpp>
|
||||
#include <boost/math/special_functions/atanh.hpp>
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#include <boost/math/special_functions/beta.hpp>
|
||||
#include <boost/math/special_functions/binomial.hpp>
|
||||
#include <boost/math/special_functions/cbrt.hpp>
|
||||
#include <boost/math/special_functions/cos_pi.hpp>
|
||||
#include <boost/math/special_functions/digamma.hpp>
|
||||
#include <boost/math/special_functions/ellint_1.hpp>
|
||||
#include <boost/math/special_functions/ellint_2.hpp>
|
||||
#include <boost/math/special_functions/ellint_3.hpp>
|
||||
#include <boost/math/special_functions/ellint_rc.hpp>
|
||||
#include <boost/math/special_functions/ellint_rd.hpp>
|
||||
#include <boost/math/special_functions/ellint_rf.hpp>
|
||||
#include <boost/math/special_functions/ellint_rj.hpp>
|
||||
#include <boost/math/special_functions/erf.hpp>
|
||||
#include <boost/math/special_functions/expm1.hpp>
|
||||
#include <boost/math/special_functions/factorials.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
#include <boost/math/special_functions/hermite.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
#include <boost/math/special_functions/laguerre.hpp>
|
||||
#include <boost/math/special_functions/lanczos.hpp>
|
||||
#include <boost/math/special_functions/legendre.hpp>
|
||||
#include <boost/math/special_functions/log1p.hpp>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/powm1.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
#include <boost/math/special_functions/sin_pi.hpp>
|
||||
#include <boost/math/special_functions/sinc.hpp>
|
||||
#include <boost/math/special_functions/sinhc.hpp>
|
||||
#include <boost/math/special_functions/spherical_harmonic.hpp>
|
||||
#include <boost/math/special_functions/sqrt1pm1.hpp>
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_FUNCTIONS_HPP
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,89 +1,89 @@
|
||||
// Copyright John Maddock 2007.
|
||||
// Copyright Paul A. Bristow 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_TOOLS_USER_HPP
|
||||
#define BOOST_MATH_TOOLS_USER_HPP
|
||||
|
||||
// This file can be modified by the user to change the default policies.
|
||||
// See "Changing the Policy Defaults" in documentation.
|
||||
|
||||
//
|
||||
// The maximum number of iterations in series evaluations etc:
|
||||
//
|
||||
// #define BOOST_MATH_MAX_ITER 1000000
|
||||
//
|
||||
// define this if the platform has no long double functions,
|
||||
// or if the long double versions have only double precision:
|
||||
//
|
||||
// #define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
//
|
||||
// Performance tuning options:
|
||||
//
|
||||
// #define BOOST_MATH_POLY_METHOD 3
|
||||
// #define BOOST_MATH_RATIONAL_METHOD 3
|
||||
//
|
||||
// The maximum order of polynomial that will be evaluated
|
||||
// via an unrolled specialisation:
|
||||
//
|
||||
// #define BOOST_MATH_MAX_POLY_ORDER 17
|
||||
//
|
||||
// decide whether to store constants as integers or reals:
|
||||
//
|
||||
// #define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
|
||||
|
||||
//
|
||||
// Default policies follow:
|
||||
//
|
||||
// Domain errors:
|
||||
//
|
||||
// #define BOOST_MATH_DOMAIN_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Pole errors:
|
||||
//
|
||||
// #define BOOST_MATH_POLE_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Overflow Errors:
|
||||
//
|
||||
// #define BOOST_MATH_OVERFLOW_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Internal Evaluation Errors:
|
||||
//
|
||||
// #define BOOST_MATH_EVALUATION_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Underfow:
|
||||
//
|
||||
// #define BOOST_MATH_UNDERFLOW_ERROR_POLICY ignore_error
|
||||
//
|
||||
// Denorms:
|
||||
//
|
||||
// #define BOOST_MATH_DENORM_ERROR_POLICY ignore_error
|
||||
//
|
||||
// Max digits to use for internal calculations:
|
||||
//
|
||||
// #define BOOST_MATH_DIGITS10_POLICY 0
|
||||
//
|
||||
// Promote floats to doubles internally?
|
||||
//
|
||||
// #define BOOST_MATH_PROMOTE_FLOAT_POLICY true
|
||||
//
|
||||
// Promote doubles to long double internally:
|
||||
//
|
||||
// #define BOOST_MATH_PROMOTE_DOUBLE_POLICY true
|
||||
//
|
||||
// What do discrete quantiles return?
|
||||
//
|
||||
// #define BOOST_MATH_DISCRETE_QUANTILE_POLICY integer_outside
|
||||
//
|
||||
// If a function is mathematically undefined
|
||||
// (for example the Cauchy distribution has no mean),
|
||||
// then do we stop the code from compiling?
|
||||
//
|
||||
// #define BOOST_MATH_ASSERT_UNDEFINED_POLICY true
|
||||
|
||||
#endif // BOOST_MATH_TOOLS_USER_HPP
|
||||
|
||||
// Copyright John Maddock 2007.
|
||||
// Copyright Paul A. Bristow 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_TOOLS_USER_HPP
|
||||
#define BOOST_MATH_TOOLS_USER_HPP
|
||||
|
||||
// This file can be modified by the user to change the default policies.
|
||||
// See "Changing the Policy Defaults" in documentation.
|
||||
|
||||
//
|
||||
// The maximum number of iterations in series evaluations etc:
|
||||
//
|
||||
// #define BOOST_MATH_MAX_ITER 1000000
|
||||
//
|
||||
// define this if the platform has no long double functions,
|
||||
// or if the long double versions have only double precision:
|
||||
//
|
||||
// #define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
//
|
||||
// Performance tuning options:
|
||||
//
|
||||
// #define BOOST_MATH_POLY_METHOD 3
|
||||
// #define BOOST_MATH_RATIONAL_METHOD 3
|
||||
//
|
||||
// The maximum order of polynomial that will be evaluated
|
||||
// via an unrolled specialisation:
|
||||
//
|
||||
// #define BOOST_MATH_MAX_POLY_ORDER 17
|
||||
//
|
||||
// decide whether to store constants as integers or reals:
|
||||
//
|
||||
// #define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
|
||||
|
||||
//
|
||||
// Default policies follow:
|
||||
//
|
||||
// Domain errors:
|
||||
//
|
||||
// #define BOOST_MATH_DOMAIN_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Pole errors:
|
||||
//
|
||||
// #define BOOST_MATH_POLE_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Overflow Errors:
|
||||
//
|
||||
// #define BOOST_MATH_OVERFLOW_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Internal Evaluation Errors:
|
||||
//
|
||||
// #define BOOST_MATH_EVALUATION_ERROR_POLICY throw_on_error
|
||||
//
|
||||
// Underfow:
|
||||
//
|
||||
// #define BOOST_MATH_UNDERFLOW_ERROR_POLICY ignore_error
|
||||
//
|
||||
// Denorms:
|
||||
//
|
||||
// #define BOOST_MATH_DENORM_ERROR_POLICY ignore_error
|
||||
//
|
||||
// Max digits to use for internal calculations:
|
||||
//
|
||||
// #define BOOST_MATH_DIGITS10_POLICY 0
|
||||
//
|
||||
// Promote floats to doubles internally?
|
||||
//
|
||||
// #define BOOST_MATH_PROMOTE_FLOAT_POLICY true
|
||||
//
|
||||
// Promote doubles to long double internally:
|
||||
//
|
||||
// #define BOOST_MATH_PROMOTE_DOUBLE_POLICY true
|
||||
//
|
||||
// What do discrete quantiles return?
|
||||
//
|
||||
// #define BOOST_MATH_DISCRETE_QUANTILE_POLICY integer_outside
|
||||
//
|
||||
// If a function is mathematically undefined
|
||||
// (for example the Cauchy distribution has no mean),
|
||||
// then do we stop the code from compiling?
|
||||
//
|
||||
// #define BOOST_MATH_ASSERT_UNDEFINED_POLICY true
|
||||
|
||||
#endif // BOOST_MATH_TOOLS_USER_HPP
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,229 +1,229 @@
|
||||
|
||||
// Copyright John Maddock 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/math/policy/policy.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/test/included/test_exec_monitor.hpp> // for test_main
|
||||
|
||||
template <class P1, class P2>
|
||||
bool check_same(const P1&, const P2&)
|
||||
{
|
||||
if(!boost::is_same<P1, P2>::value)
|
||||
{
|
||||
std::cout << "P1 = " << typeid(P1).name() << std::endl;
|
||||
std::cout << "P2 = " << typeid(P2).name() << std::endl;
|
||||
}
|
||||
return boost::is_same<P1, P2>::value;
|
||||
}
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
using namespace boost::math::policy;
|
||||
using namespace boost;
|
||||
BOOST_CHECK(is_domain_error<domain_error<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_domain_error<pole_error<ignore_error> >::value);
|
||||
BOOST_CHECK(is_pole_error<pole_error<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_pole_error<domain_error<ignore_error> >::value);
|
||||
BOOST_CHECK(is_digits10<digits10<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_digits10<digits2<ignore_error> >::value);
|
||||
|
||||
BOOST_CHECK((is_same<policy<>::domain_error_type, domain_error<BOOST_MATH_DOMAIN_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<>::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::pole_error_type, pole_error<user_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::overflow_error_type, overflow_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::underflow_error_type, underflow_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::denorm_error_type, denorm_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::evaluation_error_type, evaluation_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::promote_double_type, promote_double<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::discrete_quantile_type, discrete_quantile<integer_above> >::value));
|
||||
|
||||
//
|
||||
// Now try again with 2 policies:
|
||||
//
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::overflow_error_type, overflow_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK(check_same(make_policy(), policy<>()));
|
||||
BOOST_CHECK(check_same(make_policy(denorm_error<ignore_error>()), normalise<policy<denorm_error<ignore_error> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(digits2<20>()), normalise<policy<digits2<20> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(promote_float<false>()), normalise<policy<promote_float<false> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), normalise<policy<domain_error<ignore_error> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(pole_error<ignore_error>()), normalise<policy<pole_error<ignore_error> > >::type()));
|
||||
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), policy<domain_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits10<5>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<19> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>(), promote_double<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false>, promote_double<false> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>(), promote_double<false>(), discrete_quantile<integer_below>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false>, promote_double<false>, discrete_quantile<integer_below> >()));
|
||||
|
||||
return 0;
|
||||
} // int test_main(int, char* [])
|
||||
|
||||
|
||||
|
||||
// Copyright John Maddock 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/math/policy/policy.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/test/included/test_exec_monitor.hpp> // for test_main
|
||||
|
||||
template <class P1, class P2>
|
||||
bool check_same(const P1&, const P2&)
|
||||
{
|
||||
if(!boost::is_same<P1, P2>::value)
|
||||
{
|
||||
std::cout << "P1 = " << typeid(P1).name() << std::endl;
|
||||
std::cout << "P2 = " << typeid(P2).name() << std::endl;
|
||||
}
|
||||
return boost::is_same<P1, P2>::value;
|
||||
}
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
using namespace boost::math::policy;
|
||||
using namespace boost;
|
||||
BOOST_CHECK(is_domain_error<domain_error<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_domain_error<pole_error<ignore_error> >::value);
|
||||
BOOST_CHECK(is_pole_error<pole_error<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_pole_error<domain_error<ignore_error> >::value);
|
||||
BOOST_CHECK(is_digits10<digits10<ignore_error> >::value);
|
||||
BOOST_CHECK(0 == is_digits10<digits2<ignore_error> >::value);
|
||||
|
||||
BOOST_CHECK((is_same<policy<>::domain_error_type, domain_error<BOOST_MATH_DOMAIN_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<>::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::pole_error_type, pole_error<user_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<pole_error<user_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::overflow_error_type, overflow_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<overflow_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::underflow_error_type, underflow_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<underflow_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::denorm_error_type, denorm_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::evaluation_error_type, evaluation_error<errno_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<evaluation_error<errno_on_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<promote_float<false> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::promote_double_type, promote_double<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<promote_double<false> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::domain_error_type, policy<>::domain_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::pole_error_type, policy<>::pole_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::overflow_error_type, policy<>::overflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::underflow_error_type, policy<>::underflow_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::denorm_error_type, policy<>::denorm_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::evaluation_error_type, policy<>::evaluation_error_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::precision_type, policy<>::precision_type >::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<discrete_quantile<integer_above> >::discrete_quantile_type, discrete_quantile<integer_above> >::value));
|
||||
|
||||
//
|
||||
// Now try again with 2 policies:
|
||||
//
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::overflow_error_type, overflow_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::denorm_error_type, denorm_error<BOOST_MATH_DENORM_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<domain_error<ignore_error>, overflow_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::precision_type, policy<>::precision_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_float_type, policy<>::promote_float_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<denorm_error<throw_on_error>, domain_error<ignore_error> >::discrete_quantile_type, policy<>::discrete_quantile_type>::value));
|
||||
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> > >::type::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::domain_error_type, domain_error<ignore_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::pole_error_type, pole_error<BOOST_MATH_POLE_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::overflow_error_type, overflow_error<BOOST_MATH_OVERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::underflow_error_type, underflow_error<BOOST_MATH_UNDERFLOW_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::denorm_error_type, denorm_error<throw_on_error> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::evaluation_error_type, evaluation_error<BOOST_MATH_EVALUATION_ERROR_POLICY> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::precision_type, digits2<20> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::promote_float_type, promote_float<false> >::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::promote_double_type, policy<>::promote_double_type>::value));
|
||||
BOOST_CHECK((is_same<normalise<policy<>, digits2<20>, promote_float<false>, discrete_quantile<integer_below>, denorm_error<throw_on_error>, domain_error<ignore_error> >::type::discrete_quantile_type, discrete_quantile<integer_below> >::value));
|
||||
|
||||
BOOST_CHECK(check_same(make_policy(), policy<>()));
|
||||
BOOST_CHECK(check_same(make_policy(denorm_error<ignore_error>()), normalise<policy<denorm_error<ignore_error> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(digits2<20>()), normalise<policy<digits2<20> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(promote_float<false>()), normalise<policy<promote_float<false> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), normalise<policy<domain_error<ignore_error> > >::type()));
|
||||
BOOST_CHECK(check_same(make_policy(pole_error<ignore_error>()), normalise<policy<pole_error<ignore_error> > >::type()));
|
||||
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), policy<domain_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits10<5>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<19> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>(), promote_double<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false>, promote_double<false> >()));
|
||||
BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), digits2<10>(), promote_float<false>(), promote_double<false>(), discrete_quantile<integer_below>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, digits2<10>, promote_float<false>, promote_double<false>, discrete_quantile<integer_below> >()));
|
||||
|
||||
return 0;
|
||||
} // int test_main(int, char* [])
|
||||
|
||||
|
||||
|
||||
@@ -1,128 +1,128 @@
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
#include <boost/math/special_functions.hpp>
|
||||
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// ~~~~~~~~~~~~
|
||||
//
|
||||
// This file provides very basic sanity checks for the special functions
|
||||
// declared with BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS, basically we
|
||||
// just want to make sure that the inline forwarding functions do
|
||||
// actually forward to the right function!!
|
||||
//
|
||||
|
||||
namespace test{
|
||||
|
||||
typedef boost::math::policy::policy<> policy;
|
||||
|
||||
BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(policy);
|
||||
|
||||
}
|
||||
|
||||
#define TEST_POLICY_SF(call)\
|
||||
BOOST_CHECK_EQUAL(boost::math::call , test::call)
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
int i;
|
||||
TEST_POLICY_SF(tgamma(3.0));
|
||||
TEST_POLICY_SF(tgamma1pm1(0.25));
|
||||
TEST_POLICY_SF(lgamma(50.0));
|
||||
TEST_POLICY_SF(lgamma(50.0, &i));
|
||||
TEST_POLICY_SF(digamma(12.0));
|
||||
TEST_POLICY_SF(tgamma_ratio(12.0, 13.5));
|
||||
TEST_POLICY_SF(tgamma_delta_ratio(100.0, 0.25));
|
||||
TEST_POLICY_SF(factorial<double>(8));
|
||||
TEST_POLICY_SF(unchecked_factorial<double>(3));
|
||||
TEST_POLICY_SF(double_factorial<double>(5));
|
||||
TEST_POLICY_SF(rising_factorial(20.5, 5));
|
||||
TEST_POLICY_SF(falling_factorial(10.2, 7));
|
||||
TEST_POLICY_SF(tgamma(12.0, 13.0));
|
||||
TEST_POLICY_SF(tgamma_lower(12.0, 13.0));
|
||||
TEST_POLICY_SF(gamma_p(12.0, 13.0));
|
||||
TEST_POLICY_SF(gamma_q(12.0, 15.0));
|
||||
TEST_POLICY_SF(gamma_p_inv(12.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_q_inv(15.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_p_inva(12.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_q_inva(12.0, 0.25));
|
||||
TEST_POLICY_SF(erf(2.5));
|
||||
TEST_POLICY_SF(erfc(2.5));
|
||||
TEST_POLICY_SF(erf_inv(0.25));
|
||||
TEST_POLICY_SF(erfc_inv(0.25));
|
||||
TEST_POLICY_SF(beta(12.0, 15.0));
|
||||
TEST_POLICY_SF(beta(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(betac(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibetac(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta_inv(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibetac_inv(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta_inva(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibetac_inva(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibeta_invb(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibetac_invb(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(gamma_p_derivative(12.0, 15.0));
|
||||
TEST_POLICY_SF(ibeta_derivative(12.0, 15.75, 0.25));
|
||||
TEST_POLICY_SF(fpclassify(12.0));
|
||||
TEST_POLICY_SF(isfinite(12.0));
|
||||
TEST_POLICY_SF(isnormal(12.0));
|
||||
TEST_POLICY_SF(isnan(12.0));
|
||||
TEST_POLICY_SF(isinf(12.0));
|
||||
TEST_POLICY_SF(log1p(0.0025));
|
||||
TEST_POLICY_SF(expm1(0.0025));
|
||||
TEST_POLICY_SF(cbrt(30.0));
|
||||
TEST_POLICY_SF(sqrt1pm1(0.0025));
|
||||
TEST_POLICY_SF(powm1(1.0025, 12.0));
|
||||
TEST_POLICY_SF(legendre_p(5, 0.75));
|
||||
TEST_POLICY_SF(legendre_p(7, 3, 0.75));
|
||||
TEST_POLICY_SF(legendre_q(5, 0.75));
|
||||
TEST_POLICY_SF(legendre_next(2, 0.25, 12.0, 5.0));
|
||||
TEST_POLICY_SF(legendre_next(2, 2, 0.25, 12.0, 5.0));
|
||||
TEST_POLICY_SF(laguerre(5, 12.2));
|
||||
TEST_POLICY_SF(laguerre(7, 3, 5.0));
|
||||
TEST_POLICY_SF(laguerre_next(2, 5.0, 12.0, 5.0));
|
||||
TEST_POLICY_SF(laguerre_next(5, 3, 5.0, 20.0, 10.0));
|
||||
TEST_POLICY_SF(hermite(1, 2.0));
|
||||
TEST_POLICY_SF(hermite_next(2, 2.0, 3.0, 2.0));
|
||||
TEST_POLICY_SF(spherical_harmonic_r(5, 4, 0.75, 0.25));
|
||||
TEST_POLICY_SF(spherical_harmonic_i(5, 4, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ellint_1(0.25));
|
||||
TEST_POLICY_SF(ellint_1(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_2(0.25));
|
||||
TEST_POLICY_SF(ellint_2(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_3(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_3(0.25, 0.125, 0.75));
|
||||
TEST_POLICY_SF(ellint_rc(3.0, 5.0));
|
||||
TEST_POLICY_SF(ellint_rd(2.0, 3.0, 4.0));
|
||||
TEST_POLICY_SF(ellint_rf(2.0, 3.0, 4.0));
|
||||
TEST_POLICY_SF(ellint_rj(2.0, 3.0, 5.0, 0.25));
|
||||
TEST_POLICY_SF(hypot(5.0, 3.0));
|
||||
TEST_POLICY_SF(sinc_pi(3.0));
|
||||
TEST_POLICY_SF(sinhc_pi(2.0));
|
||||
TEST_POLICY_SF(asinh(12.0));
|
||||
TEST_POLICY_SF(acosh(5.0));
|
||||
TEST_POLICY_SF(atanh(0.75));
|
||||
TEST_POLICY_SF(sin_pi(5.0));
|
||||
TEST_POLICY_SF(cos_pi(6.0));
|
||||
TEST_POLICY_SF(cyl_neumann(2.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_neumann(2, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_j(2.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_j(2, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_i(3.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_i(3, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_k(3.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_k(3, 5.0));
|
||||
TEST_POLICY_SF(sph_bessel(3, 5.0));
|
||||
TEST_POLICY_SF(sph_bessel(3, 5));
|
||||
TEST_POLICY_SF(sph_neumann(3, 5.0));
|
||||
TEST_POLICY_SF(sph_neumann(3, 5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
#include <boost/math/special_functions.hpp>
|
||||
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// ~~~~~~~~~~~~
|
||||
//
|
||||
// This file provides very basic sanity checks for the special functions
|
||||
// declared with BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS, basically we
|
||||
// just want to make sure that the inline forwarding functions do
|
||||
// actually forward to the right function!!
|
||||
//
|
||||
|
||||
namespace test{
|
||||
|
||||
typedef boost::math::policy::policy<> policy;
|
||||
|
||||
BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(policy);
|
||||
|
||||
}
|
||||
|
||||
#define TEST_POLICY_SF(call)\
|
||||
BOOST_CHECK_EQUAL(boost::math::call , test::call)
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
int i;
|
||||
TEST_POLICY_SF(tgamma(3.0));
|
||||
TEST_POLICY_SF(tgamma1pm1(0.25));
|
||||
TEST_POLICY_SF(lgamma(50.0));
|
||||
TEST_POLICY_SF(lgamma(50.0, &i));
|
||||
TEST_POLICY_SF(digamma(12.0));
|
||||
TEST_POLICY_SF(tgamma_ratio(12.0, 13.5));
|
||||
TEST_POLICY_SF(tgamma_delta_ratio(100.0, 0.25));
|
||||
TEST_POLICY_SF(factorial<double>(8));
|
||||
TEST_POLICY_SF(unchecked_factorial<double>(3));
|
||||
TEST_POLICY_SF(double_factorial<double>(5));
|
||||
TEST_POLICY_SF(rising_factorial(20.5, 5));
|
||||
TEST_POLICY_SF(falling_factorial(10.2, 7));
|
||||
TEST_POLICY_SF(tgamma(12.0, 13.0));
|
||||
TEST_POLICY_SF(tgamma_lower(12.0, 13.0));
|
||||
TEST_POLICY_SF(gamma_p(12.0, 13.0));
|
||||
TEST_POLICY_SF(gamma_q(12.0, 15.0));
|
||||
TEST_POLICY_SF(gamma_p_inv(12.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_q_inv(15.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_p_inva(12.0, 0.25));
|
||||
TEST_POLICY_SF(gamma_q_inva(12.0, 0.25));
|
||||
TEST_POLICY_SF(erf(2.5));
|
||||
TEST_POLICY_SF(erfc(2.5));
|
||||
TEST_POLICY_SF(erf_inv(0.25));
|
||||
TEST_POLICY_SF(erfc_inv(0.25));
|
||||
TEST_POLICY_SF(beta(12.0, 15.0));
|
||||
TEST_POLICY_SF(beta(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(betac(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibetac(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta_inv(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibetac_inv(12.0, 15.0, 0.25));
|
||||
TEST_POLICY_SF(ibeta_inva(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibetac_inva(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibeta_invb(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ibetac_invb(12.0, 0.75, 0.25));
|
||||
TEST_POLICY_SF(gamma_p_derivative(12.0, 15.0));
|
||||
TEST_POLICY_SF(ibeta_derivative(12.0, 15.75, 0.25));
|
||||
TEST_POLICY_SF(fpclassify(12.0));
|
||||
TEST_POLICY_SF(isfinite(12.0));
|
||||
TEST_POLICY_SF(isnormal(12.0));
|
||||
TEST_POLICY_SF(isnan(12.0));
|
||||
TEST_POLICY_SF(isinf(12.0));
|
||||
TEST_POLICY_SF(log1p(0.0025));
|
||||
TEST_POLICY_SF(expm1(0.0025));
|
||||
TEST_POLICY_SF(cbrt(30.0));
|
||||
TEST_POLICY_SF(sqrt1pm1(0.0025));
|
||||
TEST_POLICY_SF(powm1(1.0025, 12.0));
|
||||
TEST_POLICY_SF(legendre_p(5, 0.75));
|
||||
TEST_POLICY_SF(legendre_p(7, 3, 0.75));
|
||||
TEST_POLICY_SF(legendre_q(5, 0.75));
|
||||
TEST_POLICY_SF(legendre_next(2, 0.25, 12.0, 5.0));
|
||||
TEST_POLICY_SF(legendre_next(2, 2, 0.25, 12.0, 5.0));
|
||||
TEST_POLICY_SF(laguerre(5, 12.2));
|
||||
TEST_POLICY_SF(laguerre(7, 3, 5.0));
|
||||
TEST_POLICY_SF(laguerre_next(2, 5.0, 12.0, 5.0));
|
||||
TEST_POLICY_SF(laguerre_next(5, 3, 5.0, 20.0, 10.0));
|
||||
TEST_POLICY_SF(hermite(1, 2.0));
|
||||
TEST_POLICY_SF(hermite_next(2, 2.0, 3.0, 2.0));
|
||||
TEST_POLICY_SF(spherical_harmonic_r(5, 4, 0.75, 0.25));
|
||||
TEST_POLICY_SF(spherical_harmonic_i(5, 4, 0.75, 0.25));
|
||||
TEST_POLICY_SF(ellint_1(0.25));
|
||||
TEST_POLICY_SF(ellint_1(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_2(0.25));
|
||||
TEST_POLICY_SF(ellint_2(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_3(0.25, 0.75));
|
||||
TEST_POLICY_SF(ellint_3(0.25, 0.125, 0.75));
|
||||
TEST_POLICY_SF(ellint_rc(3.0, 5.0));
|
||||
TEST_POLICY_SF(ellint_rd(2.0, 3.0, 4.0));
|
||||
TEST_POLICY_SF(ellint_rf(2.0, 3.0, 4.0));
|
||||
TEST_POLICY_SF(ellint_rj(2.0, 3.0, 5.0, 0.25));
|
||||
TEST_POLICY_SF(hypot(5.0, 3.0));
|
||||
TEST_POLICY_SF(sinc_pi(3.0));
|
||||
TEST_POLICY_SF(sinhc_pi(2.0));
|
||||
TEST_POLICY_SF(asinh(12.0));
|
||||
TEST_POLICY_SF(acosh(5.0));
|
||||
TEST_POLICY_SF(atanh(0.75));
|
||||
TEST_POLICY_SF(sin_pi(5.0));
|
||||
TEST_POLICY_SF(cos_pi(6.0));
|
||||
TEST_POLICY_SF(cyl_neumann(2.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_neumann(2, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_j(2.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_j(2, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_i(3.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_i(3, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_k(3.0, 5.0));
|
||||
TEST_POLICY_SF(cyl_bessel_k(3, 5.0));
|
||||
TEST_POLICY_SF(sph_bessel(3, 5.0));
|
||||
TEST_POLICY_SF(sph_bessel(3, 5));
|
||||
TEST_POLICY_SF(sph_neumann(3, 5.0));
|
||||
TEST_POLICY_SF(sph_neumann(3, 5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, double>(double, double);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, double>(double, double);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, int>(double, int);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, int>(double, int);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, unsigned>(double, unsigned);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, unsigned>(double, unsigned);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<double, unsigned long long>(double, unsigned long long);
|
||||
#endif
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<double, unsigned long long>(double, unsigned long long);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, float>(double, float);
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<double, float>(double, float);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, float>(float, float);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, float>(float, float);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, int>(float, int);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, int>(float, int);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, unsigned>(float, unsigned);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<float, unsigned>(float, unsigned);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<float, unsigned long long>(float, unsigned long long);
|
||||
#endif
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<float, unsigned long long>(float, unsigned long long);
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, long double>(long double, long double);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, long double>(long double, long double);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, int>(long double, int);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, int>(long double, int);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, unsigned>(long double, unsigned);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, unsigned>(long double, unsigned);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<long double, unsigned long long>(long double, unsigned long long);
|
||||
#endif
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<long double, unsigned long long>(long double, unsigned long long);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, float>(long double, float);
|
||||
|
||||
#include "test_rational.hpp"
|
||||
|
||||
template void do_test_spots<long double, float>(long double, float);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, boost::math::concepts::real_concept>(boost::math::concepts::real_concept, boost::math::concepts::real_concept);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, boost::math::concepts::real_concept>(boost::math::concepts::real_concept, boost::math::concepts::real_concept);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, int>(boost::math::concepts::real_concept, int);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, int>(boost::math::concepts::real_concept, int);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, unsigned>(boost::math::concepts::real_concept, unsigned);
|
||||
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, unsigned>(boost::math::concepts::real_concept, unsigned);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<boost::math::concepts::real_concept, unsigned long long>(boost::math::concepts::real_concept, unsigned long long);
|
||||
#endif
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template void do_test_spots<boost::math::concepts::real_concept, unsigned long long>(boost::math::concepts::real_concept, unsigned long long);
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, float>(boost::math::concepts::real_concept, float);
|
||||
|
||||
#include "test_rational.hpp"
|
||||
#include <boost/math/concepts/real_concept.hpp>
|
||||
|
||||
template void do_test_spots<boost::math::concepts::real_concept, float>(boost::math::concepts::real_concept, float);
|
||||
|
||||
Reference in New Issue
Block a user