pub struct Backend { /* private fields */ }
Expand description

Mocked backend to qoqo

Provides functions to run circuits and measurements. The mocked backend mock-simulates a quantum circuit on a given device by translating the roqoqo Circuit using the roqoqo_mocked interface. This interface produces random measurements coherent with the measured quantity. These results are then output from the run function in this backend and are accessible through the classical registers dictionary.

Arguments

  • number_qubits - Number of qubits in the Backend

Implementations

Creates new Mocked backend

Arguments
  • number_qubits - Number of qubits in the Backend
Returns
  • Backend - The new instance of Backend with the specified number of qubits

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Trait for Backends that can evaluate measurements to expectation values.

Example

use roqoqo::{Circuit, backends::EvaluatingBackend, operations::*};
use roqoqo_mock::Backend;

let backend = Backend::new(2_usize);
let mut circuit = Circuit::new();
circuit += DefinitionBit::new("ro".to_string(), 2, true);
circuit += RotateX::new(0, std::f64::consts::FRAC_PI_2.into());
circuit += PauliX::new(1);
circuit += PragmaRepeatedMeasurement::new("ro".to_string(), None, 20);
let (bit_registers, _float_registers, _complex_registers) =
    backend.run_circuit(&circuit).unwrap();
assert!(bit_registers.contains_key("ro"));
let out_reg = bit_registers.get("ro").unwrap();
assert_eq!(out_reg.len(), 20);
for reg in out_reg.iter() {
    assert_eq!(reg.len(), 2);
}

Runs a circuit with the backend.

A circuit is passed to the roqoqo-mock 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 a circuit with the backend. Read more

Runs all circuits corresponding to one measurement with the backend. Read more

Evaluates expectation values of a measurement with the backend. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

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

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

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

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.