pprop.gates.controlledrotation module

This submodule defines ControlledRotationGate, the base class for single-parameter controlled rotation gates, and the concrete gates CRX, CRY, and CRZ.

Coefficient encoding

Controlled rotation gates produce factors of the form \(\cos(\theta/2)\), \(\sin(\theta/2)\), \(\cos^2(\theta/2)\), \(\sin^2(\theta/2)\), and \(\sin(\theta/2)\cos(\theta/2)\). Setting \(p\) = parameter, these map directly onto CoeffTerm tuples with repeated indices:

Factor

CoeffTerm multiplier

\(\cos(\theta/2)\)

(1.0, [], [p])

\(\sin(\theta/2)\)

(1.0, [p], [])

\(\cos^2(\theta/2) = (1+\cos\theta)/2\)

(1.0, [], [p, p])

\(\sin^2(\theta/2) = (1-\cos\theta)/2\)

(1.0, [p, p], [])

\(\sin(\theta/2)\cos(\theta/2) = \sin(\theta)/2\)

(1.0, [p], [p])

Warning

Half-angle convention for cos(θ/2) and sin(θ/2) terms.

Rules involving cos(θ/2) or sin(θ/2) (e.g. the "XI", "YI" entries) cannot be represented exactly as CoeffTerm tuples in θ, only in θ/2. To match PennyLane’s output exactly, the user must pass θ/2 as the parameter for any CRX, CRY, or CRZ gate in the ansatz:

# Correct: pass theta/2 so that pprop and PennyLane agree
qml.CRX(params[i] / 2, wires=[0, 1])

# Wrong: pprop will NOT match PennyLane
qml.CRX(params[i], wires=[0, 1])

The (1 \pm \cos\theta)/2 and \sin(\theta)/2 factors (e.g. "IY", "ZZ" entries) are represented exactly in θ and require no rescaling.

class pprop.gates.controlledrotation.CRX(wires, parameter)[source]

Bases: ControlledRotationGate

The controlled-\(R_x\) gate.

\[\begin{split}CR_x(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos(\theta) & -i\sin(\theta) \\ 0 & 0 & -i\sin(\theta) & \cos(\theta) \end{bmatrix}\end{split}\]

Note

The parameter θ here corresponds to θ/2 in PennyLane’s convention. Pass params[i] / 2 to qml.CRX to match.

Parameters:
  • wires (list[int]) – [control, target] qubit indices.

  • parameter (int) – Index of \(\\theta\) in the global parameter vector.

class pprop.gates.controlledrotation.CRY(wires, parameter)[source]

Bases: ControlledRotationGate

The controlled-\(R_y\) gate.

\[\begin{split}CR_y(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos(\theta) & -\sin(\theta) \\ 0 & 0 & \sin(\theta) & \cos(\theta) \end{bmatrix}\end{split}\]

Note

The parameter θ here corresponds to θ/2 in PennyLane’s convention. Pass params[i] / 2 to qml.CRY to match.

Parameters:
  • wires (list[int]) – [control, target] qubit indices.

  • parameter (int) – Index of \(\\theta\) in the global parameter vector.

class pprop.gates.controlledrotation.CRZ(wires, parameter)[source]

Bases: ControlledRotationGate

The controlled-\(R_z\) gate.

\[\begin{split}CR_z(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\theta} & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{bmatrix}\end{split}\]

Note

The parameter θ here corresponds to θ/2 in PennyLane’s convention. Pass params[i] / 2 to qml.CRZ to match.

Parameters:
  • wires (list[int]) – [control, target] qubit indices.

  • parameter (int) – Index of \(\\theta\) in the global parameter vector.

class pprop.gates.controlledrotation.ControlledRotationGate(wires, qml_gate, parameter, rule)[source]

Bases: Gate

Base class for single-parameter two-qubit controlled rotation gates.

Unlike RotationGate, controlled rotations act non-trivially only when the control qubit is in the \(|1\rangle\) state. This produces factors of \(\cos(\theta/2)\), \(\sin(\theta/2)\), and their squares, each encoded as a CoeffTerm with repeated parameter entries (see module docstring for the full table).

Each rule entry maps a two-character Pauli string "PQ" (control ⊗ target) to a list of (output_label, multiplier) pairs, where multiplier is a CoeffTerm with -1 as a placeholder for parameter.

Parameters:
  • wires (list[int]) – [control, target] qubit indices.

  • qml_gate (pennylane.operation.Operation) – Corresponding PennyLane gate class.

  • parameter (int, float) – Index of \(\theta\) in the global parameter vector if int. Actual value of the rotation if float.

  • rule (EvolutionRule) – Heisenberg evolution rule dict.

rule

The evolution rule for this gate.

Type:

EvolutionRule

evolve(word, k1, k2)[source]

Heisenberg-evolve a Pauli word through this controlled rotation gate.

For each matching rule entry the existing CoeffTerms are scaled by the rule’s multiplier: the multiplier’s sin_idx and cos_idx (which use -1 as a placeholder) are substituted with self.parameter and then appended to every existing term’s index lists.

The weight cutoff k1 is checked on the output Pauli word. The frequency cutoff k2 is checked on each existing term before appending new trig factors.

Parameters:
  • word (tuple[PauliOp, CoeffTerms]) – (pauliop, coeff_terms) pair to evolve.

  • k1 (int or None) – Pauli weight cutoff.

  • k2 (int or None) – Frequency cutoff.

Returns:

Evolved Pauli words with updated CoeffTerms.

Return type:

PauliDict