Expand description

Executes mocked qoqo Circuit.

The Mocked interface is an interface which mock-simulates a quantum circuit. The quantum gates are not applied and the measurements produce random results coherent with the measured quantity.

Arguments

  • circuit - The qoqo Circuit that is executed.
  • registers - The five registers used in the Interface: (1) HashMap containing bit readout values. (2) HashMap containing float readout values. (3) HashMap containing complex readout values. (4) HashMap containing a register for each repetition of the circuit (bit readout values). (5) HashMap containing a register for each repetition of the circuit (complex readout values).
  • `number_qubits: Number of qubits mocked.

Returns

  • `Ok(HashMap<String, BitRegister>, HashMap<String, FloatRegister>, HashMap<String, ComplexRegister>, HashMap<String, BitOutputRegister>, HashMap<String, ComplexOutputRegister>) - The five input registers with the readouts from the operations in the Circuit.
  • Err(RoqoqoBackendError) - Operation not supported by Mocked backend.

Example

use roqoqo::{Circuit, operations::{DefinitionBit, PauliX, MeasureQubit}};
use roqoqo_mock::call_circuit;
use std::collections::HashMap;

let mut circuit = Circuit::new();
circuit += DefinitionBit::new("ro".to_string(), 1, true);
circuit += PauliX::new(0);
circuit += MeasureQubit::new(0, "ro".to_string(), 1);
let (bit_registers, _f, _c, _bo, _co) = call_circuit(
    &circuit,
    (HashMap::new(), HashMap::new(), HashMap::new(), HashMap::new(), HashMap::new()),
    2,
)
.unwrap();

assert!(bit_registers.contains_key("ro"));
let out_reg = bit_registers.get("ro").unwrap();
assert_eq!(out_reg.len(), 1);
for reg in out_reg.iter() {
    assert!(*reg || !*reg);
}