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


Python Operator.inv方法代码示例

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


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

示例1: test_operator

# 需要导入模块: from sympy.physics.quantum.operator import Operator [as 别名]
# 或者: from sympy.physics.quantum.operator.Operator import inv [as 别名]
def test_operator():
    a = Operator('A')
    b = Operator('B', Symbol('t'), S(1)/2)
    inv = a.inv()
    f = Function('f')
    x = symbols('x')
    d = DifferentialOperator(Derivative(f(x), x), f(x))
    op = OuterProduct(Ket(), Bra())
    assert str(a) == 'A'
    assert pretty(a) == 'A'
    assert upretty(a) == u('A')
    assert latex(a) == 'A'
    sT(a, "Operator(Symbol('A'))")
    assert str(inv) == 'A**(-1)'
    ascii_str = \
"""\
 -1\n\
A  \
"""
    ucode_str = \
u("""\
 -1\n\
A  \
""")
    assert pretty(inv) == ascii_str
    assert upretty(inv) == ucode_str
    assert latex(inv) == r'\left(A\right)^{-1}'
    sT(inv, "Pow(Operator(Symbol('A')), Integer(-1))")
    assert str(d) == 'DifferentialOperator(Derivative(f(x), x),f(x))'
    ascii_str = \
"""\
                    /d            \\\n\
DifferentialOperator|--(f(x)),f(x)|\n\
                    \dx           /\
"""
    ucode_str = \
u("""\
                    ⎛d            ⎞\n\
DifferentialOperator⎜──(f(x)),f(x)⎟\n\
                    ⎝dx           ⎠\
""")
    assert pretty(d) == ascii_str
    assert upretty(d) == ucode_str
    assert latex(d) == \
        r'DifferentialOperator\left(\frac{d}{d x} f{\left (x \right )},f{\left (x \right )}\right)'
    sT(d, "DifferentialOperator(Derivative(Function('f')(Symbol('x')), Symbol('x')),Function('f')(Symbol('x')))")
    assert str(b) == 'Operator(B,t,1/2)'
    assert pretty(b) == 'Operator(B,t,1/2)'
    assert upretty(b) == u('Operator(B,t,1/2)')
    assert latex(b) == r'Operator\left(B,t,\frac{1}{2}\right)'
    sT(b, "Operator(Symbol('B'),Symbol('t'),Rational(1, 2))")
    assert str(op) == '|psi><psi|'
    assert pretty(op) == '|psi><psi|'
    assert upretty(op) == u('❘ψ⟩⟨ψ❘')
    assert latex(op) == r'{\left|\psi\right\rangle }{\left\langle \psi\right|}'
    sT(op, "OuterProduct(Ket(Symbol('psi')),Bra(Symbol('psi')))")
开发者ID:B-Rich,项目名称:sympy,代码行数:58,代码来源:test_printing.py

示例2: test_operator

# 需要导入模块: from sympy.physics.quantum.operator import Operator [as 别名]
# 或者: from sympy.physics.quantum.operator.Operator import inv [as 别名]
def test_operator():
    a = Operator("A")
    b = Operator("B", Symbol("t"), S(1) / 2)
    inv = a.inv()
    f = Function("f")
    x = symbols("x")
    d = DifferentialOperator(Derivative(f(x), x), f(x))
    op = OuterProduct(Ket(), Bra())
    assert str(a) == "A"
    assert pretty(a) == "A"
    assert upretty(a) == u"A"
    assert latex(a) == "A"
    sT(a, "Operator(Symbol('A'))")
    assert str(inv) == "A**(-1)"
    ascii_str = """\
 -1\n\
A  \
"""
    ucode_str = u(
        """\
 -1\n\
A  \
"""
    )
    assert pretty(inv) == ascii_str
    assert upretty(inv) == ucode_str
    assert latex(inv) == r"A^{-1}"
    sT(inv, "Pow(Operator(Symbol('A')), Integer(-1))")
    assert str(d) == "DifferentialOperator(Derivative(f(x), x),f(x))"
    ascii_str = """\
                    /d            \\\n\
DifferentialOperator|--(f(x)),f(x)|\n\
                    \dx           /\
"""
    ucode_str = u(
        """\
                    ⎛d            ⎞\n\
DifferentialOperator⎜──(f(x)),f(x)⎟\n\
                    ⎝dx           ⎠\
"""
    )
    assert pretty(d) == ascii_str
    assert upretty(d) == ucode_str
    assert latex(d) == r"DifferentialOperator\left(\frac{d}{d x} f{\left (x \right )},f{\left (x \right )}\right)"
    sT(d, "DifferentialOperator(Derivative(Function('f')(Symbol('x')), Symbol('x')),Function('f')(Symbol('x')))")
    assert str(b) == "Operator(B,t,1/2)"
    assert pretty(b) == "Operator(B,t,1/2)"
    assert upretty(b) == u"Operator(B,t,1/2)"
    assert latex(b) == r"Operator\left(B,t,\frac{1}{2}\right)"
    sT(b, "Operator(Symbol('B'),Symbol('t'),Rational(1, 2))")
    assert str(op) == "|psi><psi|"
    assert pretty(op) == "|psi><psi|"
    assert upretty(op) == u"❘ψ⟩⟨ψ❘"
    assert latex(op) == r"{\left|\psi\right\rangle }{\left\langle \psi\right|}"
    sT(op, "OuterProduct(Ket(Symbol('psi')),Bra(Symbol('psi')))")
开发者ID:scopatz,项目名称:sympy,代码行数:57,代码来源:test_printing.py

示例3: test_operator_inv

# 需要导入模块: from sympy.physics.quantum.operator import Operator [as 别名]
# 或者: from sympy.physics.quantum.operator.Operator import inv [as 别名]
def test_operator_inv():
    A = Operator('A')
    assert A*A.inv() == 1
    assert A.inv()*A == 1
开发者ID:AdrianPotter,项目名称:sympy,代码行数:6,代码来源:test_operator.py


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