Ejemplo n.º 1
0
 def _apply_unitary_(self, args: 'protocols.ApplyUnitaryArgs'):
     if not self._has_unitary_():
         return None
     if self.coefficient != 1:
         args.target_tensor *= self.coefficient
     return protocols.apply_unitaries([self[q].on(q) for q in self.qubits],
                                      self.qubits, args)
Ejemplo n.º 2
0
 def _apply_unitary_(self, args):
     if not self._has_unitary_():
         return NotImplemented
     from cirq import devices
     qubits = devices.LineQubit.range(len(self))
     return protocols.apply_unitaries(self._decompose_(qubits), qubits,
                                      args)
Ejemplo n.º 3
0
 def _apply_unitary_(self, args: 'protocols.ApplyUnitaryArgs'
                    ) -> Union[np.ndarray, None, NotImplementedType]:
     """Replicates the logic the simulators use to apply the equivalent
        sequence of GateOperations
     """
     if not protocols.has_unitary(self.gate):
         return NotImplemented
     return protocols.apply_unitaries((self.gate.on(q) for q in self.qubits),
                                      self.qubits, args)