Revision 795 branches/replacement/src/linad99/cgamdev.cpp
cgamdev.cpp (revision 795)  

4  4 
* Author: David Fournier 
5  5 
* Copyright (c) 2008, 2009 Regents of the University of California 
6  6 
*/ 
7 
/** 

8 
* \file 

9 
* This file deals with the Incomplete Gamma Functions 

10 
* of constant types. All supporting mathematical functions 

11 
* required to compute the Inmomplete Gamma Function 

12 
* are included. They being: log gamma, 

13 
* and some polynomial evaluation functions. 

14 
*/ 

7  15  
8  16 
#include <fvar.hpp> 
9 
//#include "mconf.h" 

10 
//#define ITMAX 100 

11 
//#define EPS 1.e9 

12 
//#define FPMIN 1.0e30 

13 
//#ifdef INFINITIES 

14 
//#undef INFINITIES 

15 
//#endif 

16 
//#ifdef NANS 

17 
//#undef NANS 

18 
//#endif 

19 
//#define MAXGAM 171.624376956302725 

20 
//void gcf(double& gammcf,double a,double x,double &gln); 

21 
//void gser(double& gamser,double a,double x,double& gln); 

22  17  
23  18 
namespace Cephes 
24  19 
{ 
...  ...  
39  34 
extern const double LS2PI; 
40  35 
extern const double MAXSTIR; 
41  36  
42 
extern double polevl(double x, void *_coef, int N); 

43 
extern double p1evl(double x, void *_coef, int N); 

37 
double polevl(double x, void *_coef, int N); 

38 
double p1evl(double x, void *_coef, int N); 

39 
/** 

40 
* \ingroup gammafunc 

41 
* Polynomial evaluation 

42 
* \param x \f$x\f$ the point to be evaluated 

43 
* \param _coef The coefficents of the polynomial 

44 
* \param N \f$N\f$ The degree of the polynomial 

45 
* \return The polynomial evaluated at \f$x\f$ 

46 
* 

47 
* \n\n Cephes Math Library Release 2.1: December, 1988 

48 
* Copyright 1984, 1987, 1988 by Stephen L. Moshier 

49 
* Direct inquiries to 30 Frost Street, Cambridge, MA 02140 

50 
*/ 

51 
double polevl(double x, void *_coef, int N) 

52 
{ 

53 
double *coef = (double *) (_coef); 

54 
double ans; 

55 
int i; 

56 
double *p; 

44  57  
58 
p = coef; 

59 
ans = *p++; 

60 
i = N; 

45  61  
46 
} 

62 
do 

63 
ans = ans * x + *p++; 

64 
while (i); 

47  65  
66 
return (ans); 

67 
} 

48  68  
69 
/** 

70 
* \ingroup gammafunc 

71 
* Polynomial evaluation when leading coefficent is 1 

72 
* (i.e. leading term is \f$x^N\f$) 

73 
* \param x \f$x\f$ the point to be evaluated 

74 
* \param _coef The coefficents of the polynomial 

75 
* \param N \f$N\f$ The degree of the polynomial 

76 
* \return The polynomial evaluated at \f$x\f$ 

77 
* 

78 
* \n\n Cephes Math Library Release 2.1: December, 1988 

79 
* Copyright 1984, 1987, 1988 by Stephen L. Moshier 

80 
* Direct inquiries to 30 Frost Street, Cambridge, MA 02140 

81 
*/ 

82 
double p1evl(double x, void *_coef, int N) 

83 
{ 

84 
double *coef = (double *) (_coef); 

85 
double ans; 

86 
double *p; 

87  
88 
p = coef; 

89 
ans = x + *p++; 

90 
int i = N  1; 

91  
92 
do 

93 
ans = ans * x + *p++; 

94 
while (i); 

95  
96 
return (ans); 
Also available in: Unified diff