Skip to content

Commit aecd335

Browse files
authored
Merge pull request #1262 from boostorg/improve_coverage_4
Improve Coverage Part 4
2 parents af8ba3f + ef849f3 commit aecd335

42 files changed

Lines changed: 758 additions & 375 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/boost/math/special_functions/airy.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ BOOST_MATH_GPU_ENABLED T airy_ai_zero_imp(int m, const Policy& pol)
187187
// of decimal digits in the numeric type T, being at least 12.
188188
const int my_digits10 = static_cast<int>(static_cast<float>(policies::digits<T, Policy>() * 0.301F));
189189

190-
const std::uintmax_t iterations_allowed = static_cast<std::uintmax_t>((std::max)(12, my_digits10 * 2));
190+
const std::uintmax_t iterations_allowed = static_cast<std::uintmax_t>(BOOST_MATH_GPU_SAFE_MAX(12, my_digits10 * 2));
191191

192192
std::uintmax_t iterations_used = iterations_allowed;
193193

@@ -239,7 +239,7 @@ BOOST_MATH_GPU_ENABLED T airy_bi_zero_imp(int m, const Policy& pol)
239239
// of decimal digits in the numeric type T, being at least 12.
240240
const int my_digits10 = static_cast<int>(static_cast<float>(policies::digits<T, Policy>() * 0.301F));
241241

242-
const std::uintmax_t iterations_allowed = static_cast<std::uintmax_t>((std::max)(12, my_digits10 * 2));
242+
const std::uintmax_t iterations_allowed = static_cast<std::uintmax_t>(BOOST_MATH_GPU_SAFE_MAX(12, my_digits10 * 2));
243243

244244
std::uintmax_t iterations_used = iterations_allowed;
245245

include/boost/math/special_functions/beta.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ BOOST_MATH_GPU_ENABLED T binomial_ccdf(T n, T k, T x, T y, const Policy& pol)
11321132
}
11331133

11341134
template <class T, class Policy>
1135-
T ibeta_large_ab(T a, T b, T x, T y, bool invert, bool normalised, const Policy& pol)
1135+
BOOST_MATH_GPU_ENABLED T ibeta_large_ab(T a, T b, T x, T y, bool invert, bool normalised, const Policy& pol)
11361136
{
11371137
//
11381138
// Large arguments, symetric case, see https://dlmf.nist.gov/8.18
@@ -1571,11 +1571,11 @@ BOOST_MATH_GPU_ENABLED T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, b
15711571
{
15721572
// a and b both large:
15731573
bool use_asym = false;
1574-
T ma = (std::max)(a, b);
1574+
T ma = BOOST_MATH_GPU_SAFE_MAX(a, b);
15751575
T xa = ma == a ? x : y;
15761576
T saddle = ma / (a + b);
15771577
T powers = 0;
1578-
if ((ma > 1e-5f / tools::epsilon<T>()) && (ma / (std::min)(a, b) < (xa < saddle ? 2 : 15)))
1578+
if ((ma > 1e-5f / tools::epsilon<T>()) && (ma / BOOST_MATH_GPU_SAFE_MIN(a, b) < (xa < saddle ? 2 : 15)))
15791579
{
15801580
if (a == b)
15811581
use_asym = true;

include/boost/math/special_functions/detail/ibeta_inverse.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,16 +683,16 @@ BOOST_MATH_GPU_ENABLED T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T*
683683
}
684684
else
685685
y = 1;
686-
if((y > 1e-5) && (std::min)(a, b) < 1000)
686+
if((y > 1e-5) && BOOST_MATH_GPU_SAFE_MIN(a, b) < 1000)
687687
{
688688
x = temme_method_3_ibeta_inverse(a, b, p, q, pol);
689689
y = 1 - x;
690690
}
691-
else if ((y > 1e-5) && (std::min)(a, b) > 1000)
691+
else if ((y > 1e-5) && BOOST_MATH_GPU_SAFE_MIN(a, b) > 1000)
692692
{
693693
// All options have failed, use the saddle point as a starting location:
694-
x = (std::max)(a, b) / (a + b);
695-
y = (std::min)(a, b) / (a + b);
694+
x = BOOST_MATH_GPU_SAFE_MAX(a, b) / (a + b);
695+
y = BOOST_MATH_GPU_SAFE_MIN(a, b) / (a + b);
696696
}
697697
}
698698
}

