2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00
This commit is contained in:
jzmaddock
2018-07-28 11:33:41 +01:00
parent a2f228ca88
commit 177c642cbc
19 changed files with 195 additions and 141 deletions

View File

@@ -63,31 +63,31 @@ void test_SO3_spherical()
{ {
theta = -pi+(idxtheta*(2*pi))/number_of_intervals; theta = -pi+(idxtheta*(2*pi))/number_of_intervals;
//::std::cout << "theta = " << theta << " ; "; ::std::cout << "theta = " << theta << " ; ";
//::std::cout << "phi1 = " << phi1 << " ; "; ::std::cout << "phi1 = " << phi1 << " ; ";
//::std::cout << "phi2 = " << phi2; ::std::cout << "phi2 = " << phi2;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> q = ::boost::math::spherical(rho, theta, phi1, phi2); ::boost::math::quaternion<float> q = ::boost::math::spherical(rho, theta, phi1, phi2);
//::std::cout << "q = " << q << ::std::endl; ::std::cout << "q = " << q << ::std::endl;
R3_matrix<float> rot = quaternion_to_R3_rotation(q); R3_matrix<float> rot = quaternion_to_R3_rotation(q);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl;
::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q); ::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q);
//::std::cout << "p = " << p << ::std::endl; ::std::cout << "p = " << p << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }
@@ -119,31 +119,31 @@ void test_SO3_semipolar()
{ {
theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals; theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals;
//::std::cout << "alpha = " << alpha << " ; "; ::std::cout << "alpha = " << alpha << " ; ";
//::std::cout << "theta1 = " << theta1 << " ; "; ::std::cout << "theta1 = " << theta1 << " ; ";
//::std::cout << "theta2 = " << theta2; ::std::cout << "theta2 = " << theta2;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> q = ::boost::math::semipolar(rho, alpha, theta1, theta2); ::boost::math::quaternion<float> q = ::boost::math::semipolar(rho, alpha, theta1, theta2);
//::std::cout << "q = " << q << ::std::endl; ::std::cout << "q = " << q << ::std::endl;
R3_matrix<float> rot = quaternion_to_R3_rotation(q); R3_matrix<float> rot = quaternion_to_R3_rotation(q);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl;
::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q); ::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q);
//::std::cout << "p = " << p << ::std::endl; ::std::cout << "p = " << p << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }
@@ -176,31 +176,31 @@ void test_SO3_multipolar()
{ {
theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals; theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals;
//::std::cout << "rho1 = " << rho1 << " ; "; ::std::cout << "rho1 = " << rho1 << " ; ";
//::std::cout << "theta1 = " << theta1 << " ; "; ::std::cout << "theta1 = " << theta1 << " ; ";
//::std::cout << "theta2 = " << theta2; ::std::cout << "theta2 = " << theta2;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> q = ::boost::math::multipolar(rho1, theta1, rho2, theta2); ::boost::math::quaternion<float> q = ::boost::math::multipolar(rho1, theta1, rho2, theta2);
//::std::cout << "q = " << q << ::std::endl; ::std::cout << "q = " << q << ::std::endl;
R3_matrix<float> rot = quaternion_to_R3_rotation(q); R3_matrix<float> rot = quaternion_to_R3_rotation(q);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl;
::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q); ::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q);
//::std::cout << "p = " << p << ::std::endl; ::std::cout << "p = " << p << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }
@@ -233,31 +233,31 @@ void test_SO3_cylindrospherical()
{ {
longitude = -pi+(idxlongitude*(2*pi))/number_of_intervals; longitude = -pi+(idxlongitude*(2*pi))/number_of_intervals;
//::std::cout << "t = " << t << " ; "; ::std::cout << "t = " << t << " ; ";
//::std::cout << "longitude = " << longitude; ::std::cout << "longitude = " << longitude;
//::std::cout << "latitude = " << latitude; ::std::cout << "latitude = " << latitude;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> q = ::boost::math::cylindrospherical(t, radius, longitude, latitude); ::boost::math::quaternion<float> q = ::boost::math::cylindrospherical(t, radius, longitude, latitude);
//::std::cout << "q = " << q << ::std::endl; ::std::cout << "q = " << q << ::std::endl;
R3_matrix<float> rot = quaternion_to_R3_rotation(q); R3_matrix<float> rot = quaternion_to_R3_rotation(q);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl;
::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q); ::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q);
//::std::cout << "p = " << p << ::std::endl; ::std::cout << "p = " << p << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }
@@ -290,31 +290,31 @@ void test_SO3_cylindrical()
{ {
angle = -pi+(idxangle*(2*pi))/number_of_intervals; angle = -pi+(idxangle*(2*pi))/number_of_intervals;
//::std::cout << "angle = " << angle << " ; "; ::std::cout << "angle = " << angle << " ; ";
//::std::cout << "h1 = " << h1; ::std::cout << "h1 = " << h1;
//::std::cout << "h2 = " << h2; ::std::cout << "h2 = " << h2;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> q = ::boost::math::cylindrical(r, angle, h1, h2); ::boost::math::quaternion<float> q = ::boost::math::cylindrical(r, angle, h1, h2);
//::std::cout << "q = " << q << ::std::endl; ::std::cout << "q = " << q << ::std::endl;
R3_matrix<float> rot = quaternion_to_R3_rotation(q); R3_matrix<float> rot = quaternion_to_R3_rotation(q);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << ::std::endl;
::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q); ::boost::math::quaternion<float> p = R3_rotation_to_quaternion(rot, &q);
//::std::cout << "p = " << p << ::std::endl; ::std::cout << "p = " << p << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::boost::math::abs(q-p) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }
@@ -384,45 +384,45 @@ void test_SO4_spherical()
{ {
theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals; theta2 = -pi+(idxtheta2*(2*pi))/number_of_intervals;
//::std::cout << "theta1 = " << theta1 << " ; "; ::std::cout << "theta1 = " << theta1 << " ; ";
//::std::cout << "phi11 = " << phi11 << " ; "; ::std::cout << "phi11 = " << phi11 << " ; ";
//::std::cout << "phi21 = " << phi21; ::std::cout << "phi21 = " << phi21;
//::std::cout << "theta2 = " << theta2 << " ; "; ::std::cout << "theta2 = " << theta2 << " ; ";
//::std::cout << "phi12 = " << phi12 << " ; "; ::std::cout << "phi12 = " << phi12 << " ; ";
//::std::cout << "phi22 = " << phi22; ::std::cout << "phi22 = " << phi22;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
::boost::math::quaternion<float> p1 = ::boost::math::spherical(rho1, theta1, phi11, phi21); ::boost::math::quaternion<float> p1 = ::boost::math::spherical(rho1, theta1, phi11, phi21);
//::std::cout << "p1 = " << p1 << ::std::endl; ::std::cout << "p1 = " << p1 << ::std::endl;
::boost::math::quaternion<float> q1 = ::boost::math::spherical(rho2, theta2, phi12, phi22); ::boost::math::quaternion<float> q1 = ::boost::math::spherical(rho2, theta2, phi12, phi22);
//::std::cout << "q1 = " << q1 << ::std::endl; ::std::cout << "q1 = " << q1 << ::std::endl;
::std::pair< ::boost::math::quaternion<float> , ::boost::math::quaternion<float> > pq1 = ::std::pair< ::boost::math::quaternion<float> , ::boost::math::quaternion<float> > pq1 =
::std::make_pair(p1,q1); ::std::make_pair(p1,q1);
R4_matrix<float> rot = quaternions_to_R4_rotation(pq1); R4_matrix<float> rot = quaternions_to_R4_rotation(pq1);
//::std::cout << "rot = "; ::std::cout << "rot = ";
//::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << "\t" << rot.a14 << ::std::endl; ::std::cout << "\t" << rot.a11 << "\t" << rot.a12 << "\t" << rot.a13 << "\t" << rot.a14 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << "\t" << rot.a24 << ::std::endl; ::std::cout << "\t" << rot.a21 << "\t" << rot.a22 << "\t" << rot.a23 << "\t" << rot.a24 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << "\t" << rot.a34 << ::std::endl; ::std::cout << "\t" << rot.a31 << "\t" << rot.a32 << "\t" << rot.a33 << "\t" << rot.a34 << ::std::endl;
//::std::cout << "\t"; ::std::cout << "\t";
//::std::cout << "\t" << rot.a41 << "\t" << rot.a42 << "\t" << rot.a43 << "\t" << rot.a44 << ::std::endl; ::std::cout << "\t" << rot.a41 << "\t" << rot.a42 << "\t" << rot.a43 << "\t" << rot.a44 << ::std::endl;
::std::pair< ::boost::math::quaternion<float> , ::boost::math::quaternion<float> > pq2 = ::std::pair< ::boost::math::quaternion<float> , ::boost::math::quaternion<float> > pq2 =
R4_rotation_to_quaternions(rot, &pq1); R4_rotation_to_quaternions(rot, &pq1);
//::std::cout << "p1 = " << pq.first << ::std::endl; ::std::cout << "p1 = " << pq2.first << ::std::endl;
//::std::cout << "p2 = " << pq.second << ::std::endl; ::std::cout << "p2 = " << pq2.second << ::std::endl;
//::std::cout << "round trip discrepancy: " << ::std::sqrt(::boost::math::norm(pq1.first-pq2.first)+::boost::math::norm(pq1.second-pq2.second)) << ::std::endl; ::std::cout << "round trip discrepancy: " << ::std::sqrt(::boost::math::norm(pq1.first-pq2.first)+::boost::math::norm(pq1.second-pq2.second)) << ::std::endl;
//::std::cout << ::std::endl; ::std::cout << ::std::endl;
} }
} }
} }

View File

@@ -181,7 +181,7 @@ We set the precision of the output stream, and show trailing zeros to display a
std::ostream_iterator<float_type>(std::cout, "\n")); std::ostream_iterator<float_type>(std::cout, "\n"));
//] [/bessel_zeros_example_2] //] [/bessel_zeros_example_2]
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "Thrown exception " << ex.what() << std::endl; std::cout << "Thrown exception " << ex.what() << std::endl;
} }

View File

@@ -74,7 +74,7 @@ int main()
// nu = 1.00000, sum = 0.124990, exact = 0.125000 // nu = 1.00000, sum = 0.124990, exact = 0.125000
//] [/bessel_zeros_iterator_example_2] //] [/bessel_zeros_iterator_example_2]
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "Thrown exception " << ex.what() << std::endl; std::cout << "Thrown exception " << ex.what() << std::endl;
} }

View File

@@ -328,7 +328,7 @@ We can list quantiles for a few probabilities:
double ps[] = {0., 0.001, 0.01, 0.05, 0.1, 0.5, 0.9, 0.95, 0.99, 0.999, 1.}; double ps[] = {0., 0.001, 0.01, 0.05, 0.1, 0.5, 0.9, 0.95, 0.99, 0.999, 1.};
// Confidence as fraction = 1-alpha, as percent = 100 * (1-alpha[i]) % // Confidence as fraction = 1-alpha, as percent = 100 * (1-alpha[i]) %
cout.precision(3); cout.precision(3);
for (int i = 0; i < sizeof(ps)/sizeof(ps[0]); i++) for (unsigned i = 0; i < sizeof(ps)/sizeof(ps[0]); i++)
{ {
cout << "If confidence of meeting quota is " << ps[i] cout << "If confidence of meeting quota is " << ps[i]
<< ", then finishing house is " << quantile(nb, ps[i]) + sales_quota << ", then finishing house is " << quantile(nb, ps[i]) + sales_quota

View File

@@ -65,7 +65,7 @@ int main()
//] //[/neumann_zeros_example_2] //] //[/neumann_zeros_example_2]
} }
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "Thrown exception " << ex.what() << std::endl; std::cout << "Thrown exception " << ex.what() << std::endl;
} }

