2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merged changes in Trunk.

[SVN r40161]
This commit is contained in:
John Maddock
2007-10-18 18:05:13 +00:00
parent 6d989d0a4a
commit 722a2d848d
234 changed files with 3373 additions and 2157 deletions

View File

@@ -75,5 +75,11 @@ for these distributions.
[endsect]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -189,3 +189,9 @@ f[sub [nu]], the Wronskian yields I[sub [nu]](x) directly.
[endsect]
[/
Copyright 2006 John Maddock, Paul A. Bristow and Xiaogang Zhang.
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).
]

View File

@@ -116,3 +116,9 @@ __sph_neumann.
[endsect]
[/
Copyright 2006 John Maddock, Paul A. Bristow and Xiaogang Zhang.
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).
]

View File

@@ -54,7 +54,7 @@ cyclic for large /x/, but tends to -[infin][space] for small /x/:
[h4 Testing]
There are two sets of test values: spot values calculated using
[@http//:functions.wolfram.com functions.wolfram.com],
[@http://functions.wolfram.com functions.wolfram.com],
and a much larger set of tests computed using
a simplified version of this implementation
(with all the special case handling removed).
@@ -129,7 +129,7 @@ perform much better when the arguments become large, __cephes in particular prod
some remarkably inaccurate results with some of the test data (no significant figures
correct), and even GSL performs badly with some inputs to J[sub v]. Note that
by way of double-checking these results, the worst performing __cephes and GSL cases
were recomputed using [@http//:functions.wolfram.com functions.wolfram.com],
were recomputed using [@http://functions.wolfram.com functions.wolfram.com],
and the result checked against our test data: no errors in the test data were found.
[h4 Implementation]
@@ -253,3 +253,9 @@ without backward recurrence.
[endsect]
[/
Copyright 2006 John Maddock, Paul A. Bristow and Xiaogang Zhang.
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).
]

View File

@@ -79,3 +79,9 @@ main definition as x [rarr] 0.
[endsect]
[/
Copyright 2006 John Maddock, Paul A. Bristow and Xiaogang Zhang.
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).
]

View File

@@ -16,7 +16,7 @@ in NTL.
Finally there is a high precision __lanczos suitable for use with `boost::math::ntl::RR`,
used at 1000-bit precision in
[@../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp].
[@../../../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp].
The approximation has a theoretical precision of > 90 decimal digits,
and an experimental precision of > 100 decimal digits. To use that
approximation, just include that header before any of the special
@@ -116,7 +116,7 @@ synthesised from the others, and so no explicit specialisation is required.
# The function `epsilon` can be synthesised from the others, so no
explicit specialisation is required provided the precision
of RealType does not vary at runtime (see the header
[@../../../../../boost/math/tools/ntl.hpp boost/math/tools/ntl.hpp]
[@../../../../../boost/math/bindings/rr.hpp boost/math/bindings/rr.hpp]
for an example where the precision does vary at runtime).
# The functions `digits`, `max_value` and `min_value`, all get synthesised
automatically from `std::numeric_limits`. However, if `numeric_limits`
@@ -185,7 +185,7 @@ In addition, for efficient and accurate results, a __lanczos is highly desirable
You may be able to adapt an existing approximation from
[@../../../../../boost/math/special_functions/lanczos.hpp
boost/math/special_functions/lanczos.hpp] or
[@../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp]:
[@../../../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp]:
you will need change
static_cast's to lexical_cast's, and the constants to /strings/
(in order to ensure the coefficients aren't truncated to long double)
@@ -280,7 +280,7 @@ compile if the all the standard library functions used have
been brought into the current scope with a using declaration.
There is a test program
[@../../../teststd_real_concept_check.cpp libs/math/test/std_real_concept_check.cpp]
[@../../../test/std_real_concept_check.cpp libs/math/test/std_real_concept_check.cpp]
that instantiates every template in this library with type
`std_real_concept` to verify it's usage of standard library functions.
@@ -335,7 +335,7 @@ The class template `DistributionConcept` is a
for distribution types.
The test program
[@../../../test/distribution_concept_check.cpp distribution_concept_check.cpp]
[@../../../test/compile_test/distribution_concept_check.cpp distribution_concept_check.cpp]
is responsible for using `DistributionConcept` to verify that all the
distributions in this library conform to the
[link math_toolkit.using_udt.dist_concept Distribution concept].

View File

@@ -15,3 +15,11 @@ You can also find JM at john - at - johnmaddock.co.uk and PAB at
pbristow - at - hetp.u-net.com.
[endsect]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -109,3 +109,10 @@ the binomial distribution with a single trial should be used, for example:
[endsect][/section:bernoulli_dist bernoulli]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -322,3 +322,11 @@ less than 1 in 1000 chance of observing a component failure
[endsect] [/section:binom_size_eg Estimating Sample Sizes for a Binomial Distribution.]
[endsect][/section:binom_eg Binomial Distribution]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -178,7 +178,7 @@ situations where we wish to compare the standard deviation of a new
process to an established one.
The code for this example is contained in
[@../../../chi_square_std_dev_test.cpp chi_square_std_dev_test.cpp], and
[@../../../example/chi_square_std_dev_test.cpp chi_square_std_dev_test.cpp], and
we'll begin by defining the procedure that will print out the test
statistics:
@@ -372,7 +372,7 @@ some acceptable risk of type I failure /alpha/, type II failure
note that the method used works on variance, and not standard deviation
as is usual for the Chi Squared Test.
The code for this example is located in [@../../../chi_square_std_dev_test.cpp
The code for this example is located in [@../../../example/chi_square_std_dev_test.cpp
chi_square_std_dev_test.cpp].
We begin by defining a procedure to print out the sample sizes required
@@ -490,3 +490,11 @@ risk of failing to reject the null-hypothesis is also 0.05
[endsect][/section:chi_sq_size Estimating the Required Sample Sizes for a Chi-Square Test for the Standard Deviation]
[endsect][/section:cs_eg Chi Squared Distribution]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -1,4 +1,4 @@
[section:distribution_construction_eg Distribution Construction Example]
[section:dist_construct_eg Distribution Construction Example]
See [@../../../example/distribution_construction.cpp distribution_construction.cpp] for full source code.
@@ -6,4 +6,12 @@ See [@../../../example/distribution_construction.cpp distribution_construction.c
[distribution_construction1]
[distribution_construction2]
[endsect] [/section:distribution_construction_eg Distribution Construction Example]
[endsect] [/section:dist_construct_eg Distribution Construction Example]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -13,7 +13,7 @@ The data for this case study were collected by Said Jahanmir of the
NIST Ceramics Division in 1996 in connection with a NIST/industry
ceramics consortium for strength optimization of ceramic strength.
The example program is [@../example/f_test.cpp f_test.cpp],
The example program is [@../../../example/f_test.cpp f_test.cpp],
program output has been deliberately made as similar as possible
to the DATAPLOT output in the corresponding
[@http://www.itl.nist.gov/div898/handbook/eda/section3/eda359.htm
@@ -210,3 +210,11 @@ hypothesis must be rejected. We therefore conclude that there is a change
for the better in our standard deviation.
[endsect][/section:f_eg F Distribution]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -30,3 +30,10 @@ for full source code & appended program output.
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -129,3 +129,10 @@ and /q = 1-p/.
[endsect][/section:normal_dist Normal]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -110,3 +110,10 @@ and /q = 1-p/.
[endsect][/section:normal_dist Normal]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -51,3 +51,10 @@ See [@../../../example/binomial_example_nag.cpp binomial_example_nag.cpp] for de
[endsect] [/section:nag_library Comparison with C, R, FORTRAN-style Free Functions]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -182,3 +182,11 @@ Example program showing output of a table of values of cdf and pdf for various k
[endsect] [/section:negative_binomial_example1 Negative Binomial example 2.]
[endsect] [/section:neg_binom_eg Negative Binomial Distribution Examples]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -27,3 +27,10 @@ normal_misc_examples.cpp] illustrates their use.
[endsect] [/section:normal_misc Some Miscellaneous Examples of the Normal Distribution]
[endsect] [/section:normal_example Normal Distribution Examples]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -105,3 +105,10 @@ and its complement /q = 1-p/.
[endsect][/section:pareto pareto]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -110,3 +110,10 @@ In the following table [sigma][space] is the sigma parameter of the distribution
[endsect][/section:Rayleigh Rayleigh]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -773,3 +773,10 @@ in order to obtain a significant result].
[endsect][/section:st_eg Student's t]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -154,9 +154,15 @@ Some 'known good' test values were obtained from
* Evans, M.; Hastings, N.; and Peacock, B. "Triangular Distribution." Ch. 40 in Statistical Distributions, 3rd ed. New York: Wiley, pp. 187-188, 2000, ISBN - 0471371246]
* [@http://www.brighton-webs.co.uk/distributions/triangular.asp Brighton Webs Ltd. BW D-Calc 1.0 Distribution Calculator]
* [@http://www.worldscibooks.com/mathematics/etextbook/5720/5720_chap1.pdf The Triangular Distribution including its history.]
* [@www.measurement.sk/2002/S1/Wimmer2.pdf Gejza Wimmer, Viktor Witkovsky and Tomas Duby,
* [@http://www.measurement.sk/2002/S1/Wimmer2.pdf Gejza Wimmer, Viktor Witkovsky and Tomas Duby,
Measurement Science Review, Volume 2, Section 1, 2002, Proper Rounding Of The Measurement Results Under The Assumption Of Triangular Distribution.]
[endsect][/section:triangular_dist triangular]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -125,3 +125,10 @@ b is the /upper/ parameter,
[endsect][/section:uniform_dist Uniform]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -119,3 +119,9 @@ and /q = 1-p/.
[endsect][/section:weibull Weibull]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -188,7 +188,7 @@ are relative errors in units of epsilon.
[heading Testing]
The tests use a mixture of spot test values calculated using the online
calculator at [@functions.wolfram.com
calculator at [http://@functions.wolfram.com
functions.wolfram.com], and random test data generated using
NTL::RR at 1000-bit precision and this implementation.
@@ -296,7 +296,7 @@ are relative errors in units of epsilon.
[heading Testing]
The tests use a mixture of spot test values calculated using the online
calculator at [@functions.wolfram.com
calculator at [@http://functions.wolfram.com
functions.wolfram.com], and random test data generated using
NTL::RR at 1000-bit precision and this implementation.

View File

@@ -1,6 +1,6 @@
[section:error_handling Error Handling]
[def __format [@../../../libs/format/index.html Boost.Format]]
[def __format [@../../../../format/index.html Boost.Format]]
[heading Quick Reference]
@@ -44,7 +44,7 @@ The available actions are:
appropriate result]]
[[ignore_error][Ignores the error and simply the returns the most appropriate result.]]
[[user_error][Calls a
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies user-supplied error handler].]]
[link math_toolkit.policy.pol_tutorial.user_def_err_pol user-supplied error handler].]]
]
The following tables show all the permutations of errors and actions,
@@ -56,7 +56,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `EDOM` and returns `std::numeric_limits<T>::quiet_NaN()`]]
[[ignore_error][Returns `std::numeric_limits<T>::quiet_NaN()`]]
[[user_error][Returns the result of `boost::math::policies::user_domain_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -66,7 +66,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `EDOM` and returns `std::numeric_limits<T>::quiet_NaN()`]]
[[ignore_error][Returns `std::numeric_limits<T>::quiet_NaN()`]]
[[user_error][Returns the result of `boost::math::policies::user_pole_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -76,7 +76,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `ERANGE` and returns `std::numeric_limits<T>::infinity()`]]
[[ignore_error][Returns `std::numeric_limits<T>::infinity()`]]
[[user_error][Returns the result of `boost::math::policies::user_overflow_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -86,7 +86,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `ERANGE` and returns 0.]]
[[ignore_error][[*Returns 0]]]
[[user_error][Returns the result of `boost::math::policies::user_underflow_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -96,7 +96,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `ERANGE` and returns the denormalised value.]]
[[ignore_error][[*Returns the denormalised value.]]]
[[user_error][Returns the result of `boost::math::policies::user_denorm_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -106,7 +106,7 @@ with the default action for each error shown in bold:
[[errno_on_error][Sets `::errno` to `EDOM` and returns `std::numeric_limits<T>::infinity()`.]]
[[ignore_error][Returns `std::numeric_limits<T>::infinity()`.]]
[[user_error][Returns the result of `boost::math::policies::user_evaluation_error`:
[link math_toolkit.policy.pol_tutorial.user_defined_error_policies
[link math_toolkit.policy.pol_tutorial.user_def_err_pol
this function must be defined by the user].]]
]
@@ -159,7 +159,7 @@ the error, or set global ::errno, then a NaN will be returned.
This behaviour is chosen to assist compatibility with the behaviour of
['ISO/IEC 9899:1999 Programming languages - C]
and with the
[@www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf Draft Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph 6]:
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf Draft Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph 6]:
[:['"Each of the functions declared above shall return a NaN (Not a Number)
if any argument value is a NaN, but it shall not report a domain error.

View File

@@ -124,7 +124,7 @@ for which the mathematical function obtains a non-real value.]
This implementation is believed to follow these proposals and to assist compatibility with
['ISO/IEC 9899:1999 Programming languages - C]
and with the
[@www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf Draft Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph 5].
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf Draft Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph 5].
[link math_toolkit.main_overview.error_handling See also domain_error].
See __policy_ref for details of the error handling policies that should allow

View File

@@ -206,7 +206,7 @@ and use the function's name as the link text]
[def __math_discrete [link math_toolkit.policy.pol_ref.discrete_quant_ref discrete functions]]
[def __error_policy [link math_toolkit.policy.pol_ref.error_handling_policies error handling policies]]
[def __changing_policy_defaults [link math_toolkit.policy.pol_ref.policy_defaults changing policies defaults]]
[def __user_error_handling [link math_toolkit.policy.pol_tutorial.user_defined_error_policies user error handling]]
[def __user_error_handling [link math_toolkit.policy.pol_tutorial.user_def_err_pol user error handling]]
[def __usual_accessors __cdf, __pdf, __quantile, __hazard,
__chf, __mean, __median, __mode, __variance, __sd, __skewness,

View File

@@ -81,3 +81,10 @@ rapid generation of test data] and/or data for output to an
external graphing application.
[endsect] [/section:intro Introduction]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -361,12 +361,9 @@ __policy_section you want to test set as the default.
[endsect]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -113,7 +113,7 @@ if there is a %1% specifier in the ['message] string then it
should be replaced with the value of ['val].
There is more information on user-defined error handlers in
the [link math_toolkit.policy.pol_tutorial.user_defined_error_policies
the [link math_toolkit.policy.pol_tutorial.user_def_err_pol
tutorial here].
[h4 Kinds of Error Raised]

View File

@@ -320,7 +320,7 @@ alternate policies present in other translation units:
[endsect][/section:namespace_policies Setting Policies at Namespace or Translation Unit Scope]
[section:user_defined_error_policies Calling User Defined Error Handlers]
[section:user_def_err_pol Calling User Defined Error Handlers]
[import ../../example/policy_eg_8.cpp]
@@ -330,7 +330,7 @@ alternate policies present in other translation units:
[policy_eg_9]
[endsect][/section:user_defined_error_policies Calling User Defined Error Handlers]
[endsect][/section:user_def_err_pol Calling User Defined Error Handlers]
[section:understand_dis_quant Understanding Quantiles of Discrete Distributions]

View File

@@ -34,7 +34,7 @@ by N.A.J. Hastings, Brian Peacock, Merran Evans, ISBN: 0471371246, Wiley 2000.
[@http://bh0.physics.ubc.ca/People/matt/Doc/ThesesOthers/Phd/pugh.pdf pugh.pdf (application/pdf Object)]
Pugh Msc Thesis on the Lanczzos approximation to the gamma function.
[@www.open-std.org/jtc1/sc22/wg21/docs/papers/2003 N1514, 03-0097, A Proposal to Add Mathematical Special Functions to the C++ Standard Library (version 2), Walter E. Brown]
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003 N1514, 03-0097, A Proposal to Add Mathematical Special Functions to the C++ Standard Library (version 2), Walter E. Brown]
[h4 Calculators* that we found (and used to cross-check - as far as their widely-varying accuracy allowed).]

View File

@@ -368,4 +368,10 @@ Russian Journal of Mathematical Physics, vol.1, No. 3, 1994.
[endsect][/section:remez The Remez Method]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -77,3 +77,9 @@ and with the
[endsect]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -57,6 +57,11 @@ rational functions.
on error rates.
* Provide sufficient docs for people to be able to find their way around the library.
SVN Revisions:
Sandbox revision merged to trunk: 39833.
Trunk revision: 39833.
]
[/
Copyright 2006 John Maddock and Paul A. Bristow.

View File

@@ -21,3 +21,10 @@ race conditions.
This limitation may be addressed in a future release.
[endsect] [/section:threads Thread Safety]
[/
Copyright 2006 John Maddock and 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).
]

View File

@@ -39,8 +39,8 @@ typedef policy<
// std
#include <iostream>
using std::cout;
using std::endl;
using std::cout;
using std::endl;
int main()
{

View File

@@ -48,15 +48,15 @@ We'll begin our sample program with the needed includes:
// Boost
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t; // Probability of students_t(df, t).
// std
#include <iostream>
using std::cout;
using std::endl;
using std::cout;
using std::endl;
#include <stdexcept>
using std::exception;
using std::exception;
/*`

View File

@@ -12,8 +12,8 @@
using boost::math::normal_distribution;
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t_distribution;
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t_distribution;
// using namespace boost::math;
//.\error_policy_normal.cpp(30) : error C2872: 'policy' : ambiguous symbol
@@ -26,8 +26,8 @@
// std
#include <iostream>
using std::cout;
using std::endl;
using std::cout;
using std::endl;
using boost::math::policies::policy;
// Possible errors

View File

@@ -23,11 +23,11 @@ using boost::math::students_t; // Probability of students_t(df, t) convenience
// std
#include <iostream>
using std::cout;
using std::endl;
using std::cout;
using std::endl;
#include <stdexcept>
using std::exception;
using std::exception;
using boost::math::policies::policy;
using boost::math::policies::domain_error;
@@ -43,7 +43,7 @@ typedef students_t_distribution<double, my_policy> my_students_t;
int main()
{ // Example of error handling of bad argument(s) to a distribution.
cout << "Example error handling using Student's t function. " << endl;
cout << "Example error handling using Student's t function. " << endl;
double degrees_of_freedom = -1; double t = -1.; // Two 'bad' arguments!
@@ -71,7 +71,7 @@ int main()
"\n""Message from thrown exception was:\n " << e.what() << std::endl;
}
return 0;
return 0;
} // int main()
/*

View File

@@ -90,12 +90,12 @@ void find_number_of_trials(double failures, double p)
int main()
{
find_number_of_trials(5, 0.5);
find_number_of_trials(50, 0.5);
find_number_of_trials(500, 0.5);
find_number_of_trials(50, 0.1);
find_number_of_trials(500, 0.1);
find_number_of_trials(5, 0.9);
find_number_of_trials(5, 0.5);
find_number_of_trials(50, 0.5);
find_number_of_trials(500, 0.5);
find_number_of_trials(50, 0.1);
find_number_of_trials(500, 0.1);
find_number_of_trials(5, 0.9);
return 0;
} // int main()

View File

@@ -426,7 +426,7 @@ Message from thrown exception was:
*/
//] [/ negative_binomial_eg1_2]
}
return 0;
return 0;
} // int main()

