Thanks! "Integer(1)" worked as expected. But can you please tell me why "Qubit(0)*Dagger(Qubit(0))+Qubit(1)*Dagger(Qubit(1))" does not work as the identity operator?
from sympy import * from sympy.physics.quantum import * from sympy.physics.quantum.qubit import * state = TensorProduct(Qubit(0),Qubit(1)) # example state id1 = Integer(1) # identity op. type 1 id2 = Qubit(0)*Dagger(Qubit(0))+Qubit(1)*Dagger(Qubit(1)) # identity op. type 2 proj1 = TensorProduct(id1, Qubit(1)*Dagger(Qubit(1))) # projection op which affect only the second Hilbert space proj2 = TensorProduct(id2, Qubit(1)*Dagger(Qubit(1))) # apply operator on the state print "1)" print qapply(tensor_product_simp(proj1*state)) # this works print "2)" print qapply(tensor_product_simp(proj2*state)) # this gives an error # AttributeError: 'int' object has no attribute 'is_commutative' Regards, vug -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
