Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

cdf_47.c

Go to the documentation of this file.
00001 #include "cdflib.h"
00002 double dlngam(double *a)
00003 /*
00004 **********************************************************************
00005  
00006      double dlngam(double *a)
00007                  Double precision LN of the GAMma function
00008  
00009  
00010                               Function
00011  
00012  
00013      Returns the natural logarithm of GAMMA(X).
00014  
00015  
00016                               Arguments
00017  
00018  
00019      X --> value at which scaled log gamma is to be returned
00020                     X is DOUBLE PRECISION
00021  
00022  
00023                               Method
00024  
00025  
00026      Renames GAMLN from:
00027      DiDinato, A. R. and Morris,  A.   H.  Algorithm 708: Significant
00028      Digit Computation of the Incomplete  Beta  Function Ratios.  ACM
00029      Trans. Math.  Softw. 18 (1993), 360-373.
00030  
00031 **********************************************************************
00032 -----------------------------------------------------------------------
00033             EVALUATION OF LN(GAMMA(A)) FOR POSITIVE A
00034 -----------------------------------------------------------------------
00035      WRITTEN BY ALFRED H. MORRIS
00036           NAVAL SURFACE WARFARE CENTER
00037           DAHLGREN, VIRGINIA
00038 --------------------------
00039      D = 0.5*(LN(2*PI) - 1)
00040 --------------------------
00041 */
00042 {
00043 static double c0 = .833333333333333e-01;
00044 static double c1 = -.277777777760991e-02;
00045 static double c2 = .793650666825390e-03;
00046 static double c3 = -.595202931351870e-03;
00047 static double c4 = .837308034031215e-03;
00048 static double c5 = -.165322962780713e-02;
00049 static double d = .418938533204673e0;
00050 static double dlngam,t,w;
00051 static int i,n;
00052 static double T1;
00053 /*
00054      ..
00055      .. Executable Statements ..
00056 */
00057     if(*a > 0.8e0) goto S10;
00058     dlngam = gamln1(a)-log(*a);
00059     return dlngam;
00060 S10:
00061     if(*a > 2.25e0) goto S20;
00062     t = *a-0.5e0-0.5e0;
00063     dlngam = gamln1(&t);
00064     return dlngam;
00065 S20:
00066     if(*a >= 10.0e0) goto S40;
00067     n = *a-1.25e0;
00068     t = *a;
00069     w = 1.0e0;
00070     for(i=1; i<=n; i++) {
00071         t -= 1.0e0;
00072         w = t*w;
00073     }
00074     T1 = t-1.0e0;
00075     dlngam = gamln1(&T1)+log(w);
00076     return dlngam;
00077 S40:
00078     t = pow(1.0e0/ *a,2.0);
00079     w = (((((c5*t+c4)*t+c3)*t+c2)*t+c1)*t+c0)/ *a;
00080     dlngam = d+w+(*a-0.5e0)*(log(*a)-1.0e0);
00081     return dlngam;
00082 } /* END */
 

Powered by Plone

This site conforms to the following standards: