The R Project SVN R

Rev

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

Rev 59039 Rev 60971
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-2001 The R Core Team
4
 *  Copyright (C) 2000-2012 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 76... Line 76...
76
	return ML_POSINF;/* +Inf, since lgamma(x) = log|gamma(x)| */
76
	return ML_POSINF;/* +Inf, since lgamma(x) = log|gamma(x)| */
77
    }
77
    }
78
 
78
 
79
    y = fabs(x);
79
    y = fabs(x);
80
 
80
 
81
    if (y <= 10)
81
    if (y < 1e-306) return -log(x); // denormalized range, R change
82
	return log(fabs(gammafn(x)));
82
    if (y <= 10) return log(fabs(gammafn(x)));
83
    /*
83
    /*
84
      ELSE  y = |x| > 10 ---------------------- */
84
      ELSE  y = |x| > 10 ---------------------- */
85
 
85
 
86
    if (y > xmax) {
86
    if (y > xmax) {
87
	ML_ERROR(ME_RANGE, "lgamma");
87
	ML_ERROR(ME_RANGE, "lgamma");