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