pub enum Probabilities {
Dense(Vec<f64>),
Factored {
blocks: Vec<FactoredBlock>,
total_qubits: usize,
},
}Expand description
Probability distribution over computational basis states.
For monolithic simulations this wraps a dense Vec<f64> of length 2^n.
For decomposed simulations with independent subsystems, this stores
per-block marginal distributions that are multiplied on demand,
avoiding the O(2^N) Kronecker product unless explicitly requested.
Variants§
Dense(Vec<f64>)
Full probability vector of length 2^n.
Factored
Lazy Kronecker product of independent block distributions.
Fields
blocks: Vec<FactoredBlock>Per-block marginal probability vectors and bitmasks.
Implementations§
Source§impl Probabilities
impl Probabilities
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Always false, a probability distribution has at least one state.
Sourcepub fn get(&self, index: usize) -> f64
pub fn get(&self, index: usize) -> f64
Probability of a single computational basis state. O(1) for dense, O(K) for factored where K is the number of independent blocks.
§Panics
Panics if index >= self.len().
Sourcepub fn iter(&self) -> ProbabilitiesIter<'_> ⓘ
pub fn iter(&self) -> ProbabilitiesIter<'_> ⓘ
Iterate over all basis-state probabilities in order.
For Dense this is a direct slice iteration. For Factored each
probability is computed on the fly in O(K) per element.
Sourcepub fn to_vec(&self) -> Vec<f64>
pub fn to_vec(&self) -> Vec<f64>
Materialize the full probability vector. O(1) clone for dense,
O(K x 2^N) for factored. Prefer Probabilities::get for spot-checking.
Trait Implementations§
Source§impl Clone for Probabilities
impl Clone for Probabilities
Source§fn clone(&self) -> Probabilities
fn clone(&self) -> Probabilities
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Probabilities
impl Debug for Probabilities
Source§impl Index<usize> for Probabilities
impl Index<usize> for Probabilities
Source§fn index(&self, index: usize) -> &f64
fn index(&self, index: usize) -> &f64
Index into a dense probability vector.
Only works for Dense. Panics on Factored because Index must
return &f64 and factored values are computed, not stored.
Use Probabilities::get or Probabilities::iter instead.