Prev Next Index-> contents reference index search external Up-> f2cad library dgamma f2cad-> license Install get_started prototype library run.cpp utility add2lib.sh whats_new library-> d9knus d9lgmc daxpy dbesks dbskes dcsevl ddot dgamlm dgamma dgefa dgesl dint dscal idamax initds xerror dgamma-> dgamma.f Headings-> Prototype Fortran Source Description

dgamma

Prototype
doublereal f2cad::dgamma_(doublereal *x);

Fortran Source
dgamma.f

Description
For arbitrary   x and positive integer values of   \ell ,   $\begin{array}{rcl} \Gamma(x) & = & \int_0^\infty t^{x - 1} \exp( - t ) \; {\bf d} t \\ \Gamma(\ell+1) & = & \ell ! \\ \Gamma^{(1)} (\ell+1) & = & \ell ! \left( - \gamma + \sum_{k=1}^\ell \frac{1}{k} \right) \end{array}$  where   \gamma is the Euler-Mascheroni constant   $\gamma = 0.57721 56649 01532 86060 65120 90082 ...$   # include <f2cad/dgamma.hpp> test_result dgamma(void) { bool ok = true; // independent variables integer n = 1; // number of independent variables double ell = 3.; doublereal x[1]; // vector of independent variables x[0] = ell+1.; // value of independent variables f2cad::Independent(n, x); // declare x as independent variable vector // dependent variables integer m = 1; // number of dependent variables doublereal f[1]; // vector of dependent variables f[0] = f2cad::dgamma_(x+0); // compute value f[0] = Gamma(x[0]) f2cad::Dependent(m, f); // declare f as dependent variable vector // check the value of f ok &= f2cad::near_equal(f2cad::Value(f[0]), 6., 1e-10, 1e-10); // Compute derivative of f w.r.t x using f2cad common interface. // This general interface works with adolc, cppad, and fadbad. // See GetStarted for package specific more efficient code. double gamma = 0.577215664901532; double p = f2cad::Partial<doublereal>(0, 0); double check = 6. * ( - gamma + 1. + 1./2. + 1./3. ); ok &= f2cad::near_equal(p, check, 1e-10, 1e-10); if( ok ) return test_pass; return test_fail; } 
Input File: example/dgamma.cpp