unitaria.Simulator¶
- class unitaria.Simulator(scheme: str = 'exact', default_precision: float | None = None, default_failure_probability: float | None = None, seed: ~numpy.random.bit_generator.SeedSequence | None = None, complexity_metric: ~collections.abc.Callable[[~unitaria.circuit.Circuit, float], int] | None = <function get_t_count>, qubits: int = 100)[source]¶
Bases:
EstimatorEstimator based on matrix-arithmetic simulation
- Parameters:
scheme – The measurement scheme, which is simulated. Should be one of
"exact"or"monte-carlo".default_precision – Default for the
precisionparameter inestimate_norm.default_failure_probability – Default for the
failure_probabilityparameter inestimate_norm.complexity_metric – A function which takes a
Circuitand a precision, and returns a number to be used as the complexity for running that circuit. Defaults to an estimate of the required T gates. Set toNoneto disable complexity tracking, which avoids compliation of circuits.qubits – Determines how many ancillae are passed to
Node.circuit. Specifically, the total qubits passed to that function will be the maximum ofqubitsor the qubits required to encode the node. If you want to estimate gates for a specific device, setqubitsto the number of qubits in that device.
- count_gates(node: Node, precision: float | None = None, failure_probability: float | None = None, samples: int | None = None)[source]¶
Count the number of gates required to measure the norm of the given block encoding.
- Parameters:
node – The node representing the vector of which to compute the norm.
precision – The absolute precision, with which the norm should be computed. If
None,self.default_precisionis used instead.failure_probability – The maximum allowed failure probability, with which the absolute error of the estimate may exceed the given precision. If
None,self.default_failure_probabilityis used instead.samples – Number of times that the block encoding is executed. If given, overrides the number of samples computed from
precisionandfailure_probability.
- Raises:
ValueError – If the scheme is invalid or if arguments are incompatible with the scheme.
- estimate_norm(node: Node, precision: float | None = None, failure_probability: float | None = None) float[source]¶
Estimate the norm of the given block encoding.
The block encoding must represent a vector. The returned value is guaranteed to lie in the range
[0, node.normalization].The implementors of this method are free to interpret the
precision``argument loosely, and ignore the ``failure_probabilityargument.- Parameters:
node – The node representing the vector of which to compute the norm.
precision – The absolute precision, with which the norm should be computed. If
None,self.default_precisionis used instead.failure_probability – The maximum allowed failure probability, with which the absolute error of the estimate may exceed the given precision. If
None,self.default_failure_probabilityis used instead.
- Raises:
NotImplementedError – If the method is not implemented.