当前位置: 首页>>代码示例>>Python>>正文


Python C.gamma方法代码示例

本文整理汇总了Python中sympy.core.C.gamma方法的典型用法代码示例。如果您正苦于以下问题:Python C.gamma方法的具体用法?Python C.gamma怎么用?Python C.gamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.core.C的用法示例。


在下文中一共展示了C.gamma方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
    def eval(cls, n):
        if (n.is_Integer and n.is_nonnegative) or \
           (n.is_noninteger and n.is_negative):
            return 4**n*C.gamma(n + S.Half)/(C.gamma(S.Half)*C.gamma(n + 2))

        if (n.is_integer and n.is_negative):
            if (n + 1).is_negative:
                return S.Zero
            if (n + 1).is_zero:
                return -S.Half
开发者ID:cstoudt,项目名称:sympy,代码行数:12,代码来源:numbers.py

示例2: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
    def eval(cls, r, k):
        r, k = map(sympify, (r, k))

        if k.is_Number:
            if k is S.Zero:
                return S.One
            elif k.is_Integer:
                if k.is_negative:
                    return S.Zero
                else:
                    if r.is_Integer and r.is_nonnegative:
                        r, k = int(r), int(k)

                        if k > r:
                            return S.Zero
                        elif k > r // 2:
                            k = r - k

                        M, result = int(sqrt(r)), 1

                        for prime in sieve.primerange(2, r + 1):
                            if prime > r - k:
                                result *= prime
                            elif prime > r // 2:
                                continue
                            elif prime > M:
                                if r % prime < k % prime:
                                    result *= prime
                            else:
                                R, K = r, k
                                exp = a = 0

                                while R > 0:
                                    a = int((R % prime) < (K % prime + a))
                                    R, K = R // prime, K // prime
                                    exp = a + exp

                                if exp > 0:
                                    result *= prime ** exp

                        return C.Integer(result)
                    else:
                        result = r - k + 1

                        for i in xrange(2, k + 1):
                            result *= r - k + i
                            result /= i

                        return result

        if k.is_integer:
            if k.is_negative:
                return S.Zero
        else:
            return C.gamma(r + 1) / (C.gamma(r - k + 1) * C.gamma(k + 1))
开发者ID:sympy,项目名称:sympy,代码行数:57,代码来源:factorials.py

示例3: fdiff

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def fdiff(self, argindex=1):
     if argindex == 1:
         return C.gamma(self.args[0] + 1)*C.polygamma(0, self.args[0] + 1)
     else:
         raise ArgumentIndexError(self, argindex)
开发者ID:abhishekkumawat23,项目名称:sympy,代码行数:7,代码来源:factorials.py

示例4: _eval_rewrite_as_gamma

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def _eval_rewrite_as_gamma(self, n, k):
     return C.gamma(n + 1)/(C.gamma(k + 1)*C.gamma(n - k + 1))
开发者ID:abhishekkumawat23,项目名称:sympy,代码行数:4,代码来源:factorials.py

示例5: _eval_rewrite_as_gamma

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def _eval_rewrite_as_gamma(self, n):
     # The gamma function allows to generalize Catalan numbers to complex n
     return 4**n*C.gamma(n + S.Half)/(C.gamma(S.Half)*C.gamma(n + 2))
开发者ID:Zulko,项目名称:sympy,代码行数:5,代码来源:numbers.py

示例6: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def eval(cls, n, evaluate=True):
     if n.is_Integer and n.is_nonnegative:
         return 4**n*C.gamma(n + S.Half)/(C.gamma(S.Half)*C.gamma(n + 2))
开发者ID:Zulko,项目名称:sympy,代码行数:5,代码来源:numbers.py

示例7: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def eval(cls, n, evaluate=None):
     if evaluate is None:
         evaluate = global_evaluate[0]
     if n.is_Integer and n.is_nonnegative:
         return 4**n*C.gamma(n + S.Half)/(C.gamma(S.Half)*C.gamma(n + 2))
开发者ID:B-Rich,项目名称:sympy,代码行数:7,代码来源:numbers.py

示例8: _eval_rewrite_as_gamma

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import gamma [as 别名]
 def _eval_rewrite_as_gamma(self, r, k):
     return C.gamma(r + 1) / (C.gamma(r - k + 1) * C.gamma(k + 1))
开发者ID:addisonc,项目名称:sympy,代码行数:4,代码来源:factorials.py


注:本文中的sympy.core.C.gamma方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。