pub struct TransitionMatrix {
pub data: Vec<f64>,
pub n: usize,
}Expand description
A row-major transition probability matrix for a discrete system.
Entry tpm[i][j] = P(state j at t+1 | state i at t).
Rows must sum to 1.0. Stored as a flat Vec for cache locality.
Fields§
§data: Vec<f64>Flat row-major storage: data[i * cols + j].
n: usizeNumber of states (rows = cols for square TPM).
Implementations§
Source§impl TransitionMatrix
impl TransitionMatrix
Sourcepub fn new(n: usize, data: Vec<f64>) -> Self
pub fn new(n: usize, data: Vec<f64>) -> Self
Create from a flat row-major vec. Panics if data.len() != n * n.
Sourcepub unsafe fn get_unchecked(&self, row: usize, col: usize) -> f64
pub unsafe fn get_unchecked(&self, row: usize, col: usize) -> f64
Sourcepub fn marginalize(&self, indices: &[usize]) -> TransitionMatrix
pub fn marginalize(&self, indices: &[usize]) -> TransitionMatrix
Extract a sub-TPM for the given element indices (marginalize).
Trait Implementations§
Source§impl Clone for TransitionMatrix
impl Clone for TransitionMatrix
Source§fn clone(&self) -> TransitionMatrix
fn clone(&self) -> TransitionMatrix
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TransitionMatrix
impl Debug for TransitionMatrix
Source§impl<'de> Deserialize<'de> for TransitionMatrix
impl<'de> Deserialize<'de> for TransitionMatrix
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TransitionMatrix
impl RefUnwindSafe for TransitionMatrix
impl Send for TransitionMatrix
impl Sync for TransitionMatrix
impl Unpin for TransitionMatrix
impl UnsafeUnpin for TransitionMatrix
impl UnwindSafe for TransitionMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more