mimiqcircuits.decomposition.rules.zyz

ZYZ Euler angle decomposition rewrite rule.

Classes

ZYZRewrite()

Rewrite rule for the ZYZ Euler decomposition of single-qubit gates.

class ZYZRewrite[source]

Bases: RewriteRule

Rewrite rule for the ZYZ Euler decomposition of single-qubit gates.

Writes a single-qubit gate as Z and Y rotations, the Euler form \(R_Z(\phi) R_Y(\theta) R_Z(\lambda)\).

Supported Operations

  • GateU(theta, phi, lambda, gamma), except the identity (all of theta, phi and lambda zero), to RZ(lambda), RY(theta), RZ(phi) in circuit order, followed by GateU(0, 0, 0, gamma) for the phase gamma. Rotations by a zero angle are left out. The result equals the gate up to a global phase.

  • GateRX(theta) to S, RY(theta), S† in circuit order, which is exact.

Examples

>>> from mimiqcircuits import *
>>> from symengine import pi
>>> rule = ZYZRewrite()
>>> # the Euler angles of GateU become Z and Y rotations
>>> rule.decompose_step(GateU(pi/2, pi/4, pi/3), [0], [], [])
1-qubit circuit with 3 instructions:
├── RZ((1/3)*pi) @ q[0]
├── RY((1/2)*pi) @ q[0]
└── RZ((1/4)*pi) @ q[0]
matches(op)[source]

Check whether an operation is a GateU or GateRX.

A GateU whose theta, phi and lambda are all zero is not matched, since it is only a phase.

Parameters:

op (Operation) – The operation to check.

Returns:

True for GateRX and for a non-identity GateU.

Return type:

bool

decompose_step(op, qubits, bits, zvars)[source]

Rewrite a GateU or GateRX as Z and Y rotations.

Parameters:
  • op (Operation) – The GateU or GateRX to rewrite.

  • qubits (Sequence[int]) – Qubit index the gate acts on.

  • bits (Sequence[int]) – Classical bit indices (unused).

  • zvars (Sequence[int]) – Z-variable indices (unused).

Returns:

A new Circuit with the rewrite.

Raises:

DecompositionError – If matches() rejects op.

Return type:

Circuit