The R Project SVN R

Rev

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

Rev 68947 Rev 69250
Line 1... Line 1...
1
/*
1
/*
2
 *  Mathlib : A C Library of Special Functions
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1998 Ross Ihaka
3
 *  Copyright (C) 1998 Ross Ihaka
4
 *  Copyright (C) 2000-2002 The R Core Team
4
 *  Copyright (C) 2000-2015 The R Core Team
5
 *
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
9
 *  (at your option) any later version.
Line 34... Line 34...
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
    x = -pow(x / scale, shape);
39
    if (lower_tail)
39
    return lower_tail
40
	return (log_p
-
 
41
		/* log(1 - exp(x))  for x < 0 : */
-
 
42
		? R_Log1_Exp(x) : -expm1(x));
40
	? (log_p ? R_Log1_Exp(x) : -expm1(x))
43
    /* else:  !lower_tail */
-
 
44
    return R_D_exp(x);
41
	: R_D_exp(x);
45
}
42
}