Enum roqoqo::QuantumProgram
source · [−]pub enum QuantumProgram {
BasisRotation {
measurement: BasisRotation,
input_parameter_names: Vec<String>,
},
CheatedBasisRotation {
measurement: CheatedBasisRotation,
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 mulit-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
BasisRotation
Fields
measurement: BasisRotation
The measurement that is performed
Variant for basis rotation measurement based quantum programs
CheatedBasisRotation
Fields
measurement: CheatedBasisRotation
The measurement that is performed
Variant for cheated basis rotation measurement based quantum programs
Cheated
Fields
measurement: Cheated
The measurement that is performed
Variant for statevector/density matrix based measurements
ClassicalRegister
Fields
measurement: ClassicalRegister
The measurement that is performed
Variant quantum programs returning full classical registers
Implementations
sourceimpl 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]) -> RegisterResult where
T: EvaluatingBackend,
pub fn run_registers<T>(&self, backend: T, parameters: &[f64]) -> RegisterResult where
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
sourceimpl Clone for QuantumProgram
impl Clone for QuantumProgram
sourcefn clone(&self) -> QuantumProgram
fn clone(&self) -> QuantumProgram
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for QuantumProgram
impl Debug for QuantumProgram
sourceimpl<'de> Deserialize<'de> for QuantumProgram
impl<'de> Deserialize<'de> for QuantumProgram
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for QuantumProgram
impl Display for QuantumProgram
Implements the Display trait for QuantumProgram.
sourceimpl PartialEq<QuantumProgram> for QuantumProgram
impl PartialEq<QuantumProgram> for QuantumProgram
sourcefn eq(&self, other: &QuantumProgram) -> bool
fn eq(&self, other: &QuantumProgram) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &QuantumProgram) -> bool
fn ne(&self, other: &QuantumProgram) -> bool
This method tests for !=
.
sourceimpl Serialize for QuantumProgram
impl Serialize for QuantumProgram
impl StructuralPartialEq for QuantumProgram
Auto Trait Implementations
impl RefUnwindSafe for QuantumProgram
impl Send for QuantumProgram
impl Sync for QuantumProgram
impl Unpin for QuantumProgram
impl UnwindSafe for QuantumProgram
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more