run_and_measure(quil_program, qubits=None, trials=1, memory_map=None)¶
Run a Quil program once to determine the final wavefunction, and measure multiple times.
Alternatively, consider using
sample_bitstringson the resulting object.
For a large wavefunction and a low-medium number of trials, use this function. On the other hand, if you’re sampling a small system many times you might want to use
If your program contains measurements or noisy gates, this method may not do what you want. If the execution of
quil_programis non-deterministic then the final wavefunction from which the returned bitstrings are sampled itself only represents a stochastically generated sample and the outcomes sampled from different
run_and_measurecalls generally sample different bitstring distributions.
- quil_program (
Program) – The program to run and measure
- qubits (
int]]) – An optional list of qubits to measure. The order of this list is respected in the returned bitstrings. If not provided, all qubits used in the program will be measured and returned in their sorted order.
- trials (int) – Number of times to sample from the prepared wavefunction.
- memory_map (
An assignment of classical registers to values, representing an initial state for the QAM’s classical memory.
This is expected to be of type Dict[str, List[Union[int, float]]], where the keys are memory region names and the values are arrays of initialization data.
For now, we also support input of type Dict[MemoryReference, Any], but this is deprecated and will be removed in a future release.
An array of measurement results (0 or 1) of shape (trials, len(qubits))
- quil_program (