qoqo.operations

Operations are the atomic instructions in any quantum program that can be represented by qoqo.

Operations can be of various kinds: Definitions, GateOperations, PRAGMAs or measurement Operations.

Operations:

Definition operations define the classical registers and variables in the Circuit. GateOperations are single-, two- or multi-qubit gate operations that act on a set of qubits and can be executed on a quantum computing device. PRAGMAs are operations that can be used when running a simulation of a quantum computing program. Measurement Operations are operations that perform a measurement either on a quantum computing device (MeasuareQubit) or on a simulation of a quantum computing program (PRAGMA measurement operations).

SingleQubitGate

The general single qubit unitary gate.

RotateZ

The ZPower gate \(e^{-i \frac{\theta}{2} \sigma^z}\).

RotateY

The YPower gate \(e^{-i \frac{\theta}{2} \sigma^y}\).

RotateX

The XPower gate \(e^{-i \frac{\theta}{2} \sigma^x}\).

RotateAroundSphericalAxis

Implements a rotation around an axis in the x-y plane in spherical coordinates.

PauliZ

The Pauli Z gate.

PauliY

The Pauli Y gate.

PauliX

The Pauli X gate.

SqrtPauliX

The square root of the XPower gate \(e^{-i \frac{\pi}{4} \sigma^x}\).

InvSqrtPauliX

The inverse square root XPower gate \(e^{i \frac{\pi}{2} \sigma^x}\).

Hadamard

The Hadamard gate.

TGate

The T gate.

SGate

The S gate.

DefinitionUsize

DefinitionUsize is the Definition for an Integer type register.

DefinitionBit

DefinitionBit is the Definition for a Bit type register.

DefinitionFloat

DefinitionFloat is the Definition for a Float type register.

DefinitionComplex

DefinitionComplex is the Definition for a Complex type register.

InputSymbolic

InputSymbolic is the Definition for a Float which will replace a certain symbolic parameter.

InputSymbolic

InputSymbolic is the Definition for a Float which will replace a certain symbolic parameter.

MeasureQubit

Measurement gate operation.

PragmaGetStateVector

This PRAGMA measurement operation returns the statevector of a quantum register.

PragmaGetDensityMatrix

This PRAGMA measurement operation returns the density matrix of a quantum register.

PragmaGetOccupationProbability

This PRAGMA measurement operation returns the vector of the occupation probabilities.

PragmaGetPauliProduct

This PRAGMA measurement operation returns a Pauli product expectation value.

PragmaRepeatedMeasurement

This PRAGMA measurement operation returns a measurement record for N repeated measurements.

PragmaSetNumberOfMeasurements

Wrap function automatically generates functions in these traits.

PragmaSetStateVector

This PRAGMA operation sets the statevector of a quantum register.

PragmaSetDensityMatrix

This PRAGMA operation sets the density matrix of a quantum register.

PragmaRepeatGate

The repeated gate PRAGMA operation.

PragmaOverrotation

The statistical overrotation PRAGMA operation.

PragmaBoostNoise

This PRAGMA operation boosts noise and overrotations in the circuit.

PragmaStopParallelBlock

This PRAGMA operation signals the STOP of a parallel execution block.

PragmaGlobalPhase

The global phase PRAGMA operation.

PragmaSleep

This PRAGMA operation makes the quantum hardware wait a given amount of time.

PragmaActiveReset

This PRAGMA operation resets the chosen qubit to the zero state.

PragmaStopDecompositionBlock

This PRAGMA operation signals the STOP of a decomposition block.

PragmaDamping

The damping PRAGMA noise operation.

PragmaDepolarising

The depolarising PRAGMA noise operation.

PragmaDephasing

The dephasing PRAGMA noise operation.

PragmaRandomNoise

The random noise PRAGMA operation.

PragmaGeneralNoise

The general noise PRAGMA operation.

PragmaConditional

The conditional PRAGMA operation.

PragmaLoop

This PRAGMA measurement operation returns the statevector of a quantum register.

CNOT

The controlled NOT quantum operation.

SWAP

The controlled SWAP quantum operation.

FSwap

The controlled fermionic SWAP gate.

ISwap

The controlled ISwap quantum operation.

SqrtISwap

The controlled square root ISwap quantum operation.

InvSqrtISwap

The controlled inverse square root ISwap quantum operation.

XY

The controlled XY quantum operation

ControlledPhaseShift

The controlled-PhaseShift quantum operation.

ControlledPauliY

The controlled PauliY quantum operation

ControlledPauliZ

The controlled PauliZ quantum operation

ControlledRotateX

Implements the controlled RotateX operation.

ControlledRotateXY

Implements the controlled RotateXY operation.

ControlledControlledPauliZ

Implements the double-controlled PauliZ gate.

ControlledControlledPhaseShift

Implements the double-controlled PhaseShift gate.

Toffoli

Implements Toffoli gate.

MolmerSorensenXX

The fixed phase MolmerSorensen XX gate.

VariableMSXX

The variable-angle MolmerSorensen XX gate.

GivensRotation

The Givens rotation interaction gate in big endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

GivensRotationLittleEndian

The Givens rotation interaction gate in little endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

Qsim

The qubit simulation (Qsim) gate.

Fsim

The fermionic qubit simulation (Fsim) gate.

SpinInteraction

The generalized, anisotropic XYZ Heisenberg interaction between spins.

Bogoliubov

The Bogoliubov DeGennes interaction gate.

PMInteraction

The transversal interaction gate.

ComplexPMInteraction

The complex hopping gate.

MultiQubitMS

The Molmer-Sorensen gate between multiple qubits.

Classes

Bogoliubov

The Bogoliubov DeGennes interaction gate.

CNOT

The controlled NOT quantum operation.

ComplexPMInteraction

The complex hopping gate.

ControlledControlledPauliZ

Implements the double-controlled PauliZ gate.

ControlledControlledPhaseShift

Implements the double-controlled PhaseShift gate.

ControlledPauliY

The controlled PauliY quantum operation

ControlledPauliZ

The controlled PauliZ quantum operation

ControlledPhaseShift

The controlled-PhaseShift quantum operation.

ControlledRotateX

Implements the controlled RotateX operation.

ControlledRotateXY

Implements the controlled RotateXY operation.

DefinitionBit

DefinitionBit is the Definition for a Bit type register.

DefinitionComplex

DefinitionComplex is the Definition for a Complex type register.

DefinitionFloat

DefinitionFloat is the Definition for a Float type register.

DefinitionUsize

DefinitionUsize is the Definition for an Integer type register.

FSwap

The controlled fermionic SWAP gate.

Fsim

The fermionic qubit simulation (Fsim) gate.

GivensRotation

The Givens rotation interaction gate in big endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

GivensRotationLittleEndian

The Givens rotation interaction gate in little endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

Hadamard

The Hadamard gate.

ISwap

