using System; namespace BrazilTimestampReconstruction { /// /// Returns the incomplete gamma function P(a, x) evaluated by its series representation as gamser. /// Also returns ln\Gamma(a) as gln. /// public class Gser { private double gamser, gln; public double Gamser { get{return gamser;} } public double Gln { get{return gln;} } public Gser() { } private int ITMAX = 100; private double EPS = 3.0e-7; public void gser(double a, double x) { Gammln gam = new Gammln(); int n; double sum,del,ap; gln=gam.gammln(a); if (x <= 0.0) { if (x < 0.0) try{throw new Exception();} catch (Exception) { } gamser=0.0; return; } else { ap=a; del=sum=1.0/a; for (n=1;n<=ITMAX;n++) { ++ap; del *= x/ap; sum += del; if (Math.Abs(del) < Math.Abs(sum)*EPS) { gamser=sum*Math.Exp(-x+a*Math.Log(x)-gln); return; } } try{throw new Exception();} catch (Exception) { } return; } } } }