Module Expr Str ImportFrom alias alias ImportFrom alias alias alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias alias ImportFrom alias Assign NameStore ListLoad Str FunctionDef arguments args NameParam defaults kwarg body Expr Str ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad If CompareEq NameLoad Num body Return AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad If Call NameLoad NameLoad NameLoad body Return NameLoad orelse If Call NameLoad NameLoad NameLoad body Assign NameStore Num For NameStore AttributeLoad NameLoad attr body AugAssignAdd NameStore Call NameLoad NameLoad NameLoad Return NameLoad orelse If Call NameLoad NameLoad NameLoad body Assign NameStore ListComp TupleLoad Call NameLoad NameLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore AttributeLoad NameLoad attr Return Call NameLoad NameLoad orelse If Call NameLoad NameLoad NameLoad body Return Call NameLoad ListComp Call NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr orelse If Call NameLoad NameLoad NameLoad body Return BinOpPow Call NameLoad AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr orelse If Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad If BoolOpAnd CompareEq NameLoad NameLoad NameLoad body Return Call NameLoad Call NameLoad Call NameLoad NameLoad NameLoad orelse Return NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam defaults kwarg body Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr If BoolOpOr CompareLtE Call NameLoad NameLoad Num UnaryOpNot Call NameLoad NameLoad NameLoad body Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr If BoolOpOr BoolOpAnd AttributeLoad Call NameLoad NameLoad attr UnaryOpNot Call NameLoad NameLoad NameLoad BoolOpAnd AttributeLoad Call NameLoad NameLoad attr UnaryOpNot Call NameLoad NameLoad NameLoad body Return NameLoad If BoolOpAnd Call NameLoad NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr BinOpPow AttributeLoad NameLoad attr BinOpSub AttributeLoad NameLoad attr Num Assign NameStore AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Return Call NameLoad BinOpAdd Call AttributeLoad NameLoad attr BinOpAdd NameLoad ListLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Call AttributeLoad NameLoad attr BinOpAdd NameLoad ListLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad NameLoad orelse Return Call NameLoad BinOpMult BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad If BoolOpAnd Call NameLoad NameLoad NameLoad Call NameLoad ListComp BoolOpOr Call NameLoad NameLoad TupleLoad NameLoad NameLoad NameLoad NameLoad CompareEq NameLoad Num comprehension NameStore AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Call NameLoad ListComp BoolOpOr Call NameLoad NameLoad TupleLoad NameLoad NameLoad NameLoad NameLoad CompareEq NameLoad Num comprehension NameStore AttributeLoad NameLoad attr CompareEq Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad Call NameLoad ListComp Call NameLoad BinOpMult SubscriptLoad AttributeLoad NameLoad attr Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad NameLoad comprehension NameStore Call NameLoad Call NameLoad AttributeLoad NameLoad attr attr keyword NameLoad Return BinOpMult Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad handlers ExceptHandler type TupleLoad NameLoad NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad handlers ExceptHandler type TupleLoad NameLoad NameLoad body If BoolOpAnd Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr orelse Assign NameStore NameLoad If CompareEq NameLoad Num body Return AttributeLoad NameLoad attr orelse If CompareIs NameLoad NameLoad body If CompareEq Call NameLoad NameLoad Num body Return NameLoad orelse Return BinOpMult Call NameLoad Call AttributeLoad NameLoad attr BinOpAdd NameLoad ListLoad NameLoad NameLoad NameLoad orelse If Call NameLoad NameLoad NameLoad body Return BinOpMult NameLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Return Call NameLoad BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list
N/A N/A Logic for applying operators to states.

