ppvm_traits::traits
traits¶
ppvm_traits::traits
classNoStrategy¶source
ppvm_traits::traits::NoStrategy
Bases: Debug, Clone, Default, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, Strategy
Rust struct. Strategy that never truncates — exact simulation, all entries kept.
pub struct NoStrategyclassACMap¶source
ppvm_traits::traits::ACMap
Rust trait. Aggregate trait combining every operation a backing map must support to be usable as the storage for a `PauliSum`.
Signature
pub trait ACMap<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>: Clone + ACMapBase + ACMapAddAssign<S, V, H, W> + ACMapMulAssign<V, H> + ACMapInsert<S, V, H, W> + ACMapContains<S, V, H, W> + ACMapScale<S, V, H, W> + ACMapRetain<S, V, H, W> + ACMapConsumeYou don’t normally implement `ACMap` directly: the blanket impl below covers any type that implements all the constituent traits.
Map-backend implementor’s guide
Section titled “Map-backend implementor’s guide”A new backing map (a GPU-resident map, a sharded map, anything beyond the existing `HashMap` / `IndexMap` / `AHashMap` / `DashMap` backends) needs these to satisfy the `ACMap` bound itself:
- `Clone`.
- ACMapBase — construction, length, clear.
- ACMapAddAssign — `+=` insert-or-accumulate.
- ACMapMulAssign — scalar `*=`.
- ACMapInsert — just `map_insert_vec` and `map_insert_multiple` (there is no third variant to implement).
- ACMapContains — membership queries.
- ACMapScale — in-place per-entry transform.
- ACMapRetain — predicate-based entry removal.
- ACMapConsume — drain-and-accumulate merge of two maps.
Satisfying `ACMap` is necessary but not sufficient: `ppvm-pauli-sum` bounds individual operations on further traits, so a backend that skips them only fails to compile at those call sites. In practice you also want:
- ACMapIter — borrowing iteration over `(key, value)`; needed by `PauliSum::iter`, `Display`, and the approximate-comparison helpers.
- Trace — needed by `PauliSum::trace`.
- `Extend<(Word, Coeff)>` — needed by the arithmetic operators.
- `PartialEq` — needed by `PauliSum`‘s approximate comparisons.
Of these, `map_insert_vec`, `map_insert_multiple`, `scale`, `mul_assign`, `retain`, and `consume` are whole-collection batch entry points: a concurrent or GPU backend can dispatch each of them as one parallel pass over every entry. `add_assign` is the exception — it operates on a single key at a time, so a thread-pool backend typically only parallelizes its batch sibling, `map_add_assign`. See the `DashMap` impl in `crates/ppvm-traits/src/map/dashmap.rs` for a working concurrent precedent: `map_add_assign`, `mul_assign`, `map_insert_vec`, `map_insert_multiple`, `scale`, `consume`, and `trace` all go through rayon `par_iter`. `retain` is the one that does not — its `FnMut` predicate is not shareable across threads, so `DashMap` forwards to the sequential `DashMap::retain`.
sourceclassACMapAddAssign¶source
ppvm_traits::traits::ACMapAddAssign
Rust trait. `+=` semantics for an `ACMap`: insert a new entry or accumulate into the existing one with the same key.
Signature
pub trait ACMapAddAssign<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>methodadd_assign¶source
ppvm_traits::traits::ACMapAddAssign::add_assign
fn add_assign(&mut self, key: W, value: V)Parameters
| Name | Type | Description |
|---|---|---|
key | W | |
value | V |
Add `value` into the entry at `key`, creating the entry if absent.
sourcemethodmap_add_assign¶source
ppvm_traits::traits::ACMapAddAssign::map_add_assign
fn map_add_assign<F>(&self, dest: &mut Self, f: F)Parameters
| Name | Type | Description |
|---|---|---|
dest | &mut Self | |
f | F |
For every entry, compute `f(key, value)` and add the result into `dest` with add_assign.
sourceclassACMapBase¶source
ppvm_traits::traits::ACMapBase
Rust trait. Minimal interface for any "associative coefficient map" backing a `PauliSum` — construction, length, and clear.
pub trait ACMapBaseImplementations exist for `HashMap`, `IndexMap`, and `DashMap`; pick one via a Config.
sourcemethodclear¶source
ppvm_traits::traits::ACMapBase::clear
methodis_empty¶source
ppvm_traits::traits::ACMapBase::is_empty
methodlen¶source
ppvm_traits::traits::ACMapBase::len
methodwith_capacity¶source
ppvm_traits::traits::ACMapBase::with_capacity
fn with_capacity(capacity: usize) -> SelfParameters
| Name | Type | Description |
|---|---|---|
capacity | usize |
Returns
Self
Construct an empty map with at least `capacity` slots reserved.
sourceclassACMapConsume¶source
ppvm_traits::traits::ACMapConsume
Rust trait. Merge two maps with accumulation: drain `dest` into `self`, summing values that share a key.
classACMapContains¶source
ppvm_traits::traits::ACMapContains
Rust trait. Membership queries — `(key, value)` exact match or with a custom predicate on the value.
Signature
pub trait ACMapContains<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>methodcontains¶source
ppvm_traits::traits::ACMapContains::contains
fn contains(&self, key: &W, value: &V) -> boolParameters
| Name | Type | Description |
|---|---|---|
key | &W | |
value | &V |
Returns
bool
`true` if an entry with this exact `(key, value)` is present.
sourcemethodcontains_with¶source
ppvm_traits::traits::ACMapContains::contains_with
fn contains_with<F>(&self, key: &W, f: F) -> boolParameters
| Name | Type | Description |
|---|---|---|
key | &W | |
f | F |
Returns
bool
`true` if an entry for `key` exists whose value satisfies `f`.
sourceclassACMapInsert¶source
ppvm_traits::traits::ACMapInsert
Rust trait. In-place modify + insert pattern used to express branching gates (where one input entry can produce zero, one, or several output entries).
Signature
pub trait ACMapInsert<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>methodmap_insert_multiple¶source
ppvm_traits::traits::ACMapInsert::map_insert_multiple
fn map_insert_multiple<F>(&mut self, dest: &mut Self, f: F)Parameters
| Name | Type | Description |
|---|---|---|
dest | &mut Self | |
f | F |
Like map_insert_vec but `f` may return a `Vec` of new entries per existing entry, inserted directly into the destination map `dest`.
sourcemethodmap_insert_vec¶source
ppvm_traits::traits::ACMapInsert::map_insert_vec
fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, V)>, f: F)Parameters
| Name | Type | Description |
|---|---|---|
dest | &mut Vec<(W, V)> | |
f | F |
Modify each existing entry in place; if `f` returns `Some((k’, v’))`, append that new entry into `dest`, a plain `Vec` (a push per entry, no hashing). This is the primary hot-path entry point: the caller merges the buffer into the destination map afterwards, avoiding a second hashmap probe per produced entry.
sourceclassACMapIter¶source
ppvm_traits::traits::ACMapIter
Rust trait. Borrowing iteration over an `ACMap`. Lives in its own trait so that implementations may pick their own item / iterator types.
pub trait ACMapIter<'a>Associated items
| Name | Type | Description |
|---|---|---|
Item | type Item | associated type. Yielded item type. |
Iter | type Iter: Iterator | associated type. Iterator type. |
methoditer¶source
ppvm_traits::traits::ACMapIter::iter
fn iter(&'a self) -> <Self as >::IterReturns
<Self as >::Iter
Iterate over `(key, value)` pairs (or their representation).
sourceclassACMapMulAssign¶source
ppvm_traits::traits::ACMapMulAssign
Rust trait. Scalar `*=` semantics for an `ACMap`: multiply every value by a constant.
classACMapRetain¶source
ppvm_traits::traits::ACMapRetain
Rust trait. Drop entries that don't satisfy a predicate — used by truncation strategies.
Signature
pub trait ACMapRetain<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>methodretain¶source
ppvm_traits::traits::ACMapRetain::retain
fn retain<F>(&mut self, f: F)Parameters
| Name | Type | Description |
|---|---|---|
f | F |
Keep only entries for which `f(key, value)` returns `true`.
sourceclassACMapScale¶source
ppvm_traits::traits::ACMapScale
Rust trait. In-place per-entry transformation of values.
Signature
pub trait ACMapScale<S: PauliStorage, V: Coefficient, H: BuildHasher + Clone + Default, W: PauliWordTrait>methodscale¶source
ppvm_traits::traits::ACMapScale::scale
fn scale<F>(&mut self, f: F)Parameters
| Name | Type | Description |
|---|---|---|
f | F |
Apply `f(key, value)` to every entry; only the value is mutable.
sourceclassAmplitudeDamping¶source
ppvm_traits::traits::AmplitudeDamping
Rust trait. Amplitude-damping channel (single qubit).
pub trait AmplitudeDamping<T: Config>methodamplitude_damping¶source
ppvm_traits::traits::AmplitudeDamping::amplitude_damping
fn amplitude_damping(&mut self, addr0: usize, gamma: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
gamma | <T as >::Coeff |
Apply amplitude damping with damping parameter `gamma`.
sourceclassAsymmetricLossChannel¶source
ppvm_traits::traits::AsymmetricLossChannel
Rust trait. State-dependent ("asymmetric") single-qubit loss channel: a qubit is lost from `|0⟩` with probability `p0` and from `|1⟩` with probability `p1`. Unlike [`LossChannel`], the total loss probability depends on the qubit's populations, so the channel reads the current `⟨Z⟩`.
pub trait AsymmetricLossChannel<T: Config>methodasymmetric_loss_channel¶source
ppvm_traits::traits::AsymmetricLossChannel::asymmetric_loss_channel
Signature
fn asymmetric_loss_channel(&mut self, addr0: usize, p0: <T as >::Coeff, p1: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p0 | <T as >::Coeff | |
p1 | <T as >::Coeff |
Apply asymmetric loss to qubit `addr0`, with `p0` / `p1` the loss probabilities from `|0⟩` / `|1⟩`. See the backend impl for the trajectory approximation used (the survival back-action is omitted).
sourceclassCRx¶source
ppvm_traits::traits::CRx
Rust trait. Controlled `RX` rotation.
classClifford¶source
ppvm_traits::traits::Clifford
Rust trait. The minimal Clifford gate set: the single-qubit Paulis (`X`, `Y`, `Z`), Hadamard (`H`), phase gate (`S`), and the two entangling Cliffords `CNOT` and `CZ`.
pub trait CliffordImplemented by `PauliSum`, by every tableau type, and — via the blanket impl in this module — by every PauliWordTrait implementor.
Examples
Section titled “Examples”Build the GHZ-preparation circuit on a `PauliSum` (Heisenberg picture, so gates are applied in reverse). `PauliSum` lives in the downstream `ppvm-pauli-sum` crate, so this example is `ignore`d here:
```ignore use ppvm_pauli_sum::prelude::*;
let mut state: PauliSum<config::indexmap::ByteFxHashF64<1>> = PauliSum::builder().n_qubits(2).build(); state += (“ZZ”, 1.0); state.cnot(0, 1); state.h(0); assert_eq!(state.len(), 1); ```
sourcemethodcnot¶source
ppvm_traits::traits::Clifford::cnot
fn cnot(&mut self, control: usize, target: usize)Parameters
| Name | Type | Description |
|---|---|---|
control | usize | |
target | usize |
Apply `CNOT` to one `(control, target)` pair.
sourcemethodcx¶source
ppvm_traits::traits::Clifford::cx
methodcz¶source
ppvm_traits::traits::Clifford::cz
fn cz(&mut self, addr0: usize, addr1: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
addr1 | usize |
Apply `CZ` to one qubit pair.
sourcemethodh¶source
ppvm_traits::traits::Clifford::h
fn h(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply Hadamard `H` to one qubit.
sourcemethods¶source
ppvm_traits::traits::Clifford::s
fn s(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply phase gate `S` to one qubit.
sourcemethodx¶source
ppvm_traits::traits::Clifford::x
fn x(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply Pauli `X` to one qubit.
sourcemethody¶source
ppvm_traits::traits::Clifford::y
fn y(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply Pauli `Y` to one qubit.
sourcemethodz¶source
ppvm_traits::traits::Clifford::z
fn z(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply Pauli `Z` to one qubit.
sourcemethodzcx¶source
ppvm_traits::traits::Clifford::zcx
methodzcz¶source
ppvm_traits::traits::Clifford::zcz
classCliffordBatch¶source
ppvm_traits::traits::CliffordBatch
Rust trait. Batched Clifford gates: apply the same gate to many qubits in one call.
pub trait CliffordBatch: CliffordDefault implementations loop over the corresponding single-qubit (or single-pair) method on Clifford. Types like the stabilizer `Tableau` override these methods with a fused inner-loop or bitmask implementation. Types that don’t need specialization can implement this trait with an empty `impl` to use the defaults.
sourcemethodcnot_many¶source
ppvm_traits::traits::CliffordBatch::cnot_many
fn cnot_many(&mut self, pairs: &[(usize, usize)])Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] |
Apply `CNOT` to every `(control, target)` pair.
sourcemethodcz_many¶source
ppvm_traits::traits::CliffordBatch::cz_many
fn cz_many(&mut self, pairs: &[(usize, usize)])Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] |
Apply `CZ` to every `(control, target)` pair.
sourcemethodh_many¶source
ppvm_traits::traits::CliffordBatch::h_many
fn h_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply Hadamard `H` to every qubit in `indices`.
sourcemethods_many¶source
ppvm_traits::traits::CliffordBatch::s_many
fn s_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply phase gate `S` to every qubit in `indices`.
sourcemethodx_many¶source
ppvm_traits::traits::CliffordBatch::x_many
fn x_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply Pauli `X` to every qubit in `indices`.
sourcemethody_many¶source
ppvm_traits::traits::CliffordBatch::y_many
fn y_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply Pauli `Y` to every qubit in `indices`.
sourcemethodz_many¶source
ppvm_traits::traits::CliffordBatch::z_many
fn z_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply Pauli `Z` to every qubit in `indices`.
sourceclassCliffordExtensions¶source
ppvm_traits::traits::CliffordExtensions
Rust trait. Additional Clifford gates beyond the minimal set: `S†`, `√X`, `√X†`, `√Y`, `√Y†`, and `CY`.
pub trait CliffordExtensions: Cliffordmethodcy¶source
ppvm_traits::traits::CliffordExtensions::cy
fn cy(&mut self, control: usize, target: usize)Parameters
| Name | Type | Description |
|---|---|---|
control | usize | |
target | usize |
Apply `CY` to one `(control, target)` pair.
sourcemethods_dag¶source
ppvm_traits::traits::CliffordExtensions::s_dag
fn s_dag(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `S†` to one qubit.
sourcemethodsqrt_x¶source
ppvm_traits::traits::CliffordExtensions::sqrt_x
fn sqrt_x(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `√X` to one qubit.
sourcemethodsqrt_x_dag¶source
ppvm_traits::traits::CliffordExtensions::sqrt_x_dag
fn sqrt_x_dag(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `(√X)†` to one qubit.
sourcemethodsqrt_y¶source
ppvm_traits::traits::CliffordExtensions::sqrt_y
fn sqrt_y(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `√Y` to one qubit.
sourcemethodsqrt_y_dag¶source
ppvm_traits::traits::CliffordExtensions::sqrt_y_dag
fn sqrt_y_dag(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `(√Y)†` to one qubit.
sourcemethodzcy¶source
ppvm_traits::traits::CliffordExtensions::zcy
classCliffordExtensionsBatch¶source
ppvm_traits::traits::CliffordExtensionsBatch
Rust trait. Batched form of [`CliffordExtensions`].
pub trait CliffordExtensionsBatch: CliffordExtensions + CliffordBatchmethodcy_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::cy_many
fn cy_many(&mut self, pairs: &[(usize, usize)])Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] |
Apply `CY` to every `(control, target)` pair.
sourcemethods_dag_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::s_dag_many
fn s_dag_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply `S†` to every qubit in `indices`.
sourcemethodsqrt_x_dag_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::sqrt_x_dag_many
fn sqrt_x_dag_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply `(√X)†` to every qubit in `indices`.
sourcemethodsqrt_x_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::sqrt_x_many
fn sqrt_x_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply `√X` to every qubit in `indices`.
sourcemethodsqrt_y_dag_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::sqrt_y_dag_many
fn sqrt_y_dag_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply `(√Y)†` to every qubit in `indices`.
sourcemethodsqrt_y_many¶source
ppvm_traits::traits::CliffordExtensionsBatch::sqrt_y_many
fn sqrt_y_many(&mut self, indices: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
indices | &[usize] |
Apply `√Y` to every qubit in `indices`.
sourceclassCoefficient¶source
ppvm_traits::traits::Coefficient
Rust trait. Numeric coefficient type usable inside a `PauliSum`.
Signature
pub trait Coefficient: PartialEq + Clone + Zero + From<f64> + Neg + Add<f64> + Add<Self> + Sub<f64> + Sub<Self> + Mul<f64> + Mul<Self> + AddAssign<f64> + AddAssign<Self> + MulAssign<f64> + MulAssign<Self> + Sum + Sync + Send`Coefficient` bundles every arithmetic operation a Pauli-propagation step needs — addition, multiplication, signed multiplication, half, sin/cos, and a `cutoff` predicate used by truncation strategies. The built-in `f64` impl covers the common case; `Complex<f64>` is available when phase tracking is required.
sourcemethodcutoff¶source
ppvm_traits::traits::Coefficient::cutoff
fn cutoff(&self, threshold: f64) -> boolParameters
| Name | Type | Description |
|---|---|---|
threshold | f64 |
Returns
bool
Determine whether this coefficient should be cutoff Returns `true`, if the coefficient should be cut, and `false` else.
sourcemethodhalf¶source
ppvm_traits::traits::Coefficient::half
methodmul_sign¶source
ppvm_traits::traits::Coefficient::mul_sign
fn mul_sign(&self, sign: i8) -> SelfParameters
| Name | Type | Description |
|---|---|---|
sign | i8 |
Returns
Self
Multiply by `sign ∈ {-1, +1}` (encoded as `i8`).
sourcemethodsin_cos¶source
ppvm_traits::traits::Coefficient::sin_cos
classComplexCoefficient¶source
ppvm_traits::traits::ComplexCoefficient
Rust trait. A [`Coefficient`] extended with multiplication by a fourth-root-of-unity phase. Used by `PhasedPauliWord`.
classCorrelatedLossChannel¶source
ppvm_traits::traits::CorrelatedLossChannel
Rust trait. Correlated two-qubit loss channel.
pub trait CorrelatedLossChannel<T: Config>The `p[1]` convention (normative)
Section titled “The `p[1]` convention (normative)”This is the one place the parameterization is defined; every backend (`ppvm-pauli-sum`, `ppvm-tableau`‘s trajectory, `ppvm-tableau-sum`‘s mixture) and every binding cites it rather than restating it. In the paper’s notation `p = [p_LL, p_LQ, p_LN]`, and `p[1] = p_LQ` is the probability that a named one of the two atoms is lost while the other survives. The two single-loss events are disjoint, so
- the probability of losing exactly one atom is `2·p[1]`, and
- the probability that both remain in the qubit subspace — the factor a fully in-subspace observable is scaled by — is `1 − 2·p[1] − p[0]`.
The channel is completely positive exactly on `p[0], p[1] >= 0`, `p[0] + 2·p[1] <= 1`, `p[2] ∈ [0, 1]`; the tableau backends `debug_assert` that region.
sourcemethodcorrelated_loss_channel¶source
ppvm_traits::traits::CorrelatedLossChannel::correlated_loss_channel
Signature
fn correlated_loss_channel(&mut self, addr0: usize, addr1: usize, p: [<T as >::Coeff; 3])Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
addr1 | usize | |
p | [<T as >::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 losing exactly one has probability `2·p[1]` and the both-present survivor is scaled by `1 − 2·p[1] − p[0]` (which qubit is lost is 50/50).
- `p[2]`: The probability of losing one qubit when the other one has already been lost prior to the channel.
classDepolarizing¶source
ppvm_traits::traits::Depolarizing
Rust trait. Single-qubit depolarizing channel.
pub trait Depolarizing<T: Config>methoddepolarize1¶source
ppvm_traits::traits::Depolarizing::depolarize1
fn depolarize1(&mut self, addr0: usize, p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p | <T as >::Coeff |
Depolarize one qubit with probability `p`.
sourcemethoddepolarize1_many¶source
ppvm_traits::traits::Depolarizing::depolarize1_many
fn depolarize1_many(&mut self, targets: &[usize], p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
p | <T as >::Coeff |
Explicit batched single-qubit depolarizing channel.
sourceclassDepolarizing2¶source
ppvm_traits::traits::Depolarizing2
Rust trait. Two-qubit depolarizing channel.
pub trait Depolarizing2<T: Config>methoddepolarize2¶source
ppvm_traits::traits::Depolarizing2::depolarize2
fn depolarize2(&mut self, addr0: usize, addr1: usize, p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
addr1 | usize | |
p | <T as >::Coeff |
Depolarize one qubit pair with probability `p`.
sourcemethoddepolarize2_many¶source
ppvm_traits::traits::Depolarizing2::depolarize2_many
Signature
fn depolarize2_many(&mut self, pairs: &[(usize, usize)], p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
p | <T as >::Coeff |
Explicit batched two-qubit depolarizing channel.
sourceclassHashFinalize¶source
ppvm_traits::traits::HashFinalize
Rust trait. Post-processing that a `PauliWord`'s hasher applies to its raw 64-bit digest before it is cached as the map-key hash.
pub trait HashFinalizeThe cached value is what `hashbrown` ultimately splits into a bucket index (low bits) and a control-byte tag (top 7 bits). Whether the raw digest is good enough for that split is a property of the hasher, not of the Pauli word: an AES-based hasher such as `gxhash` avalanches well even for an 8-byte key, whereas `FxHasher` — a couple of multiply-rotate rounds — leaves the low bits of a short key highly correlated and needs a fold to fix them.
Keeping this on the hasher is what makes the abstraction correct. An earlier version folded based on storage width alone, which conflated “narrow storage” with “weak hasher” and so wrongly folded `gxhash` too. Here each hasher declares how (if at all) its output must be adjusted, and `PauliWord::rehash` just defers to it. The default is the identity — the right choice for any hasher that already distributes its low bits well — so a custom hasher opts in with a bare `impl HashFinalize for MyHasher {}`.
sourcemethodfinalize_hash¶source
ppvm_traits::traits::HashFinalize::finalize_hash
fn finalize_hash(raw: u64, storage_bytes: usize) -> u64Parameters
| Name | Type | Description |
|---|---|---|
raw | u64 | |
storage_bytes | usize |
Returns
u64
Finalize `raw` (the value returned by `Hasher::finish`) for a key whose backing storage is `storage_bytes` wide per bit-array.
The width is supplied so a hasher can fold only for the short keys that actually need it and pass wider keys through. It is a compile-time constant at every call site (`size_of` of the storage), so any branch on it is monomorphized away.
sourceclassLossChannel¶source
ppvm_traits::traits::LossChannel
Rust trait. Single-qubit loss channel — with probability `p`, mark the qubit as lost (`Pauli::L`).
classLossyMeasure¶source
ppvm_traits::traits::LossyMeasure
Rust trait. Loss-aware Z-basis measurement.
pub trait LossyMeasuremethodmeasure¶source
ppvm_traits::traits::LossyMeasure::measure
fn measure(&mut self, addr0: usize) -> Option<bool>Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Returns
Option<bool>
Measure qubit `addr0`. Returns `Some(bit)` for an in-subspace outcome, or `None` if the qubit has been lost.
sourcemethodmeasure_many¶source
ppvm_traits::traits::LossyMeasure::measure_many
fn measure_many(&mut self, targets: &[usize]) -> Vec<Option<bool>>Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Returns
Vec<Option<bool>>
Explicit batched measurement: measure each target in order, returning one result per target.
sourceclassMeasure¶source
ppvm_traits::traits::Measure
Rust trait. Projective Z-basis measurement returning a bare boolean outcome.
classPauliError¶source
ppvm_traits::traits::PauliError
Rust trait. Single-qubit Pauli error channel — apply `X`, `Y`, or `Z` with the three given probabilities.
pub trait PauliError<T: Config>methodpauli_error¶source
ppvm_traits::traits::PauliError::pauli_error
fn pauli_error(&mut self, addr0: usize, p: [<T as >::Coeff; 3])Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p | [<T as >::Coeff; 3] |
Apply a Pauli-error channel `[p_x, p_y, p_z]` to one qubit.
sourcemethodpauli_error_many¶source
ppvm_traits::traits::PauliError::pauli_error_many
Signature
fn pauli_error_many(&mut self, targets: &[usize], p: [<T as >::Coeff; 3])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
p | [<T as >::Coeff; 3] |
Explicit batched Pauli-error channel.
sourcemethodx_error¶source
ppvm_traits::traits::PauliError::x_error
fn x_error(&mut self, addr0: usize, p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p | <T as >::Coeff |
stim `X_ERROR(p)` — apply X with probability `p` to one qubit.
sourcemethodx_error_many¶source
ppvm_traits::traits::PauliError::x_error_many
fn x_error_many(&mut self, targets: &[usize], p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
p | <T as >::Coeff |
Explicit batched `X_ERROR(p)`.
sourcemethody_error¶source
ppvm_traits::traits::PauliError::y_error
fn y_error(&mut self, addr0: usize, p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p | <T as >::Coeff |
stim `Y_ERROR(p)` — apply Y with probability `p` to one qubit.
sourcemethody_error_many¶source
ppvm_traits::traits::PauliError::y_error_many
fn y_error_many(&mut self, targets: &[usize], p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
p | <T as >::Coeff |
Explicit batched `Y_ERROR(p)`.
sourcemethodz_error¶source
ppvm_traits::traits::PauliError::z_error
fn z_error(&mut self, addr0: usize, p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
p | <T as >::Coeff |
stim `Z_ERROR(p)` — apply Z with probability `p` to one qubit.
sourcemethodz_error_many¶source
ppvm_traits::traits::PauliError::z_error_many
fn z_error_many(&mut self, targets: &[usize], p: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
p | <T as >::Coeff |
Explicit batched `Z_ERROR(p)`.
sourceclassPauliIter¶source
ppvm_traits::traits::PauliIter
Rust trait. Iterate over a Pauli word slot-by-slot.
classPauliStorage¶source
ppvm_traits::traits::PauliStorage
Rust trait. Backing storage for a `PauliWord` — a fixed-size, `Copy`-able block of bits (typically `[u8; N]` or `[u64; N]`).
Signature
pub trait PauliStorage: BitViewSized + Clone + Copy + Hash + Eq + PartialEq + Send + Sync + Debug + Ord + PartialOrd + PodThe bytemuck::Pod bound guarantees the storage is a plain-old-data type with no padding and all bit patterns valid, which lets `PauliWord::rehash` view it as a `&[u8]` for fast byte-slice hashing without `unsafe`. Every concrete storage used here (`[u8; N]`, `[u64; N]`) is already `Pod`.
sourceclassPauliWordTrait¶source
ppvm_traits::traits::PauliWordTrait
Rust trait. Word-level Pauli operations. Types implementing this trait automatically gain [`crate::traits::Clifford`] and [`crate::traits::CliffordExtensions`] behavior via blanket impls in the `crate::traits::clifford` module, using `get_lbit` / `get_xbit` / `set_xbit` / `set_zbit` / `rehash` to transform Pauli words.
Signature
pub trait PauliWordTrait: Clone + Hash + Eq + PauliIter + From<String> + DisplayWord-level vs. state-level gate semantics
Section titled “Word-level vs. state-level gate semantics”The blanket `Clifford` impl applies gates at the bit level of a single Pauli word. X / Y / Z are bit-level no-ops on a Pauli word — they affect phase, not the X/Z bits — so `word.x(i)`, `word.y(i)`, `word.z(i)` are deliberately silent. Phase is tracked separately by `PhasedPauliWord`, which implements `Clifford` manually.
If you need a word representation whose gate behavior is not pure bit manipulation (phase tracking, fused multi-qubit updates, alternative loss semantics), do not implement `PauliWordTrait` on it — define a specialized `Clifford` impl instead, the way `PhasedPauliWord` does. Implementing both `PauliWordTrait` and a custom `impl Clifford for …` for the same type will not compile: the blanket impl overlaps with your custom impl (coherence error), not silently shadows it.
sourcemethodanticommutes_at¶source
ppvm_traits::traits::PauliWordTrait::anticommutes_at
fn anticommutes_at(&self, addr0: usize, pauli: (bool, bool)) -> boolParameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
pauli | (bool, bool) |
Returns
bool
Check if this word anticommutes with a single-qubit Pauli at `addr0`, where `pauli = (xbit, zbit)`.
sourcemethodget¶source
ppvm_traits::traits::PauliWordTrait::get
methodget_lbit¶source
ppvm_traits::traits::PauliWordTrait::get_lbit
fn get_lbit(&self, index: usize) -> boolParameters
| Name | Type | Description |
|---|---|---|
index | usize |
Returns
bool
Loss bit at `index` (always `false` for non-lossy implementations).
sourcemethodget_xbit¶source
ppvm_traits::traits::PauliWordTrait::get_xbit
fn get_xbit(&self, index: usize) -> boolParameters
| Name | Type | Description |
|---|---|---|
index | usize |
Returns
bool
X bit at `index`.
sourcemethodget_zbit¶source
ppvm_traits::traits::PauliWordTrait::get_zbit
fn get_zbit(&self, index: usize) -> boolParameters
| Name | Type | Description |
|---|---|---|
index | usize |
Returns
bool
Z bit at `index`.
sourcemethodis¶source
ppvm_traits::traits::PauliWordTrait::is
fn is(&self, index: usize, pauli: Pauli) -> boolParameters
| Name | Type | Description |
|---|---|---|
index | usize | |
pauli | Pauli |
Returns
bool
Quick check: is the slot at `index` equal to `pauli`?
sourcemethodloss_weight¶source
ppvm_traits::traits::PauliWordTrait::loss_weight
fn loss_weight(&self) -> usizeReturns
usize
Number of slots marked as lost; always `0` for non-lossy variants.
sourcemethodn_qubits¶source
ppvm_traits::traits::PauliWordTrait::n_qubits
methodnew¶source
ppvm_traits::traits::PauliWordTrait::new
fn new(nqubits: usize) -> SelfParameters
| Name | Type | Description |
|---|---|---|
nqubits | usize |
Returns
Self
Construct an identity word over `nqubits` qubits.
sourcemethodrehash¶source
ppvm_traits::traits::PauliWordTrait::rehash
methodset¶source
ppvm_traits::traits::PauliWordTrait::set
fn set(&mut self, index: usize, pauli: Pauli) -> &mut SelfParameters
| Name | Type | Description |
|---|---|---|
index | usize | |
pauli | Pauli |
Returns
&mut Self
Set the slot at `index` to `pauli`, in place. Returns `&mut self` for chaining.
sourcemethodset_new¶source
ppvm_traits::traits::PauliWordTrait::set_new
fn set_new(&self, index: usize, pauli: Pauli) -> SelfParameters
| Name | Type | Description |
|---|---|---|
index | usize | |
pauli | Pauli |
Returns
Self
Return a clone with the slot at `index` set to `pauli`.
sourcemethodset_xbit¶source
ppvm_traits::traits::PauliWordTrait::set_xbit
fn set_xbit(&mut self, index: usize, value: bool)Parameters
| Name | Type | Description |
|---|---|---|
index | usize | |
value | bool |
Set the X bit at `index`.
sourcemethodset_zbit¶source
ppvm_traits::traits::PauliWordTrait::set_zbit
fn set_zbit(&mut self, index: usize, value: bool)Parameters
| Name | Type | Description |
|---|---|---|
index | usize | |
value | bool |
Set the Z bit at `index`.
sourcemethodweight¶source
ppvm_traits::traits::PauliWordTrait::weight
fn weight(&self) -> usizeReturns
usize
Number of non-identity slots (counts `X`, `Y`, `Z`, and — for lossy variants — `L`).
sourceclassProjection¶source
ppvm_traits::traits::Projection
Rust trait. Projective Z-basis projectors `|0⟩⟨0|` and `|1⟩⟨1|`.
pub trait Projectionmethodp0¶source
ppvm_traits::traits::Projection::p0
fn p0(&mut self, pos: usize)Parameters
| Name | Type | Description |
|---|---|---|
pos | usize |
Project qubit `pos` onto `|0⟩`.
sourcemethodp1¶source
ppvm_traits::traits::Projection::p1
fn p1(&mut self, pos: usize)Parameters
| Name | Type | Description |
|---|---|---|
pos | usize |
Project qubit `pos` onto `|1⟩`.
sourceclassReset¶source
ppvm_traits::traits::Reset
Rust trait. Reset one qubit to a computational/Pauli basis state.
pub trait Reset: Clifford + CliffordExtensionsmethodreset¶source
ppvm_traits::traits::Reset::reset
fn reset(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Reset one qubit to `|0⟩` (stim `R`/`RZ`).
sourcemethodreset_many¶source
ppvm_traits::traits::Reset::reset_many
fn reset_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched reset to `|0⟩`.
sourcemethodreset_x¶source
ppvm_traits::traits::Reset::reset_x
fn reset_x(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
stim `RX` — reset to `|+⟩`.
sourcemethodreset_x_many¶source
ppvm_traits::traits::Reset::reset_x_many
fn reset_x_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched `RX`.
sourcemethodreset_y¶source
ppvm_traits::traits::Reset::reset_y
fn reset_y(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
stim `RY` — reset to `|i⟩`.
sourcemethodreset_y_many¶source
ppvm_traits::traits::Reset::reset_y_many
fn reset_y_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched `RY`.
sourcemethodreset_z¶source
ppvm_traits::traits::Reset::reset_z
fn reset_z(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
stim `RZ` alias — reset to `|0⟩`.
sourcemethodreset_z_many¶source
ppvm_traits::traits::Reset::reset_z_many
fn reset_z_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched `RZ` alias.
sourceclassResetLossChannel¶source
ppvm_traits::traits::ResetLossChannel
Rust trait. Reset the loss bit on a qubit — used to model a re-cooling / re-loading event that brings a previously-lost atom back.
classRotXY¶source
ppvm_traits::traits::RotXY
Rust trait. Rotation about an axis in the x/y plane: `R(axis_angle, θ) = exp(-i θ/2 · (cos(axis_angle)·X + sin(axis_angle)·Y))`.
pub trait RotXY<T: Config>The in-plane axis is `X` rotated about `Z` by `axis_angle`, so `R(axis_angle, θ) = RZ(axis_angle)·RX(θ)·RZ(−axis_angle)`.
sourcemethodr¶source
ppvm_traits::traits::RotXY::r
Signature
fn r(&mut self, addr0: usize, axis_angle: <T as >::Coeff, theta: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
axis_angle | <T as >::Coeff | |
theta | <T as >::Coeff |
`R(axis_angle, θ)` on qubit `addr0`.
sourceclassRotationOne¶source
ppvm_traits::traits::RotationOne
Rust trait. Single-qubit Pauli rotations `exp(-i θ/2 · P)`.
pub trait RotationOne<T: Config>methodrotate_1¶source
ppvm_traits::traits::RotationOne::rotate_1
fn rotate_1(&mut self, axis: Pauli, addr0: usize, theta: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
axis | Pauli | |
addr0 | usize | |
theta | <T as >::Coeff |
Rotate about `axis` (one of `X`, `Y`, `Z`) by angle `theta`.
sourcemethodrx¶source
ppvm_traits::traits::RotationOne::rx
fn rx(&mut self, addr0: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
theta | impl Into<<T as >::Coeff> |
`RX(θ)` on one qubit.
sourcemethodrx_many¶source
ppvm_traits::traits::RotationOne::rx_many
Signature
fn rx_many(&mut self, targets: &[usize], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched `RX(θ)`.
sourcemethodry¶source
ppvm_traits::traits::RotationOne::ry
fn ry(&mut self, addr0: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
theta | impl Into<<T as >::Coeff> |
`RY(θ)` on one qubit.
sourcemethodry_many¶source
ppvm_traits::traits::RotationOne::ry_many
Signature
fn ry_many(&mut self, targets: &[usize], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched `RY(θ)`.
sourcemethodrz¶source
ppvm_traits::traits::RotationOne::rz
fn rz(&mut self, addr0: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
theta | impl Into<<T as >::Coeff> |
`RZ(θ)` on one qubit.
sourcemethodrz_many¶source
ppvm_traits::traits::RotationOne::rz_many
Signature
fn rz_many(&mut self, targets: &[usize], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched `RZ(θ)`.
sourceclassRotationTwo¶source
ppvm_traits::traits::RotationTwo
Rust trait. Two-qubit Pauli rotations, generated by `P_a ⊗ P_b` for any pair of non-identity Paulis. Provides the named convenience methods `rxx`, `rxy`, …, `rzz` on top of the generic [`rotate_2`].
pub trait RotationTwo<T: Config>methodrotate_2¶source
ppvm_traits::traits::RotationTwo::rotate_2
Signature
fn rotate_2(&mut self, axis_a: [u8; 2], axis_b: [u8; 2], a: usize, b: usize, theta: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
axis_a | [u8; 2] | |
axis_b | [u8; 2] | |
a | usize | |
b | usize | |
theta | <T as >::Coeff |
Two-qubit Pauli rotation: `exp(-i * theta/2 * P_a ⊗ P_b)`.
Each axis is encoded as `[x, z]` bits: `[0,0]` = I, `[1,0]` = X, `[0,1]` = Z, `[1,1]` = Y.
sourcemethodrxx¶source
ppvm_traits::traits::RotationTwo::rxx
fn rxx(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · X_a X_b)`.
sourcemethodrxx_many¶source
ppvm_traits::traits::RotationTwo::rxx_many
Signature
fn rxx_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rxx`].
sourcemethodrxy¶source
ppvm_traits::traits::RotationTwo::rxy
fn rxy(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · X_a Y_b)`.
sourcemethodrxy_many¶source
ppvm_traits::traits::RotationTwo::rxy_many
Signature
fn rxy_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rxy`].
sourcemethodrxz¶source
ppvm_traits::traits::RotationTwo::rxz
fn rxz(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · X_a Z_b)`.
sourcemethodrxz_many¶source
ppvm_traits::traits::RotationTwo::rxz_many
Signature
fn rxz_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rxz`].
sourcemethodryx¶source
ppvm_traits::traits::RotationTwo::ryx
fn ryx(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Y_a X_b)`.
sourcemethodryx_many¶source
ppvm_traits::traits::RotationTwo::ryx_many
Signature
fn ryx_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`ryx`].
sourcemethodryy¶source
ppvm_traits::traits::RotationTwo::ryy
fn ryy(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Y_a Y_b)`.
sourcemethodryy_many¶source
ppvm_traits::traits::RotationTwo::ryy_many
Signature
fn ryy_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`ryy`].
sourcemethodryz¶source
ppvm_traits::traits::RotationTwo::ryz
fn ryz(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Y_a Z_b)`.
sourcemethodryz_many¶source
ppvm_traits::traits::RotationTwo::ryz_many
Signature
fn ryz_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`ryz`].
sourcemethodrzx¶source
ppvm_traits::traits::RotationTwo::rzx
fn rzx(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Z_a X_b)`.
sourcemethodrzx_many¶source
ppvm_traits::traits::RotationTwo::rzx_many
Signature
fn rzx_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rzx`].
sourcemethodrzy¶source
ppvm_traits::traits::RotationTwo::rzy
fn rzy(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Z_a Y_b)`.
sourcemethodrzy_many¶source
ppvm_traits::traits::RotationTwo::rzy_many
Signature
fn rzy_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rzy`].
sourcemethodrzz¶source
ppvm_traits::traits::RotationTwo::rzz
fn rzz(&mut self, a: usize, b: usize, theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
a | usize | |
b | usize | |
theta | impl Into<<T as >::Coeff> |
`exp(-i θ/2 · Z_a Z_b)`.
sourcemethodrzz_many¶source
ppvm_traits::traits::RotationTwo::rzz_many
Signature
fn rzz_many(&mut self, pairs: &[(usize, usize)], theta: impl Into<<T as >::Coeff>)Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
theta | impl Into<<T as >::Coeff> |
Explicit batched form of [`rzz`].
sourceclassStrategy¶source
ppvm_traits::traits::Strategy
Rust trait. A truncation policy applied to a `PauliSum` during Pauli propagation.
pub trait Strategy: Default + Clone + CopyThe strategy controls two things: the initial capacity allocated for the underlying map (estimating how many Pauli paths the simulation is expected to generate) and the cut applied when truncate is called explicitly. Implementations include NoStrategy, the coefficient-magnitude threshold, the max-Pauli-weight bound, etc.
sourcemethodcapacity¶source
ppvm_traits::traits::Strategy::capacity
fn capacity(&self, n_qubits: usize) -> usizeParameters
| Name | Type | Description |
|---|---|---|
n_qubits | usize |
Returns
usize
Given the number of qubits, predict the initial capacity of the map. Ideally this is about guessing the maximum Pauli paths will be generated during the computation, the more precise the better.
sourcemethodtruncate¶source
ppvm_traits::traits::Strategy::truncate
fn truncate<S, V, H, M, W>(&self, map: &mut M)Parameters
| Name | Type | Description |
|---|---|---|
map | &mut M |
Drop entries from `map` that fall outside this strategy’s policy.
sourceclassTGate¶source
ppvm_traits::traits::TGate
Rust trait. The non-Clifford `T` gate and its adjoint.
pub trait TGate<T: Config>`T = diag(1, e^{iπ/4})`. Implemented by the simulator backends; see the example in `ppvm_tableau`.
sourcemethodt¶source
ppvm_traits::traits::TGate::t
fn t(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `T` (`diag(1, e^{iπ/4})`) to one qubit.
sourcemethodt_dag¶source
ppvm_traits::traits::TGate::t_dag
fn t_dag(&mut self, addr0: usize)Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize |
Apply `T†` to one qubit.
sourcemethodt_dag_many¶source
ppvm_traits::traits::TGate::t_dag_many
fn t_dag_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched `T†`.
sourcemethodt_many¶source
ppvm_traits::traits::TGate::t_many
fn t_many(&mut self, targets: &[usize])Parameters
| Name | Type | Description |
|---|---|---|
targets | &[usize] |
Explicit batched `T`.
sourceclassTrace¶source
ppvm_traits::traits::Trace
Rust trait. Trait for computing `trace(self * RHS)`.
pub trait Trace<'a, RHS: 'a>Associated items
| Name | Type | Description |
|---|---|---|
Output | type Output | associated type. Numeric output of the trace. |
If a type implements `Trace`, a corresponding `TraceBy` implementation is also provided automatically.
sourcemethodtrace¶source
ppvm_traits::traits::Trace::trace
fn trace(&'a self, value: &'a RHS) -> <Self as >::OutputParameters
| Name | Type | Description |
|---|---|---|
value | &'a RHS |
Returns
<Self as >::Output
Compute `tr(self · value)`.
sourceclassTwoQubitPauliError¶source
ppvm_traits::traits::TwoQubitPauliError
Rust trait. Two-qubit Pauli error channel.
pub trait TwoQubitPauliError<T: Config>methodtwo_qubit_pauli_error¶source
ppvm_traits::traits::TwoQubitPauliError::two_qubit_pauli_error
Signature
fn two_qubit_pauli_error(&mut self, addr0: usize, addr1: usize, p: [<T as >::Coeff; 15])Parameters
| Name | Type | Description |
|---|---|---|
addr0 | usize | |
addr1 | usize | |
p | [<T as >::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}`.
sourcemethodtwo_qubit_pauli_error_many¶source
ppvm_traits::traits::TwoQubitPauliError::two_qubit_pauli_error_many
Signature
fn two_qubit_pauli_error_many(&mut self, pairs: &[(usize, usize)], p: [<T as >::Coeff; 15])Parameters
| Name | Type | Description |
|---|---|---|
pairs | &[(usize, usize)] | |
p | [<T as >::Coeff; 15] |
Explicit batched two-qubit Pauli-error channel.
sourceclassU3Gate¶source
ppvm_traits::traits::U3Gate
Rust trait. The general single-qubit `U3(θ, φ, λ)` gate.
pub trait U3Gate<T: Config>methodu3¶source
ppvm_traits::traits::U3Gate::u3
Signature
fn u3(&mut self, addr: usize, theta: <T as >::Coeff, phi: <T as >::Coeff, lambda: <T as >::Coeff)Parameters
| Name | Type | Description |
|---|---|---|
addr | usize | |
theta | <T as >::Coeff | |
phi | <T as >::Coeff | |
lambda | <T as >::Coeff |
Apply `U3(θ, φ, λ)` to qubit `addr`.
source