Ejemplo n.º 1
0
   /// Complement of incomplete gamma function Q(a,x), a > 0, x >= 0.
   /// Q(a,x) = (1/gamma(a)) integral (x to inf) { exp(-t) t^(a-1) dt }
   /// @param a  first argument, a > 0
   /// @param x  second argument, x >= 0
   /// @return          Q(a,x)
   /// @throw           if input arguments have a <= 0 or x < 0
   double compIncompGamma(const double& a, const double& x) throw(Exception)
   {
      try {
         if(x < 0) GPSTK_THROW(Exception("Negative first argument"));
         if(a <= 0) GPSTK_THROW(Exception("Non-positive second argument"));

         if(x < a+1.0)
            return (1.0 - seriesIncompGamma(a,x));
         else
            return contfracIncompGamma(a,x);
      }
      catch(Exception& e) { GPSTK_RETHROW(e); }
   }
Ejemplo n.º 2
0
   /// Complement of incomplete gamma function Q(a,x), a > 0, x >= 0.
   /// Q(a,x) = (1/gamma(a)) integral (x to inf) { exp(-t) t^(a-1) dt }
   /// @param double a  first argument, a > 0
   /// @param double x  second argument, x >= 0
   /// @return          Q(a,x)
   /// @throw           if input arguments have a <= 0 or x < 0
   double compIncompGamma(const double& a, const double& x) throw(Exception)
   {
      if(x < 0) {
         Exception e("Negative first argument in compIncompGamma()");
         GPSTK_THROW(e);
      }
      if(a <= 0) {
         Exception e("Non-positive second argument in compIncompGamma()");
         GPSTK_THROW(e);
      }

      if(x < a+1.0)
         return (1.0 - seriesIncompGamma(a,x));
      else
         return contfracIncompGamma(a,x);
   }