Skip to main content

GeneralizedTableau

Struct GeneralizedTableau 

Source
pub struct GeneralizedTableau<T: Config, IndexType = usize, SparseVectorType: SparseVector<Complex<T::Coeff>, IndexType> = Vec<(Complex64, IndexType)>> {
    pub tableau: Tableau<T>,
    pub coefficients: SparseVectorType,
    pub qubit_status: Vec<QubitStatus>,
    pub coefficient_threshold: T::Coeff,
    pub measurement_record: Vec<Option<bool>>,
    /* private fields */
}
Expand description

A Tableau extended with sparse coefficient tracking to handle non-Clifford gates.

Non-Clifford gates (T, rotations) split a single tableau into a sum of weighted branches indexed by bitstrings. GeneralizedTableau stores those weights in a SparseVector keyed by an IndexType. Choose:

  • IndexType = usize for up to 64 qubits,
  • IndexType = u128 for up to 128,
  • IndexType = bnum::types::U256 and friends for the very wide regime.

Per-qubit status (loss / leakage) is tracked in qubit_status; gates skip any qubit that is not QubitStatus::Live.

§Examples

Prepare a Bell pair and sample one shot. With a fixed seed the two measurements are perfectly correlated on every shot:

use ppvm_pauli_sum::config::fxhash::ByteF64;
use ppvm_traits::traits::{Clifford, LossyMeasure};
use ppvm_tableau::data::GeneralizedTableau;

let mut tab: GeneralizedTableau<ByteF64<1>> =
    GeneralizedTableau::new_with_seed(2, 1e-12, 0);
tab.h(0);
tab.cnot(0, 1);

let r0 = LossyMeasure::measure(&mut tab, 0);
let r1 = LossyMeasure::measure(&mut tab, 1);
assert_eq!(r0, r1);

Non-Clifford gates work through the same interface — apply a T gate followed by T† and the state is unchanged:

use ppvm_pauli_sum::config::fxhash::ByteF64;
use ppvm_traits::traits::{Clifford, TGate};
use ppvm_tableau::data::GeneralizedTableau;

let mut tab: GeneralizedTableau<ByteF64<1>> =
    GeneralizedTableau::new_with_seed(1, 1e-12, 0);
tab.h(0);
tab.t(0);
tab.t_dag(0);
// T followed by T† is the identity; the |+⟩ state is restored.

Fields§

§tableau: Tableau<T>

Underlying Clifford tableau.

§coefficients: SparseVectorType

Sparse coefficient vector indexed by bitstrings.

§qubit_status: Vec<QubitStatus>

Per-qubit status relative to the computational subspace.

§coefficient_threshold: T::Coeff

Coefficient-magnitude threshold below which branches are dropped.

§measurement_record: Vec<Option<bool>>

Ordered log of every measurement performed (mirrors stim’s record).

Implementations§

Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> GeneralizedTableau<T, I, C>
where T::Coeff: One + Zero + Clone + Num, Complex<T::Coeff>: Mul<Output = Complex<T::Coeff>> + AddAssign + From<Complex64> + ComplexFloat + Copy, I: TableauIndex,

Source

pub fn new(n_qubits: usize, coefficient_threshold: T::Coeff) -> Self

Construct a generalized tableau in the |0…0⟩ state.

Branches whose coefficient magnitude falls below coefficient_threshold are dropped during gate application.

Source

pub fn new_with_seed( n_qubits: usize, coefficient_threshold: T::Coeff, seed: u64, ) -> Self

Same as GeneralizedTableau::new, but seed the RNG deterministically.

Source

pub fn reset_all(&mut self)

Source

pub fn fork(&self, seed: Option<u64>) -> Self

Clone the quantum state but reinitialize the RNG, producing an independent simulation branch. If seed is Some, the new RNG is seeded deterministically; if None, it is seeded from OS entropy.

Source

pub fn n_qubits(&self) -> usize

Number of qubits.

Source

pub fn current_measurement_record(&self) -> &[Option<bool>]

