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

Python operator.Operator类代码示例

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

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



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

示例1: test_operator

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,代码行数:56,代码来源:test_printing.py


示例2: test_operator

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,代码行数:55,代码来源:test_printing.py


示例3: _eval_anticommutator

 def _eval_anticommutator(self, other, **hints):
     if isinstance(other, OneQubitGate):
         if self.targets != other.targets or self.__class__ == other.__class__:
             return Integer(2)*self*other
     return Operator._eval_anticommutator(self, other, **hints)
开发者ID:yangle,项目名称:sympy,代码行数:5,代码来源:gate.py


示例4: test_operator_inv

def test_operator_inv():
    A = Operator('A')
    assert A*A.inv() == 1
    assert A.inv()*A == 1
开发者ID:AdrianPotter,项目名称:sympy,代码行数:4,代码来源:test_operator.py


示例5: HermitianOperator

from sympy.physics.quantum.dagger import Dagger 



A = HermitianOperator('A')
B = HermitianOperator('B')
C = Operator('C')
D = Operator('D')
#E = Operator('E')
F = Operator('F')
G = Operator('G')
H = HermitianOperator('H')
I = IdentityOperator('I')
J = Operator('J')
K = Operator('K')
K_1 = Operator('K_1')
K_2 = Operator('K_2')
L = Operator('L')
L_1 = Operator('L_1')
L_2 = Operator('L_2')
M = Operator('M')
M_1 = Operator('M_1')
M_2 = Operator('M_2')
N = Operator('N')
O = Operator('O')
P = Operator('P')
#Q = Operator('Q')
Q_1 = Operator('Q_1')
Q_2 = Operator('Q_2')
R = Operator('R')
S = Operator('S')
开发者ID:Nty24,项目名称:Series-Product,代码行数:31,代码来源:seriesproduct.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python operator.UnitaryOperator类代码示例发布时间:2022-05-27
下一篇:
Python matrixutils.matrix_zeros函数代码示例发布时间: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