def default_decompose(self, qubits: Sequence[raw_types.QubitId]
                       ) -> op_tree.OP_TREE:
     q0, q1 = qubits
     right_gate0 = CliffordGate.from_single_map(
                                 z_to=(self.pauli0, self.invert0))
     right_gate1 = CliffordGate.from_single_map(
                                 z_to=(self.pauli1, self.invert1))
     left_gate0 = right_gate0.inverse()
     left_gate1 = right_gate1.inverse()
     yield left_gate0(q0)
     yield left_gate1(q1)
     yield common_gates.Rot11Gate(half_turns=self._exponent)(q0, q1)
     yield right_gate0(q0)
     yield right_gate1(q1)
Beispiel #2
0
 def default_decompose(self, qubits: Sequence[raw_types.QubitId]
                       ) -> op_tree.OP_TREE:
     q0, q1 = qubits
     right_gate0 = CliffordGate.from_single_map(
                                 z_to=(self.pauli0, self.invert0))
     right_gate1 = CliffordGate.from_single_map(
                                 z_to=(self.pauli1, self.invert1))
     left_gate0 = right_gate0.inverse()
     left_gate1 = right_gate1.inverse()
     yield left_gate0(q0)
     yield left_gate1(q1)
     yield common_gates.Rot11Gate(half_turns=self._exponent)(q0, q1)
     yield right_gate0(q0)
     yield right_gate1(q1)
Beispiel #3
0
def pauli_string_to_z_ops(
        pauli_string: PauliString) -> Iterable[ops.Operation]:
    """Yields the single qubit operations to apply before a Pauli string of Zs
    (and apply the inverse of these operations after) to make it equivalent to
    the given pauli_string."""
    for qubit, pauli in pauli_string.items():
        yield CliffordGate.from_single_map({pauli: (Pauli.Z, False)})(qubit)
Beispiel #4
0
 def to_z_basis_ops(self) -> op_tree.OP_TREE:
     """Returns operations to convert the qubits to the computational basis.
     """
     for qubit, pauli in self.items():
         yield CliffordGate.from_single_map({pauli: (Pauli.Z, False)})(qubit)