All measurement outcomes recorded so far, in order.

Source

pub fn append_measurement_record(&mut self, result: Option<bool>)

Append an externally defined measurement result to the record.

Used by Stim instructions such as MPAD, which append measurement record bits without measuring a qubit.

Source

pub fn overwrite_last_measurement_record(&mut self, result: Option<bool>)

Replace the most recent measurement record entry.

Used by noisy measurement paths where the quantum state follows the true outcome but the public record should hold the reported bit.

Source

pub fn cz_block_pairs(&mut self, base: usize, offset: usize, count: usize)

Apply CZ to N pairs with constant offset: (base+i, base+offset+i) for i in 0..count. Falls back to individual CZ calls if any qubit in the range is lost or leaked. Overlap (offset < count) is owned by Tableau::cz_block_pairs.

Source

pub fn cz_block_pairs_cross_word( &mut self, word_c: usize, base_bit_c: usize, word_t: usize, base_bit_t: usize, count: usize, )
where <T::Storage as BitView>::Store: PrimInt,

Apply CZ to N cross-word pairs. Controls at word_c, targets at word_t. Falls back to individual CZ calls if any qubit is lost or leaked.

Source

pub fn cz_block( &mut self, control_base: usize, target_base: usize, count: usize, )

Apply CZ to count pairs with a constant offset, given in qubit-index terms: (control_base + i, target_base + i) for i in 0..count.

This is the high-level entry point for a fused block of CZs: it splits the run at storage-word boundaries internally and dispatches each segment to Self::cz_block_pairs (control and target in the same word) or Self::cz_block_pairs_cross_word (straddling two words), so callers never need to reason about the u64 packing. CZ is symmetric, so the two bases may be passed in either order.

Overlapping pairs — |target_base - control_base| < count, of which adjacent-pair brickwork cz_block(0, 1, n) is the extreme case — are handled: the same-word segments route through Self::cz_block_pairs into Tableau::cz_block_pairs, which falls back to the per-pair loop. A cross-word segment is always disjoint (its run never exceeds the offset), so the fused kernel stays live there.

Source

pub fn compute_decomposition(&self, addr0: usize, pauli: Pauli) -> (u8, I, I)
where <<T as Config>::Storage as BitView>::Store: PrimInt,

Compute the decomposition of a pauli into stabilizer destabilizer products Any Pauli can be written as P_addr0 = phase * prod(d_k ^ gamma_k) * prod(s_l ^ lambda_l) where: gamma_k == 1 iff {P_addr0, s_k} = 0 lambda_l == 1 iff {P_addr0, d_l} = 0 Lemma 5. from T. J. Yoder (2012) NOTE: this is O(n^2)

The function returns (phase, stab_anticomm_bits, destab_anticomm_bits), where stab_anticomm_bits[k] = 1 iff P_addr0 anticommutes with stabilizer s_k, and destab_anticomm_bits[l] = 1 iff P_addr0 anticommutes with destabilizer d_l. Note that stab_anticomm_bits is equal to the shift of the index when branching (beta in Eq(4) of the SOFT paper).

Source

pub fn odd_phase_destabilizer_mask(&self) -> I

Build a bitmask where bit i is set if destabilizer i has odd phase (phase % 2 != 0).

Source§

impl<T, I, C> GeneralizedTableau<T, I, C>

Source

pub fn expectation<W: PauliWordTrait>(&self, word: &W) -> f64

⟨ψ|word|ψ⟩ for the multi-qubit Pauli word.

Conjugates word through the Clifford tableau (giving a Pauli on the canonical basis: an X-mask, Z-mask, and i^φ phase), then sums ⟨α|P_conj|β⟩ c_α* c_β over the sparse coefficient vector. Always returns a real number (Hermitian operator on a normalized state).

Source

pub fn trace(&self, pattern: &PauliPattern) -> f64

Σ_{P matches pattern} ⟨ψ|P|ψ⟩.

