The R Project SVN R

Rev

Rev 18510 | Rev 42302 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18510 Rev 19729
Line 33... Line 33...
33
#endif
33
#endif
34
    if(shape <= 0 || scale <= 0) ML_ERR_return_NAN;
34
    if(shape <= 0 || scale <= 0) ML_ERR_return_NAN;
35
 
35
 
36
    if (x <= 0)
36
    if (x <= 0)
37
	return R_DT_0;
37
	return R_DT_0;
-
 
38
    x = -pow(x / scale, shape);
38
    if (lower_tail)
39
    if (lower_tail)
39
	return R_D_val(-expm1(-pow(x / scale, shape)));
40
	return (log_p
40
    if (log_p) /* && !lower_tail */
41
		/* log(1 - exp(x))  for x < 0 : */
41
	return 		      -pow(x / scale, shape);
42
		? (x > -M_LN2 ? log(-expm1(x)) : log1p(-exp(x)))
-
 
43
		: -expm1(x));
42
    /* else !log_p and !lower_tail :*/
44
    /* else:  !lower_tail */
43
    return                exp(-pow(x / scale, shape));
45
    return R_D_exp(x);
44
}
46
}