Example #1
0
    def apply_inexact(self, n, k, evaluation):
        'Binomial[n_?InexactNumberQ, k_?NumberQ]'

        with workprec(min_prec(n, k)):
            n = gmpy2mpmath(n.value)
            k = gmpy2mpmath(k.value)
            result = mpmath.binomial(n, k)
            try:
                result = mpmath2gmpy(result)
            except SpecialValueError, exc:
                return Symbol(exc.name)
            number = Number.from_mp(result)
            return number
Example #2
0
 def apply_inexact(self, n, k, evaluation):
     'Binomial[n_?InexactNumberQ, k_?NumberQ]'
     
     with workprec(min_prec(n, k)):
         n = gmpy2mpmath(n.value)
         k = gmpy2mpmath(k.value)
         result = mpmath.binomial(n, k)
         try:
             result = mpmath2gmpy(result)
         except SpecialValueError, exc:
             return Symbol(exc.name)
         number = Number.from_mp(result)
         return number
Example #3
0
 def apply_inexact(self, z, evaluation):
     '%(name)s[z_Real|z_Complex?InexactNumberQ]'
     
     with workprec(z.get_precision()):
         z = gmpy2mpmath(z.value)
         try:
             result = self.eval(z)
         except ValueError, exc:
             text = str(exc)
             if text == 'gamma function pole':
                 return Symbol('ComplexInfinity')
             else:
                 raise
         except ZeroDivisionError:
             return
Example #4
0
    def apply_inexact(self, z, evaluation):
        '%(name)s[z_Real|z_Complex?InexactNumberQ]'

        with workprec(z.get_precision()):
            z = gmpy2mpmath(z.value)
            try:
                result = self.eval(z)
            except ValueError, exc:
                text = str(exc)
                if text == 'gamma function pole':
                    return Symbol('ComplexInfinity')
                else:
                    raise
            except ZeroDivisionError:
                return