Skip to content

Commit 15f3264

Browse files
committed
Fix expressions for 3F2
1 parent 00553bd commit 15f3264

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

stan/math/prim/fun/hypergeometric_3F2.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,20 @@ template <typename Ta, typename Tb, typename Tz,
114114
require_all_vector_t<Ta, Tb>* = nullptr,
115115
require_stan_scalar_t<Tz>* = nullptr>
116116
inline auto hypergeometric_3F2(const Ta& a, const Tb& b, const Tz& z) {
117-
check_3F2_converges("hypergeometric_3F2", a[0], a[1], a[2], b[0], b[1], z);
117+
check_size_match("hypergeometric_3F2", "a", a.size(), "3", 3);
118+
check_size_match("hypergeometric_3F2", "b", b.size(), "2", 2);
119+
120+
auto a_ref = to_vector(a);
121+
auto b_ref = to_vector(b);
122+
123+
check_3F2_converges("hypergeometric_3F2", a_ref[0], a_ref[1], a_ref[2],
124+
b_ref[0], b_ref[1], z);
118125
// Boost's pFq throws convergence errors in some cases, fallback to naive
119126
// infinite-sum approach (tests pass for these)
120-
if (z == 1.0 && (sum(b) - sum(a)) < 0.0) {
121-
return internal::hypergeometric_3F2_infsum(to_vector(a), to_vector(b), z);
127+
if (z == 1.0 && (sum(b_ref) - sum(a_ref)) < 0.0) {
128+
return internal::hypergeometric_3F2_infsum(a_ref, b_ref, z);
122129
}
123-
return hypergeometric_pFq(to_vector(a), to_vector(b), z);
130+
return hypergeometric_pFq(a_ref, b_ref, z);
124131
}
125132

126133
/**

test/sig_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def get_cpp_type(stan_type):
153153
ignored = [
154154
"std_normal_qf", # synonym for inv_Phi
155155
"if_else",
156+
"hypergeometric_3F2", # requires arguments of specific lengths
156157
]
157158

158159
# these are all slight renames compared to stan math

0 commit comments

Comments
 (0)