The Uniform Rotation

This module implements the uniform rotation gate defined by Möttönen et. al. (10.1103/PhysRevLett.93.130502). There are many convenience functions also being monkey patched.

dc_qiskit_algorithms.UniformRotation.binary_codes(number_qubits)[source]

Convenience function to get a list of numbers from 0 to 2**number_qubits - 1

Parameters

number_qubits (int) – exponent

Return type

List[int]

Returns

list of numbers

dc_qiskit_algorithms.UniformRotation.gray_code(number)[source]

Cyclic Gray Code of number

Parameters

number (int) – input number

Return type

int

Returns

Gray Code

dc_qiskit_algorithms.UniformRotation.matrix_M_entry(row, col)[source]

The matrix for the angle computation

Parameters
  • row (int) – row number (one based!)

  • col (int) – column number (one based!)

Return type

float

Returns

matrix entry

dc_qiskit_algorithms.UniformRotation.compute_theta(alpha)[source]

Compute the rotational angles from alpha

Parameters

alpha (dok_matrix) – the input uniform rotation angles

Return type

dok_matrix

Returns

the single qubit rotation angles

dc_qiskit_algorithms.UniformRotation.pairwise(iterable)[source]

Calculates pairwise consecutive pairs of an iterable s -> (s0,s1), (s1,s2), (s2, s3), …

Parameters

iterable (Iterable) – any iterable

Return type

Iterable[Tuple]

Returns

an iterable of tuples

class dc_qiskit_algorithms.UniformRotation.UniformRotationGate(gate, alpha)[source]

Bases: qiskit.circuit.gate.Gate

Uniform rotation gate (Möttönen).

dc_qiskit_algorithms.UniformRotation.uni_rot(self, rotation_gate, alpha, control_qubits, tgt)[source]

Apply a generic uniform rotation with rotation gate.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • rotation_gate (Callable[[float], Gate]) – A single qubit rotation gate

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.uni_rot_dg(self, rotation_gate, alpha, control_qubits, tgt)[source]

Apply the dagger (inverse) of a generic uniform rotation with rotation gate.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • rotation_gate (Callable[[float], Gate]) – A single qubit rotation gate

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.unirz(self, alpha, control_qubits, tgt)[source]

Apply a uniform rotation around z.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.unirz_dg(self, alpha, control_qubits, tgt)[source]

Apply dagger (inverse) of a uniform rotation around z.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.uniry(self, alpha, control_qubits, tgt)[source]

Apply a uniform rotation around y.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.uniry_dg(self, alpha, control_qubits, tgt)[source]

Apply the dagger (inverse) of a uniform rotation around y.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • alpha (Union[List[float], dok_matrix]) – conditional rotation angles

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.cnry(self, theta, control_qubits, tgt)[source]

Apply a multiple controlled y rotation on the target qubit.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • theta (float) – rotation angle

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.cnry_dg(self, theta, control_qubits, tgt)[source]

Apply the dagger (inverse) of a multiple controlled y rotation on the target qubit.

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • theta (float) – rotation angle

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

class dc_qiskit_algorithms.UniformRotation.MultiControlledXGate(conditional_case, control_qubits)[source]

Bases: qiskit.circuit.gate.Gate

Multi-Controlled X-Gate (via Möttönen).

dc_qiskit_algorithms.UniformRotation.ccx_uni_rot(self, conditional_case, control_qubits, tgt)[source]

Apply a multi-controlled X gate depending on conditional binary representation

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • conditional_case (int) – the controlled case (1 or 0) in binary

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit

dc_qiskit_algorithms.UniformRotation.ccx_uni_rot_dg(self, conditional_case, control_qubits, tgt)[source]

Apply the dagger (inverse) a multi-controlled X gate depending on conditional binary representation

Parameters
  • self (QuantumCircuit) – either a composite gate or a circuit

  • conditional_case (int) – the controlled case (1 or 0) in binary

  • control_qubits (Union[List[Qubit], QuantumRegister]) – control qubits

  • tgt (Union[Qubit, QuantumRegister]) – target

Return type

Instruction

Returns

applied composite gate or circuit