qml.estimator.templates.AliasSampling¶
- class AliasSampling(num_coeffs, precision=None, wires=None)[source]
Bases:
ResourceOperator
Resource class for preparing a state using coherent alias sampling.
- Parameters:
num_coeffs (int) – the number of unique coefficients in the state
precision (float) – the precision with which the coefficients are loaded
wires (WiresLike | None) – the wires the operation acts on
- Resources:
The resources are obtained from Section III D in arXiv:1805.03662. The circuit uses coherent alias sampling to prepare a state with the given coefficients.
Example
The resources for this operation are computed using:
>>> alias_sampling = qre.AliasSampling(num_coeffs=100) >>> print(qre.estimate(alias_sampling)) --- Resources: --- Total wires: 133 algorithmic wires: 7 allocated wires: 126 zero state: 58 any state: 68 Total gates : 6.505E+3 'Toffoli': 272, 'T': 88, 'CNOT': 4.646E+3, 'X': 595, 'Hadamard': 904
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'num_coeffs', 'precision'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
num_coeffs (int): the number of unique coefficients in the state
precision (float): the precision with which the coefficients are loaded
- Return type:
dict
Methods
resource_decomp
(num_coeffs[, precision])Returns a list representing the resources of the operator.
resource_rep
(num_coeffs[, precision])Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.
- classmethod resource_decomp(num_coeffs, precision=None)[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:
num_coeffs (int) – the number of unique coefficients in the state
precision (float) – the precision with which the coefficients are loaded
- Resources:
The resources are obtained from Section III D in arXiv:1805.03662. The circuit uses coherent alias sampling to prepare a state with the given coefficients.
- 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
]