The controlled ISwap quantum operation.

InputBit

InputBit sets a certain bit in an existing BitRegister of the circuit.

InputSymbolic

InputSymbolic is the Definition for a Float which will replace a certain symbolic parameter.

InvSqrtISwap

The controlled inverse square root ISwap quantum operation.

InvSqrtPauliX

The inverse square root XPower gate \(e^{i \frac{\pi}{2} \sigma^x}\).

MeasureQubit

Measurement gate operation.

MolmerSorensenXX

The fixed phase MolmerSorensen XX gate.

MultiQubitMS

The Molmer-Sorensen gate between multiple qubits.

MultiQubitZZ

The multi qubit Pauli-Z-Product gate.

PMInteraction

The transversal interaction gate.

PauliX

The Pauli X gate.

PauliY

The Pauli Y gate.

PauliZ

The Pauli Z gate.

PhaseShiftState0

The phase shift gate applied on state |0>.

PhaseShiftState1

The phase shift gate applied on state |1>.

PhaseShiftedControlledPhase

Implements the phase-shifted controlled PhaseShift gate.

PhaseShiftedControlledZ

The phased-shifted controlled-Z gate.

PragmaActiveReset

This PRAGMA operation resets the chosen qubit to the zero state.

PragmaBoostNoise

This PRAGMA operation boosts noise and overrotations in the circuit.

PragmaChangeDevice

A wrapper around backend specific PRAGMA operations capable of changing a device.

PragmaConditional

The conditional PRAGMA operation.

PragmaDamping

The damping PRAGMA noise operation.

PragmaDephasing

The dephasing PRAGMA noise operation.

PragmaDepolarising

The depolarising PRAGMA noise operation.

PragmaGeneralNoise

The general noise PRAGMA operation.

PragmaGetDensityMatrix

This PRAGMA measurement operation returns the density matrix of a quantum register.

PragmaGetOccupationProbability

This PRAGMA measurement operation returns the vector of the occupation probabilities.

PragmaGetPauliProduct

This PRAGMA measurement operation returns a Pauli product expectation value.

PragmaGetStateVector

This PRAGMA measurement operation returns the statevector of a quantum register.

PragmaGlobalPhase

The global phase PRAGMA operation.

PragmaLoop

This PRAGMA measurement operation returns the statevector of a quantum register.

PragmaOverrotation

The statistical overrotation PRAGMA operation.

PragmaRandomNoise

The random noise PRAGMA operation.

PragmaRepeatGate

The repeated gate PRAGMA operation.

PragmaRepeatedMeasurement

This PRAGMA measurement operation returns a measurement record for N repeated measurements.

PragmaSetDensityMatrix

This PRAGMA operation sets the density matrix of a quantum register.

PragmaSetNumberOfMeasurements

Wrap function automatically generates functions in these traits.

PragmaSetStateVector

This PRAGMA operation sets the statevector of a quantum register.

PragmaSleep

This PRAGMA operation makes the quantum hardware wait a given amount of time.

PragmaStartDecompositionBlock

This PRAGMA operation signals the START of a decomposition block.

PragmaStopDecompositionBlock

This PRAGMA operation signals the STOP of a decomposition block.

PragmaStopParallelBlock

This PRAGMA operation signals the STOP of a parallel execution block.

Qsim

The qubit simulation (Qsim) gate.

RotateAroundSphericalAxis

Implements a rotation around an axis in the x-y plane in spherical coordinates.

RotateX

The XPower gate \(e^{-i \frac{\theta}{2} \sigma^x}\).

RotateXY

Implements a rotation around an axis in the x-y plane in spherical coordinates.

RotateY

The YPower gate \(e^{-i \frac{\theta}{2} \sigma^y}\).

RotateZ

The ZPower gate \(e^{-i \frac{\theta}{2} \sigma^z}\).

SGate

The S gate.

SWAP

The controlled SWAP quantum operation.

SingleQubitGate

The general single qubit unitary gate.

SpinInteraction

The generalized, anisotropic XYZ Heisenberg interaction between spins.

SqrtISwap

The controlled square root ISwap quantum operation.

SqrtPauliX

The square root of the XPower gate \(e^{-i \frac{\pi}{4} \sigma^x}\).

TGate

The T gate.

Toffoli

Implements Toffoli gate.

VariableMSXX

The variable-angle MolmerSorensen XX gate.

XY

The controlled XY quantum operation

class qoqo.operations.Bogoliubov

The Bogoliubov DeGennes interaction gate.

\(e^{-\mathrm{i} Re(\Delta) (X_c X_t - Y_c Y_t)/2 + Im(\Delta) (X_c Y_t+Y_c X_t)/2}\)

Where \(X_c\) is the Pauli matrix \(\sigma^x\) acting on the control qubit and \(Y_t\) is the Pauli matrix \(\sigma^y\) acting on the target qubit.

The unitary matrix representation is:

\[\begin{split}U = \begin{pmatrix} \cos(|\Delta|) & 0 & 0 & \mathrm{i} \sin(|\Delta|) e^{\mathrm{i} \cdot \mathrm{angle}(\Delta)} \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ \mathrm{i} \sin(|\Delta|) e^{-\mathrm{i} \cdot \mathrm{angle}(\Delta)} & 0 & 0 & \cos(|\Delta|) \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • delta_real (CalculatorFloat) – The real part of the complex Bogoliubov interaction strength \(Re(\Delta)\).

  • delta_imag (CalculatorFloat) – The imaginary part of the complex Bogoliubov interaction strength \(Im(\Delta)\).

control()

Returns control qubit of the two-qubit operation

delta_imag()

Returns value of attribute delta_imag

delta_real()

Returns value of attribute delta_real

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.CNOT

The controlled NOT quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of NOT on the target qubit.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit NOT is applied to.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ComplexPMInteraction

The complex hopping gate.

\(e^{-\mathrm{i} \left[ Re(\theta) \cdot (X_c X_t + Y_c Y_t) - Im(\theta) \cdot (X_c Y_t - Y_c X_t) \right] }\)

Where \(X_c\) is the Pauli matrix \(\sigma^x\) acting on the control qubit and \(Y_t\) is the Pauli matrix \(\sigma^y\) acting on the target qubit.

Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • t_real (CalculatorFloat) – The real part of the strength of the rotation \(Re(\theta)\).

  • t_imag (CalculatorFloat) – The imaginary part of the strength of the rotation \(Im(\theta)\).

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

t_imag()

Returns value of attribute t_imag

t_real()

Returns value of attribute t_real

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledControlledPauliZ

Implements the double-controlled PauliZ gate.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \end{pmatrix}\end{split}\]
Parameters:
  • control_0 (int) – The index of the most significant qubit in the unitary representation. Here, the first controlling qubit of the operation.

  • control_1 (int) – The index of the second most significant qubit in the unitary representation. Here, the second controlling qubit of the operation.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit PauliZ is applied to.

