本文整理汇总了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
示例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))
示例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)
示例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))
示例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))
示例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))
示例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))
示例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))