Struct rusq::simulator::simulator::QuantumSimulator [] [src]

pub struct QuantumSimulator { /* fields omitted */ }

A simulator for a quantum computer

This type represents a quantum computer.

Memory consumption scales 2n with a given qubits number n. Thus, usually quantum machines up to around 30 qubits can be simulated although internal implementation is usize.

Examples

An example to set the given qubit state to the desired one;

use rusq::prelude::*;

fn set(sim: &mut QuantumSimulator, qubit: &Qubit, r: MeasuredResult) {
    if sim.measure(qubit) != r {
        sim.X(qubit);
    }
}

let mut sim = QuantumSimulator::new(1);
let qubit = &sim.get_qubits()[0];
set(&mut sim, qubit, MeasuredResult::Zero);

assert_eq!(sim.measure(qubit), MeasuredResult::Zero);

As is discussed in new method, the initial values of the qubits are not definite (although in the code one can find some value). Thus, one needs to initialize qubits in this way. This behavior is because not the wavefunction itself but the ray corresponds to the physical state.

Methods

impl QuantumSimulator
[src]

[src]

Creates a new instance with a given number of qubits. Note that the initial states of the qubits are not guaranteed to be a definite value.

Examples

use rusq::prelude::*;

// A simulator with 3 qubits.
let sim = QuantumSimulator::new(3);

Trait Implementations

impl QuantumMachine for QuantumSimulator
[src]

[src]

Measures the given qubit. Note that the qubit is expected to be projected to the corresponding state. Read more

[src]

Returns all the qubits in the machine.

impl SingleGateApplicator for QuantumSimulator
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl DoubleGateApplicator for QuantumSimulator
[src]

[src]

[src]

[src]

[src]

[src]

impl TripleGateApplicator for QuantumSimulator
[src]

[src]

[src]

[src]