Skip to main content

CircuitBox

Enum CircuitBox 

Source
pub enum CircuitBox<R: RealField> {
    Encoder {
        input: WireId,
        outputs: Vec<WireId>,
        states: Vec<CausalTensor<Complex<R>>>,
    },
    Unitary {
        wires: Vec<WireId>,
        program: Vec<GateOp>,
    },
    Channel {
        wires: Vec<WireId>,
        channel: Channel<R>,
    },
    Kraus {
        wires: Vec<WireId>,
        kraus: Vec<CausalTensor<Complex<R>>>,
    },
    Instrument {
        wires: Vec<WireId>,
        outcome: WireId,
        kraus: Vec<Vec<CausalTensor<Complex<R>>>>,
    },
    Measurement {
        wires: Vec<WireId>,
        outcome: WireId,
    },
}
Expand description

One box of a CircuitModel: a morphism of QC (Lorenz & Tull, arXiv:2602.16612, Figure 2) on the wires it names.

Quantum wires are register lines and every box acts on them in place, so a box’s quantum wires are both its inputs and its outputs. A classical wire is written by the one box that names it as outcome and read by the encoders that name it as input.

Variants§

§

Encoder

Classical input to quantum: on reading value x from input, prepares states[x] on outputs, which must be fresh lines in |0…0⟩. Each state is a ket of dimension the product of the output dimensions.

Fields

§input: WireId

The classical wire read.

§outputs: Vec<WireId>

The quantum wires prepared, first most significant.

§states: Vec<CausalTensor<Complex<R>>>

One ket per classical value.

§

Unitary

A gate program on qubit wires; gate indices are local to wires.

Fields

§wires: Vec<WireId>

The qubit wires, in the order the program’s local indices refer to them.

§program: Vec<GateOp>

The program, in application order.

§

Channel

A CPTP map on quantum wires, the noise box.

Fields

§wires: Vec<WireId>

The quantum wires, first most significant.

§channel: Channel<R>

The channel, validated CPTP once at its construction.

§

Kraus

A CPTP map on quantum wires given by its Kraus operators, each 2^|wires| × 2^|wires|. The numeric semantics is Kraus-level, so a wide box, an encoder unitary on every qubit of a code for one, is held here without the Choi operator a Channel carries.

Fields

§wires: Vec<WireId>

The quantum wires, first most significant.

§kraus: Vec<CausalTensor<Complex<R>>>

The Kraus operators.

§

Instrument

A quantum instrument: for each classical outcome y, a Kraus family kraus[y] on the wires; jointly trace-preserving over y.

Fields

§wires: Vec<WireId>

The quantum wires, first most significant.

§outcome: WireId

The classical wire written with the outcome.

§kraus: Vec<Vec<CausalTensor<Complex<R>>>>

One Kraus family per outcome.

§

Measurement

A computational-basis measurement of the wires, writing the outcome index (first wire most significant) and leaving the wires in |0…0⟩.

Fields

§wires: Vec<WireId>

The quantum wires measured.

§outcome: WireId

The classical wire written.

Implementations§

Source§

impl<R: RealField> CircuitBox<R>

Source

pub fn quantum_wires(&self) -> &[WireId]

The quantum wires the box acts on, in the box’s own order.

Source

pub fn classical_read(&self) -> Option<WireId>

The classical wire the box reads, if any.

Source

pub fn classical_write(&self) -> Option<WireId>

The classical wire the box writes, if any.

Source

pub fn kind(&self) -> &'static str

The box kind, for messages.

Trait Implementations§

Source§

impl<R: Clone + RealField> Clone for CircuitBox<R>

Source§

fn clone(&self) -> CircuitBox<R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<R: Debug + RealField> Debug for CircuitBox<R>

Source§

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

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

impl<R: PartialEq + RealField> PartialEq for CircuitBox<R>

Source§

fn eq(&self, other: &CircuitBox<R>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<R: PartialEq + RealField> StructuralPartialEq for CircuitBox<R>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<Borrowed> SampleBorrow<Borrowed> for Borrowed

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.