Enumerates every PauliWord accepted by pattern via PauliPattern::enumerate_matches and sums their expectations. Star quantifiers (X*) panic — the pattern must be bounded; use counted repetition (Z?{n}) or positional anchors instead.

Source§

impl<T, I, C> GeneralizedTableau<T, I, C>

Source

pub fn project_case_a( &mut self, outcome: bool, scratch: &mut MeasureScratch<I, T::Coeff>, phase_decomp: u8, stab_anticomm_bits: I, destab_anticomm_bits: I, addr0: usize, )

Source

pub fn project_case_b( &mut self, entries: &[(Complex<T::Coeff>, I)], outcome: bool, phase_decomp: u8, destab_anticomm_bits: I, )

project state in case b (Z is a stabilizer) according to sampled outcome

Source§

impl<T, I, C> GeneralizedTableau<T, I, C>

Source

pub fn measure_noisy(&mut self, addr0: usize, flip_prob: f64) -> Option<bool>

Measure qubit addr0 in Z basis with optional readout noise.

Behaves like measure, then with probability flip_prob flips the recorded bit. The qubit’s quantum state stays consistent with the true outcome — only the returned value flips. flip_prob = 0.0 is equivalent to measure.

If the qubit is lost, returns None regardless of flip_prob.

Source

pub fn bernoulli(&mut self, p: f64) -> bool

Sample a Bernoulli(p) outcome using the tableau’s internal RNG. Used by Stim measurement-noise dispatch in ppvm-stim.

Source

pub fn flip_with_prob(&mut self, bit: bool, p: f64) -> bool

Flip bit with probability p. Used by Stim MR/MPad readout-noise dispatch in ppvm-stim. Returns bit unchanged when p <= 0.0.

Source§

impl<T, I, C> GeneralizedTableau<T, I, C>

Measurement overlap helper functions, with optional rayon parallelism.

Source

pub fn z_expectation(&self, addr0: usize) -> f64

⟨Z⟩ on qubit addr0, computed non-destructively (the state is not collapsed). Reuses the measurement overlap machinery; cost scales with the number of coefficients (and n²).

Source

pub fn compute_overlap_case_b( entries: &[(Complex<T::Coeff>, I)], phase_decomp: u8, destab_anticomm_bits: I, ) -> f64

Case_b overlap: self-pairing (branch_index = idx), so overlap = ±|c|^2. Only even phases contribute to the real part. Divided by ⟨ψ|ψ⟩, since gate-time truncation leaves the state unnormalized.

Source

pub fn compute_overlap_case_a( coeff_map: &HashMap<I, Complex<T::Coeff>>, phase_decomp: u8, destab_anticomm_bits: I, stab_anticomm_bits: I, odd_phase_mask: I, ) -> f64

Case_a overlap: cross-index pairing via HashMap lookup. Accumulates only the real part of z_overlap. Divided by ⟨ψ|ψ⟩, since gate-time truncation leaves the state unnormalized.

Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> GeneralizedTableau<T, I, C>

Source

pub fn is_inactive(&self, addr0: usize) -> bool

Whether qubit addr0 is outside the computational subspace — either lost or leaked. Gates skip such qubits.

Source

pub fn is_lost(&self, addr0: usize) -> bool

Whether qubit addr0 is lost. Measurement of a lost qubit returns None.

Source

pub fn is_leaked(&self, addr0: usize) -> bool

Whether qubit addr0 is leaked. Measurement of a leaked qubit returns the pinned computational bit.

Source§

impl<T, I, C> GeneralizedTableau<T, I, C>

Source

pub fn measure_all_with_scratch( &mut self, scratch: &mut MeasureScratch<I, T::Coeff>, ) -> Vec<Option<bool>>

Same as LossyMeasureAll::measure_all, but the caller supplies a MeasureScratch that’s reused across the n per-qubit measurements (and, if the caller chooses, across many invocations / shots).

This is the entry point samplers should use when running many shots: initialize one scratch alongside the sampler and thread it through every shot to amortize the case-a HashMap and b_entries allocations.

