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

Merge branch 'develop' into daubechies_attempt_2

This commit is contained in:
NAThompson
2020-01-25 08:12:13 +08:00
907 changed files with 5998 additions and 4063 deletions

View File

@@ -4,7 +4,7 @@
/* HSO4.hpp header file */
/* */
/* This file is not currently part of the Boost library. It is simply an example of the use */
/* quaternions can be put to. Hopefully it will be usefull too. */
/* quaternions can be put to. Hopefully it will be useful too. */
/* */
/* This file provides tools to convert between quaternions and R^4 rotation matrices. */
/* */

View File

@@ -62,7 +62,7 @@ int main()
//[arcsine_snip_8
using boost::math::arcsine_distribution;
arcsine_distribution<> as(2, 5); // Cconstructs a double arcsine distribution.
arcsine_distribution<> as(2, 5); // Constructs a double arcsine distribution.
BOOST_ASSERT(as.x_min() == 2.); // as.x_min() returns 2.
BOOST_ASSERT(as.x_max() == 5.); // as.x_max() returns 5.
//] [/arcsine_snip_8]

View File

@@ -23,7 +23,7 @@ achieves a specific value.
int main()
{
// The lithium potential is given in Kohn's paper, Table I.
// (We could equally easily use an unordered_map, a list of tuples or pairs, or a 2-dimentional array).
// (We could equally easily use an unordered_map, a list of tuples or pairs, or a 2-dimensional array).
std::map<double, double> r;
r[0.02] = 5.727;
@@ -78,7 +78,7 @@ int main()
auto y_range = boost::adaptors::values(r);
boost::math::barycentric_rational<double> b(x_range.begin(), x_range.end(), y_range.begin());
//
// We'll use a lamda expression to provide the functor to our root finder, since we want
// We'll use a lambda expression to provide the functor to our root finder, since we want
// the abscissa value that yields 3, not zero. We pass the functor b by value to the
// lambda expression since barycentric_rational is trivial to copy.
// Here we're using simple bisection to find the root:

View File

@@ -3,8 +3,9 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// Copyright Paul A. Bristow 2012.
// Copyright Paul A. Bristow 2019.
// Copyright Christopher Kormanyos 2012.
// Copyright John Maddock 2012.
// This file is written to be included from a Quickbook .qbk document.
// It can be compiled by the C++ compiler, and run. Any output can
@@ -13,86 +14,191 @@
// and comments: don't change any of the special comment markups!
#ifdef _MSC_VER
# pragma warning (disable : 4512) // assignment operator could not be generated.
# pragma warning (disable : 4996)
#pragma warning(disable : 4512) // assignment operator could not be generated.
#pragma warning(disable : 4996)
#endif
//[big_seventh_example_1
/*`[h5 Using Boost.Multiprecision `cpp_float` for numerical calculations with high precision.]
/*`[h5 Using Boost.Multiprecision `cpp_float` types for numerical calculations with higher precision than built-in `long double`.]
The Boost.Multiprecision library can be used for computations requiring precision
exceeding that of standard built-in types such as float, double
and long double. For extended-precision calculations, Boost.Multiprecision
supplies a template data type called cpp_dec_float. The number of decimal
digits of precision is fixed at compile-time via template parameter.
exceeding that of standard built-in types such as `float`, `double`
and `long double`. For extended-precision calculations, Boost.Multiprecision
supplies several template data types called `cpp_bin_float_`.
To use these floating-point types and constants, we need some includes:
The number of decimal digits of precision is fixed at compile-time via template parameter.
To use these floating-point types and
[@https://www.boost.org/doc/libs/release/libs/math/doc/html/constants.html Boost.Math collection of high-precision constants],
we need some includes:
*/
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// using boost::multiprecision::cpp_dec_float
#include <boost/multiprecision/cpp_bin_float.hpp>
// that includes some predefined typedefs that can be used thus:
// using boost::multiprecision::cpp_bin_float_quad;
// using boost::multiprecision::cpp_bin_float_50;
// using boost::multiprecision::cpp_bin_float_100;
#include <iostream>
#include <limits>
#include <type_traits>
/*` So now we can demonstrate with some trivial calculations:
*/
//] //[big_seventh_example_1]
void no_et()
{
using namespace boost::multiprecision;
std::cout.setf(std::ios_base::boolalpha);
typedef number<backends::cpp_bin_float<113, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_on> cpp_bin_float_quad_et_on;
typedef number<backends::cpp_bin_float<113, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> cpp_bin_float_quad_et_off;
typedef number<backends::cpp_bin_float<113, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> cpp_bin_float_oct;
cpp_bin_float_quad x("42.");
std::cout << "cpp_bin_float_quad x = " << x << std::endl;
cpp_bin_float_quad_et_on q("42.");
std::cout << "std::is_same<cpp_bin_float_quad, cpp_bin_float_quad_et_off>::value is " << std::is_same<cpp_bin_float_quad, cpp_bin_float_quad_et_off>::value << std::endl;
std::cout << "std::is_same<cpp_bin_float_quad, cpp_bin_float_quad_et_on>::value is " << std::is_same<cpp_bin_float_quad, cpp_bin_float_quad_et_on>::value << std::endl;
std::cout << "cpp_bin_float_quad_et_on q = " << q << std::endl;
cpp_bin_float_50 y("42."); // typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50;
std::cout << "cpp_bin_float_50 y = " << y << std::endl;
typedef number<backends::cpp_bin_float<50>, et_off > cpp_bin_float_50_no_et;
typedef number<backends::cpp_bin_float<50>, et_on > cpp_bin_float_50_et;
cpp_bin_float_50_no_et z("42."); // typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50;
std::cout << "cpp_bin_float_50_no_et z = " << z << std::endl;
std::cout << " std::is_same<cpp_bin_float_50, cpp_bin_float_50_no_et>::value is " << std::is_same<cpp_bin_float_50, cpp_bin_float_50_no_et>::value << std::endl;
std::cout << " std::is_same<cpp_bin_float_50_et, cpp_bin_float_50_no_et>::value is " << std::is_same<cpp_bin_float_50_et, cpp_bin_float_50_no_et>::value << std::endl;
} // void no_et()
int main()
{
//[big_seventh_example_2
/*`Using `typedef cpp_dec_float_50` hides the complexity of multiprecision,
allows us to define variables with 50 decimal digit precision just like built-in `double`.
no_et();
return 0;
//[big_seventh_example_2
/*`Using `typedef cpp_bin_float_50` hides the complexity of multiprecision,
allows us to define variables with 50 decimal digit precision just like built-in `double`.
*/
using boost::multiprecision::cpp_dec_float_50;
using boost::multiprecision::cpp_bin_float_50;
cpp_dec_float_50 seventh = cpp_dec_float_50(1) / 7; // 1 / 7
cpp_bin_float_50 seventh = cpp_bin_float_50(1) / 7; // 1 / 7
/*`By default, output would only show the standard 6 decimal digits,
/*`By default, output would only show the standard 6 decimal digits,
so set precision to show all 50 significant digits, including any trailing zeros.
*/
std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10);
std::cout << std::showpoint << std::endl; // Append any trailing zeros.
std::cout << seventh << std::endl;
/*`which outputs:
std::cout.precision(std::numeric_limits<cpp_bin_float_50>::digits10);
std::cout << std::showpoint << std::endl; // Append any trailing zeros.
std::cout << seventh << std::endl;
/*`which outputs:
0.14285714285714285714285714285714285714285714285714
We can also use Boost.Math __constants like [pi],
guaranteed to be initialized with the very last bit of precision for the floating-point type.
We can also use __math_constants like [pi],
guaranteed to be initialized with the very last bit of precision (__ULP) for the floating-point type.
*/
std::cout << "pi = " << boost::math::constants::pi<cpp_bin_float_50>() << std::endl;
cpp_bin_float_50 circumference = boost::math::constants::pi<cpp_bin_float_50>() * 2 * seventh;
std::cout << "c = " << circumference << std::endl;
std::cout << "pi = " << boost::math::constants::pi<cpp_dec_float_50>() << std::endl;
cpp_dec_float_50 circumference = boost::math::constants::pi<cpp_dec_float_50>() * 2 * seventh;
std::cout << "c = "<< circumference << std::endl;
/*`which outputs
/*`which outputs
pi = 3.1415926535897932384626433832795028841971693993751
c = 0.89759790102565521098932668093700082405633411410717
*/
//] [/big_seventh_example_2]
//] [/big_seventh_example_2]
return 0;
//[big_seventh_example_3
/*`So using `cpp_bin_float_50` looks like a simple 'drop-in' for the __fundamental_type like 'double',
but beware of loss of precision from construction or conversion from `double` or other lower precision types.
This is a mistake that is very easy to make,
and very difficult to detect because the loss of precision is only visible after the 17th decimal digit.
We can show this by constructing from `double`, (avoiding the schoolboy-error `double d7 = 1 / 7;` giving zero!)
*/
double d7 = 1. / 7; //
std::cout << "d7 = " << d7 << std::endl;
cpp_bin_float_50 seventh_0 = cpp_bin_float_50(1 / 7); // Avoid the schoolboy-error 1 / 7 == 0!)
std::cout << "seventh_0 = " << seventh_0 << std::endl;
// seventh_double0 = 0.0000000000000000000000000000000000000000000000000
cpp_bin_float_50 seventh_double = cpp_bin_float_50(1. / 7); // Construct from double!
std::cout << "seventh_double = " << seventh_double << std::endl; // Boost.Multiprecision post-school error!
// seventh_double = 0.14285714285714284921269268124888185411691665649414
/*`Did you spot the mistake? After the 17th decimal digit, result is random!
14285714285714 should be recurring.
*/
cpp_bin_float_50 seventh_big(1); // 1
seventh_big /= 7;
std::cout << "seventh_big = " << seventh_big << std::endl; //
// seventh_big = 0.14285714285714285714285714285714285714285714285714
/*`Note the recurring 14285714285714 pattern as expected.
As one would expect, the variable can be `const` (but sadly [*not yet `constexpr`]).
*/
const cpp_bin_float_50 seventh_const(cpp_bin_float_50(1) / 7);
std::cout << "seventh_const = " << seventh_const << std::endl;
// seventh_const = 0.14285714285714285714285714285714285714285714285714
/*`The full output is:
*/
//] [/big_seventh_example_3
//[big_seventh_example_constexpr
// Sadly we cannot (yet) write:
// constexpr cpp_bin_float_50 any_constexpr(0);
// constexpr cpp_bin_float_50 seventh_constexpr (cpp_bin_float_50(1) / 7);
// std::cout << "seventh_constexpr = " << seventh_constexpr << std::endl; //
// nor use the macro BOOST_CONSTEXPR_OR_CONST unless it returns `const`
// BOOST_CONSTEXPR_OR_CONST cpp_bin_float_50 seventh_constexpr(seventh_const);
//] [/big_seventh_example_constexpr
return 0;
} // int main()
/*
//[big_seventh_example_output
0.14285714285714285714285714285714285714285714285714
pi = 3.1415926535897932384626433832795028841971693993751
c = 0.89759790102565521098932668093700082405633411410717
d7 = 0.14285714285714284921269268124888185411691665649414
seventh_0 = 0.0000000000000000000000000000000000000000000000000
seventh_double = 0.14285714285714284921269268124888185411691665649414
seventh_big = 0.14285714285714285714285714285714285714285714285714
seventh_const = 0.14285714285714285714285714285714285714285714285714
//] //[big_seventh_example_output]
*/

