|  | 
| 1 | 1 | /* | 
| 2 | 2 |  *  R : A Computer Language for Statistical Data Analysis | 
| 3 |  | - *  Copyright (C) 1998--2022  The R Core Team | 
|  | 3 | + *  Copyright (C) 1998--2025  The R Core Team | 
| 4 | 4 |  *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka | 
| 5 | 5 |  *  based on code (C) 1979 and later Royal Statistical Society | 
| 6 | 6 |  * | 
|  | 
| 53 | 53 | 
 | 
| 54 | 54 | //attribute_hidden | 
| 55 | 55 | static void | 
| 56 |  | -qbeta_raw(double alpha, double p, double q, int lower_tail, int log_p, | 
|  | 56 | +qbeta_raw(double alpha, double p, double q, | 
|  | 57 | +	  Rboolean lower_tail, Rboolean log_p, | 
| 57 | 58 | 	  int swap_01, double log_q_cut, int n_N, double* qb); | 
| 58 | 59 | 
 | 
|  | 60 | +/* This is the public interface in Rmath.h, so has to use 'int' */ | 
| 59 | 61 | double qbeta(double alpha, double p, double q, int lower_tail, int log_p) | 
| 60 | 62 | { | 
| 61 | 63 | 
 | 
| @@ -109,8 +111,12 @@ static const double | 
| 109 | 111 | #define const4 0.04481 | 
| 110 | 112 | 
 | 
| 111 | 113 | // Returns both qbeta() and its "mirror" 1-qbeta(). Useful notably when qbeta() ~= 1 | 
| 112 |  | -attribute_hidden void | 
| 113 |  | -qbeta_raw(double alpha, double p, double q, int lower_tail, int log_p, | 
|  | 114 | +// This was hidden, but it is only used in this file so could be static | 
|  | 115 | +// and be simplifed as swap_01 is always NA. | 
|  | 116 | +// attribute_hidden void | 
|  | 117 | +static void | 
|  | 118 | +qbeta_raw(double alpha, double p, double q, | 
|  | 119 | +	  Rboolean lower_tail, Rboolean log_p, | 
| 114 | 120 | 	  int swap_01, // {TRUE, NA, FALSE}: if NA, algorithm decides swap_tail | 
| 115 | 121 | 	  double log_q_cut, /* if == Inf: return log(qbeta(..)); | 
| 116 | 122 | 			       otherwise, if finite: the bound for | 
| @@ -189,7 +195,8 @@ qbeta_raw(double alpha, double p, double q, int lower_tail, int log_p, | 
| 189 | 195 |     // Conceptually,  0 < p_ < 1  (but can be 0 or 1 because of cancellation!) | 
| 190 | 196 |     logbeta = lbeta(p, q); | 
| 191 | 197 | 
 | 
| 192 |  | -    swap_tail = (swap_choose) ? (p_ > 0.5) : swap_01; | 
|  | 198 | +    // this is only ever called with swap_choose = TRUE | 
|  | 199 | +    swap_tail = (swap_choose) ? (p_ > 0.5) : (Rboolean) swap_01; | 
| 193 | 200 | 
 | 
| 194 | 201 |     R_ifDEBUG_printf( | 
| 195 | 202 | 	"qbeta(%g, %g, %g, lower_t=%d, log_p=%d, swap_01=%d, log_q_cut=%g, n_N=%d):%s\n" | 
| @@ -402,7 +409,7 @@ qbeta_raw(double alpha, double p, double q, int lower_tail, int log_p, | 
| 402 | 409 | 		tx   = 0.; | 
| 403 | 410 | 		u_n  = ML_NEGINF; | 
| 404 | 411 | 	    } | 
| 405 |  | -	    use_log_x = log_p; add_N_step = FALSE; goto L_return; | 
|  | 412 | +	    use_log_x = (Rboolean) log_p; add_N_step = FALSE; goto L_return; | 
| 406 | 413 | 	} | 
| 407 | 414 | 	else { | 
| 408 | 415 | 	    R_ifDEBUG_printf(" pbeta(%g, %g, %g, T, log) = %g <= %g (= %s) --> continuing\n", | 
|  | 
0 commit comments