Source

pub fn measure_many_with_scratch( &mut self, indices: &[usize], scratch: &mut MeasureScratch<I, T::Coeff>, ) -> Vec<Option<bool>>

Measure the given qubit indices in order, reusing a caller-supplied MeasureScratch across the per-index measurements (and, if the caller chooses, across many invocations / shots) — the explicit-index analogue of measure_all_with_scratch. This is the scratch-reusing engine behind the tableau’s LossyMeasure::measure_many override (in measure.rs), which the Stim executor and the Python measure_many binding both go through.

Trait Implementations§

Source§

impl<T: Config, I, C> AsymmetricLossChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn asymmetric_loss_channel(&mut self, addr0: usize, p0: T::Coeff, p1: T::Coeff)

State-dependent single-qubit loss (“asymmetric loss”).

Models a three-level atom whose |0⟩ and |1⟩ levels leak into a loss state |L⟩ at different rates: the qubit is lost from |0⟩ with probability p0 and from |1⟩ with p1. The total loss probability is state-dependent,

    p_tot = p0 * (1 + ⟨Z⟩)/2 + p1 * (1 - ⟨Z⟩)/2,

with ⟨Z⟩ the current Z-expectation of addr0. With probability p_tot the qubit is collapsed, reset to |0⟩, and marked lost (as in LossChannel::loss_channel); otherwise it is left unchanged.

§Approximation

This is the trajectory approximation of the true loss channel. It reproduces the loss statistics (which qubits are flagged lost, and how often) and is exact in the symmetric limit p0 == p1, where it reduces to LossChannel::loss_channel. It does NOT apply the survival back-action K0 = sqrt(1-p0)|0⟩⟨0| + sqrt(1-p1)|1⟩⟨1|: for p0 != p1 the faithful channel reshapes the surviving qubit (population tilts toward the less-leaky level, coherences are damped), and this implementation skips that reshaping. The back-action is non-Clifford (it branches the coefficient vector like an rz), so it is omitted to keep the channel cheap enough to apply after every gate. See issue #39.

Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> Clifford for GeneralizedTableau<T, I, C>
where Complex<<T as Config>::Coeff>: From<Complex<f64>>, <T::Storage as BitView>::Store: PrimInt,

Source§

fn x(&mut self, index: usize)

Apply Pauli X to one qubit.
Source§

fn y(&mut self, index: usize)

Apply Pauli Y to one qubit.
Source§

fn z(&mut self, index: usize)

Apply Pauli Z to one qubit.
Source§

fn h(&mut self, index: usize)

Apply Hadamard H to one qubit.
Source§

fn s(&mut self, index: usize)

Apply phase gate S to one qubit.
Source§

fn cnot(&mut self, control: usize, target: usize)

Apply CNOT to one (control, target) pair.
Source§

fn cz(&mut self, control: usize, target: usize)

Apply CZ to one qubit pair.
Source§

fn cx(&mut self, control: usize, target: usize)

stim alias for cnot.
Source§

fn zcx(&mut self, control: usize, target: usize)

stim alias for cnot.
Source§

fn zcz(&mut self, addr0: usize, addr1: usize)

stim alias for cz.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> CliffordBatch for GeneralizedTableau<T, I, C>
where Complex<<T as Config>::Coeff>: From<Complex<f64>>, <T::Storage as BitView>::Store: PrimInt,

Source§

fn x_many(&mut self, indices: &[usize])

Apply Pauli X to every qubit in indices.
Source§

fn y_many(&mut self, indices: &[usize])

Apply Pauli Y to every qubit in indices.
Source§

fn z_many(&mut self, indices: &[usize])

Apply Pauli Z to every qubit in indices.
Source§

fn h_many(&mut self, indices: &[usize])

Apply Hadamard H to every qubit in indices.
Source§

fn s_many(&mut self, indices: &[usize])

Apply phase gate S to every qubit in indices.
Source§

