#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PauliZProduct

Variant for basis rotation measurement based quantum programs

Fields

§measurement: PauliZProduct

The measurement that is performed

§input_parameter_names: Vec<String>

List of free input parameters that can be set when the QuantumProgram is executed

§

CheatedPauliZProduct

Variant for cheated basis rotation measurement based quantum programs

Fields

§measurement: CheatedPauliZProduct

The measurement that is performed

§input_parameter_names: Vec<String>

List of free input parameters that can be set when the QuantumProgram is executed

§

Cheated

Variant for statevector/density matrix based measurements

Fields

§measurement: Cheated

The measurement that is performed

§input_parameter_names: Vec<String>

List of free input parameters that can be set when the QuantumProgram is executed

§

ClassicalRegister

Variant quantum programs returning full classical registers

Fields

§measurement: ClassicalRegister

The measurement that is performed

§input_parameter_names: Vec<String>

List of free input parameters that can be set when the QuantumProgram is executed

Implementations§

source§

impl QuantumProgram

source

pub fn run<T>( &self, backend: T, parameters: &[f64] ) -> Result<Option<HashMap<String, f64>>, RoqoqoBackendError>

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 of input_parameter_names
source

pub fn run_registers<T>(&self, backend: T, parameters: &[f64]) -> RegisterResult

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 of input_parameter_names

Trait Implementations§

source§

impl Clone for QuantumProgram

source§

fn clone(&self) -> QuantumProgram

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for QuantumProgram

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for QuantumProgram

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for QuantumProgram

Implements the Display trait for QuantumProgram.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for QuantumProgram

source§

fn eq(&self, other: &QuantumProgram) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for QuantumProgram

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SupportedVersion for QuantumProgram

source§

fn minimum_supported_roqoqo_version(&self) -> (u32, u32, u32)

Returns the minimum roqoqo version that supports the operation. Read more
source§

impl StructuralPartialEq for QuantumProgram

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,