Trait roqoqo::backends::EvaluatingBackend[][src]

pub trait EvaluatingBackend: Sized {
    fn run_circuit_iterator<'a>(
        &self,
        circuit: impl Iterator<Item = &'a Operation>
    ) -> RegisterResult; fn run_circuit(&self, circuit: &Circuit) -> RegisterResult { ... }
fn run_measurement_registers<T>(&self, measurement: &T) -> RegisterResult
    where
        T: Measure
, { ... }
fn run_measurement<T>(
        &self,
        measurement: &T
    ) -> Result<Option<HashMap<String, f64>>, RoqoqoBackendError>
    where
        T: MeasureExpectationValues
, { ... } }
Expand description

Trait for Backends that can evaluate measurements to expectation values.

Required methods

Runs each operation obtained from an iterator over operations on the backend.

An iterator over operations is passed to the backend and executed. During execution values are written to and read from classical registers (crate::registers::BitRegister, crate::registers::FloatRegister and crate::registers::ComplexRegister). To produce sufficient statistics for evaluating expectationg values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (crate::registers::BitOutputRegister, crate::registers::FloatOutputRegister and crate::registers::ComplexOutputRegister).

Arguments

  • circuit - The iterator over operations that is run on the backend (corresponds to a circuit).

Returns

RegisterResult - The output registers written by the evaluated circuits.

Provided methods

Runs a circuit with the backend.

A circuit is passed to the backend and executed. During execution values are written to and read from classical registers (crate::registers::BitRegister, crate::registers::FloatRegister and crate::registers::ComplexRegister). To produce sufficient statistics for evaluating expectationg values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (crate::registers::BitOutputRegister, crate::registers::FloatOutputRegister and crate::registers::ComplexOutputRegister).

Arguments

  • circuit - The circuit that is run on the backend.

Returns

RegisterResult - The output registers written by the evaluated circuits.

Runs all circuits corresponding to one measurement with the backend.

An expectation value measurement in general involves several circuits. Each circuit is passes to the backend and executed separately. During execution values are written to and read from classical registers (crate::registers::BitRegister, crate::registers::FloatRegister and crate::registers::ComplexRegister). To produce sufficient statistics for evaluating expectationg values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (crate::registers::BitOutputRegister, crate::registers::FloatOutputRegister and crate::registers::ComplexOutputRegister).
At the end all OutputRegisters are combined in a single HashMap for each type of register.

Arguments

  • measurement - The measurement that is run on the backend.

Returns

RegisterResult - The output registers written by the evaluated measurement circuits.

Evaluates expectation values of a measurement with the backend.

Arguments

  • measurement - The measurement that is run on the backend.

Returns

Ok(Option<HashMap<String, f64>>) - The HashMap of measurement results. Err(RoqoqoBackendError) - The measurement run failed.

Implementors