• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sympy.Integer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.Integer的典型用法代码示例。如果您正苦于以下问题:Python Integer类的具体用法?Python Integer怎么用?Python Integer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_has_any

def test_has_any():
    x,y,z,t,u = symbols('x y z t u')
    f = Function("f")
    g = Function("g")
    p = Wild('p')

    assert sin(x).has(x)
    assert sin(x).has(sin)
    assert not sin(x).has(y)
    assert not sin(x).has(cos)
    assert f(x).has(x)
    assert f(x).has(f)
    assert not f(x).has(y)
    assert not f(x).has(g)

    assert f(x).diff(x).has(x)
    assert f(x).diff(x).has(f)
    assert f(x).diff(x).has(Derivative)
    assert not f(x).diff(x).has(y)
    assert not f(x).diff(x).has(g)
    assert not f(x).diff(x).has(sin)

    assert (x**2).has(Symbol)
    assert not (x**2).has(Wild)
    assert (2*p).has(Wild)

    i = Integer(4400)

    assert i.has(x) is False

    assert (i*x**i).has(x)
    assert (i*y**i).has(x) is False
    assert (i*y**i).has(x, y)

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has(u) is False

    assert expr.has(x)
    assert expr.has(y)
    assert expr.has(z)
    assert expr.has(t)

    assert expr.has(x, y, z, t)
    assert expr.has(x, y, z, t, u)

    from sympy.physics.units import m, s

    assert (x*m/s).has(x)
    assert (x*m/s).has(y, z) is False

    poly = Poly(x**2 + x*y*sin(z), x, y, t)

    assert poly.has(x)
    assert poly.has(x, y, z)
    assert poly.has(x, y, z, t)

    assert FockState((x, y)).has(x)
开发者ID:qmattpap,项目名称:sympy,代码行数:58,代码来源:test_expr.py


示例2: _big_delta_coeff

def _big_delta_coeff(aa, bb, cc, prec=None):
    r"""
    Calculates the Delta coefficient of the 3 angular momenta for
    Racah symbols. Also checks that the differences are of integer
    value.

    INPUT:

    -  ``aa`` - first angular momentum, integer or half integer

    -  ``bb`` - second angular momentum, integer or half integer

    -  ``cc`` - third angular momentum, integer or half integer

    -  ``prec`` - precision of the ``sqrt()`` calculation

    OUTPUT:

    double - Value of the Delta coefficient

    EXAMPLES::

        sage: from sage.functions.wigner import _big_delta_coeff
        sage: _big_delta_coeff(1,1,1)
        1/2*sqrt(1/6)
    """
    if int(aa + bb - cc) != (aa + bb - cc):
        raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
    if int(aa + cc - bb) != (aa + cc - bb):
        raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
    if int(bb + cc - aa) != (bb + cc - aa):
        raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
    if (aa + bb - cc) < 0:
        return 0
    if (aa + cc - bb) < 0:
        return 0
    if (bb + cc - aa) < 0:
        return 0

    maxfact = max(aa + bb - cc, aa + cc - bb, bb + cc - aa, aa + bb + cc + 1)
    _calc_factlist(maxfact)

    argsqrt = Integer(_Factlist[int(aa + bb - cc)] * \
                          _Factlist[int(aa + cc - bb)] * \
                          _Factlist[int(bb + cc - aa)]) / \
                          Integer(_Factlist[int(aa + bb + cc + 1)])

    ressqrt = argsqrt.sqrt(prec)
    if type(ressqrt) is ComplexNumber:
        res = ressqrt.real()
    else:
        res = ressqrt
    return res
开发者ID:Aang,项目名称:sympy,代码行数:53,代码来源:wigner.py


示例3: test_power

def test_power():
    x,y,a,b,c = map(Symbol, 'xyabc')
    p,q,r = map(Wild, 'pqr')

    e = (x+y)**a
    assert e.match(p**q) == {p: x+y, q: a}
    assert e.match(p**p) == None

    e = (x+y)**(x+y)
    assert e.match(p**p) == {p: x+y}
    assert e.match(p**q) == {p: x+y, q: x+y}

    e = (2*x)**2
    assert e.match(p*q**r) == {p: 4, q: x, r: 2}

    e = Integer(1)
    assert e.match(x**p) == {p: 0}
开发者ID:cran,项目名称:rSymPy,代码行数:17,代码来源:test_match.py