View File

@@ -124,7 +124,7 @@ that the true occurrence frequency lies *inside* the calculated interval.
*/ */
cout << "level of significance (alpha)" << setprecision(4) << endl; cout << "level of significance (alpha)" << setprecision(4) << endl;
cout << "2-sided 1 -sided z(alpha) " << endl; cout << "2-sided 1 -sided z(alpha) " << endl;
for (int i = 0; i < sizeof(alpha)/sizeof(alpha[0]); ++i) for (unsigned i = 0; i < sizeof(alpha)/sizeof(alpha[0]); ++i)
{ {
cout << setw(15) << alpha[i] << setw(15) << alpha[i] /2 << setw(10) << quantile(complement(s, alpha[i]/2)) << endl; cout << setw(15) << alpha[i] << setw(15) << alpha[i] /2 << setw(10) << quantile(complement(s, alpha[i]/2)) << endl;
// Use quantile(complement(s, alpha[i]/2)) to avoid potential loss of accuracy from quantile(s, 1 - alpha[i]/2) // Use quantile(complement(s, alpha[i]/2)) to avoid potential loss of accuracy from quantile(s, 1 - alpha[i]/2)

View File

@@ -7,9 +7,13 @@
// Note that this file contains quickbook mark-up as well as code // Note that this file contains quickbook mark-up as well as code
// and comments, don't change any of the special comment mark-ups! // and comments, don't change any of the special comment mark-ups!
#include <boost/config.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning (disable : 4189) // 'd' : local variable is initialized but not referenced # pragma warning (disable : 4189) // 'd' : local variable is initialized but not referenced
#endif #endif
#ifdef BOOST_GCC
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <iostream> #include <iostream>
using std::cout; using std::endl; using std::cout; using std::endl;

View File

@@ -599,14 +599,13 @@ void table_root_info(cpp_bin_float_100 radius, cpp_bin_float_100 arc)
// Compute the 'right' answer for root N at 100 decimal digits. // Compute the 'right' answer for root N at 100 decimal digits.
cpp_bin_float_100 full_answer = elliptic_root_noderiv(radius, arc); cpp_bin_float_100 full_answer = elliptic_root_noderiv(radius, arc);
int type_count = 0;
root_infos.clear(); // Erase any previous data. root_infos.clear(); // Erase any previous data.
// Fill the elements of the array for each floating-point type. // Fill the elements of the array for each floating-point type.
type_count = test_root<float>(radius, arc, full_answer, "float", 0); test_root<float>(radius, arc, full_answer, "float", 0);
type_count = test_root<double>(radius, arc, full_answer, "double", 1); test_root<double>(radius, arc, full_answer, "double", 1);
type_count = test_root<long double>(radius, arc, full_answer, "long double", 2); test_root<long double>(radius, arc, full_answer, "long double", 2);
type_count = test_root<cpp_bin_float_50>(radius, arc, full_answer, "cpp_bin_float_50", 3); test_root<cpp_bin_float_50>(radius, arc, full_answer, "cpp_bin_float_50", 3);
// Use info from 4 floating point types to // Use info from 4 floating point types to
@@ -868,7 +867,7 @@ int main()
return boost::exit_success; return boost::exit_success;
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "exception thrown: " << ex.what() << std::endl; std::cout << "exception thrown: " << ex.what() << std::endl;
return boost::exit_failure; return boost::exit_failure;

View File

@@ -222,7 +222,6 @@ T cbrt_noderiv(T x)
const boost::uintmax_t maxit = 50; // Limit to maximum iterations. 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; // Initally 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. 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. // 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); int get_digits = static_cast<int>(std::numeric_limits<T>::digits - 2);
@@ -269,7 +268,6 @@ T cbrt_deriv(T x)
guess = boost::math::cbrt(static_cast<double>(x)); guess = boost::math::cbrt(static_cast<double>(x));
T min = guess / 2; // Minimum possible value is half our guess. T min = guess / 2; // Minimum possible value is half our guess.
T max = 2 * guess; // Maximum possible value is twice our guess. T max = 2 * guess; // Maximum possible value is twice our guess.
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.6); int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.6);
const boost::uintmax_t maxit = 20; const boost::uintmax_t maxit = 20;
boost::uintmax_t it = maxit; boost::uintmax_t it = maxit;
@@ -314,7 +312,6 @@ T cbrt_2deriv(T x)
guess = boost::math::cbrt(static_cast<double>(x)); guess = boost::math::cbrt(static_cast<double>(x));
T min = guess / 2; // Minimum possible value is half our guess. T min = guess / 2; // Minimum possible value is half our guess.
T max = 2 * guess; // Maximum possible value is twice our guess. T max = 2 * guess; // Maximum possible value is twice our guess.
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// digits used to control how accurate to try to make the result. // digits used to control how accurate to try to make the result.
int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.4); int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.4);
boost::uintmax_t maxit = 20; boost::uintmax_t maxit = 20;
@@ -342,7 +339,6 @@ T cbrt_2deriv_s(T x)
guess = boost::math::cbrt(static_cast<double>(x)); guess = boost::math::cbrt(static_cast<double>(x));
T min = guess / 2; // Minimum possible value is half our guess. T min = guess / 2; // Minimum possible value is half our guess.
T max = 2 * guess; // Maximum possible value is twice our guess. T max = 2 * guess; // Maximum possible value is twice our guess.
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// digits used to control how accurate to try to make the result. // digits used to control how accurate to try to make the result.
int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.4); int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.4);
const boost::uintmax_t maxit = 20; const boost::uintmax_t maxit = 20;
@@ -451,7 +447,6 @@ int test_root(cpp_bin_float_100 big_value, cpp_bin_float_100 answer, const char*
sum += result; sum += result;
} }
now = ti.elapsed(); now = ti.elapsed();
boost:int_least64_t n = now.user;
long time = static_cast<long>(now.user/1000); // convert nanoseconds to microseconds (assuming this is resolution). long time = static_cast<long>(now.user/1000); // convert nanoseconds to microseconds (assuming this is resolution).
root_infos[type_no].times.push_back(time); // CPU time taken. root_infos[type_no].times.push_back(time); // CPU time taken.
@@ -573,12 +568,11 @@ int test_root(cpp_bin_float_100 big_value, cpp_bin_float_100 answer, const char*
void table_root_info(cpp_bin_float_100 full_value, cpp_bin_float_100 full_answer) void table_root_info(cpp_bin_float_100 full_value, cpp_bin_float_100 full_answer)
{ {
// Fill the elements. // Fill the elements.
int type_count = 0; test_root<float>(full_value, full_answer, "float");
type_count = test_root<float>(full_value, full_answer, "float"); test_root<double>(full_value, full_answer, "double");
type_count = test_root<double>(full_value, full_answer, "double"); test_root<long double>(full_value, full_answer, "long double");
type_count = test_root<long double>(full_value, full_answer, "long double"); test_root<cpp_bin_float_50>(full_value, full_answer, "cpp_bin_float_50");
type_count = test_root<cpp_bin_float_50>(full_value, full_answer, "cpp_bin_float_50"); //test_root<cpp_bin_float_100>(full_value, full_answer, "cpp_bin_float_100");
//type_count = test_root<cpp_bin_float_100>(full_value, full_answer, "cpp_bin_float_100");
std::cout << root_infos.size() << " floating-point types tested:" << std::endl; std::cout << root_infos.size() << " floating-point types tested:" << std::endl;
#ifndef NDEBUG #ifndef NDEBUG
@@ -606,10 +600,9 @@ void table_root_info(cpp_bin_float_100 full_value, cpp_bin_float_100 full_answer
// Header row. // Header row.
std::cout << "Algorithm " << "Iterations " << "Times " << "Norm_times " << "Distance" << std::endl; std::cout << "Algorithm " << "Iterations " << "Times " << "Norm_times " << "Distance" << std::endl;
std::vector<std::string>::iterator al_iter = algo_names.begin();
// Row for all algorithms. // Row for all algorithms.
for (int algo = 0; algo != algo_names.size(); algo++) for (unsigned algo = 0; algo != algo_names.size(); algo++)
{ {
std::cout std::cout
<< std::left << std::setw(20) << algo_names[algo] << " " << std::left << std::setw(20) << algo_names[algo] << " "
@@ -647,7 +640,7 @@ void table_root_info(cpp_bin_float_100 full_value, cpp_bin_float_100 full_answer
fout << "]" << std::endl; fout << "]" << std::endl;
// Row for all algorithms. // Row for all algorithms.
for (int algo = 0; algo != algo_names.size(); algo++) for (size_t algo = 0; algo != algo_names.size(); algo++)
{ {
fout << "[[" << std::left << std::setw(9) << algo_names[algo] << "]"; fout << "[[" << std::left << std::setw(9) << algo_names[algo] << "]";
for (size_t tp = 0; tp != root_infos.size(); tp++) for (size_t tp = 0; tp != root_infos.size(); tp++)
@@ -737,7 +730,7 @@ int main()
return boost::exit_success; return boost::exit_success;
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "exception thrown: " << ex.what() << std::endl; std::cout << "exception thrown: " << ex.what() << std::endl;
return boost::exit_failure; return boost::exit_failure;

View File

@@ -587,14 +587,13 @@ void table_root_info(cpp_bin_float_100 full_value)
// Compute the 'right' answer for root N at 100 decimal digits. // Compute the 'right' answer for root N at 100 decimal digits.
cpp_bin_float_100 full_answer = nth_root_noderiv<N, cpp_bin_float_100>(full_value); cpp_bin_float_100 full_answer = nth_root_noderiv<N, cpp_bin_float_100>(full_value);
int type_count = 0;
root_infos.clear(); // Erase any previous data. root_infos.clear(); // Erase any previous data.
// Fill the elements of the array for each floating-point type. // Fill the elements of the array for each floating-point type.
type_count = test_root<N, float>(full_value, full_answer, "float", 0); test_root<N, float>(full_value, full_answer, "float", 0);
type_count = test_root<N, double>(full_value, full_answer, "double", 1); test_root<N, double>(full_value, full_answer, "double", 1);
type_count = test_root<N, long double>(full_value, full_answer, "long double", 2); test_root<N, long double>(full_value, full_answer, "long double", 2);
type_count = test_root<N, cpp_bin_float_50>(full_value, full_answer, "cpp_bin_float_50", 3); test_root<N, cpp_bin_float_50>(full_value, full_answer, "cpp_bin_float_50", 3);
// Use info from 4 floating point types to // Use info from 4 floating point types to
@@ -860,7 +859,7 @@ int main()
return boost::exit_success; return boost::exit_success;
} }
catch (std::exception ex) catch (std::exception const& ex)
{ {
std::cout << "exception thrown: " << ex.what() << std::endl; std::cout << "exception thrown: " << ex.what() << std::endl;
return boost::exit_failure; return boost::exit_failure;

View File

@@ -208,6 +208,7 @@ test-suite special_fun :
: # requirements : # requirements
<define>TEST_FLOAT <define>TEST_FLOAT
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_float ] : test_ibeta_derivative_float ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -215,6 +216,7 @@ test-suite special_fun :
: # requirements : # requirements
<define>TEST_DOUBLE <define>TEST_DOUBLE
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_double ] : test_ibeta_derivative_double ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -222,6 +224,7 @@ test-suite special_fun :
: # requirements : # requirements
<define>TEST_LDOUBLE <define>TEST_LDOUBLE
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_long_double ] : test_ibeta_derivative_long_double ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -230,6 +233,7 @@ test-suite special_fun :
<define>TEST_REAL_CONCEPT <define>TEST_REAL_CONCEPT
<define>TEST_DATA=1 <define>TEST_DATA=1
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_real_concept1 ] : test_ibeta_derivative_real_concept1 ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -238,6 +242,7 @@ test-suite special_fun :
<define>TEST_REAL_CONCEPT <define>TEST_REAL_CONCEPT
<define>TEST_DATA=2 <define>TEST_DATA=2
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_real_concept2 ] : test_ibeta_derivative_real_concept2 ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -246,6 +251,7 @@ test-suite special_fun :
<define>TEST_REAL_CONCEPT <define>TEST_REAL_CONCEPT
<define>TEST_DATA=3 <define>TEST_DATA=3
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_real_concept3 ] : test_ibeta_derivative_real_concept3 ]
[ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_derivative.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework
: # command line : # command line
@@ -254,6 +260,7 @@ test-suite special_fun :
<define>TEST_REAL_CONCEPT <define>TEST_REAL_CONCEPT
<define>TEST_DATA=4 <define>TEST_DATA=4
<toolset>intel:<pch>off <toolset>intel:<pch>off
<toolset>gcc:<cxxflags>-Wno-overflow
: test_ibeta_derivative_real_concept4 ] : test_ibeta_derivative_real_concept4 ]
[ run test_ibeta_inv.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework [ run test_ibeta_inv.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework

View File

@@ -44,10 +44,14 @@ void compile_and_link_test()
// //
#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES #ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
constexpr float ce_f = boost::math::unchecked_factorial<float>(2); constexpr float ce_f = boost::math::unchecked_factorial<float>(2);
constexpr float ce_d = boost::math::unchecked_factorial<double>(2); constexpr double ce_d = boost::math::unchecked_factorial<double>(2);
constexpr float ce_l = boost::math::unchecked_factorial<long double>(2); constexpr long double ce_l = boost::math::unchecked_factorial<long double>(2);
check_result<float>(ce_f);
check_result<double>(ce_d);
check_result<long double>(ce_l);
#ifdef BOOST_MATH_USE_FLOAT128 #ifdef BOOST_MATH_USE_FLOAT128
constexpr __float128 ce_q = boost::math::unchecked_factorial<__float128>(2); constexpr __float128 ce_q = boost::math::unchecked_factorial<__float128>(2);
check_result<__float128>(ce_q);
#endif #endif
#endif #endif
} }

View File

@@ -21,6 +21,7 @@ void compile_and_link_test()
// //
#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES #ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
constexpr boost::uint32_t ce_f = boost::math::prime(2); constexpr boost::uint32_t ce_f = boost::math::prime(2);
check_result<boost::uint32_t>(ce_f);
#endif #endif
} }