fn cnot_many(&mut self, pairs: &[(usize, usize)])

Apply CNOT to every (control, target) pair.
Source§

fn cz_many(&mut self, pairs: &[(usize, usize)])

Apply CZ to every (control, target) pair.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> CliffordExtensions for GeneralizedTableau<T, I, C>
where Complex<<T as Config>::Coeff>: From<Complex<f64>>, <T::Storage as BitView>::Store: PrimInt,

Source§

fn s_dag(&mut self, index: usize)

Apply S† to one qubit.
Source§

fn sqrt_x(&mut self, index: usize)

Apply √X to one qubit.
Source§

fn sqrt_x_dag(&mut self, index: usize)

Apply (√X)† to one qubit.
Source§

fn sqrt_y(&mut self, index: usize)

Apply √Y to one qubit.
Source§

fn sqrt_y_dag(&mut self, index: usize)

Apply (√Y)† to one qubit.
Source§

fn cy(&mut self, control: usize, target: usize)

Apply CY to one (control, target) pair.
Source§

fn zcy(&mut self, control: usize, target: usize)

stim alias for cy.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> CliffordExtensionsBatch for GeneralizedTableau<T, I, C>
where Complex<<T as Config>::Coeff>: From<Complex<f64>>, <T::Storage as BitView>::Store: PrimInt,

Source§

fn s_dag_many(&mut self, indices: &[usize])

Apply S† to every qubit in indices.
Source§

fn sqrt_x_many(&mut self, indices: &[usize])

Apply √X to every qubit in indices.
Source§

fn sqrt_x_dag_many(&mut self, indices: &[usize])

Apply (√X)† to every qubit in indices.
Source§

fn sqrt_y_many(&mut self, indices: &[usize])

Apply √Y to every qubit in indices.
Source§

fn sqrt_y_dag_many(&mut self, indices: &[usize])

Apply (√Y)† to every qubit in indices.
Source§

fn cy_many(&mut self, pairs: &[(usize, usize)])

Apply CY to every (control, target) pair.
Source§

impl<T: Clone + Config, IndexType: Clone, SparseVectorType: Clone + SparseVector<Complex<T::Coeff>, IndexType>> Clone for GeneralizedTableau<T, IndexType, SparseVectorType>
where T::Coeff: Clone,

Source§

fn clone(&self) -> Self

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<T: Config, I, C> CorrelatedLossChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn correlated_loss_channel( &mut self, addr0: usize, addr1: usize, p: [<T as Config>::Coeff; 3], )

Apply a correlated loss channel to qubits at addr0 and addr1.

The three probabilities are:

  • p[0]: The probability of losing both qubits simultaneously when both of them are in the qubit subspace.
  • p[1]: The probability of losing a named one of the two qubits when both of them are in the qubit subspace, so the probability of losing exactly one is 2·p[1] and the both-present survivor keeps 1 − 2·p[1] − p[0] (which qubit is lost is 50/50). See ppvm_traits::traits::CorrelatedLossChannel for the normative statement.
  • p[2]: The probability of losing one qubit when the other one has already been lost prior to the channel.
Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> Depolarizing2<T> for GeneralizedTableau<T, I, C>

Source§

fn depolarize2(&mut self, addr0: usize, addr1: usize, p: T::Coeff)

Depolarize one qubit pair with probability p.
Source§

fn depolarize2_many( &mut self, pairs: &[(usize, usize)], p: <T as Config>::Coeff, )

Explicit batched two-qubit depolarizing channel.
Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> Depolarizing<T> for GeneralizedTableau<T, I, C>

Source§

fn depolarize1(&mut self, addr0: usize, p: T::Coeff)

Depolarize one qubit with probability p.
Source§

fn depolarize1_many(&mut self, targets: &[usize], p: <T as Config>::Coeff)

Explicit batched single-qubit depolarizing channel.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> Display for GeneralizedTableau<T, I, C>
where Complex<T::Coeff>: Display, <T as Config>::Coeff: Num, I: TableauIndex + Display, <I as BitAnd<<I as Shl<usize>>::Output>>::Output: PartialEq<I>,

