![]() |
General excitation-preserving two-qubit gate.
Inherits From: InterchangeableQubitsGate
, Gate
cirq.PhasedFSimGate(
theta: 'cirq.TParamVal',
zeta: 'cirq.TParamVal' = 0.0,
chi: 'cirq.TParamVal' = 0.0,
gamma: 'cirq.TParamVal' = 0.0,
phi: 'cirq.TParamVal' = 0.0
) -> None
Used in the notebooks
Used in the tutorials |
---|
The unitary matrix of PhasedFSimGate(θ, ζ, χ, γ, φ) is:
[[1, 0, 0, 0],
[0, exp(-iγ - iζ) cos(θ), -i exp(-iγ + iχ) sin(θ), 0],
[0, -i exp(-iγ - iχ) sin(θ), exp(-iγ + iζ) cos(θ), 0],
[0, 0, 0, exp(-2iγ-iφ)]].
This parametrization follows eq (18) in https://arxiv.org/abs/2010.07965 See also eq (43) in https://arxiv.org/abs/1910.11333 for an older variant which uses the same θ and φ parameters, but its three phase angles have different names and opposite sign. Specifically, ∆+ angle corresponds to -γ, ∆- corresponds to -ζ and ∆-,off corresponds to -χ.
Another useful parametrization of PhasedFSimGate is based on the fact that the gate is equivalent up to global phase to the following circuit:
0: ───Rz(α0)───FSim(θ, φ)───Rz(β0)───
│
1: ───Rz(α1)───FSim(θ, φ)───Rz(β1)───
where α0 and α1 are Rz angles to be applied before the core FSimGate, β0 and β1 are Rz angles to be applied after FSimGate and θ and φ specify the core FSimGate. Use the static factory function from_fsim_rz to instantiate the gate using this parametrization.
Note that the θ and φ parameters in the two parametrizations are the same.
The matrix above is block diagonal where the middle block may be any element of U(2) and the bottom right block may be any element of U(1). Consequently, five real parameters are required to specify an instance of PhasedFSimGate. Therefore, the second parametrization is not injective. Indeed, for any angle δ
cirq.PhasedFSimGate.from_fsim_rz(θ, φ, (α0, α1), (β0, β1))
and
cirq.PhasedFSimGate.from_fsim_rz(θ, φ,
(α0 + δ, α1 + δ),
(β0 - δ, β1 - δ))
specify the same gate and therefore the two instances will compare as equal up to numerical error. Another consequence of the non-injective character of the second parametrization is the fact that the properties rz_angles_before and rz_angles_after may return different Rz angles than the ones used in the call to from_fsim_rz.
This gate is generally not symmetric under exchange of qubits. It becomes symmetric if both of the following conditions are satisfied:
- ζ = kπ or θ = π/2 + lπ for k and l integers,
- χ = kπ or θ = lπ for k and l integers.
Args | |
---|---|
theta
|
Swap angle on the |01⟩ |10⟩ subspace, in radians.
See class docstring above for details.
|
zeta
|
One of the phase angles, in radians. See class docstring above for details. |
chi
|
One of the phase angles, in radians. See class docstring above for details. |
gamma
|
One of the phase angles, in radians. See class docstring above for details. |
phi
|
Controlled phase angle, in radians. See class docstring above for details. |
Attributes | |
---|---|
chi
|
|
gamma
|
|
phi
|
|
rz_angles_after
|
Returns 2-tuple of phase angles applied to qubits after FSimGate. |
rz_angles_before
|
Returns 2-tuple of phase angles applied to qubits before FSimGate. |
theta
|
|
zeta
|
Methods
controlled
controlled(
num_controls: int = None,
control_values: Optional[Sequence[Union[int, Collection[int]]]] = None,
control_qid_shape: Optional[Tuple[int, ...]] = None
) -> 'Gate'
Returns a controlled version of this gate. If no arguments are specified, defaults to a single qubit control.
num_controls: Total number of control qubits.
control_values: For which control qubit values to apply the sub
gate. A sequence of length num_controls
where each
entry is an integer (or set of integers) corresponding to the
qubit value (or set of possible values) where that control is
enabled. When all controls are enabled, the sub gate is
applied. If unspecified, control values default to 1.
control_qid_shape: The qid shape of the controls. A tuple of the
expected dimension of each control qid. Defaults to
(2,) * num_controls
. Specify this argument when using qudits.
from_fsim_rz
@staticmethod
from_fsim_rz( theta: 'cirq.TParamVal', phi: 'cirq.TParamVal', rz_angles_before: Tuple['cirq.TParamVal', 'cirq.TParamVal'], rz_angles_after: Tuple['cirq.TParamVal', 'cirq.TParamVal'] ) -> 'PhasedFSimGate'
Creates PhasedFSimGate using an alternate parametrization.
Args | |
---|---|
theta
|
Swap angle on the |01⟩ |10⟩ subspace, in radians.
See class docstring above for details.
|
phi
|
Controlled phase angle, in radians. See class docstring above for details. |
rz_angles_before
|
2-tuple of phase angles to apply to each qubit before the core FSimGate. See class docstring for details. |
rz_angles_after
|
2-tuple of phase angles to apply to each qubit after the core FSimGate. See class docstring for details. |
num_qubits
num_qubits() -> int
The number of qubits this gate acts on.
on
on(
*qubits
) -> 'Operation'
Returns an application of this gate to the given qubits.
Args | |
---|---|
*qubits
|
The collection of qubits to potentially apply the gate to. |
on_each
on_each(
*targets
) -> List['cirq.Operation']
Returns a list of operations applying the gate to all targets.
Args | |
---|---|
*targets
|
The qubits to apply this gate to. For single-qubit gates
this can be provided as varargs or a combination of nested
iterables. For multi-qubit gates this must be provided as an
Iterable[Sequence[Qid]] , where each sequence has num_qubits
qubits.
|
Returns | |
---|---|
Operations applying this gate to the target qubits. |
Raises | |
---|---|
ValueError
|
If targets are not instances of Qid or Iterable[Qid]. If the gate qubit number is incompatible. |
TypeError
|
If a single target is supplied and it is not iterable. |
qubit_index_to_equivalence_group_key
qubit_index_to_equivalence_group_key(
index: int
) -> int
Returns a key that differs between non-interchangeable qubits.
validate_args
validate_args(
qubits: Sequence['cirq.Qid']
) -> None
Checks if this gate can be applied to the given qubits.
By default checks that:
- inputs are of type
Qid
- len(qubits) == num_qubits()
- qubit_i.dimension == qid_shape[i] for all qubits
Child classes can override. The child implementation should call
super().validate_args(qubits)
then do custom checks.
Args | |
---|---|
qubits
|
The sequence of qubits to potentially apply the gate to. |
Throws:
ValueError
: The gate can't be applied to the qubits.
with_probability
with_probability(
probability: 'cirq.TParamVal'
) -> 'cirq.Gate'
wrap_in_linear_combination
wrap_in_linear_combination(
coefficient: Union[complex, float, int] = 1
) -> 'cirq.LinearCombinationOfGates'
__add__
__add__(
other: Union['Gate', 'cirq.LinearCombinationOfGates']
) -> 'cirq.LinearCombinationOfGates'
__call__
__call__(
*args, **kwargs
)
Call self as a function.
__eq__
__eq__(
other: _SupportsValueEquality
) -> bool
__mul__
__mul__(
other: Union[complex, float, int]
) -> 'cirq.LinearCombinationOfGates'
__neg__
__neg__() -> 'cirq.LinearCombinationOfGates'
__pow__
__pow__(
power
)
__rmul__
__rmul__(
other: Union[complex, float, int]
) -> 'cirq.LinearCombinationOfGates'
__sub__
__sub__(
other: Union['Gate', 'cirq.LinearCombinationOfGates']
) -> 'cirq.LinearCombinationOfGates'
__truediv__
__truediv__(
other: Union[complex, float, int]
) -> 'cirq.LinearCombinationOfGates'