general_merger
compose_bloch_sphere_rotations(a, b)
Computes the Bloch sphere rotation resulting from the composition of two Bloch sphere rotations.
The first rotation is applied and then the second.
The resulting gate is anonymous except if a
is the identity and b
is not anonymous, or vice versa.
Uses Rodrigues' rotation formula, see for instance https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula.
Source code in opensquirrel\merger\general_merger.py
merge_single_qubit_gates(circuit)
Merge all consecutive 1-qubit gates in the circuit.
Gates obtained from merging other gates become anonymous gates.
Source code in opensquirrel\merger\general_merger.py
try_name_anonymous_bloch(bsr)
Try converting a given BlochSphereRotation to a default BlochSphereRotation. It does that by checking if the input BlochSphereRotation is close to a default BlochSphereRotation.
Notice we don't try to match Rx, Ry, and Rz rotations, as those gates use an extra angle parameter.
Returns:
Type | Description |
---|---|
BlochSphereRotation
|
A default BlockSphereRotation if this BlochSphereRotation is close to it, |
BlochSphereRotation
|
or the input BlochSphereRotation otherwise. |