Source§

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

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

impl<T: Config, I, C> LeakageChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn leakage_channel(&mut self, addr0: usize, p0: T::Coeff, p1: T::Coeff)

Apply leakage to qubit addr0, with p0 / p1 the probabilities of leaking into |0⟩ / |1⟩.
Source§

impl<T: Config, I, C> LossChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn loss_channel(&mut self, addr0: usize, p: <T as Config>::Coeff)

Apply a loss channel to qubit addr0 with loss probability p.
Source§

impl<T, I, C> LossyMeasure for GeneralizedTableau<T, I, C>

Source§

fn measure_many(&mut self, targets: &[usize]) -> Vec<Option<bool>>

Override the trait default (a per-target measure loop, which allocates a fresh MeasureScratch on every call) with a single scratch reused across the whole batch, amortizing the case-a HashMap / b_entries allocations and the cached odd-phase-destabilizer mask. Outcomes, the measurement record, and the RNG-draw order are identical to measuring each target individually — only the internal allocation pattern changes.

Source§

fn measure(&mut self, addr0: usize) -> Option<bool>

Measure qubit addr0. Returns Some(bit) for an in-subspace outcome, or None if the qubit has been lost.
Source§

impl<T, I, C> LossyMeasureAll for GeneralizedTableau<T, I, C>

Source§

fn measure_all(&mut self) -> Vec<Option<bool>>

Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> PauliError<T> for GeneralizedTableau<T, I, C>

Source§

fn pauli_error(&mut self, addr0: usize, p: [T::Coeff; 3])

Apply a Pauli-error channel [p_x, p_y, p_z] to one qubit.
Source§

fn x_error(&mut self, addr0: usize, p: <T as Config>::Coeff)

stim X_ERROR(p) — apply X with probability p to one qubit.
Source§

fn y_error(&mut self, addr0: usize, p: <T as Config>::Coeff)

stim Y_ERROR(p) — apply Y with probability p to one qubit.
Source§

fn z_error(&mut self, addr0: usize, p: <T as Config>::Coeff)

stim Z_ERROR(p) — apply Z with probability p to one qubit.
Source§

fn pauli_error_many(&mut self, targets: &[usize], p: [<T as Config>::Coeff; 3])

Explicit batched Pauli-error channel.
Source§

fn x_error_many(&mut self, targets: &[usize], p: <T as Config>::Coeff)

Explicit batched X_ERROR(p).
Source§

fn y_error_many(&mut self, targets: &[usize], p: <T as Config>::Coeff)

Explicit batched Y_ERROR(p).
Source§

fn z_error_many(&mut self, targets: &[usize], p: <T as Config>::Coeff)

Explicit batched Z_ERROR(p).
Source§

impl<T, I, C> Reset for GeneralizedTableau<T, I, C>

Source§

fn reset(&mut self, addr0: usize)

Reset one qubit to |0⟩ (stim R/RZ).
Source§

fn reset_z(&mut self, addr0: usize)

stim RZ alias — reset to |0⟩.
Source§

fn reset_x(&mut self, addr0: usize)

stim RX — reset to |+⟩.
Source§

fn reset_y(&mut self, addr0: usize)

stim RY — reset to |i⟩.
Source§

fn reset_many(&mut self, targets: &[usize])

Explicit batched reset to |0⟩.
Source§

fn reset_z_many(&mut self, targets: &[usize])

Explicit batched RZ alias.
Source§

fn reset_x_many(&mut self, targets: &[usize])

Explicit batched RX.
Source§

fn reset_y_many(&mut self, targets: &[usize])

Explicit batched RY.
Source§

impl<T, I, C> ResetLeakageChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn reset_leakage_channel(&mut self, addr0: usize)

Clear leakage at addr0 and reset the qubit to |0⟩. Read more
Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> ResetLossChannel<T> for GeneralizedTableau<T, I, C>

