@@ -39,13 +39,12 @@ namespace internal {
3939 * @tparam T_z Type of value parameter z (double or fvar types)
4040 * @param a Shape parameter
4141 * @param z Value at which to evaluate
42- * @param max_steps Maximum number of continued fraction iterations
4342 * @param precision Convergence threshold
43+ * @param max_steps Maximum number of continued fraction iterations
4444 * @return log(Q(a,z)) with same type as T_a and T_z
4545 */
4646template <typename T_a, typename T_z>
47- inline auto log_q_gamma_cf (const T_a& a, const T_z& z, int max_steps = 250 ,
48- double precision = 1e-16 ) {
47+ inline auto log_q_gamma_cf (const T_a& a, const T_z& z, double precision = 1e-16 , int max_steps = 250 ) {
4948 using stan::math::lgamma;
5049 using stan::math::log;
5150 using stan::math::value_of;
@@ -102,13 +101,13 @@ inline auto log_q_gamma_cf(const T_a& a, const T_z& z, int max_steps = 250,
102101 * @tparam T_z type of the value parameter
103102 * @param a shape parameter (must be positive)
104103 * @param z value parameter (must be non-negative)
105- * @param max_steps maximum iterations for continued fraction
106104 * @param precision convergence threshold
105+ * @param max_steps maximum iterations for continued fraction
107106 * @return structure containing log(Q(a,z)) and d/da log(Q(a,z))
108107 */
109108template <typename T_a, typename T_z>
110109inline log_gamma_q_result<return_type_t <T_a, T_z>> log_gamma_q_dgamma (
111- const T_a& a, const T_z& z, int max_steps = 250 , double precision = 1e-16 ) {
110+ const T_a& a, const T_z& z, double precision = 1e-16 , int max_steps = 250 ) {
112111 using std::exp;
113112 using std::log;
114113 using T_return = return_type_t <T_a, T_z>;
@@ -120,7 +119,8 @@ inline log_gamma_q_result<return_type_t<T_a, T_z>> log_gamma_q_dgamma(
120119
121120 // For z > a + 1, use continued fraction for better numerical stability
122121 if (z_dbl > a_dbl + 1.0 ) {
123- result.log_q = internal::log_q_gamma_cf (a_dbl, z_dbl, max_steps, precision);
122+ result.log_q
123+ = internal::log_q_gamma_cf (a_dbl, z_dbl, precision, max_steps);
124124
125125 // For gradient, use: d/da log(Q) = (1/Q) * dQ/da
126126 // grad_reg_inc_gamma computes dQ/da
0 commit comments