Esempio n. 1
0
 def _value_equality_values_(self):
     if self.phase_exponent == 0:
         return common_gates.XPowGate(
             exponent=self._exponent,
             global_shift=self._global_shift)._value_equality_values_()
     if self.phase_exponent == 0.5:
         return common_gates.YPowGate(
             exponent=self._exponent,
             global_shift=self._global_shift)._value_equality_values_()
     return self.phase_exponent, self._canonical_exponent, self._global_shift
def _strat_act_on_clifford_tableau_from_single_qubit_decompose(
    val: Any, args: 'cirq.ActOnCliffordTableauArgs', qubits: Sequence['cirq.Qid']
) -> bool:
    if num_qubits(val) == 1:
        if not has_unitary(val):
            return NotImplemented
        u = unitary(val)
        clifford_gate = SingleQubitCliffordGate.from_unitary(u)
        if clifford_gate is not None:
            for axis, quarter_turns in clifford_gate.decompose_rotation():
                if axis == pauli_gates.X:
                    common_gates.XPowGate(exponent=quarter_turns / 2)._act_on_(args, qubits)
                elif axis == pauli_gates.Y:
                    common_gates.YPowGate(exponent=quarter_turns / 2)._act_on_(args, qubits)
                else:
                    assert axis == pauli_gates.Z
                    common_gates.ZPowGate(exponent=quarter_turns / 2)._act_on_(args, qubits)
            return True

    return NotImplemented
Esempio n. 3
0
 def __pow__(self: '_PauliY',
             exponent: 'cirq.TParamVal') -> common_gates.YPowGate:
     return common_gates.YPowGate(
         exponent=exponent) if exponent != 1 else _PauliY()
Esempio n. 4
0
 def __pow__(self: '_PauliY',
             exponent: value.TParamVal) -> common_gates.YPowGate:
     return common_gates.YPowGate(exponent=exponent)
Esempio n. 5
0
 def _decompose_(self, qubits: Tuple['cirq.Qid', ...]) -> 'cirq.OP_TREE':
     yield common_gates.YPowGate(exponent=-0.5).on_each(*qubits)
     yield ZZPowGate(exponent=self.exponent, global_shift=self.global_shift)(*qubits)
     yield common_gates.YPowGate(exponent=0.5).on_each(*qubits)
Esempio n. 6
0
 def __pow__(self: '_PauliY',
             exponent: Union[sympy.Basic, float]) -> common_gates.YPowGate:
     return common_gates.YPowGate(exponent=exponent)