Todo:
* Sometimes the final result needs to be expanded, we should do this by hand.
 __future__ print_function division sympy Add Mul Pow sympify S sympy.core.compatibility range sympy.physics.quantum.anticommutator AntiCommutator sympy.physics.quantum.commutator Commutator sympy.physics.quantum.dagger Dagger sympy.physics.quantum.innerproduct InnerProduct sympy.physics.quantum.operator OuterProduct Operator sympy.physics.quantum.state State KetBase BraBase Wavefunction sympy.physics.quantum.tensorproduct TensorProduct N/A __all__ N/A qapply qapply N/A N/A e N/A options N/A N/A Apply operators to states in a quantum expression.

    Parameters
    ==========

    e : Expr
        The expression containing operators and states. This expression tree
        will be walked to find operators acting on states symbolically.
    options : dict
        A dict of key/value pairs that determine how the operator actions
        are carried out.

        The following options are valid:

        * ``dagger``: try to apply Dagger operators to the left
          (default: False).
        * ``ip_doit``: call ``.doit()`` in inner products when they are
          encountered (default: True).

    Returns
    =======

    e : Expr
        The original expression, but with the operators applied to states.
     sympy.physics.quantum.density Density N/A dagger N/A N/A options get dagger False N/A N/A e 0 N/A N/A N/A S Zero N/A e N/A N/A e expand commutator True tensorproduct True N/A N/A isinstance e KetBase N/A N/A e N/A N/A N/A isinstance e Add N/A N/A result 0 N/A arg N/A e args N/A N/A result N/A qapply arg options N/A result N/A N/A N/A isinstance e Density N/A N/A new_args N/A N/A N/A qapply state options prob N/A N/A state prob N/A e args N/A N/A Density new_args N/A N/A N/A isinstance e TensorProduct N/A N/A N/A TensorProduct N/A N/A qapply t options N/A t N/A e args N/A N/A N/A isinstance e Pow N/A N/A N/A N/A qapply N/A e base options N/A e exp N/A N/A N/A isinstance e Mul N/A N/A result N/A qapply_Mul e options N/A N/A N/A result e dagger N/A N/A N/A Dagger N/A qapply_Mul N/A Dagger e options N/A N/A result N/A N/A e N/A qapply_Mul N/A N/A e N/A options N/A N/A ip_doit N/A N/A options get ip_doit True N/A args N/A list N/A e args N/A N/A N/A N/A len args 1 N/A N/A isinstance e Mul N/A N/A e N/A rhs N/A N/A args pop N/A lhs N/A N/A args pop N/A N/A N/A N/A N/A sympify rhs is_commutative N/A N/A isinstance rhs Wavefunction N/A N/A N/A sympify lhs is_commutative N/A N/A isinstance lhs Wavefunction N/A N/A e N/A N/A N/A isinstance lhs Pow N/A N/A lhs exp is_Integer N/A N/A N/A N/A args append N/A N/A lhs base N/A N/A lhs exp 1 N/A lhs N/A lhs base N/A N/A isinstance lhs OuterProduct N/A N/A N/A N/A args append N/A lhs ket N/A lhs N/A lhs bra N/A N/A isinstance lhs N/A Commutator AntiCommutator N/A N/A comm N/A N/A lhs doit N/A N/A isinstance comm Add N/A N/A N/A qapply N/A N/A N/A e func N/A args N/A N/A N/A comm args N/A 0 rhs N/A N/A e func N/A args N/A N/A N/A comm args N/A 1 rhs options N/A N/A N/A qapply N/A N/A N/A N/A e func args comm rhs options N/A N/A N/A isinstance lhs TensorProduct N/A all N/A N/A N/A isinstance arg N/A Operator State Mul Pow N/A arg 1 N/A arg N/A lhs args N/A isinstance rhs TensorProduct N/A all N/A N/A N/A isinstance arg N/A Operator State Mul Pow N/A arg 1 N/A arg N/A rhs args N/A N/A len N/A lhs args N/A len N/A rhs args N/A N/A result N/A N/A N/A TensorProduct N/A N/A qapply N/A N/A N/A lhs args N/A n N/A N/A rhs args N/A n options N/A n N/A range N/A len N/A lhs args expand tensorproduct True N/A N/A N/A qapply_Mul N/A N/A e func args options result N/A N/A N/A result N/A N/A lhs _apply_operator rhs options N/A N/A N/A N/A NotImplementedError AttributeError N/A N/A N/A N/A result N/A N/A rhs _apply_operator lhs options N/A N/A N/A N/A NotImplementedError AttributeError N/A N/A N/A N/A isinstance lhs BraBase N/A isinstance rhs KetBase N/A N/A result N/A InnerProduct lhs rhs N/A ip_doit N/A N/A result N/A N/A result doit N/A N/A result None N/A N/A result 0 N/A N/A N/A S Zero N/A N/A N/A result None N/A N/A N/A N/A len args 0 N/A N/A e N/A N/A N/A N/A qapply_Mul N/A N/A e func N/A args N/A lhs options rhs N/A N/A N/A isinstance result InnerProduct N/A N/A N/A result N/A qapply_Mul N/A N/A e func args options N/A N/A N/A qapply N/A N/A N/A e func args result options N/A