circuit()

Returns circuit implementing the ThreeQubitGateOperation

Returns:

Circuit

control_0()

Returns control_0 qubit of the three-qubit operation

control_1()

Returns control_1 qubit of the three-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the three-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledControlledPhaseShift

Implements the double-controlled PhaseShift gate.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & e^{i \theta} \end{pmatrix}\end{split}\]
Parameters:
  • control_0 (int) – The index of the most significant qubit in the unitary representation. Here, the first controlling qubit of the operation.

  • control_1 (int) – The index of the second most significant qubit in the unitary representation. Here, the second controlling qubit of the operation.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit the phase-shift is applied to.

  • theta (float) – The rotation angle θ.

circuit()

Returns circuit implementing the ThreeQubitGateOperation

Returns:

Circuit

control_0()

Returns control_0 qubit of the three-qubit operation

control_1()

Returns control_1 qubit of the three-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the three-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledPauliY

The controlled PauliY quantum operation

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & -i \\\\ 0 & 0 & i & 0 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of PauliY gate on the target qubit.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit PauliY is applied to.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledPauliZ

The controlled PauliZ quantum operation

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & -1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of PauliZ gate on the target qubit.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit PauliZ is applied to.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledPhaseShift

The controlled-PhaseShift quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & e^{i \theta} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of the phase-shift on the target qubit.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit phase-shift is applied to.

  • theta (CalculatorFloat) – The rotation angle \(\theta\).

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledRotateX

Implements the controlled RotateX operation.

The unitary matrix representation is:

