cirq.merge_single_qubit_gates_to_phxz_symbolized
Merges consecutive single qubit gates as PhasedXZ Gates.
cirq.merge_single_qubit_gates_to_phxz_symbolized(
circuit: cirq.AbstractCircuit,
*,
context: (cirq.TransformerContext | None) = None,
sweep: Sweep,
atol: float = 1e-08
) -> tuple[cirq.Circuit, Sweep]
Symbolizes if any of
the consecutive gates is symbolized.
Example |
>>> q0, q1 = cirq.LineQubit.range(2)
>>> c = cirq.Circuit( cirq.X(q0), cirq.CZ(q0,q1)**sympy.Symbol("cz_exp"), cirq.Y(q0)**sympy.Symbol("y_exp"), cirq.X(q0))
>>> print(c)
</td>
</tr>
<tr>
<td>
`0`<a id="0"></a>
</td>
<td>
───X───@──────────Y^y_exp───X───
│
</td>
</tr><tr>
<td>
`1`<a id="1"></a>
</td>
<td>
───────@^cz_exp─────────────────
>>> new_circuit, new_sweep = cirq.merge_single_qubit_gates_to_phxz_symbolized( c, sweep=cirq.Zip(cirq.Points(key="cz_exp", points=[0, 1]), cirq.Points(key="y_exp", points=[0, 1])))
>>> print(new_circuit)
</td>
</tr><tr>
<td>
`0`<a id="0"></a>
</td>
<td>
───PhXZ(a=-1,x=1,z=0)───@──────────PhXZ(a=a0,x=x0,z=z0)───
│
</td>
</tr><tr>
<td>
`1`<a id="1"></a>
</td>
<td>
────────────────────────@^cz_exp──────────────────────────
>>> assert new_sweep[0] == cirq.ParamResolver({'a0': -1, 'x0': 1, 'z0': 0, 'cz_exp': 0})
>>> assert new_sweep[1] == cirq.ParamResolver({'a0': -0.5, 'x0': 0, 'z0': -1, 'cz_exp': 1})
|
Args |
circuit
|
Input circuit to transform. It will not be modified.
|
context
|
cirq.TransformerContext storing common configurable options for transformers.
|
sweep
|
Sweep of the symbols in the input circuit. An updated Sweep will be returned
based on the transformation.
|
atol
|
Absolute tolerance to angle error. Larger values allow more negligible gates to be
dropped, smaller values increase accuracy.
|
Returns |
Copy of the transformed input circuit.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-23 UTC."],[],[]]