using System; namespace BrazilTimestampReconstruction { /// /// Returns the incomplete gamma function Q(a, x) evaluated by its continued fraction representation /// as gammcf. Also returns ln\Gamma(a) as gln. /// public class Gcf { private double gammcf, gln; public double Gammcf { get{return gammcf;} } public double Gln { get{return gln;} } public Gcf() { } private int ITMAX = 100; private double EPS = 3.0e-7; private double FPMIN = 1.0e-30; public void gcf(double a, double x) { Gammln gam = new Gammln(); int i; double an,b,c,d,del,h; gln=gam.gammln(a); b=x+1.0-a; c=1.0/FPMIN; d=1.0/b; h=d; for (i=1;i<=ITMAX;i++) { an = -i*(i-a); b += 2.0; d=an*d+b; if (Math.Abs(d) < FPMIN) d=FPMIN; c=b+an/c; if (Math.Abs(c) < FPMIN) c=FPMIN; d=1.0/d; del=d*c; h *= del; if (Math.Abs(del-1.0) < EPS) break; } if (i > ITMAX) try{throw new Exception();} catch (Exception) { } gammcf=Math.Exp(-x+a*Math.Log(x)-gln)*h; } } }