View File

@@ -54,7 +54,7 @@ inline void check_result_imp(T1, T2)
// This is a static assertion that should always fail to compile... // This is a static assertion that should always fail to compile...
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedef" #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif #endif
typedef BOOST_MATH_ASSERT_UNUSED_ATTRIBUTE int static_assertion[local_is_same<T1, T2>::value ? 1 : 0]; typedef BOOST_MATH_ASSERT_UNUSED_ATTRIBUTE int static_assertion[local_is_same<T1, T2>::value ? 1 : 0];
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))

View File

@@ -120,11 +120,44 @@ int main()
constexpr bool b9 = q2 == q1; constexpr bool b9 = q2 == q1;
constexpr bool b10 = q1 != q2; constexpr bool b10 = q1 != q2;
(void)q9;
(void)d2;
(void)d3;
(void)d4;
(void)d6;
(void)d5;
(void)c3;
(void)q10;
(void)q11;
(void)q12;
(void)q13;
(void)q14;
(void)q15;
(void)q16;
(void)q17;
(void)q18;
(void)q19;
(void)q20;
(void)q21;
(void)q22;
(void)q23;
(void)b1;
(void)b2;
(void)b3;
(void)b4;
(void)b5;
(void)b6;
(void)b7;
(void)b8;
(void)b9;
(void)b10;
#endif #endif
#ifndef BOOST_NO_CXX14_CONSTEXPR #ifndef BOOST_NO_CXX14_CONSTEXPR
constexpr qt q24 = full_constexpr_test(q5, q5 + 1, 3.2, q5.C_component_1()); constexpr qt q24 = full_constexpr_test(q5, q5 + 1, 3.2, q5.C_component_1());
(void)q24;
#endif #endif

