qoqo
Qoqo
qoqo is the HQS python package to represent quantum circuits.
|
Circuit of Operations. |
|
Represents the Direct Acyclic Graph (DAG) of a Circuit. |
Operations are the atomic instructions in any quantum program that can be represented by qoqo. |
|
|
Represents a quantum program evaluating measurements based on a one or more free float parameters. |
Measurements |
|
Devices in qoqo have two use cases: |
|
A collection of noise models that represent different types of noise that can be present in Quantum Computing hardware. |
Functions
List of hqslang of all available gates |
Classes
|
A generic device with all-to-all connectivity. |
|
The 2-mode beam splitter which splits a beam with a transmission amplitude cos(θ) and a reflection amplitude exp(i * φ) * sin(θ). |
|
The Bogoliubov DeGennes interaction gate. |
|
The controlled NOT quantum operation. |
|
Controlled-Z operation between a qubit and a bosonic mode, where the two-dimensional subspace of the bosonic mode spanned by the occupation number states |0⟩_B and |1⟩_B is considered as the second qubit involved in the CZ operation. |
|
Collected information for executing a cheated measurement. |
|
Provides Necessary Information to run a cheated measurement. |
|
Collected information for executing a cheated measurement of PauliZ product. |
Collected information for executing a cheated basis rotation measurement. |
|
|
Circuit of Operations. |
|
Represents the Direct Acyclic Graph (DAG) of a Circuit. |
|
Collected information for executing a classical register. |
|
The complex hopping gate. |
|
Noise model representing a continuous decoherence process on qubits. |
|
Implements the double-controlled PauliZ gate. |
|
Implements the double-controlled PhaseShift gate. |
|
The controlled PauliY quantum operation |
|
The controlled PauliZ quantum operation |
|
The controlled-PhaseShift quantum operation. |
|
Implements the controlled RotateX operation. |
|
Implements the controlled RotateXY operation. |
|
Implements ControlledSWAP gate. |
Error model for noise that is only present on gate executions. |
|
|
Noise model representing a continuous decoherence process on idle qubits. |
|
DefinitionBit is the Definition for a Bit type register. |
|
DefinitionComplex is the Definition for a Complex type register. |
|
DefinitionFloat is the Definition for a Float type register. |
|
DefinitionUsize is the Definition for an Integer type register. |
|
Implements the controlled RotateXY operation. |
|
The controlled fermionic SWAP gate. |
|
The fermionic qubit simulation (Fsim) gate. |
|
Implements a pi-rotation with an embedded phase. |
|
Implements a pi/2-rotation with an embedded phase. |
|
A generic device assuming all-to-all connectivity between all involved qubits. |
|
The Givens rotation interaction gate in big endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\). |
|
The Givens rotation interaction gate in little endian notation: \(e^{-\mathrm{i} \theta (X_c Y_t - Y_c X_t)}\). |
|
The Hadamard gate. |
|
The controlled ISwap quantum operation. |
|
The Identity gate. |
Noise model representing readout errors. |
|
|
InputBit sets a certain bit in an existing BitRegister of the circuit. |
|
InputSymbolic is the Definition for a Float which will replace a certain symbolic parameter. |
|
The InvS gate. |
|
The InvSX gate. |
|
The controlled inverse square root ISwap quantum operation. |
|
The inverse square root XPower gate \(e^{i \frac{\pi}{4} \sigma^x}\). |
|
The inverse square root YPower gate \(e^{i \frac{\pi}{4} \sigma^y}\). |
|
The InvT gate. |
|
The Jaynes-Cummings gate exp(-i * θ * (σ^- * b^† + σ^+ * b)) |
|
Longitudinal coupling gate exp(-i * θ * Z * (b^† + b)) |
|
Measurement gate operation. |
|
The fixed phase MolmerSorensen XX gate. |
|
The Molmer-Sorensen gate between multiple qubits. |
|
The multi qubit Pauli-Z-Product gate. |
|
The transversal interaction gate. |
|
The Pauli X gate. |
|
The Pauli Y gate. |
|
The Pauli Z gate. |
|
Collected information for executing a measurement of PauliZ product. |
|
Provides Necessary Information to run a [roqoqo::measurements::PauliZProduct] measurement. |
|
The single-mode phase-displacement gate with variable magnitude and phase. |
|
The single-mode phase-shift gate with variable phase, given by R(θ) = eexp(i * θ * 𝑁̂). |
|
The phase shift gate applied on state |0>. |
|
The phase shift gate applied on state |1>. |
The phased-shifted double-controlled-Z gate. |
|
|
The phased-shifted double-controlled-Z gate. |
|
Implements the phase-shifted controlled PhaseShift gate. |
|
The phased-shifted controlled-Z gate. |
|
The photon number-resolving detector measurement for bosons. |
|
This PRAGMA operation resets the chosen qubit to the zero state. |
|
An annotated Operation. |
|
This PRAGMA operation boosts noise and overrotations in the circuit. |
A wrapper around backend specific PRAGMA operations capable of changing a device. |
|
|
The conditional PRAGMA operation. |
|
A circuit controlled by a qubit. |
|
The damping PRAGMA noise operation. |
|
The dephasing PRAGMA noise operation. |
|
The depolarising PRAGMA noise operation. |
|
The general noise PRAGMA operation. |
|
This PRAGMA measurement operation returns the density matrix of a quantum register. |
|
This PRAGMA measurement operation returns the vector of the occupation probabilities. |
|
This PRAGMA measurement operation returns a Pauli product expectation value. |
|
This PRAGMA measurement operation returns the statevector of a quantum register. |
|
The global phase PRAGMA operation. |
|
This PRAGMA measurement operation returns the statevector of a quantum register. |
|
The statistical overrotation PRAGMA operation. |
|
The random noise PRAGMA operation. |
|
The repeated gate PRAGMA operation. |
|
This PRAGMA measurement operation returns a measurement record for N repeated measurements. |
|
This PRAGMA operation sets the density matrix of a quantum register. |
Wrap function automatically generates functions in these traits. |
|
|
This PRAGMA operation sets the statevector of a quantum register. |
|
This PRAGMA operation makes the quantum hardware wait a given amount of time. |
|
This PRAGMA operation signals the START of a decomposition block. |
|
This PRAGMA operation signals the STOP of a decomposition block. |
|
This PRAGMA operation signals the STOP of a parallel execution block. |
|
The qubit simulation (Qsim) gate. |
|
Represents a quantum program evaluating measurements based on a one or more free float parameters. |
|
The quantum Rabi interaction exp(-i * θ * X * (b^† + b)) |
|
Implements a rotation around an axis in the x-y plane in spherical coordinates. |
|
The XPower gate \(e^{-i \frac{\theta}{2} \sigma^x}\). |
|
Implements a rotation around an axis in the x-y plane in spherical coordinates. |
|
The YPower gate \(e^{-i \frac{\theta}{2} \sigma^y}\). |
|
The ZPower gate \(e^{-i \frac{\theta}{2} \sigma^z}\). |
|
The S gate. |
|
The controlled SWAP quantum operation. |
|
The SX gate. |
|
Loads a single excitation from a bosonic mode into a qubit as follows (c1 |0⟩_B + c2 |1⟩_B) ⨂ |0⟩_Q -> |0⟩_B ⨂ (c1 |0⟩_Q + c2 |1⟩_Q) |
|
Stores a single excitation from the involved qubit into the involved bosonic mode as follows |0⟩_B ⨂ (a |0⟩_Q + b |1⟩_Q) -> (a|0⟩_B + b |1⟩_B ) ⨂ |0⟩_Q |
|
The general single qubit unitary gate. |
|
Description of single qubit overrotation noise model, [roqoqo::noise_models::SingleQubitOverrotationOnGate]. |
Single qubit overrotation noise model on gate. |
|
|
The generalized, anisotropic XYZ Heisenberg interaction between spins. |
|
The controlled square root ISwap quantum operation. |
|
The square root of the XPower gate \(e^{-i \frac{\pi}{4} \sigma^x}\). |
|
The square root of the YPower gate \(e^{-i \frac{\pi}{4} \sigma^y}\). |
|
A generic square lattice device with only next-neighbours-connectivity. |
|
The single-mode squeezing gate with tunable squeezing. |
|
The T gate. |
|
Implements Toffoli gate. |
|
The triple-controlled PauliX gate. |
|
The triple-controlled PauliZ gate. |
|
The triple-controlled PhaseShift gate. |
|
The variable-angle MolmerSorensen XX gate. |
|
The controlled XY quantum operation |
- class qoqo.AllToAllDevice(number_qubits, single_qubit_gates, two_qubit_gates, default_gate_time)
A generic device with all-to-all connectivity.
- Parameters:
number_qubits (int) -- Fixed number of qubits.
single_qubit_gates (List[str]) -- A list of 'hqslang' names of single-qubit-gates supported by the device.
two_qubit_gates (List[str]) -- A list of 'hqslang' names of basic two-qubit-gates supported by the device.
default_gate_time (float) -- The default startig gate time.
- add_damping(damping)
Adds single qubit damping to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
damping (float) -- The damping rates.
- Raises:
PyValueError -- Qubit is not in device
- add_damping_all()
Adds qubit damping to noise rates.
- Parameters:
damping (float) -- The damping rates.
- Returns:
The new device with the new properties
- Return type:
Self
- add_dephasing(dephasing)
Adds single qubit dephasing to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
dephasing (float) -- The dephasing rates.
- Raises:
PyValueError -- Qubit is not in device
- add_dephasing_all()
Adds qubit dephasing to noise rates.
- Parameters:
dephasing (float) -- The dephasing rates.
- Returns:
The new device with the new properties
- Return type:
Self
- add_depolarising(depolarising)
Adds single qubit depolarising to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
depolarising (float) -- The depolarising rates.
- Raises:
PyValueError -- Qubit is not in device
- add_depolarising_all()
Adds qubit depolarising to noise rates.
- Parameters:
depolarising (float) -- The depolarising rates.
- Returns:
The new device with the new properties
- Return type:
Self
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the qoqo device to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Device (in bincode form).
- Returns:
The deserialized Device.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Device.
- static from_json(input)
Convert the json representation of a device to a qoqo device.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Device.
- generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- multi_qubit_gate_names()
Returns the names of a mutli qubit operations available on the device.
The list of names also includes the three qubit gate operations.
- Returns:
The list of gate names.
- Return type:
List[str]
- multi_qubit_gate_time(qubits)
Returns the gate time of a multi qubit operation if the multi qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a multi qubit gate.
qubits (List[int]) -- The qubits the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- number_qubits()
Return number of qubits in device.
- Returns:
The number of qubits.
- Return type:
int
- qubit_decoherence_rates()
Return the matrix of the decoherence rates of the Lindblad equation.
- Parameters:
qubit (int) -- The qubit for which the rate matrix M is returned
- Returns:
3 by 3 numpy array of decoherence rates
- Return type:
np.array
- set_all_qubit_decoherence_rates()
Function to set the decoherence rates for all qubits in the AllToAllDevice device.
- Parameters:
rates (2darray):: Decoherence rates provided as (3x3)
- Returns:
The new device with the new properties
- Return type:
Self
- Raises:
PyValueError -- The input parameter rates needs to be a (3x3)-matrix.
- set_all_single_qubit_gate_times(gate_time, /)
Set gate time of all single-qubit gates of specific type
- Parameters:
gate (str) -- The hqslang name of the single-qubit-gate.
gate_time (float) -- New gate time.
- Returns:
The new device with the new properties
- Return type:
Self
- set_all_two_qubit_gate_times(gate_time, /)
Set gate time of all single-qubit gates of specific type
- Parameters:
gate (str) -- The hqslang name of the two-qubit-gate.
gate_time (float) -- New gate time.
- Returns:
The new device with the new properties.
- Return type:
Self
- set_multi_qubit_gate_time(qubits, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (List[int]) -- The qubits for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubits not in device
- set_qubit_decoherence_rates(rates)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_single_qubit_gate_time(qubit, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubit (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_three_qubit_gate_time(control_0, control_1, target, gate_time)
Set the gate time of a three qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control_0 (int) -- The control_0 qubit for which the gate time is set
control_1 (int) -- The control_1 qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_two_qubit_gate_time(control, target, gate_time)
Set the gate time of a two qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control (int) -- The control qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- single_qubit_gate_names()
Returns the names of a single qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- single_qubit_gate_time(qubit)
Returns the gate time of a single qubit operation if the single qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
qubit (int) -- The qubit the gate acts on
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- three_qubit_gate_time()
three_qubit_gate_time(gate, control_0, control_1, target --
Returns the gate time of a three qubit operation if the three qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control_0 (int) -- The control_0 qubit the gate acts on.
control_1 (int) -- The control_1 qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- to_bincode()
Return the bincode representation of the Device using the bincode crate.
- Returns:
The serialized Device (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Device to bytes.
- to_generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- to_json()
Return the json representation of the Device.
- Returns:
The serialized form of Device.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Device to json.
- two_qubit_edges()
Return the list of pairs of qubits linked by a native two-qubit-gate in the device.
A pair of qubits is considered linked by a native two-qubit-gate if the device can implement a two-qubit-gate between the two qubits without decomposing it into a sequence of gates that involves a third qubit of the device. The two-qubit-gate also has to form a universal set together with the available single qubit gates.
The returned vectors is a simple, graph-library independent, representation of the undirected connectivity graph of the device. It can be used to construct the connectivity graph in a graph library of the user's choice from a list of edges and can be used for applications like routing in quantum algorithms.
- Returns:
List of two qubit edges in the undirected connectivity graph
- Return type:
Sequence[(int, int)]
- two_qubit_gate_names()
Returns the names of a two qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- two_qubit_gate_time(control, target)
Returns the gate time of a two qubit operation if the two qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- class qoqo.BeamSplitter(mode_0, mode_1, theta, phi)
The 2-mode beam splitter which splits a beam with a transmission amplitude cos(θ) and a reflection amplitude exp(i * φ) * sin(θ).
- Parameters:
mode_0 (int) -- The first mode the beam-splitter is applied to.
mode_1 (int) -- The second mode the beam-splitter is applied to.
theta (CalculatorFloat) -- The transmittivity angle of the beam-splitter.
phi (CalculatorFloat) -- The phase angle of the beam-splitter.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode_0()
Return mode_0 bosonic mode of two bosonic mode Operation.
- Returns:
int
- mode_1()
Return mode_1 bosonic mode of two bosonic mode Operation.
- Returns:
int
- phi()
Returns value of attribute phi
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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 value of attribute theta
- class qoqo.Bogoliubov(control, target, delta_real, delta_imag)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.CNOT(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.CZQubitResonator(qubit, mode)
Controlled-Z operation between a qubit and a bosonic mode, where the two-dimensional subspace of the bosonic mode spanned by the occupation number states |0⟩_B and |1⟩_B is considered as the second qubit involved in the CZ operation.
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.Cheated(constant_circuit, circuits, input)
Collected information for executing a cheated measurement.
- Parameters:
constant_circuit (Optional[Circuit]) -- The constant Circuit that is executed before each Circuit in circuits.
circuits (List[Circuit]) -- The collection of quantum circuits executed for the measurement.
input (CheatedInput) -- The additional input information required for measurement.
- Returns:
The new measurement.
- Return type:
- circuits()
Return the collection of quantum circuits for the separate cheated measurements.
- Returns:
The quantum circuits.
- Return type:
List[Circuit]
- constant_circuit()
Returns constant circuit that is executed before any Circuit in circuits.
- Returns:
The constant Circuit (None if not defined).
- Return type:
Optional[Circuit]
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- evaluate(input_bit_registers, float_registers, complex_registers)
Execute the cheated measurement.
- Parameters:
input_bit_registers (Dict[str, Union[List[List[int]], List[List[bool]]]]) -- The classical bit registers with the register name as key.
float_registers (Dict[str, List[List[float]]]) -- The classical float registers as a dictionary with the register name as key.
complex_registers (Dict[str, List[List[complex]]]) -- The classical complex registers as a dictionary with the register name as key.
- Returns:
The evaluated expectation values.
- Return type:
Optional[Dict[str, float]]
- Raises:
RuntimeError -- Unexpected repetition of key in bit_register.
RuntimeError -- Error evaluating cheated measurement.
- static from_bincode(input)
Convert the bincode representation of the Cheated to a Cheated using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized Cheated (in [bincode] form).
- Returns:
The deserialized Cheated.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to Cheated.
- static from_json(json_string)
Deserialize the Cheated measurement from json form.
- Returns:
The deserialized Cheated Measurement.
- Return type:
- Raises:
RuntimeError -- Cannot deserialize string to Cheated.
- input()
Returns the measurement input data defining how to construct expectation values from measurements.
- Returns:
The input of Cheated measurement
- Return type:
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- measurement_type()
Returns the type of the measurement in string form.
- Returns:
The type of the measurement.
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- substitute_parameters(substituted_parameters)
Return copy of Measurement with symbolic parameters replaced.
- Parameters:
substituted_parameters (Dict[str, float]) -- The dictionary containing the substitutions to use in the Circuit.
- Raises:
RuntimeError -- Error substituting symbolic parameters.
- to_bincode()
Return the bincode representation of the Cheated using the [bincode] crate.
- Returns:
The serialized Cheated (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Cheated to bytes.
- to_json()
Serialize the Cheated measurement to json form.
- Returns:
The serialized Cheated measurement.
- Return type:
str
- Raises:
RuntimeError -- Unexpected error serializing Cheated.
- class qoqo.CheatedInput(number_qubits)
Provides Necessary Information to run a cheated measurement.
The CheatedInput stores the number of qubits that are measured and a dictionary mapping expectation value names to operators on the Hilbert space of the qubits. The operators are represented by sparse lists of non-zero entry triples of an operator matrix.
- Parameters:
number_qubits (int) -- The number of qubits in the PauliZProduct measurement.
- Returns:
- The new instance of CheatedInput with the specified number of qubits in input,
and an empty dictionay of expectation values.
- Return type:
- add_operator_exp_val(name, operator, readout)
Add operator based expectation value to measurement input.
Adds an expectation value that is defined by an operator on the Hilbert space.
- Parameters:
name (str) -- The name of the expectation value.
operator (List[(int, int, complex)]) -- The measured operator on the Hilbert space, given as a list of sparse matrix entries of the form (row, col, value).
readout (str) -- The mame of the readout register that contains the density matrix or satevector.
- Raises:
RuntimeError -- Failed to add operator based expectation value.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the CheatedInput to a CheatedInput using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized CheatedInput (in [bincode] form).
- Returns:
The deserialized CheatedInput.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to CheatedInput.
- static from_json(json_string)
Deserialize the CheatedInput from json form.
- Returns:
The deserialized CheatedInput.
- Return type:
- Raises:
PyRuntimeError -- Cannot deserialize string to CheatedInput.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of the CheatedInput using the [bincode] crate.
- Returns:
The serialized CheatedInput (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize CheatedInput to bytes.
- to_json()
Serialize the CheatedInput to json form.
- Returns:
The serialized CheatedInput.
- Return type:
str
- Raises:
PyRuntimeError -- Unexpected error serializing CheatedInput.
- class qoqo.CheatedPauliZProduct(constant_circuit, circuits, input)
Collected information for executing a cheated measurement of PauliZ product.
- Parameters:
constant_circuit (Optional[Circuit]) -- The constant Circuit that is executed before each Circuit in circuits.
circuits (List[Circuit]) -- The collection of quantum circuits for the separate basis rotations.
input (CheatedPauliZProductInput) -- The additional input information required for measurement.
- Returns:
The CheatedPauliZProduct containing the new cheated PauliZ product measurement.
- Return type:
self
- circuits()
Returns the collection of quantum circuits for the separate basis rotations.
- Returns:
The quantum circuits.
- Return type:
List[Circuit]
- constant_circuit()
Returns constant circuit that is executed before any Circuit in circuits.
- Returns:
The constant Circuit (None if not defined).
- Return type:
Optional[Circuit]
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- evaluate(input_bit_registers, float_registers, complex_registers)
Executes the cheated PauliZ product measurement.
- Parameters:
input_bit_registers (Dict[str, Union[List[List[int]], List[List[bool]]]]) -- The classical bit registers with the register name as key
float_registers (Dict[str, List[List[float]]]) -- The classical float registers as a dictionary with the register name as key
complex_registers (Dict[str, List[List[complex]]]) -- The classical complex registers as a dictionary with the register name as key
- Returns:
The evaluated measurement.
- Return type:
Optional[Dict[str, float]]
- Raises:
RuntimeError -- Unexpected repetition of key in bit_register.
RuntimeError -- Error evaluating cheated PauliZ product measurement.
- static from_bincode(input)
Convert the bincode representation of the CheatedPauliZProduct to a CheatedPauliZProduct using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized CheatedPauliZProduct (in [bincode] form).
- Returns:
The deserialized CheatedPauliZProduct.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to CheatedPauliZProduct.
- static from_json(json_string)
Deserialize the CheatedPauliZProduct from json form using the [serde_json] crate.
- Returns:
the deserialized CheatedPauliZProduct.
- Return type:
- Raises:
RuntimeError -- Cannot deserialize string to CheatedPauliZProduct.
- input()
Returns the measurement input data defining how to construct expectation values from measurements.
- Returns:
The measurment input of CheatedPauliZProduct.
- Return type:
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- measurement_type()
Returns the type of the measurement in string form.
- Returns:
The type of the measurement.
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- substitute_parameters(substituted_parameters)
Returns clone of Measurement with symbolic parameters replaced
- Parameters:
substituted_parameters (Dict[str, float]) -- The dictionary containing the substitutions to use in the Circuit.
- to_bincode()
Return the bincode representation of the CheatedPauliZProduct using the [bincode] crate.
- Returns:
The serialized CheatedPauliZProduct (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize CheatedPauliZProduct to bytes.
- to_json()
Serializes the CheatedPauliZProduct to json form using the [serde_json] crate.
- Returns:
The serialized CheatedPauliZProduct.
- Return type:
str
- Raises:
RuntimeError -- Unexpected error serializing CheatedPauliZProduct.
- class qoqo.CheatedPauliZProductInput
Collected information for executing a cheated basis rotation measurement.
The CheatedPauliZProductInput starts with just the number of qubtis and flipped measurements set. The pauli_poduct_qubit_masks and measured_exp_vals start empty and can be extended with [CheatedPauliZProductInput::add_linear_exp_val] and [CheatedPauliZProductInput::add_symbolic_exp_val].
- Returns:
- The new instance of CheatedPauliZProductInput with measured_exp_vals = an empty
HashMap and pauli_product_keys = an empty HashMap.
- Return type:
self
- add_linear_exp_val(name, linear)
Add linear definition of expectation value to measurement input.
Adds an expectation value that is defined by a linear combination of expectation values of Pauli products.
- Parameters:
name (str) -- The name of the expectation value.
linear (Dict[int, float]) -- The linear combination of expectation values as a map between Pauli product index and coefficient.
- Raises:
RuntimeError -- Failed to add linear expectation value.
- add_pauliz_product(readout)
Add measured Pauli product to CheatedPauliZProductInput and returns index of Pauli product.
When the pauli product is already in the measurement input the function only returns its index.
- Parameters:
readout (str) -- The name of the readout register containing the pauli_product expectation value.
- Returns:
The index of the added Pauli product in the list of all Pauli products.
- Return type:
int
- add_symbolic_exp_val(name, symbolic)
Add symbolic definition of expectation value to measurement input.
Adds an expectation value that is defined by a symbolic combination of expectation values of Pauli products.
- Parameters:
name (str) -- The name of the expectation value.
symbolic (str) -- The symbolic expression for the expectation values given by [qoqo_calculator::CalculatorFloat].
- Raises:
RuntimeError -- Failed to add symbolic expectation value.
The i-th PauliProducts are hardcoded as variables pauli_product_i in the string expression of CalculatorFloat.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the CheatedPauliZProductInput to a CheatedPauliZProductInput using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized CheatedPauliZProductInput (in [bincode] form).
- Returns:
The deserialized CheatedPauliZProductInput.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to CheatedPauliZProductInput.
- static from_json(json_string)
Deserialize the CheatedPauliZProductInput from json form.
- Returns:
The deserialized CheatedPauliZProductInput.
- Return type:
- Raises:
PyRuntimeError -- Cannot deserialize string to CheatedPauliZProductInput.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of the CheatedPauliZProductInput using the [bincode] crate.
- Returns:
The serialized CheatedPauliZProductInput (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize CheatedPauliZProductInput to bytes.
- to_json()
Serialize the CheatedPauliZProductInput to json form.
- Returns:
The serialized CheatedPauliZProductInput.
- Return type:
str
- Raises:
PyRuntimeError -- Unexpected error serializing CheatedPauliZProductInput.
- class qoqo.Circuit
Circuit of Operations.
A quantum program is represented as a linear sequence of Operations.
- add(op)
Add an Operation to Circuit.
- Parameters:
op (Operation) -- The Operation to add to the Circuit.
- count_occurences(operations)
Count the number of occurences of a set of operation tags in the circuit.
- Parameters:
operations (List[str]) -- List of operation tags that should be counted.
- Returns:
The number of occurences of these operation tags.
- Return type:
int
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- definitions()
Return a list of definitions in the Circuit.
Definitions need to be unique.
- Returns:
A vector of the definitions in the Circuit.
- Return type:
List[Operation]
- filter_by_tag(tag)
Return a list of operations with given tag.
- Parameters:
tag (str) -- tag by which to filter operations.
- Returns:
A vector of the operations with the specified tag in the Circuit.
- Return type:
List[Operation]
- static from_bincode(input)
Convert the bincode representation of the Circuit to a Circuit using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized Circuit (in [bincode] form).
- Returns:
The deserialized Circuit.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to Circuit.
- static from_json(json_string)
Convert the json representation of a Circuit to a Circuit.
- Parameters:
input (str) -- The serialized Circuit in json form.
- Returns:
The deserialized Circuit.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to Circuit.
- get(index)
Return a copy of the Operation at a certain index of the Circuit.
- Parameters:
index (int) -- The index of the Operation to get in the Circuit.
- Returns:
The operation at the given index (if it exists).
- Return type:
Operation
- Raises:
IndexError -- Index out of range.
- get_operation_types()
Return a list of the hqslang names of all operations occuring in the circuit.
- Returns:
The operation types in the Circuit.
- Return type:
Set[str]
- get_slice(start=None, stop=None)
Return the copy of a slice of the Circuit.
- Parameters:
start (Optional[int]) -- The starting index of the slice (inclusive).
stop (Optional[int]) -- The stopping index of the slice (exclusive).
- Returns:
The slice of the operations in the Circuit with the specified indices.
- Return type:
- Raises:
IndexError -- Stop index smaller than start index.
IndexError -- Stop index out of range.
IndexError -- Start index out of range.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- operations()
Return a list of all operations in the Circuit.
- Returns:
A vector of the operations in the Circuit.
- Return type:
List[Operation]
- overrotate()
Return clone of the circuit with all overrotation Pragmas applied.
- Returns:
Circuit with the overrotation applied
- Return type:
- Raises:
RuntimeError -- Error applying PragmaOverrotation in circuit.
Example:
>>> circuit = Circuit() >>> circuit += PragmaOverrotation("RotateY", [1,], 20.0, 30.0) >>> circuit += RotateX(0, 0.0) >>> circuit += RotateY(0, 1.0) >>> circuit += RotateY(1, 2.0) >>> circuit += RotateY(1, 3.0) >>> circuit_overrotated = circuit.overrotate() print(circuit) print(circuit_overrotated)
- remap_qubits(mapping)
Remap qubits in operations in clone of Circuit.
- Parameters:
mapping (Dict[int, int]) -- The dictionary containing the {qubit: qubit} mapping to use in the Circuit.
- Returns:
The Circuit 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 Circuit according to the substitution_parameters input.
- Parameters:
substitution_parameters (Dict[str, float]) -- The dictionary containing the substitutions to use in the Circuit.
- Returns:
The Circuit with the parameters substituted.
- Return type:
self
- Raises:
RuntimeError -- The parameter substitution failed.
- to_bincode()
Return the bincode representation of the Circuit using the [bincode] crate.
- Returns:
The serialized Circuit (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Circuit to bytes.
- to_json()
Return the json representation of the Circuit.
- Returns:
The serialized form of Circuit.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Circuit to json.
- class qoqo.CircuitDag(node_number=100, edge_number=300)
Represents the Direct Acyclic Graph (DAG) of a Circuit.
- add_to_back(op)
Add an Operation to the back of the CircuitDag, if necessary.
- Parameters:
op (Operation) -- The Operation to add to the back of the CircuitDag.
- Raises:
TypeError -- The Python Object cannot be converted to Operation.
- add_to_front(op)
Add an Operation to the front of the CircuitDag, if necessary.
- Parameters:
op (Operation) -- The Operation to add to the front of the CircuitDag.
- Raises:
TypeError -- The Python Object cannot be converted to Operation.
- blocking_predecessors(already_executed, to_be_executed)
Checks which of the direct predecessors of an Operation in the CircuitDag blocks the execution.
Warning: This method can only be used to determine if an operation can be executed when already_executed is consistent. When the list already_executed is inconsistent (a n operation is reported as executed that could not have been executed yet) this method returning an empty vector does not imply that the to_be_executed operation can be executed.
- Parameters:
already_executed (List[int]) -- List of NodeIndices of Nodes that have already been executed in the Circuit.
to_be_executed (int) -- NodeIndex of the Operation that should be executed next.
- Returns:
List containing the sorted blocking elements.
- Return type:
List[int]
- commuting_operations()
Returns the list of nodes of commuting operations in CircuitDag.
- Returns:
The list of nodes of commuting operations.
- Return type:
List[int]
- execution_blocked(already_executed, to_be_executed)
Checks if executing an operation is blocked by any not-yet executed operation.
- Parameters:
already_executed (List[int]) -- List of NodeIndices of Nodes that have already been executed in the Circuit.
to_be_executed (int) -- NodeIndex of the operation that should be executed next.
- Returns:
List containing the sorted blocking elements.
- Return type:
List[int]
- first_operation_involving_classical()
Returns a dictionary where a key is composed by the name and the size of the classical register and its value represents the first node that involves that register.
- Returns:
The dictionary of {(str, int), int} elements.
- Return type:
Dict[(str, int), int]
- first_operation_involving_qubit()
Returns a dictionary where a key represents a qubit and its value represents the first node that involves that qubit.
- Returns:
The dictionary of {qubit: node} elements.
- Return type:
Dict[int, int]
- first_parallel_block()
Returns a set containing the nodes in the first parallel block.
- Returns:
The set of nodes in the first parallel block.
- Return type:
Set[int]
- static from_bincode(input)
Convert the bincode representation of the CircuitDag to a CircuitDag using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized CircuitDag (in [bincode] form).
- Returns:
The deserialized CircuitDag.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to CircuitDag.
- from_circuit()
Create a CircuitDag from a given Circuit;
- Parameters:
circuit (Circuit) -- The Circuit to build the new CircuitDag from.
- Returns:
The new CircuitDag.
- Return type:
self
- get(index)
Given a NodeIndex, returns the Operation contained in the node of the CircuitDag.
- Parameters:
index (int) -- The index of the node to get from the CircuitDag.
- Returns:
The Operation at the given index (if it exists).
- Return type:
Operation
- Raises:
IndexError -- Index out of range.
- last_operation_involving_classical()
Returns a dictionary where a key is composed by the name and the size of the classical register and its value represents the last node that involves that register.
- Returns:
The dictionary of {(str, int), int} elements.
- Return type:
Dict[(str, int), int]
- last_operation_involving_qubit()
Returns a dictionary where a key represents a qubit and its value represents the last node that involves that qubit.
- Returns:
The dictionary of {qubit: node} elements.
- Return type:
Dict[int, int]
- last_parallel_block()
Returns a set containing the nodes in the last parallel block.
- Returns:
The set of nodes in the last parallel block.
- Return type:
Set[int]
- new_front_layer(already_executed, current_front_layer, to_be_executed)
Returns a new front-layer after executing an operation from the current front layer.
Returns an error if operation to be executed is not in the current front layer.
- Parameters:
already_executed (List[int]) -- List of NodeIndices of Nodes that have already been executed in the Circuit.
current_front_layer (List[int]) -- List of NodeIndices in the current front layer ready to be executed if physically possible.
to_be_executed (int) -- NodeIndex of the operation that should be executed next.
- parallel_blocks()
Returns an iterator over the possible parallel blocks in circuit that can be executed simultaneously
Returns an Iterator over Vectors of references to the NodeIndices in the parallel block as well as references to the Operation in the blocks
- successors(node)
Returns the list of the successors of a given node in the CircuitDag.
- to_bincode()
Return the bincode representation of the CircuitDag using the [bincode] crate.
- Returns:
The serialized CircuitDag (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize CircuitDag to bytes.
- to_circuit()
Transforms the CircuitDag into a Circuit.
- class qoqo.ClassicalRegister(constant_circuit, circuits)
Collected information for executing a classical register.
- Parameters:
- Returns:
The new register.
- Return type:
- circuits()
Return the collection of quantum circuits that make up the total measurement.
- Returns:
The quantum circuits.
- Return type:
List[Circuit]
- constant_circuit()
Returns constant circuit that is executed before any Circuit in circuits.
- Returns:
The constant Circuit (None if not defined).
- Return type:
Optional[Circuit]
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the ClassicalRegister to a ClassicalRegister using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized ClassicalRegister (in [bincode] form).
- Returns:
The deserialized ClassicalRegister.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to ClassicalRegister.
- static from_json(json_string)
Deserialize the ClassicalRegister measurement from json form.
- Returns:
The deserialized ClassicalRegister Measurement.
- Return type:
- Raises:
PyRuntimeError -- Cannot deserialize string to ClassicalRegister.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- measurement_type()
Returns the type of the measurement in string form.
- Returns:
The type of the measurement.
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- substitute_parameters(substituted_parameters)
Return copy of Measurement with symbolic parameters replaced.
- Parameters:
substituted_parameters (Dict[str, float]) -- The dictionary containing the substitutions to use in the Circuit.
- Raises:
RuntimeError -- Error substituting symbolic parameters.
- to_bincode()
Return the bincode representation of the ClassicalRegister using the [bincode] crate.
- Returns:
The serialized ClassicalRegister (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize ClassicalRegister to bytes.
- to_json()
Serialize the ClassicalRegister measurement to json form.
- Returns:
The serialized ClassicalRegister measurement.
- Return type:
str
- Raises:
PyRuntimeError -- Unexpected error serializing ClassicalRegister.
- class qoqo.ComplexPMInteraction(control, target, t_real, t_imag)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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
- 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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ContinuousDecoherenceModel(noise_operator=None)
Noise model representing a continuous decoherence process on qubits.
This noise model assumes that all qubits are constantly experiencing decoherence over time (e.g. due to coupling to the environment). The noise for each qubit can be different but only single qubit noise is included in the model.
Noise is given by the rates of the Lindblad equation. The Lindblad equation is a so-called master equation for the time evolution of a density matrix. For the example of a single qubit the non-coherent part of the Lindblad equation can take the following form:
d/dt * ρ = Σ Mij * Li * ρ * Lj† - 1/2 * ( Lj† * Li * ρ + ρ * Lj† * Li),
where the indices i and j run from 0 to 2
with L0 = σ+, L1 = σ- and L3 = σz.
Here the genreal incoherent part of the Lindblad equation is internally represented by a [struqture::spins::PlusMinusLindbladNoiseOperator].
To create a complex decoherence model first create the Lindblad noise and then turn it into a ContinuousDecoherenceModel. For a simple decoherence model, use new to create an empty model and use the add_damping, add_excitation and add_dephasing methods. For more fine control access the internal lindblad_noise directly and modify it.
- Parameters:
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- Optional initialisation of Noise Model with given Lindblad operator.
- add_damping_rate(qubits, rate)
Convenience function to add damping to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add damping to.
rate (float) -- The damping rate.
- Returns:
The model with the damping added.
- Return type:
- add_dephasing_rate(qubits, rate)
Convenience function to add dephasing to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add dephasing to.
rate (float) -- The dephasing rate.
- Returns:
The model with the dephasing added.
- Return type:
- add_depolarising_rate(qubits, rate)
Convenience function to add depolarising to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add depolarising to.
rate (float) -- The depolarising rate.
- Returns:
The model with the depolarising added.
- Return type:
- add_excitation_rate(qubits, rate)
Convenience function to add excitation to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add excitation to.
rate (float) -- The excitation rate.
- Returns:
The model with the excitation added.
- Return type:
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the Noise-Model to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a Noise-Model.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- get_noise_operator()
Return the internal Lindblad noise operator of the continuous noise model.
- Returns:
The internal Lindblad noise operator of the continuous noise
- Return type:
PlusMinusLindbladNoiseOperator
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of the Noise-Model using the bincode crate.
- Returns:
The serialized Noise-Model (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Noise-Model to bytes.
- to_json()
Return the json representation of the Noise-Model.
- Returns:
The serialized form of Noise-Model.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Noise-Model to json.
- class qoqo.ControlledControlledPauliZ(control_0, control_1, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the three-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledControlledPhaseShift(control_0, control_1, target, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledPauliY(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledPauliZ(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledPhaseShift(control, target, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledRotateX(control, target, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledRotateXY(control, target, theta, phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ControlledSWAP(control, target_0, target_1)
Implements ControlledSWAP 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 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 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 controlling qubit of the operation.
target_0 (int) -- The index of the second most significant qubit in the unitary representation. Here, the first targeting qubit of the operation.
target_1 (int) -- The index of the least significant qubit in the unitary representation. Here, the second targeting qubit of the operation.
- circuit()
Returns circuit implementing the ThreeQubitGateOperation
- Returns:
Circuit
- control()
Returns control qubit of the three-qubit operation
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_qubits()
List all involved qubits in the ControlledSWAP operation.
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- remap_qubits(mapping)
Remap qubits in the ControlledSWAP operation
- Parameters:
mapping (Dict[int, int]) -- The mapping to be used in the remapping.
- 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_0()
Returns target_0 qubit of the three-qubit operation
- target_1()
Returns target_1 qubit of the three-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.DecoherenceOnGateModel
Error model for noise that is only present on gate executions.
Adds additional noise when specific gates (identified by hqslang name and qubits acted on) are executed. The noise is given in the form of a struqture.spins.PlusMinusLindbladNoiseOperator the same way it is for the ContinuousDecoherence model.
Example:
``` from qoqo.noise_models import DecoherenceOnGateModel from struqture_py.spins import (PlusMinusLindbladNoiseOperator, PlusMinusProduct)
noise_model = DecoherenceOnGateModel() lindblad_noise = PlusMinusLindbladNoiseOperator() lindblad_noise.add_operator_product(
(PlusMinusProduct().z(0), PlusMinusProduct().z(0)), 0.9)
- lindblad_noise.add_operator_product(
(PlusMinusProduct().z(1), PlusMinusProduct().z(1)), 0.9)
noise_model = noise_model.set_two_qubit_term( "CNOT", 0,1, lindblad_noise ) ```
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the Noise-Model to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a Noise-Model.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- get_multi_qubit_gate_error(gate, qubits)
Return the extra noise for a multi qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
qubits (List[int]) -- The qubits the gate acts on.
- Returns:
The error model applied when gate is applied.
- Return type:
Optional[struqture_py.spins.PlusMinusLindbladNoiseOperator]
- get_single_qubit_gate_error(gate, qubit)
Return the extra noise for a single qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
qubit (int) -- The qubit the gate acts on.
- Returns:
The error model applied when gate is applied.
- Return type:
Optional[struqture_py.spins.PlusMinusLindbladNoiseOperator]
- get_three_qubit_gate_error(gate, control0, control1, target)
Return the extra noise for a three qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
control0 (int) -- The first control qubit the gate acts on.
control1 (int) -- The second control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
The error model applied when gate is applied.
- Return type:
Optional[struqture_py.spins.PlusMinusLindbladNoiseOperator]
- get_two_qubit_gate_error(gate, control, target)
Return the extra noise for a single qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
The error model applied when gate is applied.
- Return type:
Optional[struqture_py.spins.PlusMinusLindbladNoiseOperator]
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- set_multi_qubit_gate_error(gate, qubits, noise_operator)
Set extra noise for a multi qubit gate.
- Parameters:
gate (str) -- The name of the gate.
qubits (list) -- The qubits the gate acts on.
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- The noise affecting system when gate is applied.
- Returns:
The error model with the new noise on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise operator is not a struqture.spins.PlusMinusLindbladNoiseOperator.
- set_single_qubit_gate_error(gate, qubit, noise_operator)
Set extra noise for a single qubit gate.
- Parameters:
gate (str) -- The name of the gate.
qubit (int) -- The qubit the gate acts on.
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- The noise affecting system when gate is applied.
- Returns:
The error model with the new noise on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise operator is not a struqture.spins.PlusMinusLindbladNoiseOperator.
- set_three_qubit_gate_error(gate, control0, control1, target, noise_operator)
Set extra noise for a single qubit gate.
- Parameters:
gate (str) -- The name of the gate.
control0 (int) -- The first control qubit the gate acts on.
control1 (int) -- The second control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- The noise affecting system when gate is applied.
- Returns:
The error model with the new noise on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise operator is not a struqture.spins.PlusMinusLindbladNoiseOperator.
- set_two_qubit_gate_error(gate, control, target, noise_operator)
Set extra noise for a two qubit gate.
- Parameters:
gate (str) -- The name of the gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- The noise affecting system when gate is applied.
- Returns:
The error model with the new noise on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise operator is not a struqture.spins.PlusMinusLindbladNoiseOperator.
- to_bincode()
Return the bincode representation of the Noise-Model using the bincode crate.
- Returns:
The serialized Noise-Model (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Noise-Model to bytes.
- to_json()
Return the json representation of the Noise-Model.
- Returns:
The serialized form of Noise-Model.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Noise-Model to json.
- class qoqo.DecoherenceOnIdleModel(noise_operator=None)
Noise model representing a continuous decoherence process on idle qubits.
The purpose of this noise model is to enable defining background noise models that exclude the qubits involved in a gate, as these might be decoupled from the background noise.The noise for each qubit can be different but only single qubit noise is included in the model.
Noise is given by the rates of the Lindblad equation. The Lindblad equation is a so-called master equation for the time evolution of a density matrix. For the example of a single qubit the non-coherent part of the Lindblad equation can take the following form:
d/dt * ρ = Σ Mij * Li * ρ * Lj† - 1/2 * ( Lj† * Li * ρ + ρ * Lj† * Li),
where the indices i and j run from 0 to 2
with L0 = σ+, L1 = σ- and L3 = σz.
Here the genreal incoherent part of the Lindblad equation is internally represented by a [struqture::spins::PlusMinusLindbladNoiseOperator].
To create a complex decoherence model first create the Lindblad noise and then turn it into a DecoherenceOnIdleModel. For a simple decoherence model, use new to create an empty model and use the add_damping, add_excitation and add_dephasing methods. For more fine control access the internal lindblad_noise directly and modify it.
- Parameters:
noise_operator (struqture_py.spins.PlusMinusLindbladNoiseOperator) -- Optional initialisation of Noise Model with given Lindblad operator.
- add_damping_rate(qubits, rate)
Convenience function to add damping to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add damping to.
rate (float) -- The damping rate.
- Returns:
The model with the damping added.
- Return type:
- add_dephasing_rate(qubits, rate)
Convenience function to add dephasing to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add dephasing to.
rate (float) -- The dephasing rate.
- Returns:
The model with the dephasing added.
- Return type:
- add_depolarising_rate(qubits, rate)
Convenience function to add depolarising to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add depolarising to.
rate (float) -- The depolarising rate.
- Returns:
The model with the depolarising added.
- Return type:
- add_excitation_rate(qubits, rate)
Convenience function to add excitation to several qubits
- Parameters:
qubits (List[int]) -- The qubits to add excitation to.
rate (float) -- The excitation rate.
- Returns:
The model with the excitation added.
- Return type:
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the Noise-Model to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a Noise-Model.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- get_noise_operator()
Return the internal Lindblad noise operator of the continuous noise model.
- Returns:
The internal Lindblad noise operator of the continuous noise
- Return type:
PlusMinusLindbladNoiseOperator
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of the Noise-Model using the bincode crate.
- Returns:
The serialized Noise-Model (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Noise-Model to bytes.
- to_json()
Return the json representation of the Noise-Model.
- Returns:
The serialized form of Noise-Model.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Noise-Model to json.
- class qoqo.DefinitionBit(name, length, is_output)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- length()
Get value of struct field length
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.DefinitionComplex(name, length, is_output)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- length()
Get value of struct field length
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.DefinitionFloat(name, length, is_output)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- length()
Get value of struct field length
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.DefinitionUsize(name, length, is_output)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- length()
Get value of struct field length
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.EchoCrossResonance(control, target)
Implements the controlled RotateXY operation.
The unitary matrix representation is:
\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 0 & 1 & 0 & i \\\\ 1 & 0 & -i & 0 \\\\ 0 & i & 0 & 1 \\\\ -i & 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 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.FSwap(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.Fsim(control, target, t, u, delta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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
- 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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.GPi(qubit, theta)
Implements a pi-rotation with an embedded phase.
\[\begin{split}U = \begin{pmatrix} 0 & e^{-i \theta} \\\\ e^{i \theta} & 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.GPi2(qubit, theta)
Implements a pi/2-rotation with an embedded phase.
\[\begin{split}U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -i e^{-i \theta} \\\\ -i e^{i \theta} & 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.GenericDevice(number_qubits)
A generic device assuming all-to-all connectivity between all involved qubits.
- Parameters:
number_qubits (int) -- The number of qubits in the device
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- add_damping(damping)
Adds single qubit damping to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
damping (float) -- The damping rates.
- Raises:
PyValueError -- Qubit is not in device
- add_dephasing(dephasing)
Adds single qubit dephasing to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
dephasing (float) -- The dephasing rates.
- Raises:
PyValueError -- Qubit is not in device
- add_depolarising(depolarising)
Adds single qubit depolarising to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
depolarising (float) -- The depolarising rates.
- Raises:
PyValueError -- Qubit is not in device
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the qoqo device to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Device (in bincode form).
- Returns:
The deserialized Device.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Device.
- static from_json(input)
Convert the json representation of a device to a qoqo device.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Device.
- generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- multi_qubit_gate_names()
Returns the names of a mutli qubit operations available on the device.
The list of names also includes the three qubit gate operations.
- Returns:
The list of gate names.
- Return type:
List[str]
- multi_qubit_gate_time(qubits)
Returns the gate time of a multi qubit operation if the multi qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a multi qubit gate.
qubits (List[int]) -- The qubits the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- number_qubits()
Return number of qubits in device.
- Returns:
The number of qubits.
- Return type:
int
- qubit_decoherence_rates()
Return the matrix of the decoherence rates of the Lindblad equation.
- Parameters:
qubit (int) -- The qubit for which the rate matrix M is returned
- Returns:
3 by 3 numpy array of decoherence rates
- Return type:
np.array
- set_multi_qubit_gate_time(qubits, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (List[int]) -- The qubits for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubits not in device
- set_qubit_decoherence_rates(rates)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_single_qubit_gate_time(qubit, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubit (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_three_qubit_gate_time(control_0, control_1, target, gate_time)
Set the gate time of a three qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control_0 (int) -- The control_0 qubit for which the gate time is set
control_1 (int) -- The control_1 qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_two_qubit_gate_time(control, target, gate_time)
Set the gate time of a two qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control (int) -- The control qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- single_qubit_gate_names()
Returns the names of a single qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- single_qubit_gate_time(qubit)
Returns the gate time of a single qubit operation if the single qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
qubit (int) -- The qubit the gate acts on
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- three_qubit_gate_time()
three_qubit_gate_time(gate, control_0, control_1, target --
Returns the gate time of a three qubit operation if the three qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control_0 (int) -- The control_0 qubit the gate acts on.
control_1 (int) -- The control_1 qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- to_bincode()
Return the bincode representation of the Device using the bincode crate.
- Returns:
The serialized Device (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Device to bytes.
- to_generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- to_json()
Return the json representation of the Device.
- Returns:
The serialized form of Device.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Device to json.
- two_qubit_edges()
Return the list of pairs of qubits linked by a native two-qubit-gate in the device.
A pair of qubits is considered linked by a native two-qubit-gate if the device can implement a two-qubit-gate between the two qubits without decomposing it into a sequence of gates that involves a third qubit of the device. The two-qubit-gate also has to form a universal set together with the available single qubit gates.
The returned vectors is a simple, graph-library independent, representation of the undirected connectivity graph of the device. It can be used to construct the connectivity graph in a graph library of the user's choice from a list of edges and can be used for applications like routing in quantum algorithms.
- Returns:
List of two qubit edges in the undirected connectivity graph
- Return type:
Sequence[(int, int)]
- two_qubit_gate_names()
Returns the names of a two qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- two_qubit_gate_time(control, target)
Returns the gate time of a two qubit operation if the two qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- class qoqo.GivensRotation(control, target, theta, phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.GivensRotationLittleEndian(control, target, theta, phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.Hadamard(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ISwap(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.Identity(qubit)
The Identity 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.ImperfectReadoutModel
Noise model representing readout errors.
Readout errors are modeled by two probabilities in this simple model. One probability to detect a 1 instead of a 0 when the quantum measurement gives 0 and one probability to detect a 0 instead of a 1 when the quantum measurement gives 1.
# Example
```Python form qoqo.noise_models import ImperfectReadoutModel
model = ImperfectReadoutModel.new_with_uniform_error(3, 0.5, 0.5); model = model.set_error_probabilites(2, 0.3, 0.7) uniform_prob = model.prob_detect_0_as_1(0) assert uniform_prob == 0.5 lower_prob = model.prob_detect_0_as_1(2) assert lower_prob == 0.3 higher_prob = model.prob_detect_1_as_0(2) assert higher_prob == 0.7 ```
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the Noise-Model to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a Noise-Model.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- static new_with_uniform_error(number_qubits, prob_detect_0_as_1, prob_detect_1_as_0)
Convenience function to create uniform error probabilities
- Parameters:
number_qubits (int) -- The number of qubits the uniform error probabilites should be initialized for.
prob_detect_0_as_1 (float) -- The error probability to detect a 1 instead of a 0 when measuring 0
prob_detect_1_as_0 (float) -- The error probability to detect a 0 instead of a 1 when measuring 1
- Returns:
The new error model
- Return type:
- Raises:
ValueError -- Raised if the error probabilities are not valid (< 0 or > 1)
- prob_detect_0_as_1(qubit)
Return probability to detect 0 as 1 for a qubit
- Parameters:
qubit (int) -- The qubit for which the probability is returned.
- Returns:
The probability to detect 0 as 1 for the qubit
- Return type:
float
- prob_detect_1_as_0(qubit)
Return probability to detect 1 as 0 for a qubit
- Parameters:
qubit (int) -- The qubit for which the probability is returned.
- Returns:
The probability to detect 1 as 0 for the qubit
- Return type:
float
- set_error_probabilites(qubit, prob_detect_0_as_1, prob_detect_1_as_0)
Set and overwrite the measurement error probabilities
- Parameters:
qubit (int) -- The qubitsfor which error rates is set.
prob_detect_0_as_1 (float) -- The error probability to detect a 1 instead of a 0 when measuring 0
prob_detect_1_as_0 (float) -- The error probability to detect a 0 instead of a 1 when measuring 1
- Returns:
The updated error model
- Return type:
Self
- Raises:
ValueError -- Raised if the error probabilities are not valid (< 0 or > 1).
- to_bincode()
Return the bincode representation of the Noise-Model using the bincode crate.
- Returns:
The serialized Noise-Model (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Noise-Model to bytes.
- to_json()
Return the json representation of the Noise-Model.
- Returns:
The serialized form of Noise-Model.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Noise-Model to json.
- class qoqo.InputBit(name, index, value)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.InputSymbolic(name, input)
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".
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.InvSGate(qubit)
The InvS 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.InvSXGate(qubit)
The InvSX gate.
\[\begin{split}U = \frac{1}{\sqrt(2)} \begin{pmatrix} 1-i & 1+i \\\\ 1+i & 1-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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.InvSqrtISwap(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.InvSqrtPauliX(qubit)
The inverse square root 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.InvSqrtPauliY(qubit)
The inverse square root YPower gate \(e^{i \frac{\pi}{4} \sigma^y}\).
\[\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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.InvTGate(qubit)
The InvT 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.JaynesCummings(qubit, mode, theta)
The Jaynes-Cummings gate exp(-i * θ * (σ^- * b^† + σ^+ * b))
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
theta (CalculatorFloat) -- The strength of the interaction.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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 value of attribute theta
- class qoqo.LongitudinalCoupling(qubit, mode, theta)
Longitudinal coupling gate exp(-i * θ * Z * (b^† + b))
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
theta (CalculatorFloat) -- The strength of the interaction.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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 value of attribute theta
- class qoqo.MeasureQubit(qubit, readout, readout_index)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.MolmerSorensenXX(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.MultiQubitMS(qubits, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.MultiQubitZZ(qubits, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PMInteraction(control, target, t)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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
- 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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PauliX(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PauliY(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PauliZ(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PauliZProduct(constant_circuit, circuits, input)
Collected information for executing a measurement of PauliZ product.
- Parameters:
constant_circuit (Optional[Circuit]) -- The constant Circuit that is executed before each Circuit in circuits.
circuits (List[Circuit]) -- The collection of quantum circuits for the separate basis rotations.
input (PauliZProductInput) -- The additional input information required for measurement.
- Returns:
The PauliZProduct containing the new PauliZ product measurement.
- Return type:
- circuits()
Return the collection of quantum circuits for the separate basis rotations.
- Returns:
The quantum circuits.
- Return type:
List[Circuit]
- constant_circuit()
Return constant circuit that is executed before any Circuit in circuits.
- Returns:
The constant Circuit (None if not defined).
- Return type:
Optional[Circuit]
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- evaluate(input_bit_registers, float_registers, complex_registers)
Execute the PauliZ product measurement.
- Parameters:
input_bit_registers (Dict[str, Union[List[List[int]], List[List[bool]]]]) -- The classical bit registers with the register name as key
float_registers (Dict[str, List[List[float]]]) -- The classical float registers as a dictionary with the register name as key
complex_registers (Dict[str, List[List[complex]]]) -- The classical complex registers as a dictionary with the register name as key
- Returns:
The evaluated measurement.
- Return type:
Optional[Dict[str, float]]
- Raises:
RuntimeError -- Unexpected repetition of key in bit_register.
RuntimeError -- Error evaluating PauliZ product measurement.
- static from_bincode(input)
Convert the bincode representation of the PauliZProduct to a PauliZProduct using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized PauliZProduct (in [bincode] form).
- Returns:
The deserialized PauliZProduct.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to PauliZProduct.
- static from_json(json_string)
Deserialize the PauliZProduct from json form using the [serde_json] crate.
- Returns:
The deserialized PauliZProduct.
- Return type:
- Raises:
RuntimeError -- Cannot deserialize string to PauliZProduct.
- input()
Returns the measurement input data defining how to construct expectation values from measurements.
- Returns:
The measurment input of PauliZProduct.
- Return type:
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- measurement_type()
Returns the type of the measurement in string form.
- Returns:
The type of the measurement.
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- substitute_parameters(substituted_parameters)
Return clone of Measurement with symbolic parameters replaced.
- Parameters:
substituted_parameters (Dict[str, float]) -- The dictionary containing the substitutions to use in the Circuit.
- to_bincode()
Return the bincode representation of the PauliZProduct using the [bincode] crate.
- Returns:
The serialized PauliZProduct (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize PauliZProduct to bytes.
- to_json()
Serialize the PauliZProduct to json form using the [serde_json] crate.
- Returns:
The serialized PauliZProduct.
- Return type:
str
- Raises:
RuntimeError -- Unexpected error serializing PauliZProduct.
- class qoqo.PauliZProductInput(number_qubits, use_flipped_measurement)
Provides Necessary Information to run a [roqoqo::measurements::PauliZProduct] measurement.
The PauliZProductInput starts with just the number of qubtis and flipped measurements set. The pauli_poduct_qubit_masks and measured_exp_vals start empty and can be extended with [PauliZProductInput::add_pauliz_product] [PauliZProductInput::add_linear_exp_val] and [PauliZProductInput::add_symbolic_exp_val]
- Parameters:
number_qubits (int) -- The number of qubits in the PauliZProduct measurement.
use_flipped_measurement (bool) -- Whether or not to use flipped measurements.
- Returns:
- The new instance of PauliZProductInput with pauli_product_qubit_masks = an empty dictionary, the
specified number of qubits in input, number_pauli_products = 0, measured_exp_vals = an empty dictionary, and whether to use flipped measurements as specified in input.
- Return type:
self
- add_linear_exp_val(name, linear)
Add linear definition of expectation value to measurement input.
Adds an expectation value that is defined by a linear combination of expectation values of Pauli products.
- Parameters:
name (str) -- The name of the expectation value.
linear (Dict[int, float]) -- The linear combination of expectation values as a map between Pauli product index and coefficient.
- Raises:
RuntimeError -- Failed to add linear expectation value.
- add_pauliz_product(readout, pauli_product_mask)
Add measured Pauli product to PauliZProductInput and returns index of Pauli product.
When the pauli product is already in the measurement input the function only returns it index.
- Parameters:
readout (str) -- The name of the readout register the pauli_product is defined on.
pauli_product_mask (List[int]) -- List of the qubits involved in the Pauli produc measurement.
- Returns:
The index of the added Pauli product in the list of all Pauli products.
- Return type:
int
- Raises:
RuntimeError -- Failed to add pauli product.
- add_symbolic_exp_val(name, symbolic)
Add symbolic definition of expectation value to measurement input.
Adds an expectation value that is defined by a symbolic combination of expectation values of Pauli products.
- Parameters:
name (str) -- The name of the expectation value.
symbolic (str) -- The symbolic expression for the expectation values given by [qoqo_calculator::CalculatorFloat].
- Raises:
RuntimeError -- Failed to add symbolic expectation value.
The i-th PauliProducts are hardcoded as variables pauli_product_i in the string expression of CalculatorFloat.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the PauliZProductInput to a PauliZProductInput using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized PauliZProductInput (in [bincode] form).
- Returns:
The deserialized PauliZProductInput.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to PauliZProductInput.
- static from_json(json_string)
Deserialize the PauliZProductInput from json form.
- Returns:
The deserialized PauliZProductInput.
- Return type:
- Raises:
PyRuntimeError -- Cannot deserialize string to PauliZProductInput.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of the PauliZProductInput using the [bincode] crate.
- Returns:
The serialized PauliZProductInput (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize PauliZProductInput to bytes.
- to_json()
Serialize the PauliZProductInput to json form.
- Returns:
The serialized PauliZProductInput.
- Return type:
str
- Raises:
PyRuntimeError -- Unexpected error serializing PauliZProductInput.
- class qoqo.PhaseDisplacement(mode, displacement, phase)
The single-mode phase-displacement gate with variable magnitude and phase.
- Parameters:
mode (int) -- The mode the phase-shift gate is applied to.
displacement (CalculatorFloat) -- The magnitude by which to displace the mode.
phase (CalculatorFloat) -- The angle by which to displace the mode.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- displacement()
Returns value of attribute displacement
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- phase()
Returns value of attribute phase
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.PhaseShift(mode, phase)
The single-mode phase-shift gate with variable phase, given by R(θ) = eexp(i * θ * 𝑁̂).
https://arxiv.org/pdf/2104.03241.pdf
- Parameters:
mode (int) -- The mode the phase-shift gate is applied to.
phase (CalculatorFloat) -- The phase by which to shift the mode.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- phase()
Returns value of attribute phase
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.PhaseShiftState0(qubit, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhaseShiftState1(qubit, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhaseShiftedControlledControlledPhase(control_0, control_1, target, theta, phi)
The phased-shifted double-controlled-Z gate.
The unitary matrix representation is:
\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & e^{i \phi} & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & e^{i \phi} & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & e^{i \phi} & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & e^{i (3\cdot\phi + \theta)} \end{pmatrix}\end{split}\]- Parameters:
control_0 (int) -- The index of the most significant qubit in the unitary representation. Here, the first qubit that controls the application of the phase-shift on the target qubit.
control_1 (int) -- The index of the second most significant qubit in the unitary representation. Here, the second qubit that controls the application of the phase-shift on the target qubit.
target (int)
phi (CalculatorFloat) -- The single qubit phase $phi$.
theta (CalculatorFloat) -- The phase rotation $theta$.
- 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 three-qubit operation
- theta()
Returns value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhaseShiftedControlledControlledZ(control_0, control_1, target, phi)
The phased-shifted double-controlled-Z gate.
The unitary matrix representation is:
\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & e^{i \phi} & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & e^{i \phi} & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & e^{i \phi} & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & e^{i (2\cdot\phi)} & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & e^{i (3\cdot\phi + \pi)} \end{pmatrix}\end{split}\]- Parameters:
control_0 (int) -- The index of the most significant qubit in the unitary representation. Here, the first qubit that controls the application of the phase-shift on the target qubit.
control_1 (int) -- The index of the second most significant qubit in the unitary representation. Here, the second qubit that controls the application of the phase-shift on the target qubit.
target (int)
phi (CalculatorFloat) -- The single qubit phase $phi$.
- 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 three-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhaseShiftedControlledPhase(control, target, theta, phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhaseShiftedControlledZ(control, target, phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.PhotonDetection(mode, readout, readout_index)
The photon number-resolving detector measurement for bosons.
This can be used as a single-shot measurement of the photon number. https://arxiv.org/pdf/0902.4824.pdf
- Parameters:
mode (int) -- The mode the detector (measurement) is applied to.
readout (str) -- The register for the readout.
readout_index (int) -- The index in the readout the result is saved to.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- readout()
Get value of struct field readout
- readout_index()
Get value of struct field readout_index
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.PragmaActiveReset(qubit)
This PRAGMA operation resets the chosen qubit to the zero state.
- Parameters:
qubit (int) -- The qubit to be reset.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaAnnotatedOp(operation, annotation)
An annotated Operation.
- Parameters:
operation (Operation) --
The Operation to be annotated.
annotation (str) --
The annotation.
- annotation()
Return the annotation.
- Returns:
The annotation.
- Return type:
str
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- operation()
Return the internal Operation.
- Returns:
The annotated Operation.
- Return type:
Operation
- 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]
- class qoqo.PragmaBoostNoise(noise_coefficient)
This PRAGMA operation boosts noise and overrotations in the circuit.
- Parameters:
noise_coefficient (CalculatorFloat) -- The coefficient by which the noise is boosted.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaConditional(condition_register, condition_index, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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.PragmaControlledCircuit(controlling_qubit, circuit)
A circuit controlled by a qubit.
The circuit is applied when the qubit is in state 1. Note that this is a unitary operation (for example a CNOT(0,1) is equvalent to a PragmaControlledCircuit(0, [PauliX(1)]) but it cannot be represented by a unitary operation in qoqo for arbitraty circuits.
- Parameters:
controlling_qubit (int) --
The qubit controlling circuit application.
circuit (Circuit) --
The circuit executed if the condition is met.
- circuit()
Get value of struct field circuit
- controlling_qubit()
Get value of struct field controlling_qubit
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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.PragmaDamping(qubit, gate_time, rate)
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).
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
superoperator of gate.
- Return type:
np.ndarray
- tags()
Returns tags identifying the Operation
- Returns:
The tags identifying the operation
- Return type:
List[str]
- class qoqo.PragmaDephasing(qubit, gate_time, rate)
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).
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
superoperator of gate.
- Return type:
np.ndarray
- tags()
Returns tags identifying the Operation
- Returns:
The tags identifying the operation
- Return type:
List[str]
- class qoqo.PragmaDepolarising(qubit, gate_time, rate)
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).
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
superoperator of gate.
- Return type:
np.ndarray
- tags()
Returns tags identifying the Operation
- Returns:
The tags identifying the operation
- Return type:
List[str]
- class qoqo.PragmaGeneralNoise(qubit, gate_time, rates)
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).
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaGetDensityMatrix(readout, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaGetOccupationProbability(readout, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaGetPauliProduct(qubit_paulis, readout, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaGetStateVector(readout, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaGlobalPhase(phase)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaLoop(repetitions, circuit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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
- 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.PragmaOverrotation(gate_hqslang, qubits, amplitude, variance)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaRandomNoise(qubit, gate_time, depolarising_rate, dephasing_rate)
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).
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
superoperator of gate.
- Return type:
np.ndarray
- tags()
Returns tags identifying the Operation
- Returns:
The tags identifying the operation
- Return type:
List[str]
- class qoqo.PragmaRepeatGate(repetition_coefficient)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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
- 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.PragmaRepeatedMeasurement(readout, number_measurements, qubit_mapping=None)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaSetDensityMatrix(density_matrix)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaSetNumberOfMeasurements(number_measurements, readout)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaSetStateVector(statevector)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaSleep(qubits, sleep_time)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaStartDecompositionBlock(qubits, reordering_dictionary)
This PRAGMA operation signals the START of a decomposition block.
- Parameters:
qubits (List[int]) -- The qubits involved in the decomposition block.
reordering_dictionary (Dict[int, int]) -- The reordering dictionary of the block.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaStopDecompositionBlock(qubits)
This PRAGMA operation signals the STOP of a decomposition block.
- Parameters:
qubits (List[int]) -- The qubits involved in the decomposition block.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.PragmaStopParallelBlock(qubits, execution_time)
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.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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.Qsim(control, target, x, y, z)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
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.QuantumProgram(measurement, input_parameter_names)
Represents a quantum program evaluating measurements based on a one or more free float parameters.
The main use of QuantumProgram is to contain a Measurements implementing [crate::measurements::Measure] that measures expectation values or output registers of [crate::Circuit] quantum circuits that contain symbolic parameters. Circuit with symbolic parameters can not be simulated or executed on real hardware. The symbolic parameters need to be replaced with real floating point numbers first. A QuantumProgram contains a list of the free parameters (input_parameter_names) and can automatically replace the parameters with its run methods and return the result.
The QuantumProgram should correspond as closely as possible to a normal multi-parameter function in classical computing that can be called with a set of parameters and returns a result. It is the intended way to interface between normal program code and roqoqo based quantum programs.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the QuantumProgram to a QuantumProgram using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized QuantumProgram (in [bincode] form).
- Returns:
The deserialized QuantumProgram.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to QuantumProgram.
- static from_json(input)
Convert the json representation of a QuantumProgram to a QuantumProgram.
- Parameters:
input (str) -- The serialized QuantumProgram in json form.
- Returns:
The deserialized QuantumProgram.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to QuantumProgram.
- input_parameter_names()
Returns the input_parameter_names attribute of the qoqo QuantumProgram.
- Returns:
List of input parameter names.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- measurement()
Returns the measurement attribute of the QuantumProgram as Python object.
- Returns:
PyObject corresponding to the qoqo measurement type of the QuantumProgram, i.e. PauliZProduct, CheatedPauliZProduct, Cheated or ClassicalRegister.
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- run(backend, parameters=None)
Runs the QuantumProgram and returns expectation values.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters listed in input_parameter_names and returns expectation values.
- Parameters:
backend (Backend) -- The backend the program is executed on.
parameters (Optional[List[float]]) -- List of float parameters of the function call in order of input_parameter_names
- run_registers(backend, parameters=None)
Runs the QuantumProgram and returns the classical registers of the quantum program.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters listed in input_parameter_names and returns the classical register output. The classical registers usually contain a record of measurement values for the repeated execution of a [crate::Circuit] quantum circuit for real quantum hardware or the readout of the statevector or the density matrix for simulators.
- Parameters:
backend (Backend) -- The backend the program is executed on.
parameters (Optional[List[float]]) -- List of float parameters of the function call in order of input_parameter_names
- to_bincode()
Return the bincode representation of the QuantumProgram using the [bincode] crate.
- Returns:
The serialized QuantumProgram (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize QuantumProgram to bytes.
- to_json()
Return the json representation of the QuantumProgram.
- Returns:
The serialized form of QuantumProgram.
- Return type:
str
- Raises:
ValueError -- Cannot serialize QuantumProgram to json.
- class qoqo.QuantumRabi(qubit, mode, theta)
The quantum Rabi interaction exp(-i * θ * X * (b^† + b))
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
theta (CalculatorFloat) -- The strength of the interaction.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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 value of attribute theta
- class qoqo.RotateAroundSphericalAxis(qubit, theta, spherical_theta, spherical_phi)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.RotateX(qubit, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.RotateXY(qubit, theta, phi)
Implements a rotation around an axis in the x-y plane in spherical coordinates.
\[\begin{split}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}\end{split}\]- 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.RotateY(qubit, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.RotateZ(qubit, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SGate(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SWAP(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SXGate(qubit)
The SX gate.
\[\begin{split}U = \frac{1}{\sqrt(2)} \begin{pmatrix} 1+i & 1-i \\\\ 1-i & 1+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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SingleExcitationLoad(qubit, mode)
Loads a single excitation from a bosonic mode into a qubit as follows (c1 |0⟩_B + c2 |1⟩_B) ⨂ |0⟩_Q -> |0⟩_B ⨂ (c1 |0⟩_Q + c2 |1⟩_Q)
Note: if the initial qubit state is |1⟩_Q the operation is only defined if c2 = 0
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.SingleExcitationStore(qubit, mode)
Stores a single excitation from the involved qubit into the involved bosonic mode as follows |0⟩_B ⨂ (a |0⟩_Q + b |1⟩_Q) -> (a|0⟩_B + b |1⟩_B ) ⨂ |0⟩_Q
Note: not defined if the bosonic mode is in a state |n⟩ with n != 0
- Parameters:
qubit (int) -- The qubit the gate is applied to.
mode (int) -- The mode the gate is applied to.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- qubit()
Return the qubit the operation acts on
- Returns:
int
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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.SingleQubitGate(qubit, alpha_r, alpha_i, beta_r, beta_i, global_phase)
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 (int) -- The qubit that the unitary gate is applied to.
alpha_r (CalculatorFloat) -- The real part of the on-diagonal elements of the single-qubit unitary.
alpha_i (CalculatorFloat) -- The imaginary part of the on-diagonal elements of the single-qubit unitary.
beta_r (CalculatorFloat) -- The real part of the off-diagonal elements of the single-qubit unitary.
beta_i (CalculatorFloat) -- The imaginary part of the off-diagonal elements of the single-qubit unitary.
global_phase (CalculatorFloat) -- 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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SingleQubitOverrotationDescription(gate, theta_mean, theta_std)
Description of single qubit overrotation noise model, [roqoqo::noise_models::SingleQubitOverrotationOnGate].
Consists of the raw data needed to construct a rotation gate that adds overrotation: gate name and statistics (mean and standard deviation) of a Gaussian distribution from which the overrotation angle is sampled. Example:
` from qoqo.noise_models import SingleQubitOverrotationDescription; gate = "RotateX"; theta_mean = 0.0; theta_std = 1.0; noise_desc = SingleQubitOverrotationDescription(gate, theta_mean, theta_std); `
- static current_version()
Return the current version of the qoqo library.
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the overotation description to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a overotation description.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- to_bincode()
Return the bincode representation of SingleQubitOverrotationDescription using the bincode crate.
- Returns:
The serialized SingleQubitOverrotationDescription (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize SingleQubitOverrotationDescription to bytes.
- to_json()
Return the json representation of the SingleQubitOverrotationDescription.
- Returns:
The serialized form of SingleQubitOverrotationDescription.
- Return type:
str
- Raises:
ValueError -- Cannot serialize SingleQubitOverrotationDescription.
- class qoqo.SingleQubitOverrotationOnGate
Single qubit overrotation noise model on gate.
Adds a rotation gate with a randomly distributed rotation angle after specified gates in a quantum circuit. Example:
``` from qoqo.noise_models import SingleQubitOverrotationDescription from qoqo.noise_models import SingleQubitOverrotationOnGate gate = "RotateX" theta_mean = 0.0 theta_std = 1.0 noise_desc = SingleQubitOverrotationDescription(gate, theta_mean, theta_std)
noise = SingleQubitOverrotationOnGate(); circuit_gate_with_noise = "RotateZ"; qubit = 0; noise.set_single_qubit_overrotation(circuit_gate_with_noise, qubit, noise_desc); ```
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the Noise-Model to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Noise-Model (in bincode form).
- Returns:
The deserialized Noise-Model.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Noise-Model.
- static from_json(input)
Convert the json representation of a device to a Noise-Model.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Noise-Model.
- get_single_qubit_overrotation(gate, qubit)
Return the overrotation description for a single qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
qubit (int) -- The qubit the gate acts on.
- Returns:
The overrotation applied when gate is applied.
- Return type:
Optional[SingleQubitOverrotationDescription]
- get_two_qubit_overrotation(gate, control, target)
Return the extra noise for a single qubit gate, if it exists.
- Parameters:
gate (str) -- The name of the gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
The overrotation applied when gate is applied.
- Return type:
Optional[Tuple[SingleQubitOverrotationDescription, SingleQubitOverrotationDescription]]
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- set_single_qubit_overrotation(gate, qubit, noise_description)
Set overrotation for a single qubit gate.
- Parameters:
gate (str) -- The name of the gate.
qubit (int) -- The qubit the gate acts on.
noise_description (SingleQubitOverrotationDescription)
- Returns:
The overotation model with the new overrotation on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise description is not a SingleQubitOverrotationDescription.
- set_two_qubit_overrotation(gate, control, target, noise_operator)
Set extra noise for a two qubit gate.
- Parameters:
gate (str) -- The name of the gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
noise_description ((SingleQubitOverrotationDescription, SingleQubitOverrotationDescription))
- Returns:
The overrotation model with the new overrotation on gate set.
- Return type:
Self
- Raises:
PyTypeError -- Noise description is not a (SingleQubitOverrotationDescription, SingleQubitOverrotationDescription).
- to_bincode()
Return the bincode representation of the Noise-Model using the bincode crate.
- Returns:
The serialized Noise-Model (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Noise-Model to bytes.
- to_json()
Return the json representation of the Noise-Model.
- Returns:
The serialized form of Noise-Model.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Noise-Model to json.
- class qoqo.SpinInteraction(control, target, x, y, z)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
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.SqrtISwap(control, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the two-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SqrtPauliX(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SqrtPauliY(qubit)
The square root of the YPower gate \(e^{-i \frac{\pi}{4} \sigma^y}\).
\[\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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.SquareLatticeDevice(number_rows, number_columns, single_qubit_gates, two_qubit_gates, default_gate_time)
A generic square lattice device with only next-neighbours-connectivity.
- Parameters:
number_rows (int) -- The fixed number of rows in device..
number_columns (int) -- Fixed number of columns in device.
single_qubit_gates (List[str]) -- A list of 'hqslang' names of single-qubit-gates supported by the device.
two_qubit_gates (List[str]) -- A list of 'hqslang' names of basic two-qubit-gates supported by the device.
default_gate_time (float) -- The default startig gate time.
- add_damping(damping)
Adds single qubit damping to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
damping (float) -- The damping rates.
- Raises:
PyValueError -- Qubit is not in device
- add_damping_all()
Adds qubit damping to noise rates.
- Parameters:
damping (float) -- The damping rates.
- Returns:
The new device with the new properties
- Return type:
Self
- add_dephasing(dephasing)
Adds single qubit dephasing to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
dephasing (float) -- The dephasing rates.
- Raises:
PyValueError -- Qubit is not in device
- add_dephasing_all()
Adds qubit dephasing to noise rates.
- Parameters:
dephasing (float) -- The dephasing rates.
- Returns:
The new device with the new properties
- Return type:
Self
- add_depolarising(depolarising)
Adds single qubit depolarising to noise rates.
- Parameters:
qubit (int) -- The qubit for which the decoherence is added
depolarising (float) -- The depolarising rates.
- Raises:
PyValueError -- Qubit is not in device
- add_depolarising_all()
Adds qubit depolarising to noise rates.
- Parameters:
depolarising (float) -- The depolarising rates.
- Returns:
The new device with the new properties
- Return type:
Self
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- static from_bincode(input)
Convert the bincode representation of the qoqo device to a device using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized Device (in bincode form).
- Returns:
The deserialized Device.
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to selected Device.
- static from_json(input)
Convert the json representation of a device to a qoqo device.
- Parameters:
input (str) -- The serialized device in json form.
- Returns:
The deserialized device.
- Raises:
ValueError -- Input cannot be deserialized to selected Device.
- generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- multi_qubit_gate_names()
Returns the names of a mutli qubit operations available on the device.
The list of names also includes the three qubit gate operations.
- Returns:
The list of gate names.
- Return type:
List[str]
- multi_qubit_gate_time(qubits)
Returns the gate time of a multi qubit operation if the multi qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a multi qubit gate.
qubits (List[int]) -- The qubits the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- number_columns()
Return number of columns in device.
- Returns:
The number of columns.
- Return type:
int
- number_qubits()
Return number of qubits in device.
- Returns:
The number of qubits.
- Return type:
int
- number_rows()
Return the number of rows of optical tweezers in the two-dimensional grid of potential qubit positions.
- Returns:
The number of rows.
- Return type:
int
- qubit_decoherence_rates()
Return the matrix of the decoherence rates of the Lindblad equation.
- Parameters:
qubit (int) -- The qubit for which the rate matrix M is returned
- Returns:
3 by 3 numpy array of decoherence rates
- Return type:
np.array
- set_all_qubit_decoherence_rates()
Set the decoherence rates for all qubits in the SquareLatticeDevice device.
- Parameters:
rates (2darray):: Decoherence rates provided as (3x3)
- Returns:
The new device with the new properties
- Return type:
Self
- Raises:
PyValueError -- The input parameter rates needs to be a (3x3)-matrix.
- set_all_single_qubit_gate_times(gate_time, /)
Set gate time of all single-qubit gates of specific type
- Parameters:
gate (str) -- The hqslang name of the single-qubit-gate.
gate_time (float) -- New gate time.
- Returns:
A qoqo Device with updated gate times.
- Return type:
Self
- set_all_two_qubit_gate_times(gate_time, /)
Set gate time of all two-qubit gates of specific type
- Parameters:
gate (str) -- The hqslang name of the two-qubit-gate.
gate_time (float) -- Gate time for the given gate, valid for all qubits in the device.
- Returns:
A qoqo Device with updated gate times.
- Return type:
Self
- set_multi_qubit_gate_time(qubits, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (List[int]) -- The qubits for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubits not in device
- set_qubit_decoherence_rates(rates)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubits (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_single_qubit_gate_time(qubit, gate_time)
Set the gate time of a single qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
qubit (int) -- The qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_three_qubit_gate_time(control_0, control_1, target, gate_time)
Set the gate time of a three qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control_0 (int) -- The control_0 qubit for which the gate time is set
control_1 (int) -- The control_1 qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- set_two_qubit_gate_time(control, target, gate_time)
Set the gate time of a two qubit gate.
- Parameters:
gate (str) -- hqslang name of the single-qubit-gate.
control (int) -- The control qubit for which the gate time is set
target (int) -- The control qubit for which the gate time is set
gate_time (float) -- The gate time for the given gate.
- Raises:
PyValueError -- Qubit is not in device
- single_qubit_gate_names()
Returns the names of a single qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- single_qubit_gate_time(qubit)
Returns the gate time of a single qubit operation if the single qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
qubit (int) -- The qubit the gate acts on
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- three_qubit_gate_time()
three_qubit_gate_time(gate, control_0, control_1, target --
Returns the gate time of a three qubit operation if the three qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control_0 (int) -- The control_0 qubit the gate acts on.
control_1 (int) -- The control_1 qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- to_bincode()
Return the bincode representation of the Device using the bincode crate.
- Returns:
The serialized Device (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize Device to bytes.
- to_generic_device()
Turns Device into GenericDevice
Can be used as a generic interface for devices when a boxed dyn trait object cannot be used (for example when the interface needs to be serialized)
- Returns:
The device in generic representation
- Return type:
Note
GenericDevice uses nested HashMaps to represent the most general device connectivity. The memory usage will be inefficient for devices with large qubit numbers.
- to_json()
Return the json representation of the Device.
- Returns:
The serialized form of Device.
- Return type:
str
- Raises:
ValueError -- Cannot serialize Device to json.
- two_qubit_edges()
Return the list of pairs of qubits linked by a native two-qubit-gate in the device.
A pair of qubits is considered linked by a native two-qubit-gate if the device can implement a two-qubit-gate between the two qubits without decomposing it into a sequence of gates that involves a third qubit of the device. The two-qubit-gate also has to form a universal set together with the available single qubit gates.
The returned vectors is a simple, graph-library independent, representation of the undirected connectivity graph of the device. It can be used to construct the connectivity graph in a graph library of the user's choice from a list of edges and can be used for applications like routing in quantum algorithms.
- Returns:
List of two qubit edges in the undirected connectivity graph
- Return type:
Sequence[(int, int)]
- two_qubit_gate_names()
Returns the names of a two qubit operations available on the device.
- Returns:
The list of gate names.
- Return type:
List[str]
- two_qubit_gate_time(control, target)
Returns the gate time of a two qubit operation if the two qubit operation is available on device.
- Parameters:
hqslang (str) -- The hqslang name of a single qubit gate.
control (int) -- The control qubit the gate acts on.
target (int) -- The target qubit the gate acts on.
- Returns:
None if gate is not available
- Return type:
Option[float]
- Raises:
PyValueError -- Qubit is not in device
- class qoqo.Squeezing(mode, squeezing, phase)
The single-mode squeezing gate with tunable squeezing.
The squeezing gate is a quantum operation that allows for precise manipulation of quantum states, by reducing the uncertainty in one variable and therefore increasing the uncertainty of another. https://arxiv.org/pdf/quant-ph/0106157.pdf
- Parameters:
mode (int) -- The mode the squeezing gate is applied to.
squeezing (CalculatorFloat) -- The coefficient of the squeezing operation.
phase (CalculatorFloat) -- The squeezing phase angle of the squeezing operation.
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_modes()
List of modes the operation acts on.
- Returns:
The involved qubits as a set or 'ALL' if all qubits are involved
- Return type:
Union[Set[int], 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- mode()
Return mode the bosonic Operation acts on.
- Returns:
int
- phase()
Returns value of attribute phase
- remap_modes(mapping)
Remap the bosonic modes in copy of the operation.
- Parameters:
mapping (Dict[int, int]) -- Mapping for bosonic modes in operation.
- Returns:
self
- Raises:
PyValueError -- Remapping could not be performed
- 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
- squeezing()
Returns value of attribute squeezing
- 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.TGate(qubit)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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:
Operation
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:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.Toffoli(control_0, control_1, target)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the three-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.TripleControlledPauliX(control_0, control_1, control_2, target)
The triple-controlled PauliX gate.
- circuit()
Returns circuit implementing the FourQubitGateOperation
- Returns:
Circuit
- control_0()
Returns control_0 qubit of the four-qubit operation
- control_1()
Returns control_1 qubit of the four-qubit operation
- control_2()
Returns control_2 qubit of the four-qubit operation
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the four-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.TripleControlledPauliZ(control_0, control_1, control_2, target)
The triple-controlled PauliZ gate.
- circuit()
Returns circuit implementing the FourQubitGateOperation
- Returns:
Circuit
- control_0()
Returns control_0 qubit of the four-qubit operation
- control_1()
Returns control_1 qubit of the four-qubit operation
- control_2()
Returns control_2 qubit of the four-qubit operation
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the four-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.TripleControlledPhaseShift(control_0, control_1, control_2, target, theta)
The triple-controlled PhaseShift gate.
- circuit()
Returns circuit implementing the FourQubitGateOperation
- Returns:
Circuit
- control_0()
Returns control_0 qubit of the four-qubit operation
- control_1()
Returns control_1 qubit of the four-qubit operation
- control_2()
Returns control_2 qubit of the four-qubit operation
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
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]
- target()
Returns target qubit of the four-qubit operation
- theta()
Returns value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.VariableMSXX(control, target, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- class qoqo.XY(control, target, theta)
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
- static current_version()
Returns the current version of the qoqo library .
- Returns:
The current version of the library.
- Return type:
str
- 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:
Whether or not the operation contains symbolic parameters.
- Return type:
bool
- static json_schema()
Return the JsonSchema for the json serialisation of the class.
- Returns:
The json schema serialized to json
- Return type:
str
- min_supported_version()
Return the minimum version of qoqo that supports this object.
- Returns:
The minimum version of the qoqo library to deserialize this object.
- Return type:
str
- 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 value of attribute theta
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
matrix of gate.
- Return type:
np.ndarray
- Raises:
ValueError -- Error symbolic operation cannot return float unitary matrix
- qoqo.available_gates_hqslang()
List of hqslang of all available gates