Source§

fn reset_loss_channel(&mut self, addr0: usize)

Clear the loss bit at addr0.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> RotXY<T> for GeneralizedTableau<T, I, C>
where GeneralizedTableau<T, I, C>: RotationOne<T>,

Source§

fn r(&mut self, addr0: usize, axis_angle: T::Coeff, theta: T::Coeff)

R(axis_angle, θ) on qubit addr0.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> RotationOne<T> for GeneralizedTableau<T, I, C>

Source§

fn rotate_1(&mut self, axis: Pauli, addr0: usize, theta: <T as Config>::Coeff)

Rotate about axis (one of X, Y, Z) by angle theta.
Source§

fn rx(&mut self, addr0: usize, theta: impl Into<<T as Config>::Coeff>)

RX(θ) on one qubit.
Source§

fn ry(&mut self, addr0: usize, theta: impl Into<<T as Config>::Coeff>)

RY(θ) on one qubit.
Source§

fn rz(&mut self, addr0: usize, theta: impl Into<<T as Config>::Coeff>)

RZ(θ) on one qubit.
Source§

fn rx_many(&mut self, targets: &[usize], theta: impl Into<<T as Config>::Coeff>)

Explicit batched RX(θ).
Source§

fn ry_many(&mut self, targets: &[usize], theta: impl Into<<T as Config>::Coeff>)

Explicit batched RY(θ).
Source§

fn rz_many(&mut self, targets: &[usize], theta: impl Into<<T as Config>::Coeff>)

Explicit batched RZ(θ).
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> RotationTwo<T> for GeneralizedTableau<T, I, C>

Source§

fn rotate_2( &mut self, axis_a: [u8; 2], axis_b: [u8; 2], a: usize, b: usize, theta: <T as Config>::Coeff, )

Two-qubit Pauli rotation: exp(-i * theta/2 * P_a ⊗ P_b). Read more
Source§

fn rxx(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · X_a X_b).
Source§

fn rxx_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rxx].
Source§

fn rxy(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · X_a Y_b).
Source§

fn rxy_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rxy].
Source§

fn rxz(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · X_a Z_b).
Source§

fn rxz_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rxz].
Source§

fn ryx(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Y_a X_b).
Source§

fn ryx_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [ryx].
Source§

fn ryy(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Y_a Y_b).
Source§

fn ryy_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [ryy].
Source§

fn ryz(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Y_a Z_b).
Source§

fn ryz_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [ryz].
Source§

fn rzx(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Z_a X_b).
Source§

fn rzx_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rzx].
Source§

fn rzy(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Z_a Y_b).
Source§

fn rzy_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rzy].
Source§

fn rzz(&mut self, a: usize, b: usize, theta: impl Into<<T as Config>::Coeff>)

exp(-i θ/2 · Z_a Z_b).
Source§

fn rzz_many( &mut self, pairs: &[(usize, usize)], theta: impl Into<<T as Config>::Coeff>, )

Explicit batched form of [rzz].
Source§

impl<T, I, C> TGate<T> for GeneralizedTableau<T, I, C>
where T: Config, <<T as Config>::Storage as BitView>::Store: PrimInt, C: SparseVector<Complex<T::Coeff>, I>, T::Coeff: One + Zero + Clone + Send + Sync + Num + PartialOrd, Complex<T::Coeff>: Mul<Output = Complex<T::Coeff>> + AddAssign + From<Complex64> + ComplexFloat + Copy, I: TableauIndex + Send + Sync, <I as BitAnd<<I as Shl<usize>>::Output>>::Output: PartialEq<I>,

Source§

fn t(&mut self, index: usize)

Apply T (diag(1, e^{iπ/4})) to one qubit.
Source§

fn t_dag(&mut self, index: usize)

Apply T† to one qubit.
Source§

fn t_many(&mut self, targets: &[usize])

Explicit batched T.
Source§

fn t_dag_many(&mut self, targets: &[usize])

Explicit batched T†.
Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> TableauLike for GeneralizedTableau<T, I, C>

