Skip to main content

EngineInstruction

Enum EngineInstruction 

pub enum EngineInstruction {
Show 13 variants Gate1 { gate: Gate1Q, qubit: usize, }, Gate2 { control: PauliBasis, target: PauliBasis, control_qubit: usize, target_qubit: usize, }, Pauli { basis: PauliBasis, qubit: usize, }, T { basis: PauliBasis, qubit: usize, adjoint: bool, }, TPauli { axis: PauliString, adjoint: bool, }, PauliRotation { axis: PauliString, kernel_angle: f64, }, Measure(PauliString), MeasureWithReadoutError { observable: PauliString, probability: f64, }, Record { value: bool, flip_probability: f64, }, RandomPauli { probabilities: Vec<f64>, alternatives: Vec<PauliString>, heralded: bool, }, Expectation(PauliString), Reset { basis: PauliBasis, qubit: usize, }, ConditionalPauli { basis: PauliBasis, qubit: usize, control: usize, },
}
Expand description

One step of a TableauSimulator::apply_batch program.

§Examples

use ticit::{Gate1Q, Instruction};
use ticit::{Pauli, PauliBasis, PauliString, TableauSimulator};

// Prepare a Bell pair and read both halves out in the Z basis.
let bell = [
    Instruction::Gate1 {
        gate: Gate1Q::H,
        qubit: 0,
    },
    Instruction::Gate2 {
        control: PauliBasis::Z,
        target: PauliBasis::X,
        control_qubit: 0,
        target_qubit: 1,
    },
    Instruction::Measure(PauliString::single(2, 0, Pauli::Z)),
    Instruction::Measure(PauliString::single(2, 1, Pauli::Z)),
];

let mut sim = TableauSimulator::with_seed(2, 7);
let outcome = sim.apply_batch(&bell)?;
assert_eq!(outcome.records.len(), 2);
assert_eq!(outcome.records[0].outcome, outcome.records[1].outcome);

Variants§

§

Gate1

A named single-qubit Clifford.

Fields

§gate: Gate1Q

The gate to apply.

§qubit: usize

Its operand.

§

Gate2

A two-qubit <A>C<B> gate: apply target on target_qubit when control_qubit is in the −1 eigenstate of control. CX is control: Z, target: X; CZ is Z, Z.

Fields

§control: PauliBasis

The control qubit’s Pauli axis (A).

§target: PauliBasis

The target qubit’s Pauli axis (B).

§control_qubit: usize

Qubit the control axis is read on.

§target_qubit: usize

Qubit the target axis acts on.

§

Pauli

A single-qubit Pauli.

Fields

§basis: PauliBasis

Which Pauli.

§qubit: usize

Its operand.

§

T

T/T† about a single-qubit basis axis.

Fields

§basis: PauliBasis

The rotation axis.

§qubit: usize

Its operand.

§adjoint: bool

true selects T†.

§

TPauli

T/T† about an arbitrary Pauli axis.

Fields

§axis: PauliString

The rotation axis.

§adjoint: bool

true selects T†.

§

PauliRotation

exp(-i * kernel_angle * axis) for an arbitrary real angle.

Fields

§axis: PauliString

Hermitian Pauli rotation axis.

§kernel_angle: f64

Angle in radians under the kernel convention.

§

Measure(PauliString)

Measure a Pauli observable, appending its result to BatchOutcome::records.

§

MeasureWithReadoutError

Measure a Pauli observable and independently flip the recorded bit.

Fields

§observable: PauliString

Hermitian observable to measure.

§probability: f64

Probability of flipping the classical record after projection.

§

Record

Append a classical record, optionally flipped by Bernoulli noise.

Fields

§value: bool

Record value before noise.

§flip_probability: f64

Probability of flipping value.

§

RandomPauli

Sample at most one Pauli alternative and apply it.

Fields

§probabilities: Vec<f64>

Absolute probability of each corresponding alternative.

§alternatives: Vec<PauliString>

Pauli alternatives; remaining probability means no operation.

§heralded: bool

Whether to append a record indicating that an alternative fired.

§

Expectation(PauliString)

Read a Pauli expectation value without changing the state.

§

Reset

Reset a qubit to the +1 eigenstate of basis.

Fields

§basis: PauliBasis

The basis to reset into.

§qubit: usize

Its operand.

§

ConditionalPauli

Apply a single-qubit Pauli if an earlier measurement in this batch came out −1.

control indexes BatchOutcome::records, so it counts measurements (not instructions) from the start of the batch. Corrections conditioned on anything outside the batch belong between batches, where the caller still owns the decision.

Fields

§basis: PauliBasis

Which Pauli to apply.

§qubit: usize

Its operand.

§control: usize

Index into BatchOutcome::records of the gating measurement.

Implementations§

§

impl Instruction

pub fn from_circuit(circuit: &Circuit) -> Vec<Instruction>

Translates a circuit once into instructions reusable by TableauSimulator::apply_batch.

Trait Implementations§

§

impl Clone for Instruction

§

fn clone(&self) -> Instruction

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
§

impl Debug for Instruction

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for Instruction

§

fn eq(&self, other: &Instruction) -> bool

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

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for Instruction

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
§

impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
where T: BorrowMut<BorrowedSelf>, BorrowedSelf: BitwiseMut + ?Sized,

§

fn assign_index(&mut self, index: usize, to: bool)

§

fn negate_index(&mut self, index: usize)

§

fn clear_bits(&mut self)

§

fn assign_random( &mut self, bit_count: usize, random_number_generator: &mut impl RngExt, )
where BorrowedSelf: BitLength,

§

impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
where Bits: BorrowMut<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePairMut<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn assign(&mut self, other: &Other)

§

fn bitxor_assign(&mut self, other: &Other)

§

fn bitand_assign(&mut self, other: &Other)

§

fn bitor_assign(&mut self, other: &Other)

§

impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
where T: Borrow<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePair<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn dot(&self, other: &Other) -> bool

§

fn and_weight(&self, other: &Other) -> usize

§

fn or_weight(&self, other: &Other) -> usize

§

fn xor_weight(&self, other: &Other) -> usize

§

impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
where T: Borrow<BorrowedSelf>, BorrowedSelf: Bitwise + ?Sized,

§

fn index(&self, index: usize) -> bool

§

fn weight(&self) -> usize

§

fn parity(&self) -> bool

§

fn is_zero(&self) -> bool

§

fn is_unit(&self, index: usize) -> bool

§

fn support<'a>(&'a self) -> impl SortedIterator
where BorrowedSelf: 'a,

§

fn max_support(&self) -> Option<usize>

§

fn min_support(&self) -> Option<usize>

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.

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.