pub struct SparseFactor {
pub variables: Vec<String>,
pub cardinalities: Vec<usize>,
pub entries: Vec<(Vec<usize>, f64)>,
pub default_value: f64,
}Expand description
Sparse factor representation using coordinate format.
Efficient for factors where most entries are zero or near-zero.
Fields§
§variables: Vec<String>Variable names
cardinalities: Vec<usize>Cardinalities for each variable
entries: Vec<(Vec<usize>, f64)>Non-zero entries: (indices, value)
default_value: f64Default value for entries not in sparse representation
Implementations§
Source§impl SparseFactor
impl SparseFactor
Sourcepub fn new(variables: Vec<String>, cardinalities: Vec<usize>) -> Self
pub fn new(variables: Vec<String>, cardinalities: Vec<usize>) -> Self
Create a new sparse factor.
Sourcepub fn from_dense(factor: &Factor, threshold: f64) -> Self
pub fn from_dense(factor: &Factor, threshold: f64) -> Self
Create from a dense factor with sparsity threshold.
Values below threshold are treated as zero.
Sourcepub fn memory_savings(&self) -> f64
pub fn memory_savings(&self) -> f64
Memory savings compared to dense representation.
Trait Implementations§
Source§impl Clone for SparseFactor
impl Clone for SparseFactor
Source§fn clone(&self) -> SparseFactor
fn clone(&self) -> SparseFactor
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 moreAuto Trait Implementations§
impl Freeze for SparseFactor
impl RefUnwindSafe for SparseFactor
impl Send for SparseFactor
impl Sync for SparseFactor
impl Unpin for SparseFactor
impl UnwindSafe for SparseFactor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.