qoqo.operations.Toffoli
- class qoqo.operations.Toffoli
Implements Toffoli gate.
\[\begin{split}U = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{pmatrix}\end{split}\]- Parameters:
control_0 (int) – The index of the most significant qubit in the unitary representation. Here, the first controlling qubit of the operation.
control_1 (int) – The index of the second most significant qubit in the unitary representation. Here, the second controlling qubit of the operation.
target (int) – The index of the least significant qubit in the unitary representation. Here, the qubit the PauliX gate is applied to.
- __init__()
Methods
__init__
()circuit
()Returns circuit implementing the ThreeQubitGateOperation
Returns control_0 qubit of the three-qubit operation
Returns control_1 qubit of the three-qubit operation
hqslang
()Returns hqslang name of Operation
List all involved Qubits
Returns true if operation contains symbolic parameters
remap_qubits
(mapping)Remap qubits
substitute_parameters
(substitution_parameters)Substitutes internal symbolic parameters with float values
tags
()Returns tags identifying the Operation
target
()Returns target qubit of the three-qubit operation
Return unitary matrix of gate.
- circuit()
Returns circuit implementing the ThreeQubitGateOperation
- Returns:
Circuit
- control_0()
Returns control_0 qubit of the three-qubit operation
- control_1()
Returns control_1 qubit of the three-qubit operation
- hqslang()
Returns hqslang name of Operation
- Returns:
The name
- Return type:
str
- involved_qubits()
List all involved Qubits
- Returns:
The involved qubits as a set or ‘ALL’ if all qubits are involved
- Return type:
Union[set[int], str]
- is_parametrized()
Returns true if operation contains symbolic parameters
- Returns:
bool
- remap_qubits(mapping)
Remap qubits
- Parameters:
mapping (dict[int, int]) – The mapping
- Returns:
The operation with the remapped qubits
- Return type:
Operation
- Raises:
RuntimeError – Qubit remapping failed
- substitute_parameters(substitution_parameters)
Substitutes internal symbolic parameters with float values
Only available when all symbolic expressions can be evaluated to float with the provided parameters.
- Parameters:
substitution_parameters (dict[str, float]) – The substituted free parameters
- Returns:
The operation with the parameters substituted
- Return type:
Operation
- Raises:
RuntimeError – Parameter Substitution failed
- tags()
Returns tags identifying the Operation
- Returns:
The tags identifying the operation
- Return type:
list[str]
- target()
Returns target qubit of the three-qubit operation
- unitary_matrix()
Return unitary matrix of gate.
- Returns:
np.ndarray
- Raises:
ValueError – Error symbolic operation cannot return float unitary matrix