View File

@@ -34,19 +34,6 @@ void expected_results()
// Define the max and mean errors expected for // Define the max and mean errors expected for
// various compilers and platforms. // various compilers and platforms.
// //
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
else
{
largest_type = "long double";
}
#else
largest_type = "(long\\s+)?double";
#endif
// //
// On MacOS X erfc has much higher error levels than // On MacOS X erfc has much higher error levels than

View File

@@ -299,7 +299,7 @@ void test_legendre_p_zeros()
// Don't take the tolerances too seriously. // Don't take the tolerances too seriously.
// The other test shows that the zeros are estimated more accurately than the function! // The other test shows that the zeros are estimated more accurately than the function!
for (int n = 6; n < 130; ++n) for (unsigned n = 6; n < 130; ++n)
{ {
zeros = legendre_p_zeros<Real>(n); zeros = legendre_p_zeros<Real>(n);
if (n & 1) if (n & 1)
@@ -315,7 +315,7 @@ void test_legendre_p_zeros()
BOOST_CHECK_SMALL(legendre_p(n, zeros[0]), 550*tol); BOOST_CHECK_SMALL(legendre_p(n, zeros[0]), 550*tol);
} }
Real previous_zero = zeros[0]; Real previous_zero = zeros[0];
for (int k = 1; k < zeros.size(); ++k) for (unsigned k = 1; k < zeros.size(); ++k)
{ {
Real next_zero = zeros[k]; Real next_zero = zeros[k];
BOOST_CHECK(next_zero > previous_zero); BOOST_CHECK(next_zero > previous_zero);

View File

@@ -3,7 +3,9 @@
// Boost Software License, Version 1.0. (See accompanying file // Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MATH_OVERFLOW_ERROR_POLICY
#define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
#endif
#include <boost/math/concepts/real_concept.hpp> #include <boost/math/concepts/real_concept.hpp>
#define BOOST_TEST_MAIN #define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@@ -10,6 +10,10 @@
#include <boost/math/policies/error_handling.hpp> #include <boost/math/policies/error_handling.hpp>
#include <boost/math/tools/precision.hpp> #include <boost/math/tools/precision.hpp>
template <class T>
BOOST_CONSTEXPR int consume_constexpr(const T&)
{ return 0; }
void test() void test()
{ {
using namespace boost::math::policies; using namespace boost::math::policies;
@@ -45,6 +49,27 @@ void test()
constexpr float r8 = raise_rounding_error("func", "msg", 0.0, 0.0f, p6); constexpr float r8 = raise_rounding_error("func", "msg", 0.0, 0.0f, p6);
constexpr float r9 = raise_indeterminate_result_error("func", "msg", 0.0, 0.0f, p6); constexpr float r9 = raise_indeterminate_result_error("func", "msg", 0.0, 0.0f, p6);
consume_constexpr(p1);
consume_constexpr(p2);
consume_constexpr(p3);
consume_constexpr(p4);
consume_constexpr(p5);
consume_constexpr(p6);
consume_constexpr(d);
consume_constexpr(s);
consume_constexpr(r);
consume_constexpr(ep);
consume_constexpr(ep2);
consume_constexpr(r1);
consume_constexpr(r2);
consume_constexpr(r3);
consume_constexpr(r4);
consume_constexpr(r5);
consume_constexpr(r6);
consume_constexpr(r7);
consume_constexpr(r8);
consume_constexpr(r9);
#endif #endif
#ifndef BOOST_NO_CXX11_NOEXCEPT #ifndef BOOST_NO_CXX11_NOEXCEPT