View File

@@ -147,8 +147,8 @@ Finally, print two tables of probability for the /exactly/ and /at least/ a numb
} // for i
cout << endl;
// Tabulate the probability of getting between zero heads and 0 upto 10 heads.
cout << "Probability of getting upto (<=) heads" << endl;
// Tabulate the probability of getting between zero heads and 0 up to 10 heads.
cout << "Probability of getting up to (<=) heads" << endl;
for (int successes = 0; successes <= flips; successes++)
{ // Say success means getting a head
// (equally success could mean getting a tail).
@@ -226,7 +226,7 @@ Probability of getting exactly (==) heads
9 0.009766 or 1 in 102.4, or 0.9766%
10 0.0009766 or 1 in 1024, or 0.09766%
Probability of getting upto (<=) heads
Probability of getting up to (<=) heads
0 0.0009766 or 1 in 1024, or 0.09766%
1 0.01074 or 1 in 93.09, or 1.074%
2 0.05469 or 1 in 18.29, or 5.469%

View File

@@ -27,7 +27,7 @@ int main()
using boost::math::binomial_distribution;
// This replicates the computation of the examples of using nag-binomial_dist
// using g01bjc in section g01 Somple Calculations on Statistical Data.
// using g01bjc in section g01 Simple Calculations on Statistical Data.
// http://www.nag.co.uk/numeric/cl/manual/pdf/G01/g01bjc.pdf
// Program results section 8.3 page 3.g01bjc.3
//8.2. Program Data

View File

@@ -29,7 +29,7 @@ using boost::math::policies::errno_on_error;
using boost::math::policies::ignore_error;
//using namespace boost::math::policies;
//using namespace boost::math; // avoid potential ambiuity with std:: <random>
//using namespace boost::math; // avoid potential ambiguity with std:: <random>
// Define a policy:
typedef policy<

View File

@@ -25,7 +25,7 @@ void confidence_limits_on_std_deviation(
// For example if we set the confidence limit to
// 0.95, we know that if we repeat the sampling
// 100 times, then we expect that the true standard deviation
// will be between out limits on 95 occations.
// will be between out limits on 95 occasions.
// Note: this is not the same as saying a 95%
// confidence interval means that there is a 95%
// probability that the interval contains the true standard deviation.
@@ -300,7 +300,7 @@ int main()
// List confidence interval multipliers for standard deviation
// for a range of numbers of observations from 2 to a million,
// and for a few alpha values, 0.1, 0.05, 0.01 for condfidences 90, 95, 99 %
// and for a few alpha values, 0.1, 0.05, 0.01 for confidences 90, 95, 99 %
confidence_limits_on_std_deviation_alpha(1., 0.1);
confidence_limits_on_std_deviation_alpha(1., 0.05);
confidence_limits_on_std_deviation_alpha(1., 0.01);

View File

@@ -19,7 +19,7 @@
//[fft_sines_table_example_1
/*`[h5 Using Boost.Multiprecision to generate a high-precision array of sine coefficents for use with FFT.]
/*`[h5 Using Boost.Multiprecision to generate a high-precision array of sine coefficients for use with FFT.]
The Boost.Multiprecision library can be used for computations requiring precision
exceeding that of standard built-in types such as `float`, `double`

View File

@@ -30,7 +30,7 @@ the algorithms to find location (and some std output of course).
#include <boost/math/distributions/find_location.hpp>
using boost::math::find_location; // for mean
#include <boost/math/distributions/find_scale.hpp>
using boost::math::find_scale; // for standard devation
using boost::math::find_scale; // for standard deviation
using boost::math::complement; // Needed if you want to use the complement version.
using boost::math::policies::policy;

View File

@@ -87,7 +87,7 @@ Suppose an 'fair' 6-face dice is thrown repeatedly:
// (so failure_fraction is 1 - success_fraction = 5./6 = 1- 0.1666 = 0.8333)
/*`If the dice is thrown repeatedly until the *first* time a /three/ appears.
The probablility distribution of the number of times it is thrown *not* getting a /three/
The probability distribution of the number of times it is thrown *not* getting a /three/
(/not-a-threes/ number of failures to get a /three/)
is a geometric distribution with the success_fraction = 1/6 = 0.1666[recur].
@@ -290,7 +290,7 @@ And if we require a high confidence, they widen to 0.00005 to 0.05.
cout << "geometric::find_upper_bound_on_p(" << int(k) << ", " << alpha/2 << ") = "
<< t << endl; // 0.052
/*`In real life, there will usually be more than one event (fault or success),
when the negative binomial, which has the neccessary extra parameter, will be needed.
when the negative binomial, which has the necessary extra parameter, will be needed.
*/
/*`As noted above, using a catch block is always a good idea,

View File

@@ -58,7 +58,7 @@ see:
* Andrew Gelman, John B. Carlin, Hal E. Stern, Donald B. Rubin, Bayesian Data Analysis,
2003, ISBN 978-1439840955.
* Jim Albert, Bayesian Compution with R, Springer, 2009, ISBN 978-0387922973.
* Jim Albert, Bayesian Computation with R, Springer, 2009, ISBN 978-0387922973.
(As the scaled-inversed-chi-squared is another parameterization of the inverse-gamma distribution,
this example could also have used the inverse-gamma distribution).

View File

@@ -77,7 +77,7 @@ rsat reverse saturation current
\param v Voltage V to compute current I(V).
\param vt Thermal voltage, for example 0.0257025 = 25 mV, computed from boltzmann_k * temp / charge_q;
\param rsat Resistance in series with the diode.
\param re Instrinsic emitter resistance (estimated to be 0.3 ohm from the Rs = 0 data)
\param re Intrinsic emitter resistance (estimated to be 0.3 ohm from the Rs = 0 data)
\param isat Reverse saturation current (See equation 2).
\param nu Ideality factor (default = unity).

View File

@@ -91,7 +91,7 @@ double i(double isat, double vd, double vt, double nu)
\param v Voltage V to compute current I(V).
\param vt Thermal voltage, for example 0.0257025 = 25 mV, computed from boltzmann_k * temp / charge_q;
\param rsat Resistance in series with the diode.
\param re Instrinsic emitter resistance (estimated to be 0.3 ohm from the Rs = 0 data)
\param re Intrinsic emitter resistance (estimated to be 0.3 ohm from the Rs = 0 data)
\param isat Reverse saturation current (See equation 2).
\param nu Ideality factor (default = unity).

View File

@@ -57,7 +57,7 @@ template<typename T>
void show_value(T z)
{
std::streamsize precision = std::cout.precision(std::numeric_limits<T>::max_digits10); // Save.
std::cout.precision(std::numeric_limits<T>::max_digits10); // Show all posssibly significant digits.
std::cout.precision(std::numeric_limits<T>::max_digits10); // Show all possibly significant digits.
std::ios::fmtflags flags(std::cout.flags());
std::cout.setf(std::ios_base::showpoint); // Include any trailing zeros.
std::cout << z;

View File

@@ -77,7 +77,7 @@ int main ()
// (But these tests are expected to pass using non_finite num_put and num_get facets).
// Use the current 'native' default locale.
std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale.
std::locale default_locale (std::locale::classic ()); // Note the current (default C) locale.
// Create plus and minus infinity.
double plus_infinity = +std::numeric_limits<double>::infinity();

View File

@@ -94,7 +94,7 @@ helpful error message instead of an abrupt program abort.
/*`
Selling five candy bars means getting five successes, so successes r = 5.
The total number of trials (n, in this case, houses visited) this takes is therefore
= sucesses + failures or k + r = k + 5.
= successes + failures or k + r = k + 5.
*/
double sales_quota = 5; // Pat's sales quota - successes (r).
/*`

View File

@@ -17,7 +17,7 @@
// (Bernoulli, independent, yes or no, succeed or fail)
// with success_fraction probability p,
// negative_binomial is the probability that k or fewer failures
// preceed the r th trial's success.
// precede the r th trial's success.
#include <iostream>
using std::cout;
@@ -62,7 +62,7 @@ int main()
}
// Compare with the cdf
double cdf8 = cdf(mynbdist, static_cast<double>(k));
double diff = sum - cdf8; // Expect the diference to be very small.
double diff = sum - cdf8; // Expect the difference to be very small.
cout << setprecision(17) << "Sum pdfs = " << sum << ' ' // sum = 0.40025683281803698
<< ", cdf = " << cdf(mynbdist, static_cast<double>(k)) // cdf = 0.40025683281803687
<< ", difference = " // difference = 0.50000000000000000

View File

@@ -75,7 +75,7 @@ int main ()
return 0;
}
std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale.
std::locale default_locale (std::locale::classic ()); // Note the current (default C) locale.
// Create plus and minus infinity.
double plus_infinity = +std::numeric_limits<double>::infinity();

View File

@@ -11,7 +11,7 @@
\file
\brief Examples of nonfinite with output and input facets and stringstreams.
\detail Contruct a new locale with the nonfinite_num_put and nonfinite_num_get
\detail Construct a new locale with the nonfinite_num_put and nonfinite_num_get
facets and imbue istringstream, ostringstream and stringstreams,
showing output and input (and loopback for the stringstream).

View File

@@ -22,7 +22,7 @@ C99 standard output of infinity and NaN in serialization archives.
and imbue input and output streams with the non_finite_num put and get facets.
This allow output and input of infinity and NaN in a Standard portable way,
This permits 'loop-back' of output back into input (and portably across different system too).
This is particularly useful when used with Boost.Seralization so that non-finite NaNs and infinity
This is particularly useful when used with Boost.Serialization so that non-finite NaNs and infinity
values in text and xml archives can be handled correctly and portably.
*/

View File

@@ -53,7 +53,7 @@ bits of lost precision.
*/
/*` [note Rquires the C++11 feature of
/*` [note Requires the C++11 feature of
[@http://en.wikipedia.org/wiki/Anonymous_function#C.2B.2B anonymous functions]
for the derivative function calls like `[]( const double & x_) -> double`.
*/

View File

@@ -14,12 +14,12 @@ using std::cout; using std::endl;
//[policy_eg_7
#include <boost/math/distributions.hpp> // All distributions.
// using boost::math::normal; // Would create an ambguity between
// using boost::math::normal; // Would create an ambiguity between
// boost::math::normal_distribution<RealType> boost::math::normal and
// 'anonymous-namespace'::normal'.
namespace
{ // anonymous or unnnamed (rather than named as in policy_eg_6.cpp).
{ // anonymous or unnamed (rather than named as in policy_eg_6.cpp).
using namespace boost::math::policies;
// using boost::math::policies::errno_on_error; // etc.

View File

@@ -270,7 +270,7 @@ int main()
// Raise an underflow error:
cout << "Result of tgamma(-190.5) is: "
<< mymath::tgamma(-190.5) << std::endl << endl;
// Unfortunately we can't predicably raise a denormalised
// Unfortunately we can't predictably raise a denormalised
// result, nor can we raise an evaluation error in this example
// since these should never really occur!
} // int main()

View File

@@ -32,14 +32,14 @@ int main()
std::streamsize p = 2 + (bits * 30103UL) / 100000UL;
// Approximate number of significant decimal digits for 25 bits.
cout.precision(p);
cout << bits << " binary bits is approoximately equivalent to " << p << " decimal digits " << endl;
cout << bits << " binary bits is approximately equivalent to " << p << " decimal digits " << endl;
cout << "quantile(normal_distribution<double, policy<digits2<25> > >(), 0.05 = "
<< q << endl; // -1.64485
}
/*
Output:
25 binary bits is approoximately equivalent to 9 decimal digits
25 binary bits is approximately equivalent to 9 decimal digits
quantile(normal_distribution<double, policy<digits2<25> > >(), 0.05 = -1.64485363
*/

View File

@@ -136,7 +136,7 @@ struct root_info
// = digits * digits_accuracy
// Vector of values (4) for each algorithm, TOMS748, Newton, Halley & Schroder.
//std::vector< boost::int_least64_t> times; converted to int.
std::vector<int> times; // arbirary units (ticks).
std::vector<int> times; // arbitrary units (ticks).
//boost::int_least64_t min_time = std::numeric_limits<boost::int_least64_t>::max(); // Used to normalize times (as int).
std::vector<double> normed_times;
int min_time = (std::numeric_limits<int>::max)(); // Used to normalize times.
@@ -205,7 +205,7 @@ T elliptic_root_noderiv(T radius, T arc)
T factor = 1.2; // How big steps to take when searching.
const boost::uintmax_t maxit = 50; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // arc-length increases if one radii increases, so function is rising
// Define a termination condition, stop when nearly all digits are correct, but allow for
// the fact that we are returning a range, and must have some inaccuracy in the elliptic integral:
@@ -223,7 +223,7 @@ T elliptic_root_noderiv(T radius, T arc)
//[elliptic_1deriv_func
template <class T = double>
struct elliptic_root_functor_1deriv
{ // Functor also returning 1st derviative.
{ // Functor also returning 1st derivative.
BOOST_STATIC_ASSERT_MSG(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
elliptic_root_functor_1deriv(T const& arc, T const& radius) : m_arc(arc), m_radius(radius)
@@ -581,7 +581,7 @@ int test_root(cpp_bin_float_100 big_radius, cpp_bin_float_100 big_arc, cpp_bin_f
return 4; // eval_count of how many algorithms used.
} // test_root
/*! Fill array of times, interations, etc for Nth root for all 4 types,
/*! Fill array of times, iterations, etc for Nth root for all 4 types,
and write a table of results in Quickbook format.
*/
void table_root_info(cpp_bin_float_100 radius, cpp_bin_float_100 arc)

View File

@@ -218,7 +218,7 @@ T cbrt_noderiv(T x)
T factor = 2; // How big steps to take when searching.
const boost::uintmax_t maxit = 50; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // So if result if guess^3 is too low, then try increasing guess.
// Some fraction of digits is used to control how accurate to try to make the result.
int get_digits = static_cast<int>(std::numeric_limits<T>::digits - 2);
@@ -236,7 +236,7 @@ T cbrt_noderiv(T x)
template <class T>
struct cbrt_functor_deriv
{ // Functor also returning 1st derviative.
{ // Functor also returning 1st derivative.
cbrt_functor_deriv(T const& to_find_root_of) : a(to_find_root_of)
{ // Constructor stores value a to find root of,
// for example: calling cbrt_functor_deriv<T>(x) to use to get cube root of x.

View File

@@ -127,7 +127,7 @@ T cbrt_noderiv(T x)
T factor = 2; // How big steps to take when searching.
const boost::uintmax_t maxit = 20; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // So if result if guess^3 is too low, then try increasing guess.
int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// Some fraction of digits is used to control how accurate to try to make the result.
@@ -341,7 +341,7 @@ If your differentiation is a little rusty
then you can get help, for example from the invaluable
[@http://www.wolframalpha.com/ WolframAlpha site.]
For example, entering the commmand: `differentiate x ^ 5`
For example, entering the command: `differentiate x ^ 5`
or the Wolfram Language command: ` D[x ^ 5, x]`

View File

@@ -66,7 +66,7 @@ then you can get help, for example from the invaluable
http://www.wolframalpha.com/ site
entering the commmand
entering the command
differentiate x^5
@@ -183,7 +183,7 @@ T fifth_noderiv(T x)
// We could also have used a maximum iterations provided by any policy:
// boost::uintmax_t max_it = policies::get_max_root_iterations<Policy>();
boost::uintmax_t it = maxit; // Initally our chosen max iterations,
boost::uintmax_t it = maxit; // Initially our chosen max iterations,
bool is_rising = true; // So if result if guess^5 is too low, try increasing guess.
eps_tolerance<double> tol(digits);

View File

@@ -188,7 +188,7 @@ int main()
r = cbrt_2deriv(static_cast<cpp_dec_float_50>(2.)); // Passing a cpp_dec_float_50,
// so will compute a cpp_dec_float_50 precision result.
std::cout << "cbrt(" << two << ") = " << r << std::endl;
r = cbrt_2deriv<cpp_dec_float_50>(2.); // Explictly a cpp_dec_float_50, so will compute a cpp_dec_float_50 precision result.
r = cbrt_2deriv<cpp_dec_float_50>(2.); // Explicitly a cpp_dec_float_50, so will compute a cpp_dec_float_50 precision result.
std::cout << "cbrt(" << two << ") = " << r << std::endl;
// cpp_dec_float_50 1.2599210498948731647672106072782283505702514647015
//] [/root_finding_multiprecision_example_2

View File

@@ -43,7 +43,7 @@ boost::uintmax_t cbrt_noderiv(T x, T guess)
T factor = 2; // How big steps to take when searching.
const boost::uintmax_t maxit = 20; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // So if result if guess^3 is too low, then try increasing guess.
int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// Some fraction of digits is used to control how accurate to try to make the result.
@@ -173,7 +173,7 @@ boost::uintmax_t elliptic_root_noderiv(T radius, T arc, T guess)
T factor = 2; // How big steps to take when searching.
const boost::uintmax_t maxit = 50; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // arc-length increases if one radii increases, so function is rising
// Define a termination condition, stop when nearly all digits are correct, but allow for
// the fact that we are returning a range, and must have some inaccuracy in the elliptic integral:
@@ -185,7 +185,7 @@ boost::uintmax_t elliptic_root_noderiv(T radius, T arc, T guess)
template <class T = double>
struct elliptic_root_functor_1deriv
{ // Functor also returning 1st derviative.
{ // Functor also returning 1st derivative.
BOOST_STATIC_ASSERT_MSG(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
elliptic_root_functor_1deriv(T const& arc, T const& radius) : m_arc(arc), m_radius(radius)

View File

@@ -137,7 +137,7 @@ struct root_info
// = digits * digits_accuracy
// Vector of values (4) for each algorithm, TOMS748, Newton, Halley & Schroder.
//std::vector< boost::int_least64_t> times; converted to int.
std::vector<int> times; // arbirary units (ticks).
std::vector<int> times; // arbitrary units (ticks).
//boost::int_least64_t min_time = std::numeric_limits<boost::int_least64_t>::max(); // Used to normalize times (as int).
std::vector<double> normed_times;
int min_time = (std::numeric_limits<int>::max)(); // Used to normalize times.
@@ -207,7 +207,7 @@ T nth_root_noderiv(T x)
T factor = 2; // How big steps to take when searching.
const boost::uintmax_t maxit = 50; // Limit to maximum iterations.
boost::uintmax_t it = maxit; // Initally our chosen max iterations, but updated with actual.
boost::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // So if result if guess^3 is too low, then try increasing guess.
// Some fraction of digits is used to control how accurate to try to make the result.
int get_digits = std::numeric_limits<T>::digits - 2;
@@ -223,7 +223,7 @@ T nth_root_noderiv(T x)
template <int N, class T = double>
struct nth_root_functor_1deriv
{ // Functor also returning 1st derviative.
{ // Functor also returning 1st derivative.
BOOST_STATIC_ASSERT_MSG(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
BOOST_STATIC_ASSERT_MSG((N > 0) == true, "root N must be > 0!");
@@ -569,7 +569,7 @@ int test_root(cpp_bin_float_100 big_value, cpp_bin_float_100 answer, const char*
return 4; // eval_count of how many algorithms used.
} // test_root
/*! Fill array of times, interations, etc for Nth root for all 4 types,
/*! Fill array of times, iterations, etc for Nth root for all 4 types,
and write a table of results in Quickbook format.
*/
template <int N>

View File

@@ -34,7 +34,7 @@ void confidence_limits_on_mean(double Sm, double Sd, unsigned Sn)
// For example if we set the confidence limit to
// 0.95, we know that if we repeat the sampling
// 100 times, then we expect that the true mean
// will be between out limits on 95 occations.
// will be between out limits on 95 occasions.
// Note: this is not the same as saying a 95%
// confidence interval means that there is a 95%
// probability that the interval contains the true mean.