Skip to content

Commit 19f4933

Browse files
czgdp1807steppi
authored andcommitted
BUG: special.hyp2f1: fix for extreme inputs (#22810)
* Regression testing and patch for extreme input handling in `hyp2f1`. Fixes gh-20988.
1 parent 84b4486 commit 19f4933

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/xsf/hyp2f1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ XSF_HOST_DEVICE inline std::complex<double> hyp2f1(double a, double b, double c,
553553
* the series at a or b of smaller magnitude. This is to ensure proper
554554
* handling of situations like a < c < b <= 0, a, b, c all non-positive
555555
* integers, where terminating at a would lead to a term of the form 0 / 0. */
556-
std::uint64_t max_degree;
556+
double max_degree;
557557
if (a_neg_int || b_neg_int) {
558558
if (a_neg_int && b_neg_int) {
559559
max_degree = a > b ? std::abs(a) : std::abs(b);
@@ -562,7 +562,7 @@ XSF_HOST_DEVICE inline std::complex<double> hyp2f1(double a, double b, double c,
562562
} else {
563563
max_degree = std::abs(b);
564564
}
565-
if (max_degree <= UINT64_MAX) {
565+
if (max_degree <= (double) UINT64_MAX) {
566566
auto series_generator = detail::HypergeometricSeriesGenerator(a, b, c, z);
567567
return detail::series_eval_fixed_length(series_generator, std::complex<double>{0.0, 0.0}, max_degree + 1);
568568
} else {
@@ -583,7 +583,7 @@ XSF_HOST_DEVICE inline std::complex<double> hyp2f1(double a, double b, double c,
583583
* (DLMF 15.8.1) */
584584
if (c_minus_a_neg_int || c_minus_b_neg_int) {
585585
max_degree = c_minus_b_neg_int ? std::abs(c - b) : std::abs(c - a);
586-
if (max_degree <= UINT64_MAX) {
586+
if (max_degree <= (double) UINT64_MAX) {
587587
result = std::pow(1.0 - z, c - a - b);
588588
auto series_generator = detail::HypergeometricSeriesGenerator(c - a, c - b, c, z);
589589
result *=

0 commit comments

Comments
 (0)