View File

@@ -74,7 +74,7 @@ int main()
/*`And all this you can do with a nanoscopic amount of work compared to
the team of *human computers* toiling with Milton Abramovitz and Irene Stegen
at the US National Bureau of Standards (now [@www.nist.gov NIST]).
at the US National Bureau of Standards (now [@http://www.nist.gov NIST]).
Starting in 1938, their "Handbook of Mathematical Functions with Formulas, Graphs and Mathematical Tables",
was eventually published in 1964, and has been reprinted numerous times since.
(A major replacement is planned at [@http://dlmf.nist.gov Digital Library of Mathematical Functions]).

View File

@@ -43,46 +43,46 @@ double value[values] = {38.9, 37.4, 37.1};
// The Students't distribution function is described at
// http://en.wikipedia.org/wiki/Student%27s_t_distribution
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t; // Probability of students_t(df, t).
#include <iostream>
using std::cout; using std::endl;
using std::cout; using std::endl;
#include <iomanip>
using std::setprecision;
using std::setprecision;
#include <cmath>
using std::sqrt;
using std::sqrt;
int main()
{
cout << "Example 1 using Student's t function. " << endl;
cout << "Example 1 using Student's t function. " << endl;
// Example/test using tabulated value
// Example/test using tabulated value
// (deliberately coded as naively as possible).
// Null hypothesis is that there is no difference (greater or less)
// Null hypothesis is that there is no difference (greater or less)
// between measured and standard.
double degrees_of_freedom = values-1; // 3-1 = 2
double degrees_of_freedom = values-1; // 3-1 = 2
cout << "Measurement 1 = " << value[0] << ", measurement 2 = " << value[1] << ", measurement 3 = " << value[2] << endl;
double mean = (value[0] + value[1] + value[2]) / static_cast<double>(values);
double mean = (value[0] + value[1] + value[2]) / static_cast<double>(values);
cout << "Standard = " << standard << ", mean = " << mean << ", (mean - standard) = " << mean - standard << endl;
double sd = sqrt(((value[0] - mean) * (value[0] - mean) + (value[1] - mean) * (value[1] - mean) + (value[2] - mean) * (value[2] - mean))/ static_cast<double>(values-1));
cout << "Standard deviation = " << sd << endl;
if (sd == 0.)
{
cout << "Measured mean is identical to SRM value," << endl;
cout << "so probability of no difference between measured and standard (the 'null hypothesis') is unity." << endl;
return 0;
}
double sd = sqrt(((value[0] - mean) * (value[0] - mean) + (value[1] - mean) * (value[1] - mean) + (value[2] - mean) * (value[2] - mean))/ static_cast<double>(values-1));
cout << "Standard deviation = " << sd << endl;
if (sd == 0.)
{
cout << "Measured mean is identical to SRM value," << endl;
cout << "so probability of no difference between measured and standard (the 'null hypothesis') is unity." << endl;
return 0;
}
double t = (mean - standard) * std::sqrt(static_cast<double>(values)) / sd;
cout << "Student's t = " << t << endl;
cout.precision(2); // Useful accuracy is only a few decimal digits.
cout << "Probability of Student's t is " << cdf(students_t(degrees_of_freedom), std::abs(t)) << endl;
double t = (mean - standard) * std::sqrt(static_cast<double>(values)) / sd;
cout << "Student's t = " << t << endl;
cout.precision(2); // Useful accuracy is only a few decimal digits.
cout << "Probability of Student's t is " << cdf(students_t(degrees_of_freedom), std::abs(t)) << endl;
// 0.91, is 1 tailed.
// So there is insufficient evidence of a difference to meet a 95% (1 in 20) criterion.
// So there is insufficient evidence of a difference to meet a 95% (1 in 20) criterion.
return 0;
return 0;
} // int main()
/*

View File

@@ -30,16 +30,16 @@
// http://en.wikipedia.org/wiki/Student%27s_t_distribution
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t; // Probability of students_t(df, t).
#include <iostream>
using std::cout;
using std::endl;
using std::cout;
using std::endl;
#include <iomanip>
using std::setprecision;
using std::setw;
using std::setprecision;
using std::setw;
#include <cmath>
using std::sqrt;
using std::sqrt;
// This example of a one-sided test is from:
//
@@ -58,39 +58,39 @@ double data [values] = {25.06, 25.18, 24.87, 25.51, 25.34, 25.41};
int main()
{
cout << "Example2 using Student's t function. ";
cout << "Example2 using Student's t function. ";
#if defined(__FILE__) && defined(__TIMESTAMP__)
cout << " " << __FILE__ << ' ' << __TIMESTAMP__ << ' '<< _MSC_FULL_VER;
cout << " " << __FILE__ << ' ' << __TIMESTAMP__ << ' '<< _MSC_FULL_VER;
#endif
cout << endl;
cout << endl;
double sum = 0.;
for (int value = 0; value < values; value++)
{ // Echo data and calculate mean.
sum += data[value];
cout << setw(4) << value << ' ' << setw(14) << data[value] << endl;
}
double mean = sum /static_cast<double>(values);
cout << "Mean = " << mean << endl; // 25.2283
double sum = 0.;
for (int value = 0; value < values; value++)
{ // Echo data and calculate mean.
sum += data[value];
cout << setw(4) << value << ' ' << setw(14) << data[value] << endl;
}
double mean = sum /static_cast<double>(values);
cout << "Mean = " << mean << endl; // 25.2283
double sd = 0.;
for (int value = 0; value < values; value++)
{ // Calculate standard deviation.
sd +=(data[value] - mean) * (data[value] - mean);
}
int degrees_of_freedom = values - 1; // Use the n-1 formula.
sd /= degrees_of_freedom; // == variance.
double sd = 0.;
for (int value = 0; value < values; value++)
{ // Calculate standard deviation.
sd +=(data[value] - mean) * (data[value] - mean);
}
int degrees_of_freedom = values - 1; // Use the n-1 formula.
sd /= degrees_of_freedom; // == variance.
sd= sqrt(sd);
cout << "Standard deviation = " << sd<< endl; // = 0.238279
cout << "Standard deviation = " << sd<< endl; // = 0.238279
double t = (mean - reference) * sqrt(static_cast<double>(values))/ sd; //
cout << "Student's t = " << t << ", with " << degrees_of_freedom << " degrees of freedom." << endl; // = 2.34725
double t = (mean - reference) * sqrt(static_cast<double>(values))/ sd; //
cout << "Student's t = " << t << ", with " << degrees_of_freedom << " degrees of freedom." << endl; // = 2.34725
cout << "Probability of positive bias is " << cdf(students_t(degrees_of_freedom), t) << "."<< endl; // = 0.967108.
// A 1-sided test because only testing for a positive bias.
// If > 0.95 then greater than 1 in 20 conventional (arbitrary) requirement.
cout << "Probability of positive bias is " << cdf(students_t(degrees_of_freedom), t) << "."<< endl; // = 0.967108.
// A 1-sided test because only testing for a positive bias.
// If > 0.95 then greater than 1 in 20 conventional (arbitrary) requirement.
return 0;
return 0;
} // int main()
/*

View File

@@ -30,14 +30,14 @@
// http://en.wikipedia.org/wiki/Student%27s_t_distribution
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
using boost::math::students_t; // Probability of students_t(df, t).
#include <iostream>
using std::cout; using std::endl;
using std::cout; using std::endl;
#include <iomanip>
using std::setprecision; using std::setw;
using std::setprecision; using std::setw;
#include <cmath>
using std::sqrt;
using std::sqrt;
// This example of a two-sided test is from:
// B. M. Smith & M. B. Griffiths, Analyst, 1982, 107, 253,
@@ -64,38 +64,38 @@ float diffs[portions];
int main()
{
cout << "Example3 using Student's t function. " << endl;
float mean_diff = 0.f;
cout << "\n""Portion wet_oxidation Direct_extraction difference" << endl;
for (int portion = 0; portion < portions; portion++)
{ // Echo data and differences.
diffs[portion] = data[portion][0] - data[portion][1];
mean_diff += diffs[portion];
cout << setw(4) << portion << ' ' << setw(14) << data[portion][0] << ' ' << setw(18)<< data[portion][1] << ' ' << setw(9) << diffs[portion] << endl;
}
mean_diff /= portions;
cout << "Mean difference = " << mean_diff << endl; // -1.75
cout << "Example3 using Student's t function. " << endl;
float mean_diff = 0.f;
cout << "\n""Portion wet_oxidation Direct_extraction difference" << endl;
for (int portion = 0; portion < portions; portion++)
{ // Echo data and differences.
diffs[portion] = data[portion][0] - data[portion][1];
mean_diff += diffs[portion];
cout << setw(4) << portion << ' ' << setw(14) << data[portion][0] << ' ' << setw(18)<< data[portion][1] << ' ' << setw(9) << diffs[portion] << endl;
}
mean_diff /= portions;
cout << "Mean difference = " << mean_diff << endl; // -1.75
float sd_diffs = 0.f;
for (int portion = 0; portion < portions; portion++)
{ // Calculate standard deviation of differences.
sd_diffs +=(diffs[portion] - mean_diff) * (diffs[portion] - mean_diff);
}
int degrees_of_freedom = portions-1; // Use the n-1 formula.
sd_diffs /= degrees_of_freedom;
sd_diffs = sqrt(sd_diffs);
cout << "Standard deviation of differences = " << sd_diffs << endl; // 4.99166
// Standard deviation of differences = 4.99166
double t = mean_diff * sqrt(static_cast<double>(portions))/ sd_diffs; // -0.70117
cout << "Student's t = " << t << ", if " << degrees_of_freedom << " degrees of freedom." << endl;
// Student's t = -0.70117, if 3 degrees of freedom.
cout << "Probability of the means being different is "
float sd_diffs = 0.f;
for (int portion = 0; portion < portions; portion++)
{ // Calculate standard deviation of differences.
sd_diffs +=(diffs[portion] - mean_diff) * (diffs[portion] - mean_diff);
}
int degrees_of_freedom = portions-1; // Use the n-1 formula.
sd_diffs /= degrees_of_freedom;
sd_diffs = sqrt(sd_diffs);
cout << "Standard deviation of differences = " << sd_diffs << endl; // 4.99166
// Standard deviation of differences = 4.99166
double t = mean_diff * sqrt(static_cast<double>(portions))/ sd_diffs; // -0.70117
cout << "Student's t = " << t << ", if " << degrees_of_freedom << " degrees of freedom." << endl;
// Student's t = -0.70117, if 3 degrees of freedom.
cout << "Probability of the means being different is "
<< 2.F * cdf(students_t(degrees_of_freedom), t) << "."<< endl; // 0.266846 * 2 = 0.533692
// Double the probability because using a 'two-sided test' because
// mean for 'Wet oxidation' could be either
// greater OR LESS THAN for 'Direct extraction'.
// Double the probability because using a 'two-sided test' because
// mean for 'Wet oxidation' could be either
// greater OR LESS THAN for 'Direct extraction'.
return 0;
return 0;
} // int main()
/*

View File

@@ -425,7 +425,7 @@ namespace tools
{
template<>
inline int digits<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline int digits<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
return ::NTL::RR::precision();
}
@@ -493,7 +493,7 @@ inline int real_cast<int, boost::math::ntl::RR>(boost::math::ntl::RR t)
}
template <>
inline boost::math::ntl::RR max_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline boost::math::ntl::RR max_value<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
static bool has_init = false;
static NTL::RR val;
@@ -507,7 +507,7 @@ inline boost::math::ntl::RR max_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPL
}
template <>
inline boost::math::ntl::RR min_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline boost::math::ntl::RR min_value<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
static bool has_init = false;
static NTL::RR val;
@@ -521,7 +521,7 @@ inline boost::math::ntl::RR min_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPL
}
template <>
inline boost::math::ntl::RR log_max_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline boost::math::ntl::RR log_max_value<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
static bool has_init = false;
static NTL::RR val;
@@ -536,7 +536,7 @@ inline boost::math::ntl::RR log_max_value<boost::math::ntl::RR>(BOOST_EXPLICIT_T
}
template <>
inline boost::math::ntl::RR log_min_value<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline boost::math::ntl::RR log_min_value<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
static bool has_init = false;
static NTL::RR val;
@@ -551,7 +551,7 @@ inline boost::math::ntl::RR log_min_value<boost::math::ntl::RR>(BOOST_EXPLICIT_T
}
template <>
inline boost::math::ntl::RR epsilon<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
inline boost::math::ntl::RR epsilon<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
return ldexp(boost::math::ntl::RR(1), 1-boost::math::policies::digits<boost::math::ntl::RR, boost::math::policies::policy<> >());
}
@@ -564,17 +564,17 @@ inline boost::math::ntl::RR epsilon<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLAT
//
namespace constants{
template<> inline boost::math::ntl::RR pi<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
template<> inline boost::math::ntl::RR pi<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
NTL::RR result;
ComputePi(result);
return result;
NTL::RR result;
ComputePi(result);
return result;
}
template<> inline boost::math::ntl::RR e<boost::math::ntl::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
template<> inline boost::math::ntl::RR e<boost::math::ntl::RR>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(boost::math::ntl::RR))
{
NTL::RR result;
NTL::RR result;
result = 1;
return exp(result);
return exp(result);
}
} // namespace constants

View File

@@ -25,10 +25,10 @@
#include <boost/math/tools/real_cast.hpp>
#include <boost/math/tools/precision.hpp>
#include <boost/math/policies/policy.hpp>
#include <ostream>
#include <istream>
#include <cmath>
#include <math.h> // fmodl
#ifndef BOOST_MATH_REAL_CONCEPT_HPP
#define BOOST_MATH_REAL_CONCEPT_HPP
@@ -55,7 +55,7 @@ public:
real_concept(int c) : m_value(c){}
real_concept(unsigned long c) : m_value(c){}
real_concept(long c) : m_value(c){}
#ifdef BOOST_HAS_LONG_LONG
#if defined(BOOST_HAS_LONG_LONG) || defined(__DECCXX) || defined(__SUNPRO_CC)
real_concept(unsigned long long c) : m_value(static_cast<long double>(c)){}
real_concept(long long c) : m_value(static_cast<long double>(c)){}
#elif defined(BOOST_HAS_MS_INT64)
@@ -195,8 +195,10 @@ inline real_concept atan2(real_concept a, real_concept b)
{ return std::atan2(a.value(), b.value()); }
inline real_concept ceil(real_concept a)
{ return std::ceil(a.value()); }
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
inline real_concept fmod(real_concept a, real_concept b)
{ return boost::math::tools::fmod_workaround(a.value(), b.value()); }
{ return fmodl(a.value(), b.value()); }
#endif
inline real_concept cosh(real_concept a)
{ return std::cosh(a.value()); }
inline real_concept exp(real_concept a)
@@ -226,8 +228,13 @@ inline real_concept tan(real_concept a)
{ return std::tan(a.value()); }
inline real_concept pow(real_concept a, real_concept b)
{ return std::pow(a.value(), b.value()); }
#if !defined(__SUNPRO_CC)
inline real_concept pow(real_concept a, int b)
{ return std::pow(a.value(), b); }
#else
inline real_concept pow(real_concept a, int b)
{ return std::pow(a.value(), static_cast<long double>(b)); }
#endif
inline real_concept sin(real_concept a)
{ return std::sin(a.value()); }
inline real_concept sinh(real_concept a)
@@ -246,10 +253,28 @@ inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, t
template <class charT, class traits>
inline std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is, real_concept& a)
{
#if defined(BOOST_MSVC) && defined(__SGI_STL_PORT)
//
// STLPort 5.1.4 has a problem reading long doubles from strings,
// see http://sourceforge.net/tracker/index.php?func=detail&aid=1811043&group_id=146814&atid=766244
//
double v;
is >> v;
a = v;
return is;
#elif defined(__SGI_STL_PORT)
std::string s;
long double d;
is >> s;
std::sscanf(s.c_str(), "%Lf", &d);
a = d;
return is;
#else
long double v;
is >> v;
a = v;
return is;
#endif
}
} // namespace concepts
@@ -297,37 +322,41 @@ inline long double real_cast<long double, concepts::real_concept>(concepts::real
}
template <>
inline concepts::real_concept max_value<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline concepts::real_concept max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
return max_value<long double>();
}
template <>
inline concepts::real_concept min_value<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline concepts::real_concept min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
return min_value<long double>();
}
template <>
inline concepts::real_concept log_max_value<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline concepts::real_concept log_max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
return log_max_value<long double>();
}
template <>
inline concepts::real_concept log_min_value<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline concepts::real_concept log_min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
return log_min_value<long double>();
}
template <>
inline concepts::real_concept epsilon(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline concepts::real_concept epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
#ifdef __SUNPRO_CC
return std::numeric_limits<long double>::epsilon();
#else
return tools::epsilon<long double>();
#endif
}
template <>
inline int digits<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
inline int digits<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
// Assume number of significand bits is same as long double,
// unless std::numeric_limits<T>::is_specialized to provide digits.

View File

@@ -25,6 +25,7 @@
#include <ostream>
#include <istream>
#include <cmath>
#include <math.h> // fmodl
#ifndef BOOST_MATH_STD_REAL_CONCEPT_HPP
#define BOOST_MATH_STD_REAL_CONCEPT_HPP
@@ -194,8 +195,13 @@ inline boost::math::concepts::std_real_concept atan2(boost::math::concepts::std_
{ return std::atan2(a.value(), b.value()); }
inline boost::math::concepts::std_real_concept ceil(boost::math::concepts::std_real_concept a)
{ return std::ceil(a.value()); }
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
{ return boost::math::tools::fmod_workaround(a.value(), b.value()); }
{ return fmodl(a.value(), b.value()); }
#else
inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
{ return std::fmod(a.value(), b.value()); }
#endif
inline boost::math::concepts::std_real_concept cosh(boost::math::concepts::std_real_concept a)
{ return std::cosh(a.value()); }
inline boost::math::concepts::std_real_concept exp(boost::math::concepts::std_real_concept a)
@@ -300,37 +306,37 @@ inline long double real_cast<long double, concepts::std_real_concept>(concepts::
}
template <>
inline concepts::std_real_concept max_value<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline concepts::std_real_concept max_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return max_value<long double>();
}
template <>
inline concepts::std_real_concept min_value<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline concepts::std_real_concept min_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return min_value<long double>();
}
template <>
inline concepts::std_real_concept log_max_value<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline concepts::std_real_concept log_max_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return log_max_value<long double>();
}
template <>
inline concepts::std_real_concept log_min_value<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline concepts::std_real_concept log_min_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return log_min_value<long double>();
}
template <>
inline concepts::std_real_concept epsilon(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline concepts::std_real_concept epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return tools::epsilon<long double>();
}
template <>
inline int digits<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
inline int digits<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{ // Assume number of significand bits is same as long double,
// unless std::numeric_limits<T>::is_specialized to provide digits.
return digits<long double>();

View File

@@ -7,7 +7,7 @@
#ifndef BOOST_MATH_CONSTANTS_CONSTANTS_INCLUDED
#define BOOST_MATH_CONSTANTS_CONSTANTS_INCLUDED
#include <boost/config.hpp>
#include <boost/math/tools/config.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4127 4701)
@@ -37,16 +37,16 @@ namespace boost{ namespace math
#define BOOST_DEFINE_MATH_CONSTANT(name, x, y, exp)\
template <class T> inline T name(BOOST_EXPLICIT_TEMPLATE_TYPE(T))\
template <class T> inline T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))\
{\
static const T result = ::boost::lexical_cast<T>(BOOST_STRINGIZE(BOOST_JOIN(BOOST_JOIN(x, y), BOOST_JOIN(e, exp))));\
return result;\
}\
template <> inline float name<float>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(float))\
template <> inline float name<float>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(float))\
{ return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), F); }\
template <> inline double name<double>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(double))\
template <> inline double name<double>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(double))\
{ return BOOST_JOIN(x, BOOST_JOIN(e, exp)); }\
template <> inline long double name<long double>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(long double))\
template <> inline long double name<long double>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(long double))\
{ return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), L); }
BOOST_DEFINE_MATH_CONSTANT(pi, 3.141592653589793238462643383279502884197169399375105820974944, 59230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196, 0)

View File

@@ -149,7 +149,7 @@ namespace boost
} // variance
template <class RealType, class Policy>
RealType pdf(const bernoulli_distribution<RealType, Policy>& dist, const RealType k)
RealType pdf(const bernoulli_distribution<RealType, Policy>& dist, const RealType& k)
{ // Probability Density/Mass Function.
BOOST_FPU_EXCEPTION_GUARD
// Error check:
@@ -174,7 +174,7 @@ namespace boost
} // pdf
template <class RealType, class Policy>
inline RealType cdf(const bernoulli_distribution<RealType, Policy>& dist, const RealType k)
inline RealType cdf(const bernoulli_distribution<RealType, Policy>& dist, const RealType& k)
{ // Cumulative Distribution Function Bernoulli.
RealType p = dist.success_fraction();
// Error check:

View File

@@ -364,7 +364,7 @@ namespace boost
} // kurtosis
template <class RealType, class Policy>
inline RealType pdf(const beta_distribution<RealType, Policy>& dist, const RealType x)
inline RealType pdf(const beta_distribution<RealType, Policy>& dist, const RealType& x)
{ // Probability Density/Mass Function.
BOOST_FPU_EXCEPTION_GUARD
@@ -389,7 +389,7 @@ namespace boost
} // pdf
template <class RealType, class Policy>
inline RealType cdf(const beta_distribution<RealType, Policy>& dist, const RealType x)
inline RealType cdf(const beta_distribution<RealType, Policy>& dist, const RealType& x)
{ // Cumulative Distribution Function beta.
BOOST_MATH_STD_USING // for ADL of std functions

View File

@@ -231,8 +231,8 @@ namespace boost
}
if (p <= pow(1 - success_fraction, trials))
{ // p <= pdf(dist, 0) == cdf(dist, 0)
return 0; // So the only reasonable result is zero.
} // And root finder would fail otherwise.
return 0; // So the only reasonable result is zero.
} // And root finder would fail otherwise.
// Solve for quantile numerically:
//
@@ -406,9 +406,9 @@ namespace boost
}; // template <class RealType, class Policy> class binomial_distribution
typedef binomial_distribution<> binomial;
// typedef binomial_distribution<double> binomial;
// IS now included since no longer a name clash with function binomial.
//typedef binomial_distribution<double> binomial; // Reserved name of type double.
// typedef binomial_distribution<double> binomial;
// IS now included since no longer a name clash with function binomial.
//typedef binomial_distribution<double> binomial; // Reserved name of type double.
template <class RealType, class Policy>
const std::pair<RealType, RealType> range(const binomial_distribution<RealType, Policy>& dist)
@@ -437,7 +437,7 @@ namespace boost
} // variance
template <class RealType, class Policy>
RealType pdf(const binomial_distribution<RealType, Policy>& dist, const RealType k)
RealType pdf(const binomial_distribution<RealType, Policy>& dist, const RealType& k)
{ // Probability Density/Mass Function.
BOOST_FPU_EXCEPTION_GUARD
@@ -498,7 +498,7 @@ namespace boost
} // pdf
template <class RealType, class Policy>
inline RealType cdf(const binomial_distribution<RealType, Policy>& dist, const RealType k)
inline RealType cdf(const binomial_distribution<RealType, Policy>& dist, const RealType& k)
{ // Cumulative Distribution Function Binomial.
// The random variate k is the number of successes in n trials.
// k argument may be integral, signed, or unsigned, or floating point.
@@ -676,8 +676,8 @@ namespace boost
// 1993, vol. 40, no3-4, pp. 185-189 (4 ref.)
// Bounds for median and 50 percetage point of binomial and negative binomial distribution
// Metrika, ISSN 0026-1335 (Print) 1435-926X (Online)
// Volume 41, Number 1 / December, 1994, DOI 10.1007/BF01895303
// Metrika, ISSN 0026-1335 (Print) 1435-926X (Online)
// Volume 41, Number 1 / December, 1994, DOI 10.1007/BF01895303
BOOST_MATH_STD_USING // ADL of std functions.
RealType p = dist.success_fraction();
RealType n = dist.trials();

View File

@@ -85,7 +85,7 @@ RealType cdf_imp(const cauchy_distribution<RealType, Policy>& dist, const RealTy
return 0.5;
}
result = -atan(1 / mx) / constants::pi<RealType>();
return (((x > location) != complement) ? 1 - result : result);
return (((x > location) != complement) ? 1 - result : result);
} // cdf
template <class RealType, class Policy>
@@ -180,14 +180,14 @@ typedef cauchy_distribution<double> cauchy;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const cauchy_distribution<RealType, Policy>&)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + infinity.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + infinity.
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const cauchy_distribution<RealType, Policy>& )
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
return std::pair<RealType, RealType>(-tools::max_value<RealType>(), tools::max_value<RealType>()); // - to + infinity.
}

View File

@@ -58,14 +58,14 @@ typedef chi_squared_distribution<double> chi_squared;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const chi_squared_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // 0 to + infinity.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // 0 to + infinity.
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const chi_squared_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
return std::pair<RealType, RealType>(0, tools::max_value<RealType>()); // 0 to + infinity.
}

View File

@@ -200,7 +200,7 @@ typename Dist::value_type
// If the root hasn't been bracketed yet, try again
// using the multiplier this time:
//
if(sign(fb) == sign(fa))
if((boost::math::sign)(fb) == (boost::math::sign)(fa))
{
if(fa < 0)
{
@@ -208,7 +208,7 @@ typename Dist::value_type
// Zero is to the right of x2, so walk upwards
// until we find it:
//
while(sign(fb) == sign(fa))
while((boost::math::sign)(fb) == (boost::math::sign)(fa))
{
if(count == 0)
policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, policy_type());
@@ -228,7 +228,7 @@ typename Dist::value_type
// Zero is to the left of a, so walk downwards
// until we find it:
//
while(sign(fb) == sign(fa))
while((boost::math::sign)(fb) == (boost::math::sign)(fa))
{
if(fabs(a) < tools::min_value<value_type>())
{

View File

@@ -80,16 +80,16 @@ typedef exponential_distribution<double> exponential;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const exponential_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const exponential_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -75,16 +75,16 @@ typedef extreme_value_distribution<double> extreme_value;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const extreme_value_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const extreme_value_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -57,16 +57,16 @@ typedef fisher_f_distribution<double> fisher_f;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const fisher_f_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const fisher_f_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -102,16 +102,16 @@ private:
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const gamma_distribution<RealType, Policy>& /* dist */)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const gamma_distribution<RealType, Policy>& /* dist */)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -77,16 +77,16 @@ typedef lognormal_distribution<double> lognormal;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const lognormal_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x is >0 to +infinity.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const lognormal_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -259,16 +259,16 @@ namespace boost
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const negative_binomial_distribution<RealType, Policy>& /* dist */)
{ // Range of permissible values for random variable k.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // max_integer?
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // max_integer?
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const negative_binomial_distribution<RealType, Policy>& /* dist */)
{ // Range of supported values for random variable k.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // max_integer?
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // max_integer?
}
template <class RealType, class Policy>
@@ -335,7 +335,7 @@ namespace boost
// chf of Negative Binomial distribution provided by derived accessors.
template <class RealType, class Policy>
inline RealType pdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType k)
inline RealType pdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType& k)
{ // Probability Density/Mass Function.
BOOST_FPU_EXCEPTION_GUARD
@@ -361,7 +361,7 @@ namespace boost
} // negative_binomial_pdf
template <class RealType, class Policy>
inline RealType cdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType k)
inline RealType cdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType& k)
{ // Cumulative Distribution Function of Negative Binomial.
static const char* function = "boost::math::cdf(const negative_binomial_distribution<%1%>&, %1%)";
using boost::math::ibeta; // Regularized incomplete beta function.
@@ -458,7 +458,7 @@ namespace boost
}
if (P <= pow(dist.success_fraction(), dist.successes()))
{ // p <= pdf(dist, 0) == cdf(dist, 0)
return 0;
return 0;
}
/*
// Calculate quantile of negative_binomial using the inverse incomplete beta function.
@@ -527,7 +527,7 @@ namespace boost
// since the probability of zero failures may be non-zero,
return 0; // but zero is the best we can do:
}
if (-Q <= powm1(dist.success_fraction(), dist.successes(), Policy()))
if (-Q <= boost::math::powm1(dist.success_fraction(), dist.successes(), Policy()))
{ // q <= cdf(complement(dist, 0)) == pdf(dist, 0)
return 0; //
}

View File

@@ -74,17 +74,17 @@ typedef normal_distribution<double> normal;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const normal_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const normal_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
}
template <class RealType, class Policy>

View File

@@ -212,7 +212,7 @@ namespace boost
}
// result = RealType(1) - pow((location / x), shape);
result = -powm1(location/x, shape, Policy()); // should be more accurate.
result = -boost::math::powm1(location/x, shape, Policy()); // should be more accurate.
return result;
} // cdf

View File

@@ -233,16 +233,16 @@ namespace boost
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const poisson_distribution<RealType, Policy>& /* dist */)
{ // Range of permissible values for random variable k.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // Max integer?
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>()); // Max integer?
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const poisson_distribution<RealType, Policy>& /* dist */)
{ // Range of supported values for random variable k.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>
@@ -306,7 +306,7 @@ namespace boost
} // RealType kurtosis
template <class RealType, class Policy>
RealType pdf(const poisson_distribution<RealType, Policy>& dist, const RealType k)
RealType pdf(const poisson_distribution<RealType, Policy>& dist, const RealType& k)
{ // Probability Density/Mass Function.
// Probability that there are EXACTLY k occurrences (or arrivals).
BOOST_FPU_EXCEPTION_GUARD
@@ -353,7 +353,7 @@ namespace boost
} // pdf
template <class RealType, class Policy>
RealType cdf(const poisson_distribution<RealType, Policy>& dist, const RealType k)
RealType cdf(const poisson_distribution<RealType, Policy>& dist, const RealType& k)
{ // Cumulative Distribution Function Poisson.
// The random variate k is the number of occurrences(or arrivals)
// k argument may be integral, signed, or unsigned, or floating point.
@@ -480,10 +480,10 @@ namespace boost
BOOST_MATH_STD_USING // ADL of std functions.
// if(p == 0) NOT necessarily zero!
// Not necessarily any special value of k because is unlimited.
if (p <= exp(-dist.mean()))
{ // if p <= cdf for 0 events (== pdf for 0 events), then quantile must be zero.
return 0;
}
if (p <= exp(-dist.mean()))
{ // if p <= cdf for 0 events (== pdf for 0 events), then quantile must be zero.
return 0;
}
return gamma_q_inva(dist.mean(), p, Policy()) - 1;
*/
typedef typename Policy::discrete_quantile_type discrete_type;
@@ -549,9 +549,9 @@ namespace boost
}
/*
if (-q <= boost::math::expm1(-dist.mean()))
{ // if q <= cdf(complement for 0 events, then quantile must be zero.
return 0;
}
{ // if q <= cdf(complement for 0 events, then quantile must be zero.
return 0;
}
return gamma_p_inva(dist.mean(), q, Policy()) -1;
*/
typedef typename Policy::discrete_quantile_type discrete_type;

