qml.estimator.templates.OutOfPlaceSquare¶
- class OutOfPlaceSquare(register_size, wires=None)[source]
Bases:
ResourceOperator
Resource class for the OutofPlaceSquare gate.
- Parameters:
register_size (int) – the size of the input register
wires (Sequence[int], None) – the wires the operation acts on
- Resources:
The resources are obtained from appendix G, lemma 7 in PRX Quantum, 2, 040332 (2021). Specifically, the resources are given as \((n - 1)^2\) Toffoli gates, and \(n\) CNOT gates, where \(n\) is the size of the input register.
Example
The resources for this operation are computed using:
>>> import pennylane.estimator as qre >>> out_square = qre.OutOfPlaceSquare(register_size=3) >>> print(qre.estimate(out_square)) --- Resources: --- Total wires: 9 algorithmic wires: 9 allocated wires: 0 zero state: 0 any state: 0 Total gates : 7 'Toffoli': 4, 'CNOT': 3
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'register_size'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
register_size (int): the size of the input register
- Return type:
dict
Methods
resource_decomp
(register_size)Returns a list representing the resources of the operator.
resource_rep
(register_size)Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.
- classmethod resource_decomp(register_size)[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.
- Parameters:
register_size (int) – the size of the input register
- Resources:
The resources are obtained from appendix G, lemma 7 in PRX Quantum, 2, 040332 (2021). Specifically, the resources are given as \((n - 1)^2\) Toffoli gates, and \(n\) CNOT gates.
- 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
]
- classmethod resource_rep(register_size)[source]¶
Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.
- Parameters:
register_size (int) – the size of the input register
- Returns:
the operator in a compressed representation
- Return type: