Skip to main content

Probabilities

Enum Probabilities 

Source
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.

§total_qubits: usize

Total qubit count across all blocks.

Implementations§

Source§

impl Probabilities

Source

pub fn len(&self) -> usize

Number of basis states (2^n).

Source

pub fn is_empty(&self) -> bool

Always false, a probability distribution has at least one state.

Source

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().

Source

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.

Source

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

Source§

fn clone(&self) -> Probabilities

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 Debug for Probabilities

Source§

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

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

impl Index<usize> for Probabilities

Source§

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.

Source§

type Output = f64

The returned type after indexing.

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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V