Enum roqoqo::QuantumProgram
source · #[non_exhaustive]pub enum QuantumProgram {
PauliZProduct {
measurement: PauliZProduct,
input_parameter_names: Vec<String>,
},
CheatedPauliZProduct {
measurement: CheatedPauliZProduct,
input_parameter_names: Vec<String>,
},
Cheated {
measurement: Cheated,
input_parameter_names: Vec<String>,
},
ClassicalRegister {
measurement: ClassicalRegister,
input_parameter_names: Vec<String>,
},
}
Expand description
Represents a quantum program evaluating measurements based on a one or more free float parameters.
The main use of QuantumProgram is to contain a Measurements implementing crate::measurements::Measure
that measures expectation values or output registers of crate::Circuit quantum circuits that contain
symbolic parameters. Circuit with symbolic parameters can not be simulated or executed on real hardware.
The symbolic parameters need to be replaced with real floating point numbers first.
A QuantumProgram contains a list of the free parameters (input_parameter_names
) and can automatically
replace the parameters with its run
methods and return the result.
The QuantumProgram should correspond as closely as possible to a normal multi-parameter function in classical computing that can be called with a set of parameters and returns a result. It is the intended way to interface between normal program code and roqoqo based quantum programs.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PauliZProduct
Variant for basis rotation measurement based quantum programs
Fields
measurement: PauliZProduct
The measurement that is performed
CheatedPauliZProduct
Variant for cheated basis rotation measurement based quantum programs
Fields
measurement: CheatedPauliZProduct
The measurement that is performed
Cheated
Variant for statevector/density matrix based measurements
Fields
ClassicalRegister
Variant quantum programs returning full classical registers
Fields
measurement: ClassicalRegister
The measurement that is performed
Implementations§
source§impl QuantumProgram
impl QuantumProgram
sourcepub fn run<T>(
&self,
backend: T,
parameters: &[f64]
) -> Result<Option<HashMap<String, f64>>, RoqoqoBackendError>where
T: EvaluatingBackend,
pub fn run<T>(
&self,
backend: T,
parameters: &[f64]
) -> Result<Option<HashMap<String, f64>>, RoqoqoBackendError>where
T: EvaluatingBackend,
Runs the QuantumProgram and returns expectation values.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters
listed in input_parameter_names
and returns expectation values.
Arguments:
backend
- The backend the program is executed on.parameters
- List of float (f64) parameters of the function call in order ofinput_parameter_names
sourcepub fn run_registers<T>(&self, backend: T, parameters: &[f64]) -> RegisterResultwhere
T: EvaluatingBackend,
pub fn run_registers<T>(&self, backend: T, parameters: &[f64]) -> RegisterResultwhere
T: EvaluatingBackend,
Runs the QuantumProgram and returns the classical registers of the quantum program.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters
listed in input_parameter_names
and returns the classical register output.
The classical registers usually contain a record of measurement values for the repeated execution
of a crate::Circuit quantum circuit for real quantum hardware
or the readout of the statevector or the density matrix for simulators.
Arguments:
backend
- The backend the program is executed on.parameters
- List of float (f64) parameters of the function call in order ofinput_parameter_names
Trait Implementations§
source§impl Clone for QuantumProgram
impl Clone for QuantumProgram
source§fn clone(&self) -> QuantumProgram
fn clone(&self) -> QuantumProgram
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for QuantumProgram
impl Debug for QuantumProgram
source§impl<'de> Deserialize<'de> for QuantumProgram
impl<'de> Deserialize<'de> for QuantumProgram
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for QuantumProgram
impl Display for QuantumProgram
Implements the Display trait for QuantumProgram.
source§impl PartialEq for QuantumProgram
impl PartialEq for QuantumProgram
source§fn eq(&self, other: &QuantumProgram) -> bool
fn eq(&self, other: &QuantumProgram) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for QuantumProgram
impl Serialize for QuantumProgram
source§impl SupportedVersion for QuantumProgram
impl SupportedVersion for QuantumProgram
impl StructuralPartialEq for QuantumProgram
Auto Trait Implementations§
impl Freeze for QuantumProgram
impl RefUnwindSafe for QuantumProgram
impl Send for QuantumProgram
impl Sync for QuantumProgram
impl Unpin for QuantumProgram
impl UnwindSafe for QuantumProgram
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.