示例4: test_has_multiple

def test_has_multiple():
    f = x ** 2 * y + sin(2 ** t + log(z))

    assert f.has(x)
    assert f.has(y)
    assert f.has(z)
    assert f.has(t)

    assert not f.has(u)

    assert f.has(x, y, z, t)
    assert f.has(x, y, z, t, u)

    i = Integer(4400)

    assert not i.has(x)

    assert (i * x ** i).has(x)
    assert not (i * y ** i).has(x)
    assert (i * y ** i).has(x, y)
    assert not (i * y ** i).has(x, z)
开发者ID:Botouls,项目名称:sympy,代码行数:21,代码来源:test_expr.py


示例5: test_has_any_symbols

def test_has_any_symbols():
    x,y,z,t,u = symbols('xyztu')

    i = Integer(4400)

    assert i.has_any_symbols(x) == False

    assert (i*x**i).has_any_symbols(x) == True
    assert (i*y**i).has_any_symbols(x) == False
    assert (i*y**i).has_any_symbols(x, y) == True

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has_any_symbols(u) == False

    assert expr.has_any_symbols(x) == True
    assert expr.has_any_symbols(y) == True
    assert expr.has_any_symbols(z) == True
    assert expr.has_any_symbols(t) == True

    assert expr.has_any_symbols(x, y, z, t) == True
    assert expr.has_any_symbols(x, y, z, t, u)  == True

    from sympy.physics.units import m, s

    assert (x*m/s).has_any_symbols(x) == True
    assert (x*m/s).has_all_symbols(x) == True

    assert (x*m/s).has_any_symbols(y, z) == False
    assert (x*m/s).has_all_symbols(x, y) == False

    poly = Poly(x**2 + x*y*sin(z), x, y, t)

    assert poly.has_any_symbols(x) == True
    assert poly.has_any_symbols(x, y, z) == True
    assert poly.has_any_symbols(x, y, z, t) == True

    assert poly.has_all_symbols(x, y, z) == True
    assert poly.has_all_symbols(x, y, z, t) == False
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:39,代码来源:test_basic.py


示例6: test_has_all

def test_has_all():
    x,y,z,t,u = symbols('xyztu')
    u = symbols('u')

    i = Integer(4400)

    assert i.has(x, all=True) is False

    assert (i*x**i).has(x, all=True)
    assert (i*y**i).has(x, all=True) is False

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has(y, z, t, all=True)
    assert expr.has(x, z, t, all=True)
    assert expr.has(x, y, t, all=True)
    assert expr.has(x, y, z, all=True)

    assert expr.has(y, u, t, all=True) is False
    assert expr.has(x, z, u, all=True) is False
    assert expr.has(u, y, z, all=True) is False

    assert expr.has(x, y, z, t, all=True)
    assert expr.has(x, y, z, t, u, all=True) is False

    from sympy.physics.units import m, s

    assert (x*m/s).has(x, all=True)
    assert (x*m/s).has(x, y, all=True) is False

    poly = Poly(x**2 + x*y*sin(z), x, y, t)

    assert poly.has(x, y, z, all=True)
    assert poly.has(x, y, z, t, all=True) is False

    f = FockState((x, y))
    assert f.has(x, y, all=True)
    assert f.has(x, y, z, all=True) is False
开发者ID:rainly,项目名称:sympy,代码行数:38,代码来源:test_expr.py


示例7: test_has_all_symbols

def test_has_all_symbols():
    x,y,z,t,u = symbols('xyztu')

    i = Integer(4400)

    assert i.has_all_symbols(x) == False

    assert (i*x**i).has_all_symbols(x) == True
    assert (i*y**i).has_all_symbols(x) == False

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has_all_symbols(y, z, t) == True
    assert expr.has_all_symbols(x, z, t) == True
    assert expr.has_all_symbols(x, y, t) == True
    assert expr.has_all_symbols(x, y, z) == True

    assert expr.has_all_symbols(y, u, t) == False
    assert expr.has_all_symbols(x, z, u) == False
    assert expr.has_all_symbols(u, y, z) == False

    assert expr.has_all_symbols(x, y, z, t) == True
    assert expr.has_all_symbols(x, y, z, t, u) == False
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:23,代码来源:test_basic.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sympy.Integral类代码示例发布时间:2022-05-27
下一篇:
Python sympy.Indexed类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap