| 54 | } |
| 55 | |
| 56 | inline double pnorm_1(double x, double mu /*, double sigma [=1.]*/ , |
| 57 | int lower_tail, int log_p) { |
| 58 | double p, cp; |
| 59 | |
| 60 | /* Note: The structure of these checks has been carefully thought through. |
| 61 | * For example, if x == mu and sigma == 0, we get the correct answer 1. |
| 62 | */ |
| 63 | #ifdef IEEE_754 |
| 64 | if (ISNAN(x) || ISNAN(mu)) |
| 65 | return x + mu + 1.0; |
| 66 | #endif |
| 67 | if (!R_FINITE(x) && mu == x) return ML_NAN; /* x-mu is NaN */ |
| 68 | p = (x - mu); |
| 69 | if (!R_FINITE(p)) |
| 70 | return (x < mu) ? R_DT_0 : R_DT_1; |
| 71 | x = p; |
| 72 | |
| 73 | ::Rf_pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p); |
| 74 | |
| 75 | return(lower_tail ? p : cp); |
| 76 | } |
| 77 | |
| 78 | inline double pnorm_0(double x /*, double mu [=0.] , double sigma [=1.]*/ , int lower_tail, int log_p) { |
| 79 | double p, cp; |