View File

@@ -80,16 +80,16 @@ typedef rayleigh_distribution<double> rayleigh;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const rayleigh_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(static_cast<RealType>(1), max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(static_cast<RealType>(1), max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const rayleigh_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>((1), max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>((1), max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -63,16 +63,16 @@ typedef students_t_distribution<double> students_t;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const students_t_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const students_t_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
}
template <class RealType, class Policy>
@@ -146,7 +146,7 @@ inline RealType cdf(const students_t_distribution<RealType, Policy>& dist, const
RealType z = degrees_of_freedom / (degrees_of_freedom + t2);
probability = ibeta(degrees_of_freedom / 2, static_cast<RealType>(0.5), z, Policy()) / 2;
}
return (t > 0 ? 1 - probability : probability);
return (t > 0 ? 1 - probability : probability);
} // cdf
template <class RealType, class Policy>

View File

@@ -140,16 +140,16 @@ namespace boost{ namespace math
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const uniform_distribution<RealType, Policy>& /* dist */)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + infinity
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + infinity
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const uniform_distribution<RealType, Policy>& dist)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(dist.lower(), dist.upper());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(dist.lower(), dist.upper());
}
template <class RealType, class Policy>

View File

@@ -102,16 +102,16 @@ typedef weibull_distribution<double> weibull;
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const weibull_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const weibull_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(0, max_value<RealType>());
}
template <class RealType, class Policy>

