PtmChannel

Struct PtmChannel 

Source
pub struct PtmChannel { /* private fields */ }
Expand description

A one- or two-qubit gate or noise channel, stored as its Pauli-transfer matrix.

Built by the named constructors: the Cliffords hadamard, phase_gate, pauli_x, pauli_y, pauli_z, cnot, cz, swap; the general unitaries unitary_1q, unitary_2q; and the noise channels depolarizing, dephasing, pauli_channel, depolarizing_2q, amplitude_damping.

On the support, Paulis are indexed x | (z << 1) per qubit (I = 0, X = 1, Z = 2, Y = 3), the constructor’s first qubit in the low two bits. Channel::apply maps input Pauli s to Σ_t ptm[s][t] · P_t, and Channel::apply_adjoint reads the transpose. Channel::debug_name is the constructor’s name ("hadamard", "cnot", …), with _adjoint appended after adjoint.

Implementations§

Source§

impl PtmChannel

Source

pub fn hadamard(qubit: usize) -> Self

Hadamard: X → Z, Z → X, Y → −Y.

Source

pub fn phase_gate(qubit: usize) -> Self

Phase gate S = diag(1, i): X → Y, Z → Z, Y → −X.

Source

pub fn pauli_x(qubit: usize) -> Self

Pauli-X gate: X → X, Z → −Z, Y → −Y.

Source

pub fn pauli_y(qubit: usize) -> Self

Pauli-Y gate: X → −X, Z → −Z, Y → Y.

Source

pub fn pauli_z(qubit: usize) -> Self

Pauli-Z gate: X → −X, Z → Z, Y → −Y.

Source

pub fn cnot(control: usize, target: usize) -> Self

CNOT: X⊗I → X⊗X, I⊗X → I⊗X, Z⊗I → Z⊗I, I⊗Z → Z⊗Z, control first.

§Panics

If control == target.

Source

pub fn cz(q0: usize, q1: usize) -> Self

CZ: X⊗I → X⊗Z, I⊗X → Z⊗X, Z⊗I → Z⊗I, I⊗Z → I⊗Z.

§Panics

If q0 == q1.

Source

pub fn swap(q0: usize, q1: usize) -> Self

SWAP: P⊗Q → Q⊗P.

§Panics

If q0 == q1.

Source§

impl PtmChannel

Source

pub fn depolarizing(qubit: usize, p: f64) -> Self

Single-qubit depolarizing noise with error probability p: X, Y and Z are scaled by 1 - 4p/3.

§Panics

Unless p ∈ [0, 1].

Source

pub fn dephasing(qubit: usize, p: f64) -> Self

Single-qubit dephasing noise with error probability p: X and Y are scaled by 1 - 2p.

§Panics

Unless p ∈ [0, 1].

Source

pub fn pauli_channel(qubit: usize, px: f64, py: f64, pz: f64) -> Self

Single-qubit Pauli channel E(ρ) = (1-px-py-pz)ρ + px·XρX + py·YρY + pz·ZρZ.

It scales X by 1 - 2(py + pz), Y by 1 - 2(px + pz) and Z by 1 - 2(px + py), so (p/3, p/3, p/3) is depolarizing and (0, 0, p) is dephasing.

§Panics

Unless each probability lies in [0, 1] and px + py + pz ≤ 1.

Source

pub fn depolarizing_2q(q0: usize, q1: usize, p: f64) -> Self

Two-qubit depolarizing noise E(ρ) = (1-p)ρ + (p/15)·Σ_k P_k ρ P_k over the 15 non-identity two-qubit Paulis.

Every Pauli that is non-identity on the pair is scaled by 1 - 16p/15.

§Panics

If q0 == q1, or unless p ∈ [0, 1].

Source

pub fn amplitude_damping(qubit: usize, gamma: f64) -> Self

Single-qubit amplitude damping with Kraus operators K_0 = |0⟩⟨0| + √(1-γ)|1⟩⟨1|, K_1 = √γ |0⟩⟨1|.

Not self-adjoint: apply is the Schrödinger map (I → I + γZ, Z → (1-γ)Z) and apply_adjoint its Heisenberg dual (I → I, Z → (1-γ)Z + γI); both scale X and Y by √(1-γ).

§Panics

Unless gamma ∈ [0, 1].

Source§

impl PtmChannel

Source

pub fn unitary_1q(qubit: usize, u: [[Complex64; 2]; 2]) -> Self

A general single-qubit unitary U: ptm[s][t] = tr(P_t · U P_s U†) / 2.

§Panics

Unless every entry of U†U − I is at most 1e-10 in absolute value.

Source

pub fn unitary_2q(q0: usize, q1: usize, u: [[Complex64; 4]; 4]) -> Self

A general two-qubit unitary U on |q0 q1⟩, q0 the more significant tensor factor: ptm[s][t] = tr(P_t · U P_s U†) / 4.

§Panics

If q0 == q1, or unless every entry of U†U − I is at most 1e-10 in absolute value.

Source§

impl PtmChannel

Source

pub fn qubits(&self) -> impl ExactSizeIterator<Item = usize> + '_

The support qubits, in constructor order.

Source

pub fn adjoint(&self) -> Self

The adjoint channel, whose PTM is this one’s transpose.

Trait Implementations§

Source§

impl<const W: usize> Channel<W> for PtmChannel

Source§

fn support(&self) -> [u64; W]

Qubits this channel acts on, as a bitmask built with support_mask. Read more
Source§

fn debug_name(&self) -> &'static str

Short name for the per-layer progress log. Read more
Source§

fn apply( &self, input_x: &[u64; W], input_z: &[u64; W], coeff: Complex64, out: &mut OutputBuffer<W>, )

Apply the channel to one input term, pushing its outputs to out.
Source§

fn apply_adjoint( &self, input_x: &[u64; W], input_z: &[u64; W], coeff: Complex64, out: &mut OutputBuffer<W>, )

Apply the channel’s adjoint to one input term; run by Direction::Heisenberg. Read more
Source§

impl Clone for PtmChannel

Source§

fn clone(&self) -> PtmChannel

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PtmChannel

Source§

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

Formats the value using the given formatter. Read more

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,