def _decompose_two_qubit_operation(self, op: 'cirq.Operation', _) -> 'cirq.OP_TREE': if not protocols.has_unitary(op): return NotImplemented return two_qubit_to_cz.two_qubit_matrix_to_cz_operations( op.qubits[0], op.qubits[1], protocols.unitary(op), allow_partial_czs=self.allow_partial_czs, atol=self.atol, )
def _decompose_two_qubit_unitaries(self, op: ops.Operation) -> ops.OP_TREE: # Known matrix? if len(op.qubits) == 2: mat = protocols.unitary(op, None) if mat is not None: return two_qubit_to_cz.two_qubit_matrix_to_cz_operations( op.qubits[0], op.qubits[1], mat, allow_partial_czs=self.allow_partial_czs) return NotImplemented
def _two_qubit_matrix_to_cz_operations( self, q0: 'cirq.Qid', q1: 'cirq.Qid', mat: np.ndarray) -> Sequence['cirq.Operation']: """Decomposes the merged two-qubit gate unitary into the minimum number of CZ gates. Args: q0: The first qubit being operated on. q1: The other qubit being operated on. mat: Defines the operation to apply to the pair of qubits. Returns: A list of operations implementing the matrix. """ return two_qubit_to_cz.two_qubit_matrix_to_cz_operations( q0, q1, mat, self.allow_partial_czs, self.tolerance, False)