# Projective measurement operation in Qiskit

I would like to implement the operation $$\pi = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}$$ on qiskit but I don't know how to do that.

If I use the reset gate, but I use it for example on the first qubit of a Bell state $$|\psi\rangle = \frac{1}{\sqrt 2}(|00\rangle + |11\rangle)$$, then the result will be $$|00\rangle$$ half of the times and $$|01\rangle$$ the other half (randomly). Instead I should obtain always $$|00\rangle$$.

If I use a Swap gate with an auxiliary qubit, my final state will be $$|\psi\rangle = \frac{1}{\sqrt 2}(|00\rangle + |01\rangle)$$ instead of $$|00\rangle$$.

The Bell state is just an example, in general I need to work on an arbitrary state.

Thank you!

• It's not a unitary matrix. Oct 3, 2022 at 11:54

As narip commented, the matrix is not unitary and, therefore, not a valid "gate". Same applies to reset, so "reset gate" sounds a bit like an oxymoron to me.

If you just want to create an operator, you can:

import qiskit.quantum_info as qi
op = qi.Operator([[1, 0],
[0, 0]])


Notice that,

> op.is_unitary()
False

• Yes, I wrote "reset gate" without thinking, my bad. I know my operation is not Unitary. How do I add that operator to the quantum circuit? Obviously by normalizing the quantum state to obtain a valid quantum state. Oct 3, 2022 at 13:02

I have thought of a way to solve this problem.

If I have a QuantumCircuit "qc", I can obtain the quantum state of that circuit by using

statevector = np.array(Statevector(qc))


then I can use numpy.matmul to perform a matrix multiplication between this state and the projector that I want to apply. After that, I just normalized the state dividing it by its norm.

If I have a multi-qubit state and I want to perform the projector only on one qubit, I can use the numpy.kron function to perform the tensor product between the projector and the identity matrix that I want to apply to the other qubits. Be careful in this process, the statevector of Qiskit gives the result using the reverse order of the qubits.

After this, I just need to initialize a new circuit with my projected quantum state

qc = QuantumCircuit(Number_of_qubits)
qc.initialize(list(statevector), qc.qubits)


This kind of operation can be useful to implement quasiprobability decomposition for example.