@@ -114,13 +114,20 @@ template <typename Ta, typename Tb, typename Tz,
114
114
require_all_vector_t <Ta, Tb>* = nullptr ,
115
115
require_stan_scalar_t <Tz>* = nullptr >
116
116
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);
118
125
// Boost's pFq throws convergence errors in some cases, fallback to naive
119
126
// 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);
122
129
}
123
- return hypergeometric_pFq (to_vector (a), to_vector (b) , z);
130
+ return hypergeometric_pFq (a_ref, b_ref , z);
124
131
}
125
132
126
133
/* *
0 commit comments