I am looking for a way to implement a projection operator like $\mid +\rangle\langle+\mid$ in qiskits opflow module. I tried
Plus @ ~Plus but this gives me an error message. There must be a direct implementation of projection operators right? I can't use the operators in
qiskit.quantum_info for what I want to do, except if there is a way to convert those operators to the ones in opflow.
The error message I get from
ValueError: Composition with a Statefunctions in the first operand is not defined.
The reason I think I can't use
qiskit.quantum_info's opearotors it that I want to compute the spectrum using
qiskit.algorithms.NumPyEigensolver and this seems to me to not work with a
>>>plus = Statevector([1/np.sqrt(2),1/np.sqrt(2)]).to_operator() >>>plus Operator([[0.5+0.j, 0.5+0.j], [0.5+0.j, 0.5+0.j]], input_dims=(2,), output_dims=(2,)) >>>solver = NumPyEigensolver() >>>spectrum = solver.compute_eigenvalues(plus) AttributeError: 'Operator' object has no attribute 'to_spmatrix'
I am generally confused about the connection and difference between
qiskit.opflow because they seem to me to have a large overlap. Is one of those an older module and should not be used anymore? Is there a general way to convert objects like operators from one to the other?