The R Project SVN R

Rev

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

Rev 70087 Rev 72559
Line 19... Line 19...
19
 */
19
 */
20
#include "nmath.h"
20
#include "nmath.h"
21
#include "dpq.h"
21
#include "dpq.h"
22
 
22
 
23
/* Compute  log(1 + exp(x))  without overflow (and fast for x > 18)
23
/* Compute  log(1 + exp(x))  without overflow (and fast for x > 18)
24
   For the two cutoffs, consider
24
   For the two cutoffs, consider in R
25
   curve(log1p(exp(x)) - x,       33.1, 33.5, n=2^10)
25
   curve(log1p(exp(x)) - x,       33.1, 33.5, n=2^10)
26
   curve(x+exp(-x) - log1p(exp(x)), 15, 25,   n=2^11)
26
   curve(x+exp(-x) - log1p(exp(x)), 15, 25,   n=2^11)
27
*/
27
*/
28
double Rf_log1pexp(double x) {
28
double Rf_log1pexp(double x) {
29
    if(x <= 18.) return log1p(exp(x));
29
    if(x <= 18.) return log1p(exp(x));