| 45 | } |
| 46 | |
| 47 | inline double dlnorm_1(double x, double meanlog, int log_p){ |
| 48 | double y; |
| 49 | |
| 50 | #ifdef IEEE_754 |
| 51 | if (ISNAN(x) || ISNAN(meanlog)) |
| 52 | return x + meanlog + 1.0; |
| 53 | #endif |
| 54 | |
| 55 | if (x <= 0) return R_D__0; |
| 56 | |
| 57 | y = (::log(x) - meanlog); |
| 58 | return (log_p ? |
| 59 | -(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) : |
| 60 | M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x); |
| 61 | /* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */ |
| 62 | |
| 63 | } |
| 64 | |
| 65 | inline double plnorm_0(double x, int lower_tail, int log_p){ |
| 66 | #ifdef IEEE_754 |