brentworden    2004/06/10 11:34:53

  Modified:    math/src/java/org/apache/commons/math/special Gamma.java
  Log:
  removed some condition logic by changing the continued fraction representation.
  
  Revision  Changes    Path
  1.20      +4 -19     
jakarta-commons/math/src/java/org/apache/commons/math/special/Gamma.java
  
  Index: Gamma.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/special/Gamma.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Gamma.java        7 Jun 2004 20:30:16 -0000       1.19
  +++ Gamma.java        10 Jun 2004 18:34:53 -0000      1.20
  @@ -236,30 +236,15 @@
               // create continued fraction
               ContinuedFraction cf = new ContinuedFraction() {
                   protected double getA(int n, double x) {
  -                    double ret;
  -                    switch(n) {
  -                        case 0: ret = 0.0; break;
  -                        default:
  -                            ret = ((2.0 * n) - 1.0) - a + x; break;
  -                    }
  -                    return ret;
  +                    return ((2.0 * n) + 1.0) - a + x;
                   }
   
                   protected double getB(int n, double x) {
  -                    double ret;
  -                    double t;
  -                    switch(n) {
  -                        case 1: ret = 1.0; break;
  -                        default:
  -                            t = n - 1.0;
  -                            ret = t * (a - t);
  -                            break;
  -                    }
  -                    return ret;
  +                    return n * (a - n);
                   }
               };
               
  -            ret = cf.evaluate(x, epsilon, maxIterations);
  +            ret = 1.0 / cf.evaluate(x, epsilon, maxIterations);
               ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * ret;
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to