本文整理汇总了Python中sympy.core.basic.Basic.gamma方法的典型用法代码示例。如果您正苦于以下问题:Python Basic.gamma方法的具体用法?Python Basic.gamma怎么用?Python Basic.gamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.core.basic.Basic
的用法示例。
在下文中一共展示了Basic.gamma方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _eval_apply
# 需要导入模块: from sympy.core.basic import Basic [as 别名]
# 或者: from sympy.core.basic.Basic import gamma [as 别名]
def _eval_apply(cls, r, k):
r, k = map(Basic.sympify, (r, k))
if isinstance(k, Basic.Number):
if isinstance(k, Basic.Zero):
return S.One
elif isinstance(k, Basic.Integer):
if k.is_negative:
return S.Zero
else:
if isinstance(r, Basic.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 Basic.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 Basic.gamma(r+1)/(Basic.gamma(r-k+1)*Basic.gamma(k+1))
示例2: _eval_rewrite_as_gamma
# 需要导入模块: from sympy.core.basic import Basic [as 别名]
# 或者: from sympy.core.basic.Basic import gamma [as 别名]
def _eval_rewrite_as_gamma(self, r, k):
return Basic.gamma(r+1) / (Basic.gamma(r-k+1)*Basic.gamma(k+1))