View File

@@ -62,9 +62,9 @@ template <class E, class T>
void raise_error(const char* function, const char* message)
{
if(function == 0)
function = "Unknown function";
function = "Unknown function";
if(message == 0)
message = "Cause unknown";
message = "Cause unknown";
std::string msg("Error in function ");
msg += (boost::format(function) % typeid(T).name()).str();
@@ -79,9 +79,9 @@ template <class E, class T>
void raise_error(const char* function, const char* message, const T& val)
{
if(function == 0)
function = "Unknown function";
function = "Unknown function";
if(message == 0)
message = "Cause unknown";
message = "Cause unknown";
std::string msg("Error in function ");
msg += (boost::format(function) % typeid(T).name()).str();

View File

@@ -35,7 +35,7 @@ namespace boost{ namespace math{
namespace tools{
template <class T>
int digits(BOOST_EXPLICIT_TEMPLATE_TYPE(T));
int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T));
}

View File

@@ -86,7 +86,12 @@ inline T bessel_j_small_z_series(T v, T x, const Policy& pol)
{
bessel_j_small_z_series_term<T, Policy> s(v, x);
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
T zero = 0;
T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter, zero);
#else
T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter);
#endif
policies::check_series_iterations("boost::math::bessel_j_small_z_series<%1%>(%1%,%1%)", max_iter, pol);
return result;
}
@@ -97,7 +102,12 @@ inline T sph_bessel_j_small_z_series(unsigned v, T x, const Policy& pol)
BOOST_MATH_STD_USING // ADL of std names
sph_bessel_j_small_z_series_term<T, Policy> s(v, x);
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
T zero = 0;
T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter, zero);
#else
T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter);
#endif
policies::check_series_iterations("boost::math::sph_bessel_j_small_z_series<%1%>(%1%,%1%)", max_iter, pol);
return result * sqrt(constants::pi<T>() / 4);
}

