The R Project SVN R

Rev

Rev 82551 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 82551 Rev 87946
Line 99... Line 99...
99
     */
99
     */
100
    if (ndf > 1e20) return qnorm(p, 0., 1., lower_tail, log_p);
100
    if (ndf > 1e20) return qnorm(p, 0., 1., lower_tail, log_p);
101
 
101
 
102
    P = R_D_qIv(p); /* if exp(p) underflows, we fix below */
102
    P = R_D_qIv(p); /* if exp(p) underflows, we fix below */
103
 
103
 
104
    Rboolean neg = (!lower_tail || P < 0.5) && (lower_tail || P > 0.5),
104
    bool neg = (!lower_tail || P < 0.5) && (lower_tail || P > 0.5),
105
	is_neg_lower = (lower_tail == neg); /* both TRUE or FALSE == !xor */
105
	is_neg_lower = (lower_tail == neg); /* both TRUE or FALSE == !xor */
106
    if(neg)
106
    if(neg)
107
	P = 2 * (log_p ? (lower_tail ? P : -expm1(p)) : R_D_Lval(p));
107
	P = 2 * (log_p ? (lower_tail ? P : -expm1(p)) : R_D_Lval(p));
108
    else
108
    else
109
	P = 2 * (log_p ? (lower_tail ? -expm1(p) : P) : R_D_Cval(p));
109
	P = 2 * (log_p ? (lower_tail ? -expm1(p) : P) : R_D_Cval(p));
Line 141... Line 141...
141
	double x = 0., y, log_P2 = 0./* -Wall */,
141
	double x = 0., y, log_P2 = 0./* -Wall */,
142
	    a = 1 / (ndf - 0.5),
142
	    a = 1 / (ndf - 0.5),
143
	    b = 48 / (a * a),
143
	    b = 48 / (a * a),
144
	    c = ((20700 * a / b - 98) * a - 16) * a + 96.36,
144
	    c = ((20700 * a / b - 98) * a - 16) * a + 96.36,
145
	    d = ((94.5 / (b + c) - 3) / b + 1) * sqrt(a * M_PI_2) * ndf;
145
	    d = ((94.5 / (b + c) - 3) / b + 1) * sqrt(a * M_PI_2) * ndf;
146
	Rboolean
146
	bool
147
	    P_ok1 = P > DBL_MIN || !log_p,
147
	    P_ok1 = P > DBL_MIN || !log_p,
148
	    P_ok  = P_ok1; // when true (after check below), use "normal scale": log_p=FALSE
148
	    P_ok  = P_ok1; // when true (after check below), use "normal scale": log_p=FALSE
149
	if(P_ok1) {
149
	if(P_ok1) {
150
	    y = pow(d * P, 2.0 / ndf);
150
	    y = pow(d * P, 2.0 / ndf);
151
	    P_ok = (y >= DBL_EPSILON);
151
	    P_ok = (y >= DBL_EPSILON);