\[\begin{split}U = /begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & \cos(\frac{\theta}{2}) & -i \sin(\frac{\theta}{2}) \\\\ 0 & 0 & -i \sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of the Rotatex Operation on the target qubit.

  • target (int) –

  • theta (CalculatorFloat) – The angle $theta$ of the rotation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ControlledRotateXY

Implements the controlled RotateXY operation.

The unitary matrix representation is:

\[\begin{split}U = /begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & \cos(\frac{\theta}{2}) & -i e^{-i \phi} \sin(\frac{\theta}{2}) \\\\ 0 & 0 & -i e^{-i \phi} \sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of the Rotatex Operation on the target qubit.

  • target (int) –

  • theta (CalculatorFloat) – The angle $theta$ of the rotation.

  • phi (CalculatorFloat) – The rotation axis, in spherical coordinates \(\phi_{sph}\) gives the angle in the x-y plane.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phi()

Returns value of attribute phi

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.DefinitionBit

DefinitionBit is the Definition for a Bit type register.

Parameters:
  • name (string) – The name of the register that is defined.

  • length (int) – The length of the register that is defined, usually the number of qubits to be measured.

  • is_output (bool) – True/False if the variable is an output to the program.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_output()

Get value of struct field is_output

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

length()

Get value of struct field length

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.DefinitionComplex

DefinitionComplex is the Definition for a Complex type register.

Parameters:
  • name (string) – The name of the register that is defined.

  • length (int) – The length of the register that is defined, usually the number of qubits to be measured.

  • is_output (bool) – True/False if the variable is an output to the program.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_output()

Get value of struct field is_output

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

length()

Get value of struct field length

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.DefinitionFloat

DefinitionFloat is the Definition for a Float type register.

Parameters:
  • name (string) – The name of the register that is defined.

  • length (int) – The length of the register that is defined, usually the number of qubits to be measured.

  • is_output (bool) – True/False if the variable is an output to the program.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_output()

Get value of struct field is_output

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

length()

Get value of struct field length

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.DefinitionUsize

DefinitionUsize is the Definition for an Integer type register.

Parameters:
  • name (string) – The name of the register that is defined.

  • length (int) – The length of the register that is defined, usually the number of qubits to be measured.

  • is_output (bool) – True/False if the variable is an output to the program.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_output()

Get value of struct field is_output

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

length()

Get value of struct field length

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.FSwap

The controlled fermionic SWAP gate.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & -1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.Fsim

The fermionic qubit simulation (Fsim) gate.

\[\begin{split}U = \begin{pmatrix} \cos(\Delta) & 0 & 0 & i \sin(\Delta) \\\\ 0 & -i \sin(t) & \cos(t) & 0 \\\\ 0 & \cos(t) & -i \sin(t) & 0 \\\\ -\sin(\Delta) \cdot e^{-i U} & 0 & 0 & -\cos(\Delta) \cdot e^{-i U} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • t (CalculatorFloat) – The hopping strength.

  • u (CalculatorFloat) – The interaction strength.

  • delta (CalculatorFloat) – The Bogoliubov interaction strength \(\Delta\).

Note: The qubits have to be adjacent, i.e., \(|i-j|=1\) has to hold. This is the only case in which the gate is valid as a two-qubit gate (due to the Jordan-Wigner transformation).

control()

Returns control qubit of the two-qubit operation

delta()

Returns value of attribute delta

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

t()

Returns value of attribute t

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

u()

Returns value of attribute u

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.GivensRotation

The Givens rotation interaction gate in big endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

Where \(X_c\) is the Pauli matrix \(\sigma^x\) acting on the control qubit and \(Y_t\) is the Pauli matrix \(\sigma^y\) acting on the target qubit.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & \cos(\theta) \cdot e^{i \phi} & \sin(\theta) & 0 \\\\ 0 & -\sin(\theta) \cdot e^{i \phi} & \cos(\theta) & 0 \\\\ 0 & 0 & 0 & e^{i \phi} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

  • theta (CalculatorFloat) – The rotation angle \(\theta\).

  • phase (CalculatorFloat) – The phase \(\phi\) of the rotation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phi()

Returns value of attribute phi

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.GivensRotationLittleEndian

The Givens rotation interaction gate in little endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\).

Where \(X_c\) is the Pauli matrix \(\sigma^x\) acting on the control qubit and \(Y_t\) is the Pauli matrix \(\sigma^y\) acting on the target qubit.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & \cos(\theta) & \sin(\theta) & 0 \\\\ 0 & -\sin(\theta) \cdot e^{i \phi} & \cos(\theta) \cdot e^{i \phi} & 0 \\\\ 0 & 0 & 0 & e^{i \phi} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

  • theta (CalculatorFloat) – The rotation angle \(\theta\).

  • phase (CalculatorFloat) – The phase \(\phi\) of the rotation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phi()

Returns value of attribute phi

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.Hadamard

The Hadamard gate.

\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1\\\\ 1 & -1 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.ISwap

The controlled ISwap quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 0 & i & 0 \\\\ 0 & i & 0 & 0 \\\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.InputBit

InputBit sets a certain bit in an existing BitRegister of the circuit.

Parameters:
  • name (string) – The name of the register that is defined.

  • index (int) – The index in the register that is set.

  • value (int) – The value the bit is set to.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

index()

Get value of struct field index

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

value()

Get value of struct field value

class qoqo.operations.InputSymbolic

InputSymbolic is the Definition for a Float which will replace a certain symbolic parameter.

Parameters:
  • name (string) – The name of the register that is defined.

  • input (float) – The float by which to replace the quantities marked as “name”.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

input()

Get value of struct field input

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

name()

Return name of definition operation.

Returns:

str

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.InvSqrtISwap

The controlled inverse square root ISwap quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & \frac{1}{\sqrt{2}} & \frac{-i}{\sqrt{2}} & 0 \\\\ 0 & \frac{-i}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.InvSqrtPauliX

The inverse square root XPower gate \(e^{i \frac{\pi}{2} \sigma^x}\).

\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & i \\\\ i & 1 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.MeasureQubit

Measurement gate operation.

This Operation acts on one qubit writing the result of the measurement into a readout. The classical register for the readout needs to be defined in advance by using a Definition operation.

Parameters:
  • qubit (int) – The measured qubit.

  • readout (string) – The classical register for the readout.

  • readout_index (int) – The index in the readout the result is saved to.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubit()

Return the qubit the operation acts on

Returns:

int

readout()

Get value of struct field readout

readout_index()

Get value of struct field readout_index

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.MolmerSorensenXX

The fixed phase MolmerSorensen XX gate. <http://arxiv.org/abs/1705.02771>

\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 0 & -i \\\\ 0 & 1 & -i & 0 \\\\ 0 & -i & 1 & 0 \\\\ -i & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. The gate is symmetric under the exchange of qubits.

  • target (int) – The index of the least significant qubit in the unitary representation. The gate is symmetric under the exchange of qubits.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.MultiQubitMS

The Molmer-Sorensen gate between multiple qubits.

The gate applies the rotation under the product of Pauli X operators on multiple qubits. In mathematical terms the gate applies exp(-i * theta/2 * X_i0 * X_i1 * … * X_in).

circuit()

Return circuit implementing MultiQubitGateOperation

Returns:

Circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.MultiQubitZZ

The multi qubit Pauli-Z-Product gate.

The gate applies the rotation under the product of Pauli Z operators on multiple qubits. In mathematical terms the gate applies exp(-i * theta/2 * Z_i0 * Z_i1 * … * Z_in).

circuit()

Return circuit implementing MultiQubitGateOperation

Returns:

Circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PMInteraction

The transversal interaction gate.

\(e^{-\mathrm{i} \theta (X_c X_t + Y_c Y_t)} = e^{-\mathrm{i} \theta (\sigma^+_c \sigma^-_t + \sigma^-_c \sigma^+_t)}\)

Where \(X_c\) is the Pauli matrix \(\sigma^x\) acting on the control qubit and \(Y_t\) is the Pauli matrix \(\sigma^y\) acting on the target qubit.

Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • t (CalculatorFloat) – The strength of the rotation \(\theta\).

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

t()

Returns value of attribute t

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PauliX

The Pauli X gate.

\[\begin{split}U = \begin{pmatrix} 0 & 1 \\\\ 1 & 0 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PauliY

The Pauli Y gate.

\[\begin{split}U = \begin{pmatrix} 0 & -i \\\\ i & 0 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PauliZ

The Pauli Z gate.

\[\begin{split}U = \begin{pmatrix} 1 & 0 \\\\ 0 & -1 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PhaseShiftState0

The phase shift gate applied on state |0>.

Rotation around Z-axis by an arbitrary angle $theta$ (AC Stark shift of the state |0>).

\[\begin{split}U = \begin{pmatrix} e^{i \theta} & 0\\\\ 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PhaseShiftState1

The phase shift gate applied on state |1>.

Rotation around Z-axis by an arbitrary angle $theta$ (AC Stark shift of the state |1>).

\[\begin{split}U = \begin{pmatrix} 1 & 0\\\\ 0 & e^{i \theta} \end{pmatrix}\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PhaseShiftedControlledPhase

Implements the phase-shifted controlled PhaseShift gate.

The unitary matrix representation is:

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & e^{i \phi} & 0 & 0 \\\\ 0 & 0 & e^{i \phi} & 0 \\\\ 0 & 0 & 0 & e^{i(2\cdot\phi + \theta)} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of the phase-shift on the target qubit.

  • target (int) –

  • theta (CalculatorFloat) – The phase rotation $theta$.

  • phi (CalculatorFloat) – The single qubit phase $phi$.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phi()

Returns value of attribute phi

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PhaseShiftedControlledZ

The phased-shifted controlled-Z gate.

Modified, i.e. phase-shifted ControlledPauliZ two-qubit gate (<https://arxiv.org/pdf/1908.06101.pdf eq.(1)>).

The unitary matrix representation is:

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & e^{i \phi} & 0 & 0 \\\\ 0 & 0 & e^{i \phi} & 0 \\\\ 0 & 0 & 0 & e^{i (2\cdot\phi + \pi)} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. Here, the qubit that controls the application of the phase-shift on the target qubit.

  • target (int) –

  • phi (CalculatorFloat) – The single qubit phase $phi$.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phi()

Returns value of attribute phi

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.PragmaActiveReset

This PRAGMA operation resets the chosen qubit to the zero state.

Parameters:

qubit (int) – The qubit to be reset.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaBoostNoise

This PRAGMA operation boosts noise and overrotations in the circuit.

Parameters:

noise_coefficient (CalculatorFloat) – The coefficient by which the noise is boosted.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

noise_coefficient()

Returns value of attribute noise_coefficient

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaChangeDevice

A wrapper around backend specific PRAGMA operations capable of changing a device.

This PRAGMA is a thin wrapper around device specific operations that can change device properties.

hqslang()

Return hqslang name of the operation.

Returns:

The hqslang name of the operation.

Return type:

str

involved_qubits()

List all involved qubits.

Returns:

The involved qubits of the PRAGMA operation.

Return type:

set[int]

is_parametrized()

Return true when the operation has symbolic parameters.

Returns:

True if the operation contains symbolic parameters, False if it does not.

Return type:

is_parametrized (bool)

remap_qubits(mapping)

Remap qubits in a clone of the PRAGMA operation.

Parameters:

mapping (dict[int, int]) – The dictionary containing the {qubit: qubit} mapping to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the qubits remapped.

Return type:

self

Raises:

RuntimeError – The qubit remapping failed.

substitute_parameters(substitution_parameters)

Substitute the symbolic parameters in a clone of the PRAGMA operation according to the input.

Parameters:

substitution_parameters (dict[str, float]) – The dictionary containing the substitutions to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the parameters substituted.

Return type:

self

Raises:

RuntimeError – The parameter substitution failed.

tags()

Return tags classifying the type of the operation.

Used for the type based dispatch in ffi interfaces.

Returns:

The tags of the Operation.

Return type:

list[str]

wrapped_hqslang()

Return the hqslang name of the wrapped operations.

Returns:

The name of the wrapped operation.

Return type:

str

wrapped_operation()

Return the binary representation of the wrapped operations.

Returns:

The the binary representation of the wrapped operation.

Return type:

ByteArray

wrapped_tags()

Return the tags of the wrapped operations.

Returns:

The list of tags.

Return type:

List[str]

class qoqo.operations.PragmaConditional

The conditional PRAGMA operation.

This PRAGMA executes a circuit when the condition bit/bool stored in a classical bit register is true.

Parameters:
  • condition_register (str) – The name of the bit register containting the condition bool value.

  • condition_index (int) –

    • The index in the bit register containting the condition bool value.

  • circuit (Circuit) –

    • The circuit executed if the condition is met.

circuit()

Get value of struct field circuit

condition_index()

Get value of struct field condition_index

condition_register()

Get value of struct field condition_register

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaDamping

The damping PRAGMA noise operation.

This PRAGMA operation applies a pure damping error corresponding to zero temperature environments.

Note

Damping means going from state |1> to |0> and corresponds to zero-temperature in a physical device where |0> is the ground state. With respect to the definition of the Pauli operator Z, |0> is the excited state and damping leads to an increase in energy.

Parameters:
  • qubit (int) – The qubit on which to apply the damping.

  • gate_time (CalculatorFloat) – The time (in seconds) the gate takes to be applied to the qubit on the (simulated) hardware

  • rate (CalculatorFloat) – The error rate of the damping (in 1/second).

gate_time()

Returns value of attribute gate_time

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Return the power of the noise gate

Parameters:

power (CalculatorFloat) – exponent in the power operation of the noise gate

Returns:

Self

probability()

Returns the probability associated with the noise operation

Returns:

CalculatorFloat

qubit()

Return the qubit the operation acts on

Returns:

int

rate()

Returns value of attribute rate

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

superoperator()

Return the superoperator defining the evolution of the density matrix under the noise gate

Returns:

np.ndarray

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaDephasing

The dephasing PRAGMA noise operation.

This PRAGMA operation applies a pure dephasing error.

Parameters:
  • qubit (int) – The qubit on which to apply the dephasing.

  • gate_time (CalculatorFloat) – The time (in seconds) the gate takes to be applied to the qubit on the (simulated) hardware

  • rate (CalculatorFloat) – The error rate of the dephasing (in 1/second).

gate_time()

Returns value of attribute gate_time

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Return the power of the noise gate

Parameters:

power (CalculatorFloat) – exponent in the power operation of the noise gate

Returns:

Self

probability()

Returns the probability associated with the noise operation

Returns:

CalculatorFloat

qubit()

Return the qubit the operation acts on

Returns:

int

rate()

Returns value of attribute rate

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

superoperator()

Return the superoperator defining the evolution of the density matrix under the noise gate

Returns:

np.ndarray

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaDepolarising

The depolarising PRAGMA noise operation.

This PRAGMA operation applies a depolarising error corresponding to infinite temperature environments.

Parameters:
  • qubit (int) – The qubit on which to apply the depolarising.

  • gate_time (CalculatorFloat) – The time (in seconds) the gate takes to be applied to the qubit on the (simulated) hardware

  • rate (CalculatorFloat) – The error rate of the depolarisation (in 1/second).

gate_time()

Returns value of attribute gate_time

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Return the power of the noise gate

Parameters:

power (CalculatorFloat) – exponent in the power operation of the noise gate

Returns:

Self

probability()

Returns the probability associated with the noise operation

Returns:

CalculatorFloat

qubit()

Return the qubit the operation acts on

Returns:

int

rate()

Returns value of attribute rate

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

superoperator()

Return the superoperator defining the evolution of the density matrix under the noise gate

Returns:

np.ndarray

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaGeneralNoise

The general noise PRAGMA operation.

This PRAGMA operation applies a noise term according to the given operators.

Parameters:
  • qubit (int) – The qubit the PRAGMA operation is applied to.

  • gate_time (CalculatorFloat) – The time (in seconds) the gate takes to be applied to the qubit on the (simulated) hardware

  • Rates – The rates representing the general noise matrix M (a 3x3 matrix as 2d array).

gate_time()

Return the gate_time of the PRAGMA operation.

Returns:

The gate time of the PRAGMA operation.

Return type:

CalculatorFloat

hqslang()

Return hqslang name of the operation.

Returns:

The hqslang name of the operation.

Return type:

str

involved_qubits()

List all involved qubits.

Returns:

The involved qubits of the PRAGMA operation.

Return type:

set[int]

is_parametrized()

Return true when the operation has symbolic parameters.

Returns:

True if the operation contains symbolic parameters, False if it does not.

Return type:

is_parametrized (bool)

qubit()

Return the qubit on which the PRAGMA operation is applied.

Returns:

The qubit of the PRAGMA operation.

Return type:

int

rates()

Return the rates of the PRAGMA operation.

Returns:

The rates of the PRAGMA operation.

Return type:

np.ndarray

remap_qubits(mapping)

Remap qubits in a clone of the PRAGMA operation.

Parameters:

mapping (dict[int, int]) – The dictionary containing the {qubit: qubit} mapping to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the qubits remapped.

Return type:

self

Raises:

RuntimeError – The qubit remapping failed.

substitute_parameters(substitution_parameters)

Substitute the symbolic parameters in a clone of the PRAGMA operation according to the input.

Parameters:

substitution_parameters (dict[str, float]) – The dictionary containing the substitutions to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the parameters substituted.

Return type:

self

Raises:

RuntimeError – The parameter substitution failed.

superoperator()

Return the superoperator of the PRAGMA operation.

Returns:

The matrix form of the superoperator of the PRAGMA operation.

Return type:

np.ndarray

tags()

Return tags classifying the type of the operation.

Used for the type based dispatch in ffi interfaces.

Returns:

The tags of the Operation.

Return type:

list[str]

class qoqo.operations.PragmaGetDensityMatrix

This PRAGMA measurement operation returns the density matrix of a quantum register.

Parameters:
  • readout (string) – The name of the classical readout register.

  • circuit (Optional[Circuit]) – The measurement preparation Circuit, applied on a copy of the register before measurement.

circuit()

Get value of struct field circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaGetOccupationProbability

This PRAGMA measurement operation returns the vector of the occupation probabilities.

Occupation probabilities in the context of this PRAGMA operation are probabilities of finding the quantum register in each \(\sigma_z\) basis state. The quantum register remains unchanged by this PRAGMA measurement operation.

Parameters:
  • readout (string) – The name of the classical readout register.

  • circuit (Optional[Circuit]) – The Circuit used to rotate the qureg.

circuit()

Get value of struct field circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaGetPauliProduct

This PRAGMA measurement operation returns a Pauli product expectation value.

This PRAGMA operation returns a Pauli product expectation value after applying a Rotate to another basis. It performs all of the operation on a clone of the quantum register, sothat the actual quantum register remains unchanged.

Parameters:
  • qubit_paulis (dict[int, int]) – The dictionary of the pauli matrix to apply to each qubit in the form {qubit: pauli}. Allowed values to be provided for ‘pauli’ are: 0 = identity, 1 = PauliX, 2 = PauliY, 3 = PauliZ.

  • readout (string) – The name of the classical readout register.

  • circuit (Circuit) – The measurement preparation Circuit, applied on a copy of the register before measurement.

circuit()

Get value of struct field circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubit_paulis()

Get value of struct field qubit_paulis

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaGetStateVector

This PRAGMA measurement operation returns the statevector of a quantum register.

Parameters:
  • readout (string) – The name of the classical readout register.

  • circuit (Optional[Circuit]) – The measurement preparation Circuit, applied on a copy of the register before measurement.

circuit()

Get value of struct field circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaGlobalPhase

The global phase PRAGMA operation.

This PRAGMA operation signals that the quantum register picks up a global phase, i.e. it provides information that there is a global phase to be considered.

Parameters:

phase (CalculatorFloat) – The picked up global phase.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

phase()

Returns value of attribute phase

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaLoop

This PRAGMA measurement operation returns the statevector of a quantum register.

Parameters:
  • repetitions (CalculatorFloat) – The number of repetitions as a symbolic float. At evaluation the floor of any float value is taken

  • circuit (Circuit) – The Circuit that is looped.

circuit()

Get value of struct field circuit

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

repetitions()

Returns value of attribute repetitions

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaOverrotation

The statistical overrotation PRAGMA operation.

This PRAGMA applies a statistical overrotation to the next rotation gate in the circuit, which matches the hqslang name in the gate parameter of PragmaOverrotation and the involved qubits in qubits.

The applied overrotation corresponds to adding a random number to the rotation angle. The random number is drawn from a normal distribution with mean 0 and standard deviation variance and is multiplied by the amplitude.

Parameters:
  • gate (str) – The unique hqslang name of the gate to overrotate.

  • qubits (list[int]) – The qubits of the gate to overrotate.

  • amplitude (float) – The amplitude the random number is multiplied by.

  • variance (float) – The standard deviation of the normal distribution the random number is drawn from.

amplitude()

Get value of struct field amplitude

gate_hqslang()

Get value of struct field gate_hqslang

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

variance()

Get value of struct field variance

class qoqo.operations.PragmaRandomNoise

The random noise PRAGMA operation.

This PRAGMA operation applies a pure damping error corresponding to zero temperature environments.

Parameters:
  • qubit (int) – The qubit on which to apply the damping.

  • gate_time (CalculatorFloat) – The time (in seconds) the gate takes to be applied to the qubit on the (simulated) hardware

  • depolarising_rate (CalculatorFloat) – The error rate of the depolarisation (in 1/second).

  • dephasing_rate (CalculatorFloat) – The error rate of the dephasing (in 1/second).

dephasing_rate()

Returns value of attribute dephasing_rate

depolarising_rate()

Returns value of attribute depolarising_rate

gate_time()

Returns value of attribute gate_time

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Return the power of the noise gate

Parameters:

power (CalculatorFloat) – exponent in the power operation of the noise gate

Returns:

Self

probability()

Returns the probability associated with the noise operation

Returns:

CalculatorFloat

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

superoperator()

Return the superoperator defining the evolution of the density matrix under the noise gate

Returns:

np.ndarray

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaRepeatGate

The repeated gate PRAGMA operation.

This PRAGMA operation repeats the next gate in the circuit the given number of times to increase the rate for error mitigation.

Parameters:

repetition_coefficient (int) – The number of times the following gate is repeated.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

repetition_coefficient()

Get value of struct field repetition_coefficient

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaRepeatedMeasurement

This PRAGMA measurement operation returns a measurement record for N repeated measurements.

Parameters:
  • readout (string) – The name of the classical readout register.

  • qubit_mapping (dict[int, int]) – The mapping of qubits to indices in readout register.

  • number_measurements (int) – The number of times to repeat the measurement.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

number_measurements()

Get value of struct field number_measurements

qubit_mapping()

Get value of struct field qubit_mapping

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaSetDensityMatrix

This PRAGMA operation sets the density matrix of a quantum register.

The Circuit() module automatically initializes the qubits in the |0> state, so this PRAGMA operation allows you to set the state of the qubits by setting a density matrix of your choosing.

Parameters:

density_matrix (a 2d array of complex numbers) – The density matrix that is initialized.

density_matrix()

Return the set density matrix.

Returns:

The density matrix (2d array) representing the qubit register.

Return type:

np.ndarray

hqslang()

Return hqslang name of the operation.

Returns:

The hqslang name of the operation.

Return type:

str

involved_qubits()

List all involved qubits (here, all).

Returns:

The involved qubits of the PRAGMA operation.

Return type:

set[int]

is_parametrized()

Return true when the operation has symbolic parameters.

Returns:

True if the operation contains symbolic parameters, False if it does not.

Return type:

bool

remap_qubits(mapping)

Remap qubits in a clone of the PRAGMA operation.

Parameters:

mapping (dict[int, int]) – The dictionary containing the {qubit: qubit} mapping to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the qubits remapped.

Return type:

self

Raises:

RuntimeError – The qubit remapping failed.

substitute_parameters(substitution_parameters)

Substitute the symbolic parameters in a clone of the PRAGMA operation according to the input.

Parameters:

substitution_parameters (dict[str, float]) – The dictionary containing the substitutions to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the parameters substituted.

Return type:

self

Raises:

RuntimeError – The parameter substitution failed.

tags()

Return tags classifying the type of the operation.

Used for type based dispatch in ffi interfaces.

Returns:

The tags of the Operation.

Return type:

list[str]

class qoqo.operations.PragmaSetNumberOfMeasurements

Wrap function automatically generates functions in these traits. This PRAGMA operation sets the number of measurements of the circuit.

This is used for backends that allow setting the number of tries. However, setting the number of measurements does not allow access to the underlying wavefunction or density matrix.

Parameters:
  • number_measurements (uint) – The number of measurements.

  • readout (string) – The register for the readout.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

number_measurements()

Get value of struct field number_measurements

readout()

Get value of struct field readout

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaSetStateVector

This PRAGMA operation sets the statevector of a quantum register.

The Circuit() module automatically initializes the qubits in the |0> state, so this PRAGMA operation allows you to set the state of the qubits to a state of your choosing. For instance, to initialize the psi-minus Bell state, we pass the following vector to the PRAGMA:

vector = np.array([0, 1 / np.sqrt(2), -1 / np.sqrt(2), 0])

Parameters:

internal (PragmaSetStateVector) – The statevector that is initialized.

hqslang()

Return hqslang name of the operation.

Returns:

The hqslang name of the operation.

Return type:

str

involved_qubits()

List all involved qubits (here, all).

Returns:

The involved qubits of the PRAGMA operation.

Return type:

set[int]

is_parametrized()

Return true when the operation has symbolic parameters.

Returns:

True if the operation contains symbolic parameters, False if it does not.

Return type:

bool

remap_qubits(mapping)

Remap qubits in a clone of the PRAGMA operation.

Parameters:

mapping (dict[int, int]) – The dictionary containing the {qubit: qubit} mapping to use in the PRAGMA operation.

Returns:

The PRAGMA operation with the qubits remapped.

Return type:

self

Raises:

RuntimeError – The qubit remapping failed.

statevector()

Return the statevector.

Returns:

The statevector representing the qubit register.

Return type:

np.ndarray

substitute_parameters(substitution_parameters)

Substitute the symbolic parameters in a clone of the PRAGMA operation according to the substitution_parameters input.

Parameters:

substitution_parameters (dict[str, float]) – The dictionary containing the substitutions to use in the PRAGMA operation.

Returns:

The PRAGMA operation operation with the parameters substituted.

Return type:

self

Raises:

RuntimeError – The parameter substitution failed.

tags()

Return tags classifying the type of the operation.

Used for the type based dispatch in ffi interfaces.

Returns:

The tags of the operation.

Return type:

list[str]

class qoqo.operations.PragmaSleep

This PRAGMA operation makes the quantum hardware wait a given amount of time.

This PRAGMA operation is used for error mitigation reasons, for instance. It can be used to boost the noise on the qubits since it gets worse with time.

Parameters:
  • qubits (list[int]) – The qubits involved in the sleep block.

  • sleep_time (CalculatorFloat) – The time for the execution of the block in seconds.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

sleep_time()

Returns value of attribute sleep_time

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaStartDecompositionBlock

This PRAGMA operation signals the START of a decomposition block.

Parameters:
  • qubits (list[int]) – The qubits involved in the decomposition block.

  • dict[int (reordering_dictionary) – The reordering dictionary of the block.

  • int]) – The reordering dictionary of the block.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

reordering_dictionary()

Get value of struct field reordering_dictionary

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaStopDecompositionBlock

This PRAGMA operation signals the STOP of a decomposition block.

Parameters:

qubits (list[int]) – The qubits involved in the decomposition block.

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.PragmaStopParallelBlock

This PRAGMA operation signals the STOP of a parallel execution block.

Parameters:
  • qubits (list[int]) – The qubits involved in parallel execution block.

  • execution_time (CalculatorFloat) – The time for the execution of the block in seconds.

execution_time()

Returns value of attribute execution_time

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

qubits()

Return list of qubits of the multi qubit operation in order of descending significance

Returns:

list[int]

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

class qoqo.operations.Qsim

The qubit simulation (Qsim) gate.

\[\begin{split}U = \begin{pmatrix} \cos(x-y) \cdot e^{-i z} & 0 & 0 & -i\sin(x-y)\cdot e^{-i z}\\\\ 0 & -i \sin(x+y)\cdot e^{i z} & \cos(x+y)\cdot e^{i z} & 0 \\\\ 0 & \cos(x+y)\cdot e^{i z}& -i \sin(x+y)\cdot e^{i z} & 0 \\\\ -\sin(x-y)\cdot e^{-i z} & 0 & 0 & \cos(x-y)\cdot e^{-i z} \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • x (CalculatorFloat) – The prefactor of the XX interaction.

  • y (CalculatorFloat) – The prefactor of the YY interaction.

  • z (CalculatorFloat) – The prefactor of the ZZ interaction.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

x()

Returns value of attribute x

y()

Returns value of attribute y

z()

Returns value of attribute z

class qoqo.operations.RotateAroundSphericalAxis

Implements a rotation around an axis in the x-y plane in spherical coordinates.

\[\begin{split}U = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 \\\\ 0 & \cos(\frac{\theta}{2}) \end{pmatrix} + \begin{pmatrix} -i \sin(\frac{\theta}{2}) v_z & \sin(\frac{\theta}{2}) \left(-i v_x - v_y \right) \\\\ \sin(\frac{\theta}{2}) \left(-i v_x + v_y \right) & i \sin(\frac{\theta}{2}) v_z \end{pmatrix}\end{split}\]

with

\[\begin{split}v_x = \sin(\theta_{sph}) \cos(\phi_{sph}) \ , \\ v_y = \sin(\theta_{sph}) \sin(\phi_{sph}) \ , \\ v_z = \cos(\theta_{sph}) \ .\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

  • spherical_theta (CalculatorFloat) – The rotation axis, unit-vector spherical coordinates \(\theta_{sph}\).

  • spherical_phi (CalculatorFloat) – The rotation axis, unit-vector spherical coordinates \(\phi_{sph}\) gives the angle in the x-y plane.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

spherical_phi()

Returns value of attribute spherical_phi

spherical_theta()

Returns value of attribute spherical_theta

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.RotateX

The XPower gate \(e^{-i \frac{\theta}{2} \sigma^x}\).

\[\begin{split}U = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 \\\\ 0 & \cos(\frac{\theta}{2}) \end{pmatrix} + \begin{pmatrix} 0 & -i \sin(\frac{\theta}{2}) \\\\ -i \sin(\frac{\theta}{2}) & 0 \end{pmatrix}\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.RotateXY

Implements a rotation around an axis in the x-y plane in spherical coordinates.

\[\]

U = begin{pmatrix} cos(frac{theta}{2}) & -i e^{-i phi} sin(frac{theta}{2})\\ -i e^{i phi} sin(frac{theta}{2}) & cos(frac{theta}{2}) end{pmatrix}

Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

  • phi (CalculatorFloat) – The rotation axis, in spherical coordinates \(\phi_{sph}\) gives the angle in the x-y plane.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

phi()

Returns value of attribute phi

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.RotateY

The YPower gate \(e^{-i \frac{\theta}{2} \sigma^y}\).

\[\begin{split}U = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 \\\\ 0 & \cos(\frac{\theta}{2}) \end{pmatrix} + \begin{pmatrix} 0 & - \sin(\frac{\theta}{2}) \\\\ \sin(\frac{\theta}{2}) & 0 \end{pmatrix}\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.RotateZ

The ZPower gate \(e^{-i \frac{\theta}{2} \sigma^z}\).

\[\begin{split}U = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 \\\\ 0 & \cos(\frac{\theta}{2}) \end{pmatrix} + \begin{pmatrix} - i \sin(\frac{\theta}{2}) & 0 \\\\ 0 & i \sin(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:
  • qubit (int) – The qubit the unitary gate is applied to.

  • theta (CalculatorFloat) – The angle \(\theta\) of the rotation.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.SGate

The S gate.

\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 \\\\ 0 & i \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.SWAP

The controlled SWAP quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.SingleQubitGate

The general single qubit unitary gate.

\[\begin{split}U =\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Parameters:
  • qubit – The qubit that the unitary gate is applied to.

  • alpha_r – The real part of the on-diagonal elements of the single-qubit unitary.

  • alpha_i – The imaginary part of the on-diagonal elements of the single-qubit unitary.

  • beta_r – The real part of the off-diagonal elements of the single-qubit unitary.

  • beta_i – The imaginary part of the off-diagonal elements of the single-qubit unitary.

  • global_phase – The global phase of the single-qubit unitary.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.SpinInteraction

The generalized, anisotropic XYZ Heisenberg interaction between spins.

\(e^{-\mathrm{i} (x \cdot X_c X_t + y \cdot Y_c Y_t + z \cdot Z_c Z_t)}\)

Where x, y, z are prefactors of the \(X_c X_t\), \(Y_c Y_t\), \(Z_c Z_t\) Pauliproducts acting on control and target qubit, with \(XX \equiv \sigma_x \sigma_x\), \(YY \equiv \sigma_y \sigma_y\) and \(ZZ \equiv \sigma_z \sigma_z\).

Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) –

  • x (CalculatorFloat) – The prefactor of the XX interaction.

  • y (CalculatorFloat) – The prefactor of the YY interaction.

  • z (CalculatorFloat) – The prefactor of the ZZ interaction.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

x()

Returns value of attribute x

y()

Returns value of attribute y

z()

Returns value of attribute z

class qoqo.operations.SqrtISwap

The controlled square root ISwap quantum operation.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & \frac{1}{\sqrt{2}} & \frac{i}{\sqrt{2}} & 0 \\\\ 0 & \frac{i}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.SqrtPauliX

The square root of the XPower gate \(e^{-i \frac{\pi}{4} \sigma^x}\).

\[\begin{split}U = \frac{1}{\sqrt(2)}\begin{pmatrix} 1 & -i \\\\ -i & 1 \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.TGate

The T gate.

\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 \\\\ 0 & e^{i \frac{\pi}{4}} \end{pmatrix}\end{split}\]
Parameters:

qubit (int) – The qubit the unitary gate is applied to.

alpha_i()

Return the property alpha_i \(\alpha_i\) of a unitary gate acting on one qubit

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

alpha_r()

Return the property alpha_r \(\alpha_r\) of a unitary gate acting on one qubit

Here alpha_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_i()

Returns the property beta_i \(\beta_i\) of a unitary gate acting on one qubit

Here beta_i is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

beta_r()

Return the property beta_r \(\beta_r\) of a unitary gate acting on one qubit

Here beta_r is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

global_phase()

Return the global phase \(g\) of a unitary gate acting on one qubit

Here global_phase is defined by

\[\begin{split}U =e^{i \cdot g}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix}\end{split}\]
Returns:

CalculatorFloat

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

mul(other)

Multiplies two compatible operations implementing OperateSingleQubitGate.

Does not consume the two operations being multiplied. Only Operations

Parameters:

[OperateSingleQubitGate]. (other - An Operation implementing) –

Returns:

Result of the multiplication, i.e. the multiplied single qubit gate.

Return type:

PyResult

Example: ``` from qoqo.operations import RotateZ, RotateX

gate1 = RotateZ(qubit=0, theta=1) gate2 = RotateX(qubit=0, theta=1) multiplied = gate1.mul(gate2) print(“Multiplied gate: “, multiplied) ```

qubit()

Return the qubit the operation acts on

Returns:

int

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.Toffoli

Implements Toffoli gate.

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{pmatrix}\end{split}\]
Parameters:
  • control_0 (int) – The index of the most significant qubit in the unitary representation. Here, the first controlling qubit of the operation.

  • control_1 (int) – The index of the second most significant qubit in the unitary representation. Here, the second controlling qubit of the operation.

  • target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit the PauliX gate is applied to.

circuit()

Returns circuit implementing the ThreeQubitGateOperation

Returns:

Circuit

control_0()

Returns control_0 qubit of the three-qubit operation

control_1()

Returns control_1 qubit of the three-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the three-qubit operation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.VariableMSXX

The variable-angle MolmerSorensen XX gate.

\[\begin{split}U = \begin{pmatrix} \cos(\theta/2) & 0 & 0 & -i \sin(\theta/2) \\\\ 0 & \cos(\theta/2) & -i \sin(\theta/2) & 0 \\\\ 0 & -i \sin(\theta/2) & \cos(\theta/2) & 0 \\\\ -i \sin(\theta/2) & 0 & 0 & \cos(\theta/2) \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation. The gate is symmetric under the exchange of qubits.

  • target (int) – The index of the least significant qubit in the unitary representation. The gate is symmetric under the exchange of qubits.

  • theta (CalculatorFloat) – The rotation angle \(\theta\).

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix

class qoqo.operations.XY

The controlled XY quantum operation

\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\ 0 & cos(\theta/2) & i sin(\theta/2) & 0 \\\ 0 & i sin(\theta/2) & cos(\theta/2) & 0 \\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • control (int) – The index of the most significant qubit in the unitary representation.

  • target (int) – The index of the least significant qubit in the unitary representation.

  • theta (CalculatorFloat) – The rotation angle \(\theta\).

control()

Returns control qubit of the two-qubit operation

hqslang()

Returns hqslang name of Operation

Returns:

The name

Return type:

str

involved_qubits()

List all involved Qubits

Returns:

The involved qubits as a set or ‘ALL’ if all qubits are involved

Return type:

Union[set[int], str]

is_parametrized()

Returns true if operation contains symbolic parameters

Returns:

bool

powercf(power)

Returns Rotated gate raised to power

Parameters:

power (CalculatorFloat) – exponent of the power operation.

Returns:

gate raised to the power of power

Return type:

Self

remap_qubits(mapping)

Remap qubits

Parameters:

mapping (dict[int, int]) – The mapping

Returns:

The operation with the remapped qubits

Return type:

Operation

Raises:

RuntimeError – Qubit remapping failed

substitute_parameters(substitution_parameters)

Substitutes internal symbolic parameters with float values

Only available when all symbolic expressions can be evaluated to float with the provided parameters.

Parameters:

substitution_parameters (dict[str, float]) – The substituted free parameters

Returns:

The operation with the parameters substituted

Return type:

Operation

Raises:

RuntimeError – Parameter Substitution failed

tags()

Returns tags identifying the Operation

Returns:

The tags identifying the operation

Return type:

list[str]

target()

Returns target qubit of the two-qubit operation

theta()

Returns angle of rotation

unitary_matrix()

Return unitary matrix of gate.

Returns:

np.ndarray

Raises:

ValueError – Error symbolic operation cannot return float unitary matrix