Ancilla-assisted Pauli measurement (source code)

= Ancilla-assisted Pauli measurement

Prepare an ancilla in $|+\rangle$, use it to control a Hermitian Pauli operator $P$, apply a Hadamard gate, and measure the ancilla. Outcome $s$ applies the projector $[I+(-1)^sP]/2$ to the data register.