Source§

type Coeff = <T as Config>::Coeff

Coefficient type used for probabilities.
Source§

type Rng = SmallRng

RNG type backing the stochastic channels.
Source§

fn rng_mut(&mut self) -> &mut Self::Rng

Mutable access to the backend’s RNG.
Source§

fn is_qubit_lost(&self, addr: usize) -> bool

Whether the qubit at addr is inactive (lost or leaked), so the Pauli noise channels skip it. Default: never inactive.
Source§

fn depolarize_impl(&mut self, addr0: usize, p: Self::Coeff)

Single-qubit depolarizing channel. Read more
Source§

fn pauli_error_impl(&mut self, addr0: usize, p: [Self::Coeff; 3])

Single-qubit Pauli-error channel (X, Y, Z with given probabilities). Read more
Source§

fn two_qubit_pauli_error_impl( &mut self, addr0: usize, addr1: usize, p: [Self::Coeff; 15], )

Two-qubit Pauli-error channel (15 non-identity Pauli combinations).
Source§

fn depolarize2_impl(&mut self, addr0: usize, addr1: usize, p: Self::Coeff)

Two-qubit depolarizing channel: spreads p over the 15 non-identity two-qubit Pauli errors.
Source§

impl<T: Config, I: TableauIndex, C: SparseVector<Complex<T::Coeff>, I>> TwoQubitPauliError<T> for GeneralizedTableau<T, I, C>

Source§

fn two_qubit_pauli_error( &mut self, addr0: usize, addr1: usize, p: [T::Coeff; 15], )

Apply a two-qubit Pauli-error channel to one pair. Probabilities are given in the order: {IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ}.
Source§

fn two_qubit_pauli_error_many( &mut self, pairs: &[(usize, usize)], p: [<T as Config>::Coeff; 15], )

Explicit batched two-qubit Pauli-error channel.
Source§

impl<T: Config, I, C: SparseVector<Complex<T::Coeff>, I>> U3Gate<T> for GeneralizedTableau<T, I, C>
where GeneralizedTableau<T, I, C>: RotationOne<T>,

Source§

fn u3(&mut self, addr0: usize, theta: T::Coeff, phi: T::Coeff, lambda: T::Coeff)

Apply U3(θ, φ, λ) to qubit addr.

Auto Trait Implementations§

§

impl<T, IndexType, SparseVectorType> Freeze for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: Freeze, SparseVectorType: Freeze, <T as Config>::Coeff: Freeze, PhantomData<IndexType>: Freeze,

§

impl<T, IndexType, SparseVectorType> RefUnwindSafe for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: RefUnwindSafe, SparseVectorType: RefUnwindSafe, <T as Config>::Coeff: RefUnwindSafe, PhantomData<IndexType>: RefUnwindSafe,

§

impl<T, IndexType, SparseVectorType> Send for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: Send, SparseVectorType: Send, <T as Config>::Coeff: Send, PhantomData<IndexType>: Send,

§

impl<T, IndexType, SparseVectorType> Sync for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: Sync, SparseVectorType: Sync, <T as Config>::Coeff: Sync, PhantomData<IndexType>: Sync,

§

impl<T, IndexType, SparseVectorType> Unpin for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: Unpin, SparseVectorType: Unpin, <T as Config>::Coeff: Unpin, PhantomData<IndexType>: Unpin,

§

impl<T, IndexType, SparseVectorType> UnsafeUnpin for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: UnsafeUnpin, SparseVectorType: UnsafeUnpin, <T as Config>::Coeff: UnsafeUnpin, PhantomData<IndexType>: UnsafeUnpin,

§

impl<T, IndexType, SparseVectorType> UnwindSafe for GeneralizedTableau<T, IndexType, SparseVectorType>
where Tableau<T>: UnwindSafe, SparseVectorType: UnwindSafe, <T as Config>::Coeff: UnwindSafe, PhantomData<IndexType>: UnwindSafe,

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

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.