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


Python C.gamma方法代码示例

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


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

示例1: eval

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.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:bibile,项目名称:sympy,代码行数:57,代码来源:factorials.py

示例2: eval

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import gamma [as 别名]
 def eval(cls, n, m, x):
     if m.could_extract_minus_sign():
         # P^{-m}_n  --->  F * P^m_n
         return S.NegativeOne**(-m) * (C.factorial(m + n)/C.factorial(n - m)) * assoc_legendre(n, -m, x)
     if m == 0:
         # P^0_n  --->  L_n
         return legendre(n, x)
     if x == 0:
         return 2**m*sqrt(S.Pi) / (C.gamma((1 - m - n)/2)*C.gamma(1 - (m - n)/2))
     if n.is_Number and m.is_Number and n.is_integer and m.is_integer:
         if n.is_negative:
             raise ValueError("%s : 1st index must be nonnegative integer (got %r)" % (cls, n))
         if abs(m) > n:
             raise ValueError("%s : abs('2nd index') must be <= '1st index' (got %r, %r)" % (cls, n, m))
         return cls._eval_at_order(int(n), abs(int(m))).subs(_x, x)
开发者ID:twobitlogic,项目名称:sympy,代码行数:17,代码来源:polynomials.py

示例3: eval

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import gamma [as 别名]
    def eval(cls, n, a, x):
        # For negative n the polynomials vanish
        # See http://functions.wolfram.com/Polynomials/GegenbauerC3/03/01/03/0012/
        if n.is_negative:
            return S.Zero

        # Some special values for fixed a
        if a == S.Half:
            return legendre(n, x)
        elif a == S.One:
            return chebyshevu(n, x)
        elif a == S.NegativeOne:
            return S.Zero

        if not n.is_Number:
            # Handle this before the general sign extraction rule
            if x == S.NegativeOne:
                if (C.re(a) > S.Half) == True:
                    return S.ComplexInfinity
                else:
                    # No sec function available yet
                    # return (C.cos(S.Pi*(a+n)) * C.sec(S.Pi*a) * C.gamma(2*a+n) /
                    #            (C.gamma(2*a) * C.gamma(n+1)))
                    return None

            # Symbolic result C^a_n(x)
            # C^a_n(-x)  --->  (-1)**n * C^a_n(x)
            if x.could_extract_minus_sign():
                return S.NegativeOne ** n * gegenbauer(n, a, -x)
            # We can evaluate for some special values of x
            if x == S.Zero:
                return (
                    2 ** n * sqrt(S.Pi) * C.gamma(a + S.Half * n) / (C.gamma((1 - n) / 2) * C.gamma(n + 1) * C.gamma(a))
                )
            if x == S.One:
                return C.gamma(2 * a + n) / (C.gamma(2 * a) * C.gamma(n + 1))
            elif x == S.Infinity:
                if n.is_positive:
                    return C.RisingFactorial(a, n) * S.Infinity
        else:
            # n is a given fixed integer, evaluate into polynomial
            return gegenbauer_poly(n, a, x)
开发者ID:B-Rich,项目名称:sympy,代码行数:44,代码来源:polynomials.py

示例4: eval

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import gamma [as 别名]
 def eval(cls, n, x):
     if not n.is_Number:
         # Symbolic result L_n(x)
         # L_n(-x)  --->  (-1)**n * L_n(x)
         if x.could_extract_minus_sign():
             return S.NegativeOne**n * legendre(n,-x)
         # L_{-n}(x)  --->  L_{n-1}(x)
         if n.could_extract_minus_sign():
             return legendre(-n - S.One,x)
         # We can evaluate for some special values of x
         if x == S.Zero:
             return sqrt(S.Pi)/(C.gamma(S.Half - n/2)*C.gamma(S.One + n/2))
         elif x == S.One:
             return S.One
         elif x == S.Infinity:
             return S.Infinity
     else:
         # n is a given fixed integer, evaluate into polynomial
         if n.is_negative:
             raise ValueError("The index n must be nonnegative integer (got %r)" % n)
         else:
             return cls._eval_at_order(n, x)
开发者ID:StefenYin,项目名称:sympy,代码行数:24,代码来源:polynomials.py

示例5: _eval_rewrite_as_gamma

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.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:bibile,项目名称:sympy,代码行数:4,代码来源:factorials.py

示例6: _eval_rewrite_as_polynomial

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import gamma [as 别名]
 def _eval_rewrite_as_polynomial(self, n, x):
     # TODO: Should make sure n is in N_0
     k = C.Dummy("k")
     kern = C.RisingFactorial(
         -n, k) / (C.gamma(k + alpha + 1) * C.factorial(k)) * x**k
     return C.gamma(n + alpha + 1) / C.factorial(n) * C.Sum(kern, (k, 0, n))
开发者ID:twobitlogic,项目名称:sympy,代码行数:8,代码来源:polynomials.py


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