mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Updated debug-tracing macros.
Fixed epsilon so it works on MacOS with a 106-bit long double now. [SVN r39593]
This commit is contained in:
@@ -47,7 +47,7 @@ T ellint_f_imp(T phi, T k, const Policy& pol)
|
||||
bool invert = false;
|
||||
if(phi < 0)
|
||||
{
|
||||
BOOST_MATH_INSTRUMENT_CODE(phi);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(phi);
|
||||
phi = fabs(phi);
|
||||
invert = true;
|
||||
}
|
||||
@@ -58,14 +58,14 @@ T ellint_f_imp(T phi, T k, const Policy& pol)
|
||||
{
|
||||
// Need to handle infinity as a special case:
|
||||
result = policies::raise_overflow_error<T>(function, 0, pol);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if(phi > 1 / tools::epsilon<T>())
|
||||
{
|
||||
// Phi is so large that phi%pi is necessarily zero (or garbage),
|
||||
// just return the second part of the duplication formula:
|
||||
result = 2 * phi * ellint_k_imp(k, pol) / constants::pi<T>();
|
||||
BOOST_MATH_INSTRUMENT_CODE(result);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,25 +77,27 @@ T ellint_f_imp(T phi, T k, const Policy& pol)
|
||||
// so rewritten to use fmod instead:
|
||||
//
|
||||
T rphi = fmod(phi, constants::pi<T>() / 2);
|
||||
BOOST_MATH_INSTRUMENT_CODE(rphi);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
|
||||
T m = 2 * (phi - rphi) / constants::pi<T>();
|
||||
BOOST_MATH_INSTRUMENT_CODE(m);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(m);
|
||||
int s = 1;
|
||||
if(fmod(m, T(2)) > 0.5)
|
||||
{
|
||||
m += 1;
|
||||
s = -1;
|
||||
rphi = constants::pi<T>() / 2 - rphi;
|
||||
BOOST_MATH_INSTRUMENT_CODE(rphi);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
|
||||
}
|
||||
T sinp = sin(rphi);
|
||||
T cosp = cos(rphi);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(sinp);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(cosp);
|
||||
result = s * sinp * ellint_rf_imp(cosp * cosp, 1 - k * k * sinp * sinp, T(1), pol);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
if(m != 0)
|
||||
{
|
||||
result += m * ellint_k_imp(k, pol);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
}
|
||||
return invert ? -result : result;
|
||||
|
||||
@@ -55,12 +55,12 @@ T ellint_rf_imp(T x, T y, T z, const Policy& pol)
|
||||
if(policies::digits<T, Policy>() > 64)
|
||||
{
|
||||
tolerance = pow(tools::epsilon<T>(), T(1)/4.25f);
|
||||
BOOST_MATH_INSTRUMENT_CODE(tolerance);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(tolerance);
|
||||
}
|
||||
else
|
||||
{
|
||||
tolerance = pow(4*tools::epsilon<T>(), T(1)/6);
|
||||
BOOST_MATH_INSTRUMENT_CODE(tolerance);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(tolerance);
|
||||
}
|
||||
|
||||
// duplication
|
||||
@@ -89,13 +89,13 @@ T ellint_rf_imp(T x, T y, T z, const Policy& pol)
|
||||
|
||||
// Check to see if we gave up too soon:
|
||||
policies::check_series_iterations(function, k, pol);
|
||||
BOOST_MATH_INSTRUMENT_CODE(k);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(k);
|
||||
|
||||
// Taylor series expansion to the 5th order
|
||||
E2 = X * Y - Z * Z;
|
||||
E3 = X * Y * Z;
|
||||
value = (1 + E2*(E2/24 - E3*T(3)/44 - T(0.1)) + E3/14) / sqrt(u);
|
||||
BOOST_MATH_INSTRUMENT_CODE(value);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -138,8 +138,10 @@ inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d)
|
||||
#ifdef BOOST_MATH_INSTRUMENT
|
||||
#define BOOST_MATH_INSTRUMENT_CODE(x) \
|
||||
std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
|
||||
#define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(BOOST_STRINGIZE(name) << " = " << name)
|
||||
#else
|
||||
#define BOOST_MATH_INSTRUMENT_CODE(x)
|
||||
#define BOOST_MATH_INSTRUMENT_VARIABLE(name)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MATH_TOOLS_CONFIG_HPP
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
// These two are for LDBL_MAN_DIG:
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace boost{ namespace math
|
||||
{
|
||||
@@ -148,7 +151,7 @@ inline T epsilon(const mpl::true_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T))
|
||||
return std::numeric_limits<T>::epsilon();
|
||||
}
|
||||
|
||||
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && (LDBL_MANT_DIG == 106)
|
||||
#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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user