qml.estimator.templates.SingleQubitComparator¶
- class SingleQubitComparator(wires=None)[source]
Bases:
ResourceOperator
Resource class for comparing the values encoded in two input qubits.
This operation modifies the input qubits. The original values can be restored by applying the operation’s adjoint.
- Parameters:
wires (WiresLike | None) – the wires the operation acts on
- Resources:
The resources are obtained from appendix B, Figure 5 in arXiv:1711.10460. Specifically, the resources are given as \(1\)
TemporaryAND
gate, \(4\)CNOT
gates, and \(3\)X
gates. The circuit which applies the comparison operation on qubits \((x,y)\) is defined as:x: ─╭●───────╭●─╭●──── x y: ─├○────╭●─╰X─│───X─ x=y |0>: ─╰X─╭●─│─────│───── x<y |0>: ────╰X─╰X────╰X──── x>y
Example
The resources for this operation are computed using:
>>> import pennylane.estimator as qre >>> single_qubit_compare = qre.SingleQubitComparator() >>> print(qre.estimate(single_qubit_compare)) --- Resources: --- Total wires: 4 algorithmic wires: 4 allocated wires: 0 zero state: 0 any state: 0 Total gates : 8 'Toffoli': 1, 'CNOT': 4, 'X': 3
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- num_wires = 4¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
An empty dictionary
- Return type:
dict
Methods
Returns a list representing the resources of the operator.
Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.
- classmethod resource_decomp()[source]¶
Returns a list representing the resources of the operator. Each object in the list represents a gate and the number of times it occurs in the circuit.
- Resources:
The resources are obtained from appendix B, Figure 5 in arXiv:1711.10460. Specifically, the resources are given as \(1\)
TemporaryAND
gate, \(4\)CNOT
gates, and \(3\)X
gates.The circuit which applies the comparison operation on wires \((x,y)\) is defined as:
x: ─╭●───────╭●─╭●──── x y: ─├○────╭●─╰X─│───X─ x=y |0>: ─╰X─╭●─│─────│───── x<y |0>: ────╰X─╰X────╰X──── x>y
- Returns:
A list of
GateCount
objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount
]