View File

@@ -724,7 +724,7 @@ T beta_small_b_large_a_series(T a, T b, T x, T y, T s0, T mult, const Policy& po
return s0;
if(normalised)
{
prefix = h / tgamma_delta_ratio(a, b, pol);
prefix = h / boost::math::tgamma_delta_ratio(a, b, pol);
prefix /= pow(t, b);
}
else
@@ -741,7 +741,7 @@ T beta_small_b_large_a_series(T a, T b, T x, T y, T s0, T mult, const Policy& po
//
// Now an initial value for J, see 9.6:
//
T j = gamma_q(b, u, pol) / h;
T j = boost::math::gamma_q(b, u, pol) / h;
//
// Now we can start to pull things together and evaluate the sum in Eq 9:
//
@@ -777,11 +777,11 @@ T beta_small_b_large_a_series(T a, T b, T x, T y, T s0, T mult, const Policy& po
for(unsigned m = 1; m < n; ++m)
{
mbn = m * b - n;
p[n] += mbn * p[n-m] / unchecked_factorial<T>(tmp1);
p[n] += mbn * p[n-m] / boost::math::unchecked_factorial<T>(tmp1);
tmp1 += 2;
}
p[n] /= n;
p[n] += bm1 / unchecked_factorial<T>(tnp1);
p[n] += bm1 / boost::math::unchecked_factorial<T>(tnp1);
//
// Now we want Jn from Jn-1 using Eq 9.6:
//

View File

@@ -14,18 +14,18 @@ namespace boost{ namespace math{
namespace detail
{
template <class T>
struct cbrt_functor
{
cbrt_functor(T const& target) : a(target){}
std::tr1::tuple<T, T, T> operator()(T const& z)
{
T sqr = z * z;
return std::tr1::make_tuple(sqr * z - a, 3 * sqr, 6 * z);
}
private:
T a;
};
template <class T>
struct cbrt_functor
{
cbrt_functor(T const& target) : a(target){}
std::tr1::tuple<T, T, T> operator()(T const& z)
{
T sqr = z * z;
return std::tr1::make_tuple(sqr * z - a, 3 * sqr, 6 * z);
}
private:
T a;
};
template <class T, class Policy>
T cbrt_imp(T z, const Policy&)

View File

@@ -37,14 +37,14 @@ int temme_ik(T v, T x, T* K, T* K1, const Policy& pol)
BOOST_ASSERT(abs(x) <= 2);
BOOST_ASSERT(abs(v) <= 0.5f);
T gp = tgamma1pm1(v, pol);
T gm = tgamma1pm1(-v, pol);
T gp = boost::math::tgamma1pm1(v, pol);
T gm = boost::math::tgamma1pm1(-v, pol);
a = log(x / 2);
b = exp(v * a);
sigma = -a * v;
c = abs(v) < tools::epsilon<T>() ?
1 : sin_pi(v) / (v * pi<T>());
1 : boost::math::sin_pi(v) / (v * pi<T>());
d = abs(sigma) < tools::epsilon<T>() ?
1 : sinh(sigma) / sigma;
gamma1 = abs(v) < tools::epsilon<T>() ?
@@ -256,7 +256,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol)
if(reflect && (kind & need_i))
{
T z = (u + n % 2);
Iv = sin_pi(z, pol) == 0 ?
Iv = boost::math::sin_pi(z, pol) == 0 ?
Iv :
policies::raise_overflow_error<T>(function, 0, pol); // reflection formula
}
@@ -313,7 +313,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol)
if (reflect)
{
T z = (u + n % 2);
*I = Iv + (2 / pi<T>()) * sin_pi(z) * Kv; // reflection formula
*I = Iv + (2 / pi<T>()) * boost::math::sin_pi(z) * Kv; // reflection formula
*K = Kv;
}
else

View File

@@ -41,10 +41,10 @@ int temme_jy(T v, T x, T* Y, T* Y1, const Policy& pol)
BOOST_ASSERT(fabs(v) <= 0.5f); // precondition for using this routine
T gp = tgamma1pm1(v, pol);
T gm = tgamma1pm1(-v, pol);
T spv = sin_pi(v, pol);
T spv2 = sin_pi(v/2, pol);
T gp = boost::math::tgamma1pm1(v, pol);
T gm = boost::math::tgamma1pm1(-v, pol);
T spv = boost::math::sin_pi(v, pol);
T spv2 = boost::math::sin_pi(v/2, pol);
T xp = pow(x/2, v);
a = log(x / 2);
@@ -342,8 +342,8 @@ int bessel_jy(T v, T x, T* J, T* Y, int kind, const Policy& pol)
if (reflect)
{
T z = (u + n % 2);
*J = cos_pi(z, pol) * Jv - sin_pi(z, pol) * Yv; // reflection formula
*Y = sin_pi(z, pol) * Jv + cos_pi(z, pol) * Yv;
*J = boost::math::cos_pi(z, pol) * Jv - boost::math::sin_pi(z, pol) * Yv; // reflection formula
*Y = boost::math::sin_pi(z, pol) * Jv + boost::math::cos_pi(z, pol) * Yv;
}
else
{

View File

@@ -233,10 +233,10 @@ template <class T, class Policy>
void temme_asyptotic_y_small_x(T v, T x, T* Y, T* Y1, const Policy& pol)
{
T c = 1;
T p = (v / sin_pi(v, pol)) * pow(x / 2, -v) / tgamma(1 - v, pol);
T q = (v / sin_pi(v, pol)) * pow(x / 2, v) / tgamma(1 + v, pol);
T p = (v / boost::math::sin_pi(v, pol)) * pow(x / 2, -v) / boost::math::tgamma(1 - v, pol);
T q = (v / boost::math::sin_pi(v, pol)) * pow(x / 2, v) / boost::math::tgamma(1 + v, pol);
T f = (p - q) / v;
T g_prefix = sin_pi(v / 2, pol);
T g_prefix = boost::math::sin_pi(v / 2, pol);
g_prefix *= g_prefix * 2 / v;
T g = f + g_prefix * q;
T h = p;

View File

@@ -913,14 +913,16 @@ template <class RT1, class RT2, class RT3>
inline typename tools::promote_args<RT1, RT2, RT3>::type
ibetac_inv(RT1 a, RT2 b, RT3 q)
{
return ibetac_inv(a, b, q, static_cast<RT1*>(0), policies::policy<>());
typedef typename remove_cv<RT1>::type dummy;
return ibetac_inv(a, b, q, static_cast<dummy*>(0), policies::policy<>());
}
template <class RT1, class RT2, class RT3, class Policy>
inline typename tools::promote_args<RT1, RT2, RT3>::type
inline typename tools::promote_args<RT1, RT2, RT3>::type
ibetac_inv(RT1 a, RT2 b, RT3 q, const Policy& pol)
{
return ibetac_inv(a, b, q, static_cast<RT1*>(0), pol);
typedef typename remove_cv<RT1>::type dummy;
return ibetac_inv(a, b, q, static_cast<dummy*>(0), pol);
}
} // namespace math

View File

@@ -66,7 +66,7 @@ T igamma_temme_large(T a, T x, const Policy& pol, mpl::int_<64> const *)
{
BOOST_MATH_STD_USING // ADL of std functions
T sigma = (x - a) / a;
T phi = -log1pmx(sigma, pol);
T phi = -boost::math::log1pmx(sigma, pol);
T y = a * phi;
T z = sqrt(2 * phi);
if(x < a)
@@ -271,7 +271,7 @@ T igamma_temme_large(T a, T x, const Policy& pol, mpl::int_<53> const *)
{
BOOST_MATH_STD_USING // ADL of std functions
T sigma = (x - a) / a;
T phi = -log1pmx(sigma, pol);
T phi = -boost::math::log1pmx(sigma, pol);
T y = a * phi;
T z = sqrt(2 * phi);
if(x < a)
@@ -413,7 +413,7 @@ T igamma_temme_large(T a, T x, const Policy& pol, mpl::int_<24> const *)
{
BOOST_MATH_STD_USING // ADL of std functions
T sigma = (x - a) / a;
T phi = -log1pmx(sigma, pol);
T phi = -boost::math::log1pmx(sigma, pol);
T y = a * phi;
T z = sqrt(2 * phi);
if(x < a)
@@ -469,7 +469,7 @@ T igamma_temme_large(T a, T x, const Policy& pol, mpl::int_<113> const *)
{
BOOST_MATH_STD_USING // ADL of std functions
T sigma = (x - a) / a;
T phi = -log1pmx(sigma, pol);
T phi = -boost::math::log1pmx(sigma, pol);
T y = a * phi;
T z = sqrt(2 * phi);
if(x < a)

View File

@@ -16,18 +16,17 @@
#pragma warning(pop)
#endif
#include <cmath>
#include <boost/math/special_functions/math_fwd.hpp>
namespace boost { namespace math
{
// Forward declarations:
template <class T>
T unchecked_factorial(unsigned i);
template <class T>
struct max_factorial;
// efinitions:
template <>
inline float unchecked_factorial<float>(unsigned i)
inline float unchecked_factorial<float>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(float))
{
static const boost::array<float, 35> factorials = {{
1.0F,
@@ -78,7 +77,7 @@ struct max_factorial<float>
template <>
inline long double unchecked_factorial<long double>(unsigned i)
inline long double unchecked_factorial<long double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(long double))
{
static const boost::array<long double, 171> factorials = {{
1L,
@@ -264,9 +263,9 @@ struct max_factorial<long double>
};
template <>
inline double unchecked_factorial(unsigned i)
inline double unchecked_factorial(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(double))
{
return static_cast<double>(unchecked_factorial<long double>(i));
return static_cast<double>(boost::math::unchecked_factorial<long double>(i));
}
template <>
@@ -277,7 +276,7 @@ struct max_factorial<double>
};
template <class T>
inline T unchecked_factorial(unsigned i)
inline T unchecked_factorial(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
{
static const boost::array<T, 101> factorials = {{
boost::lexical_cast<T>("1"),

View File

@@ -17,6 +17,7 @@
#include <boost/math/special_functions/ellint_rf.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/tools/workaround.hpp>
// Elliptic integrals (complete and incomplete) of the first kind
// Carlson, Numerische Mathematik, vol 33, 1 (1979)
@@ -28,6 +29,9 @@ typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi, const Policy&
namespace detail{
template <typename T, typename Policy>
T ellint_k_imp(T k, const Policy& pol);
// Elliptic integral (Legendre form) of the first kind
template <typename T, typename Policy>
T ellint_f_imp(T phi, T k, const Policy& pol)

View File

@@ -18,6 +18,7 @@
#include <boost/math/special_functions/ellint_rd.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/tools/workaround.hpp>
// Elliptic integrals (complete and incomplete) of the second kind
// Carlson, Numerische Mathematik, vol 33, 1 (1979)

View File

@@ -21,6 +21,7 @@
#include <boost/math/special_functions/log1p.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/tools/workaround.hpp>
// Elliptic integrals (complete and incomplete) of the third kind
// Carlson, Numerische Mathematik, vol 33, 1 (1979)

View File

@@ -87,10 +87,10 @@ T ellint_rj_imp(T x, T y, T z, T p, const Policy& pol)
BOOST_ASSERT(pmy >= 0);
T p = pmy + y;
value = ellint_rj(x, y, z, p, pol);
value = boost::math::ellint_rj(x, y, z, p, pol);
value *= pmy;
value -= 3 * ellint_rf(x, y, z, pol);
value += 3 * sqrt((x * y * z) / (x * z + p * q)) * ellint_rc(x * z + p * q, p * q, pol);
value -= 3 * boost::math::ellint_rf(x, y, z, pol);
value += 3 * sqrt((x * y * z) / (x * z + p * q)) * boost::math::ellint_rc(x * z + p * q, p * q, pol);
value /= (y + q);
return value;
}
@@ -118,7 +118,7 @@ T ellint_rj_imp(T x, T y, T z, T p, const Policy& pol)
alpha = p * (sx + sy + sz) + sx * sy * sz;
alpha *= alpha;
beta = p * (p + lambda) * (p + lambda);
sigma += factor * ellint_rc(alpha, beta, pol);
sigma += factor * boost::math::ellint_rc(alpha, beta, pol);
factor /= 4;
x = (x + lambda) / 4;
y = (y + lambda) / 4;

View File

@@ -133,7 +133,7 @@ T rising_factorial_imp(T x, int n, const Policy& pol)
// tgamma_delta_ratio is alreay optimised for that
// use case:
//
return 1 / tgamma_delta_ratio(x, static_cast<T>(n), pol);
return 1 / boost::math::tgamma_delta_ratio(x, static_cast<T>(n), pol);
}
template <class T, class Policy>
@@ -162,7 +162,7 @@ inline T falling_factorial_imp(T x, unsigned n, const Policy& pol)
unsigned n2 = tools::real_cast<unsigned>(floor(xp1));
if(n2 == xp1)
return 0;
T result = tgamma_delta_ratio(xp1, -static_cast<T>(n2), pol);
T result = boost::math::tgamma_delta_ratio(xp1, -static_cast<T>(n2), pol);
x -= n2;
result *= x;
++n2;
@@ -177,7 +177,7 @@ inline T falling_factorial_imp(T x, unsigned n, const Policy& pol)
// because tgamma_delta_ratio is alreay optimised
// for that use case:
//
return tgamma_delta_ratio(x + 1, -static_cast<T>(n), pol);
return boost::math::tgamma_delta_ratio(x + 1, -static_cast<T>(n), pol);
}
} // namespace detail

View File

@@ -623,7 +623,7 @@ T regularised_gamma_prefix(T a, T z, const Policy& pol, const L& l)
else if((fabs(d*d*a) <= 100) && (a > 150))
{
// special case for large a and a ~ z.
prefix = a * log1pmx(d, pol) + z * static_cast<T>(0.5 - L::g()) / agh;
prefix = a * boost::math::log1pmx(d, pol) + z * static_cast<T>(0.5 - L::g()) / agh;
prefix = exp(prefix);
}
else
@@ -726,7 +726,8 @@ inline T tgamma_small_upper_part(T a, T x, const Policy& pol)
//
// Compute the full upper fraction (Q) when a is very small:
//
T result = tgamma1pm1(a, pol) - powm1(x, a, pol);
T result;
result = boost::math::tgamma1pm1(a, pol) - boost::math::powm1(x, a, pol);
result /= a;
detail::small_gamma2_series<T> s(a, x);
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();

View File

@@ -16,7 +16,7 @@ namespace math{
// Recurrance relation for legendre P and Q polynomials:
template <class T1, class T2, class T3>
inline typename tools::promote_args<T1, T2, T3>::type
inline typename tools::promote_args<T1, T2, T3>::type
legendre_next(unsigned l, T1 x, T2 Pl, T3 Plm1)
{
typedef typename tools::promote_args<T1, T2, T3>::type result_type;
@@ -58,7 +58,7 @@ T legendre_imp(unsigned l, T x, const Policy& pol, bool second = false)
while(n < l)
{
std::swap(p0, p1);
p1 = legendre_next(n, x, p0, p1);
p1 = boost::math::legendre_next(n, x, p0, p1);
++n;
}
return p1;
@@ -127,16 +127,16 @@ T legendre_p_imp(int l, int m, T x, T sin_theta_power, const Policy& pol)
if(m < 0)
{
int sign = (m&1) ? -1 : 1;
return sign * tgamma_ratio(static_cast<T>(l+m+1), static_cast<T>(l+1-m), pol) * legendre_p_imp(l, -m, x, sin_theta_power, pol);
return sign * boost::math::tgamma_ratio(static_cast<T>(l+m+1), static_cast<T>(l+1-m), pol) * legendre_p_imp(l, -m, x, sin_theta_power, pol);
}
// Special cases:
if(m > l)
return 0;
if(m == 0)
return legendre_p(l, x, pol);
return boost::math::legendre_p(l, x, pol);
T p0 = boost::math::double_factorial<T>(2 * m - 1, pol) * sin_theta_power;
if(m&1)
p0 *= -1;
if(m == l)
@@ -149,7 +149,7 @@ T legendre_p_imp(int l, int m, T x, T sin_theta_power, const Policy& pol)
while(n < l)
{
std::swap(p0, p1);
p1 = legendre_next(n, m, x, p0, p1);
p1 = boost::math::legendre_next(n, m, x, p0, p1);
++n;
}
return p1;
@@ -166,7 +166,7 @@ inline T legendre_p_imp(int l, int m, T x, const Policy& pol)
}
template <class T, class Policy>
inline typename tools::promote_args<T>::type
inline typename tools::promote_args<T>::type
legendre_p(int l, int m, T x, const Policy& pol)
{
typedef typename tools::promote_args<T>::type result_type;
@@ -175,7 +175,7 @@ inline typename tools::promote_args<T>::type
}
template <class T>
inline typename tools::promote_args<T>::type
inline typename tools::promote_args<T>::type
legendre_p(int l, int m, T x)
{
return boost::math::legendre_p(l, m, x, policies::policy<>());

View File

@@ -127,8 +127,8 @@ inline long double log1p(long double z)
#ifdef BOOST_HAS_LOG1P
# if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
|| defined(linux) || defined(__linux) || defined(__linux__) \
|| defined(__hpux)
|| ((defined(linux) || defined(__linux) || defined(__linux__)) && !defined(__SUNPRO_CC)) \
|| (defined(__hpux) && !defined(_PA_RISC1_1))
template <class Policy>
inline float log1p(float x, const Policy& pol)
{

View File

@@ -28,8 +28,8 @@
namespace boost
{
namespace math
{ // Math functions (in roughly alphabetic order).
namespace math
{ // Math functions (in roughly alphabetic order).
// Beta functions.
template <class RT1, class RT2>
@@ -329,7 +329,7 @@ namespace boost
template <class RT, class Policy>
RT factorial(unsigned int, const Policy& pol);
template <class RT>
RT unchecked_factorial(unsigned int);
RT unchecked_factorial(unsigned int BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(RT));
template <class RT>
RT double_factorial(unsigned i);
template <class RT, class Policy>
@@ -347,10 +347,6 @@ namespace boost
template <class RT, class Policy>
typename tools::promote_args<RT>::type rising_factorial(RT x, int n, const Policy& pol);
// Fpclassify - classify floating-point as NaN or infinity...
template <class T>
int fpclassify (T);
// Gamma functions.
template <class RT>
typename tools::promote_args<RT>::type tgamma(RT z);
@@ -625,7 +621,7 @@ namespace boost
template <class T>
bool isnormal BOOST_NO_MACRO_EXPAND(T t);
} // namespace math
} // namespace math
} // namespace boost
#define BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(Policy)\

View File

@@ -6,26 +6,27 @@
#ifndef BOOST_MATH_TOOLS_SIGN_HPP
#define BOOST_MATH_TOOLS_SIGN_HPP
#include <cmath>
#include <cstdlib>
#include <boost/math/tools/config.hpp>
#include <boost/math/special_functions/math_fwd.hpp>
namespace boost{ namespace math{
template <class T>
inline int sign(const T& z)
inline int sign BOOST_NO_MACRO_EXPAND(const T& z)
{
return (z == 0) ? 0 : (z < 0) ? -1 : 1;
}
template <class T>
inline int signbit(const T& z)
inline int signbit BOOST_NO_MACRO_EXPAND(const T& z)
{
return (z < 0) ? 1 : 0;
}
template <class T>
inline T copysign(const T& x, const T& y)
inline T copysign BOOST_NO_MACRO_EXPAND(const T& x, const T& y)
{
BOOST_MATH_STD_USING
return fabs(x) * boost::math::sign(y);
}

View File

@@ -8,6 +8,7 @@
#define BOOST_MATH_SPECIAL_SPHERICAL_HARMONIC_HPP
#include <boost/math/special_functions/legendre.hpp>
#include <boost/math/tools/workaround.hpp>
#include <complex>
namespace boost{
@@ -33,7 +34,7 @@ inline T spherical_harmonic_prefix(unsigned n, unsigned m, T theta, const Policy
T leg = detail::legendre_p_imp(n, m, x, pow(fabs(sin_theta), T(m)), pol);
T prefix = tgamma_delta_ratio(static_cast<T>(n - m + 1), static_cast<T>(2 * m), pol);
T prefix = boost::math::tgamma_delta_ratio(static_cast<T>(n - m + 1), static_cast<T>(2 * m), pol);
prefix *= (2 * n + 1) / (4 * constants::pi<T>());
prefix = sqrt(prefix);
return prefix * leg;

View File

@@ -1,3 +1,8 @@
// Copyright (c) 2006-7 John Maddock
// 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_CONFIG_HPP
#define BOOST_MATH_TOOLS_CONFIG_HPP
@@ -13,12 +18,76 @@
#include <boost/math/tools/user.hpp>
#if defined(__CYGWIN__) || defined(__FreeBSD__)
#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(_PA_RISC1_1)
# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
//
// Borland post 5.8.2 uses Dinkumware's std C lib which
// doesn't have true long double precision. Earlier
// versions are problematic too:
//
# define BOOST_MATH_NO_REAL_CONCEPT_TESTS
# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
# define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
# include <float.h>
#endif
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
//
// Darwin's rather strange "double double" is rather hard to
// support, it should be possible given enough effort though...
//
# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
#endif
#ifdef BOOST_MSVC
// Better safe than sorry, our tests don't support hardware exceptions:
# define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
#endif
#if defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
# include "boost/type.hpp"
# include "boost/non_type.hpp"
# define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) boost::type<t>* = 0
# define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::type<t>*
# define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::non_type<t, v>* = 0
# define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::non_type<t, v>*
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \
, BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \
, BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \
, BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \
, BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
#else
// no workaround needed: expand to nothing
# define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
# define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
# define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
# define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
# define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
#endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
// Sun's compiler emits a hard error if a constant underflows:
# define BOOST_MATH_SMALL_CONSTANT(x) 0
#else
# define BOOST_MATH_SMALL_CONSTANT(x) x
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
//
@@ -65,6 +134,12 @@
# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
#endif
//
// Helper macro for controlling the FP behaviour:
//
#ifndef BOOST_MATH_CONTROL_FP
# define BOOST_MATH_CONTROL_FP
#endif
//
// Helper macro for using statements:
//
#define BOOST_MATH_STD_USING \
@@ -108,53 +183,35 @@ inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d)
{
return (std::max)((std::max)(a, b), (std::max)(c, d));
}
//
// We call this short forwarding function so that we can work around a bug
// on Darwin that causes std::fmod to return a NaN. The test case is:
// std::fmod(1185.0L, 1.5L);
//
template <class T>
inline T fmod_workaround(T a, T b)
{
BOOST_MATH_STD_USING
return fmod(a, b);
}
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
template <>
inline long double fmod_workaround(long double a, long double b)
{
return ::fmodl(a, b);
}
#endif
} // namespace tools
}} // namespace boost namespace math
#ifdef __linux__
#include <fenv.h>
#include <fenv.h>
namespace boost{ namespace math{
namespace detail
{
struct fpu_guard
{
fpu_guard()
{
fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
feclearexcept(FE_ALL_EXCEPT);
}
~fpu_guard()
{
fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
}
private:
fexcept_t m_flags;
};
namespace boost{ namespace math{
namespace detail
{
struct fpu_guard
{
fpu_guard()
{
fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
feclearexcept(FE_ALL_EXCEPT);
}
~fpu_guard()
{
fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
}
private:
fexcept_t m_flags;
};
} // namespace detail
}} // namespaces
} // namespace detail
}} // namespaces
#define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
#define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
#else // All other platforms.
#define BOOST_FPU_EXCEPTION_GUARD
#endif
@@ -172,3 +229,4 @@ inline long double fmod_workaround(long double a, long double b)

View File

@@ -17,52 +17,52 @@ namespace boost{ namespace math{ namespace tools{
namespace detail
{
template <class T>
struct is_pair : public boost::false_type{};
template <class T>
struct is_pair : public boost::false_type{};
template <class T, class U>
struct is_pair<std::pair<T,U> > : public boost::true_type{};
template <class T, class U>
struct is_pair<std::pair<T,U> > : public boost::true_type{};
template <class Gen>
struct fraction_traits_simple
{
typedef typename Gen::result_type result_type;
typedef typename Gen::result_type value_type;
template <class Gen>
struct fraction_traits_simple
{
typedef typename Gen::result_type result_type;
typedef typename Gen::result_type value_type;
static result_type a(const value_type& v)
{
return 1;
}
static result_type b(const value_type& v)
{
return v;
}
};
static result_type a(const value_type& v)
{
return 1;
}
static result_type b(const value_type& v)
{
return v;
}
};
template <class Gen>
struct fraction_traits_pair
{
typedef typename Gen::result_type value_type;
typedef typename value_type::first_type result_type;
template <class Gen>
struct fraction_traits_pair
{
typedef typename Gen::result_type value_type;
typedef typename value_type::first_type result_type;
static result_type a(const value_type& v)
{
return v.first;
}
static result_type b(const value_type& v)
{
return v.second;
}
};
static result_type a(const value_type& v)
{
return v.first;
}
static result_type b(const value_type& v)
{
return v.second;
}
};
template <class Gen>
struct fraction_traits
: public boost::mpl::if_c<
is_pair<typename Gen::result_type>::value,
fraction_traits_pair<Gen>,
fraction_traits_simple<Gen> >::type
{
};
template <class Gen>
struct fraction_traits
: public boost::mpl::if_c<
is_pair<typename Gen::result_type>::value,
fraction_traits_pair<Gen>,
fraction_traits_simple<Gen> >::type
{
};
} // namespace detail

View File

@@ -37,7 +37,7 @@ namespace tools
// See Conceptual Requirements for Real Number Types.
template <class T>
inline int digits(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
@@ -48,7 +48,7 @@ inline int digits(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
}
template <class T>
inline T max_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
@@ -60,7 +60,7 @@ inline T max_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
// -max_value<double> = -1.79769e+308, max_value<double> = 1.79769e+308.
template <class T>
inline T min_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline T min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
@@ -80,13 +80,13 @@ namespace detail{
// For type float first:
//
template <class T>
inline T log_max_value(const mpl::int_<128>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_max_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return 88.0f;
}
template <class T>
inline T log_min_value(const mpl::int_<128>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_min_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return -87.0f;
}
@@ -94,13 +94,13 @@ inline T log_min_value(const mpl::int_<128>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE
// Now double:
//
template <class T>
inline T log_max_value(const mpl::int_<1024>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_max_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return 709.0;
}
template <class T>
inline T log_min_value(const mpl::int_<1024>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_min_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return -708.0;
}
@@ -108,19 +108,19 @@ inline T log_min_value(const mpl::int_<1024>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYP
// 80 and 128-bit long doubles:
//
template <class T>
inline T log_max_value(const mpl::int_<16384>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_max_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return 11356.0L;
}
template <class T>
inline T log_min_value(const mpl::int_<16384>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_min_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return -11355.0L;
}
template <class T>
inline T log_max_value(const mpl::int_<0>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_max_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
@@ -133,7 +133,7 @@ inline T log_max_value(const mpl::int_<0>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T
}
template <class T>
inline T log_min_value(const mpl::int_<0>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_min_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
@@ -146,14 +146,14 @@ inline T log_min_value(const mpl::int_<0>& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T
}
template <class T>
inline T epsilon(const mpl::true_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T epsilon(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
return std::numeric_limits<T>::epsilon();
}
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
template <>
inline long double epsilon<long double>(const mpl::true_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(long double))
inline long double epsilon<long double>(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(long double))
{
// numeric_limits on Darwin tells lies here.
// This static assert fails for some unknown reason, so
@@ -164,7 +164,7 @@ inline long double epsilon<long double>(const mpl::true_& BOOST_APPEND_EXPLICIT_
#endif
template <class T>
inline T epsilon(const mpl::false_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
inline T epsilon(const mpl::false_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
{
BOOST_MATH_STD_USING // for ADL of std names
static const T eps = ldexp(static_cast<T>(1), 1-policies::digits<T, policies::policy<> >());
@@ -174,7 +174,7 @@ inline T epsilon(const mpl::false_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
} // namespace detail
template <class T>
inline T log_max_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
typedef typename mpl::if_c<
@@ -195,7 +195,7 @@ inline T log_max_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
}
template <class T>
inline T log_min_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
typedef typename mpl::if_c<
@@ -217,7 +217,7 @@ inline T log_min_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
}
template <class T>
inline T epsilon(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
inline T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
return detail::epsilon<T>(mpl::bool_< ::std::numeric_limits<T>::is_specialized>());

View File

@@ -75,9 +75,9 @@ T relative_error(T a, T b)
if((a != 0) && (b != 0))
{
// TODO: use isfinite:
if(b > max_val)
if(fabs(b) >= max_val)
{
if(a > max_val)
if(fabs(a) >= max_val)
return 0; // one infinity is as good as another!
}
// If the result is denormalised, treat all denorms as equivalent:

View File

@@ -494,7 +494,7 @@ std::pair<T, T> bracket_and_solve_root(F f, const T& guess, T factor, bool risin
// Zero is to the right of b, so walk upwards
// until we find it:
//
while(sign(fb) == sign(fa))
while((boost::math::sign)(fb) == (boost::math::sign)(fa))
{
if(count == 0)
policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, pol);
@@ -521,7 +521,7 @@ std::pair<T, T> bracket_and_solve_root(F f, const T& guess, T factor, bool risin
// Zero is to the left of a, so walk downwards
// until we find it:
//
while(sign(fb) == sign(fa))
while((boost::math::sign)(fb) == (boost::math::sign)(fa))
{
if(fabs(a) < tools::min_value<T>())
{

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2006-7 John Maddock
// 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_WORHAROUND_HPP
#define BOOST_MATH_TOOLS_WORHAROUND_HPP
#include <boost/math/tools/config.hpp>
namespace boost{ namespace math{ namespace tools{
//
// We call this short forwarding function so that we can work around a bug
// on Darwin that causes std::fmod to return a NaN. The test case is:
// std::fmod(1185.0L, 1.5L);
//
template <class T>
inline T fmod_workaround(T a, T b)
{
BOOST_MATH_STD_USING
return fmod(a, b);
}
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
template <>
inline long double fmod_workaround(long double a, long double b)
{
return ::fmodl(a, b);
}
#endif
}}} // namespaces
#endif // BOOST_MATH_TOOLS_WORHAROUND_HPP

View File

@@ -8,12 +8,7 @@
#include "../tools/ntl_rr_digamma.hpp"
#include <boost/math/bindings/rr.hpp>
#include <boost/math/tools/polynomial.hpp>
#include <boost/math/special_functions/log1p.hpp>
#include <boost/math/special_functions/expm1.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <boost/math/special_functions/erf.hpp>
#include <boost/math/special_functions/ellint_1.hpp>
#include <boost/math/special_functions/ellint_2.hpp>
#include <boost/math/special_functions.hpp>
#include <cmath>
@@ -210,7 +205,7 @@ boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant)
boost::math::ntl::RR k = sqrt(1 - mp);
static const boost::math::ntl::RR l4 = log(boost::math::ntl::RR(4));
boost::math::ntl::RR p2 = boost::math::constants::pi<boost::math::ntl::RR>() / 2;
return boost::math::ellint_1(k) / (l4 - log(mp));
return (boost::math::ellint_1(k) + 1) / (1 + l4 - log(mp));
}
case 15:
// E(k)
@@ -219,6 +214,17 @@ boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant)
boost::math::ntl::RR z = 1 - x * log(x);
return boost::math::ellint_2(sqrt(1-x)) / z;
}
case 16:
// Bessel I0(x) over [0,16]:
{
return boost::math::cyl_bessel_i(0, sqrt(x));
}
case 17:
// Bessel I0(x) over [16,INF]
{
boost::math::ntl::RR z = 1 / (boost::math::ntl::RR(1)/16 - x);
return boost::math::cyl_bessel_i(0, z) * sqrt(z) / exp(z);
}
}
return 0;
}

View File

@@ -89,7 +89,8 @@ void step_some(unsigned count)
//
started = true;
}
for(unsigned i = 0; i < count; ++i)
unsigned i;
for(i = 0; i < count; ++i)
{
std::cout << "Stepping..." << std::endl;
p_remez->set_brake(brake);
@@ -125,7 +126,8 @@ void show(const char*, const char*)
boost::numeric::ublas::vector<boost::math::ntl::RR> v = p_remez->zero_points();
std::cout << " Zeros = {\n";
for(unsigned i = 0; i < v.size(); ++i)
unsigned i;
for(i = 0; i < v.size(); ++i)
{
std::cout << " " << v[i] << std::endl;
}
@@ -133,7 +135,7 @@ void show(const char*, const char*)
v = p_remez->chebyshev_points();
std::cout << " Chebeshev Control Points = {\n";
for(unsigned i = 0; i < v.size(); ++i)
for(i = 0; i < v.size(); ++i)
{
std::cout << " " << v[i] << std::endl;
}
@@ -143,14 +145,14 @@ void show(const char*, const char*)
std::cout << "Y offset: " << y_offset << std::endl;
std::cout << "P = {";
for(unsigned i = 0; i < n.size(); ++i)
for(i = 0; i < n.size(); ++i)
{
std::cout << " " << n[i] << std::endl;
}
std::cout << " }\n";
std::cout << "Q = {";
for(unsigned i = 0; i < d.size(); ++i)
for(i = 0; i < d.size(); ++i)
{
std::cout << " " << d[i] << std::endl;
}
@@ -216,7 +218,8 @@ void do_test(T, const char* name)
//
std::cout << "Starting tests at " << name << " precision...\n";
std::cout << "Absissa Error\n";
for(unsigned i = 0; i < zeros.size(); ++i)
unsigned i;
for(i = 0; i < zeros.size(); ++i)
{
boost::math::ntl::RR true_result = the_function(zeros[i]);
T absissa = boost::math::tools::real_cast<T>(zeros[i]);
@@ -238,7 +241,7 @@ void do_test(T, const char* name)
//
// Do the tests at the Chebeshev control points:
//
for(unsigned i = 0; i < cheb.size(); ++i)
for(i = 0; i < cheb.size(); ++i)
{
boost::math::ntl::RR true_result = the_function(cheb[i]);
T absissa = boost::math::tools::real_cast<T>(cheb[i]);
@@ -381,6 +384,38 @@ void rescale(const char*, const char*)
}
}
void graph_poly(const char*, const char*)
{
int i = 50;
boost::math::ntl::RR::SetPrecision(working_precision);
if(started)
{
//
// We want to test the approximation at fixed precision:
// either float, double or long double. Begin by getting the
// polynomials:
//
boost::math::tools::polynomial<boost::math::ntl::RR> n, d;
n = p_remez->numerator();
d = p_remez->denominator();
boost::math::ntl::RR max_error(0);
boost::math::ntl::RR step = (b - a) / i;
std::cout << "Evaluating Numerator...\n";
boost::math::ntl::RR val;
for(val = a; val <= b; val += step)
std::cout << n.evaluate(val) << std::endl;
std::cout << "Evaluating Denominator...\n";
for(val = a; val <= b; val += step)
std::cout << d.evaluate(val) << std::endl;
}
else
{
std::cout << "Nothing to test: try converging an approximation first!!!" << std::endl;
}
}
int test_main(int, char* [])
{
std::string line;
@@ -424,6 +459,8 @@ int test_main(int, char* [])
str_p("step") && int_p[&step_some]
||
str_p("step")[&step]
||
str_p("poly")[&graph_poly]
||
str_p("info")[&show]
||

Some files were not shown because too many files have changed in this diff Show More