include/boost/math/special_functions/expint.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
562562
// Maximum Deviation Found: 2.852e-18
563563
// Expected Error Term: 2.852e-18
564564
// Max Error found at double precision = Poly: 2.636335e-16 Cheb: 4.187027e-16
565+
// LCOV_EXCL_START
565566
BOOST_MATH_STATIC const T P[10] = {
566567
BOOST_MATH_BIG_CONSTANT(T, 53, 2.98677224343598593013),
567568
BOOST_MATH_BIG_CONSTANT(T, 53, 0.356343618769377415068),
@@ -590,6 +591,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
590591
BOOST_MATH_STATIC_LOCAL_VARIABLE const T r1 = static_cast<T>(c1 / c2);
591592
BOOST_MATH_STATIC_LOCAL_VARIABLE const T r2 = BOOST_MATH_BIG_CONSTANT(T, 53, 0.131401834143860282009280387409357165515556574352422001206362e-16);
592593
BOOST_MATH_STATIC_LOCAL_VARIABLE const T r = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 53, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392));
594+
// LCOV_EXCL_STOP
593595
T t = (z / 3) - 1;
594596
result = tools::evaluate_polynomial(P, t)
595597
/ tools::evaluate_polynomial(Q, t);
@@ -609,6 +611,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
609611
// Maximum Deviation Found: 6.546e-17
610612
// Expected Error Term: 6.546e-17
611613
// Max Error found at double precision = Poly: 6.890169e-17 Cheb: 6.772128e-17
614+
// LCOV_EXCL_START
612615
BOOST_MATH_STATIC_LOCAL_VARIABLE const T Y = 1.158985137939453125F;
613616
BOOST_MATH_STATIC const T P[8] = {
614617
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00139324086199402804173),
@@ -630,6 +633,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
630633
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000402453408512476836472),
631634
BOOST_MATH_BIG_CONSTANT(T, 53, 0.263649630720255691787e-4)
632635
};
636+
// LCOV_EXCL_STOP
633637
T t = z / 2 - 4;
634638
result = Y + tools::evaluate_polynomial(P, t)
635639
/ tools::evaluate_polynomial(Q, t);
@@ -641,7 +645,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
641645
// Maximum Deviation Found: 1.843e-17
642646
// Expected Error Term: -1.842e-17
643647
// Max Error found at double precision = Poly: 4.375868e-17 Cheb: 5.860967e-17
644-
648+
// LCOV_EXCL_START
645649
BOOST_MATH_STATIC_LOCAL_VARIABLE const T Y = 1.0869731903076171875F;
646650
BOOST_MATH_STATIC const T P[9] = {
647651
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00893891094356945667451),
@@ -665,6 +669,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
665669
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00278170769163303669021),
666670
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000159150281166108755531)
667671
};
672+
// LCOV_EXCL_STOP
668673
T t = z / 5 - 3;
669674
result = Y + tools::evaluate_polynomial(P, t)
670675
/ tools::evaluate_polynomial(Q, t);
@@ -676,8 +681,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
676681
// Maximum Deviation Found: 5.102e-18
677682
// Expected Error Term: 5.101e-18
678683
// Max Error found at double precision = Poly: 1.441088e-16 Cheb: 1.864792e-16
679-
680-
684+
// LCOV_EXCL_START
681685
BOOST_MATH_STATIC_LOCAL_VARIABLE const T Y = 1.03937530517578125F;
682686
BOOST_MATH_STATIC const T P[9] = {
683687
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00356165148914447597995),
@@ -700,6 +704,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
700704
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0651165455496281337831),
701705
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00488071077519227853585)
702706
};
707+
// LCOV_EXCL_STOP
703708
T t = z / 10 - 3;
704709
result = Y + tools::evaluate_polynomial(P, t)
705710
/ tools::evaluate_polynomial(Q, t);
@@ -709,6 +714,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
709714
else
710715
{
711716
// Max Error found at double precision = 3.381886e-17
717+
// LCOV_EXCL_START
712718
BOOST_MATH_STATIC_LOCAL_VARIABLE const T exp40 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 53, 2.35385266837019985407899910749034804508871617254555467236651e17));
713719
BOOST_MATH_STATIC_LOCAL_VARIABLE const T Y= 1.013065338134765625F;
714720
BOOST_MATH_STATIC const T P[6] = {
@@ -728,6 +734,7 @@ BOOST_MATH_GPU_ENABLED T expint_i_imp(T z, const Policy& pol, const boost::math:
728734
BOOST_MATH_BIG_CONSTANT(T, 53, 54738.2833147775537106),
729735
BOOST_MATH_BIG_CONSTANT(T, 53, 8297.16296356518409347)
730736
};
737+
// LCOV_EXCL_STOP
731738
T t = 1 / z;
732739
result = Y + tools::evaluate_polynomial(P, t)
733740
/ tools::evaluate_polynomial(Q, t);

include/boost/math/special_functions/fpclassify.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ template<> inline BOOST_MATH_GPU_ENABLED int (fpclassify)(float t)
127127
}
128128
else if(at > FLT_MAX)
129129
return FP_INFINITE;
130-
return FP_NAN;
130+
return FP_NAN; // LCOV_EXCL_LINE should not normally be reachable.
131131
}
132132

133133
template<> inline BOOST_MATH_GPU_ENABLED int (fpclassify)(double t)

include/boost/math/special_functions/jacobi_elliptic.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ T jacobi_imp(const T& x, const T& k, T* cn, T* dn, const Policy& pol, const char
4141
BOOST_MATH_STD_USING
4242
if(k < 0)
4343
{
44-
*cn = policies::raise_domain_error<T>(function, "Modulus k must be positive but got %1%.", k, pol);
45-
*dn = *cn;
46-
return *cn;
44+
return *dn = *cn = policies::raise_domain_error<T>(function, "Modulus k must be positive but got %1%.", k, pol);
4745
}
4846
if(k > 1)
4947
{

0 commit comments

Comments
 (0)