pub struct SparseAtomCode {
pub active_mask: BitVec,
pub weights: Vec<f64>,
}Expand description
Per-point sparse code over K candidate atoms.
Invariants (checked in debug builds):
active_mask.len() == weights.len() == K.- For any
kwithactive_mask.get(k) == false, the valueweights[k]is a nuisance — it must not influence reconstruction. Selection strategies that lower a weight to zero (e.g. an L¹-relaxed gate after thresholding) are responsible for clearing the corresponding mask bit and zeroingweights[k].
We do not require weights[k] >= 0; some strategies (entropic softmax,
TopK projection) keep the simplex, while others (L¹-relaxed) only enforce
non-negativity at the active-set step. The owning
gate/selection layer (crate::assignment::SaeAssignment) documents which
invariant it maintains.
Fields§
§active_mask: BitVecLength-K bitmask of active atoms for this point.
weights: Vec<f64>Length-K dense weight vector. Only entries at active indices are
semantically meaningful.
Implementations§
Source§impl SparseAtomCode
impl SparseAtomCode
Sourcepub fn active_weight_sum(&self) -> f64
pub fn active_weight_sum(&self) -> f64
Sum of active weights. For simplex-projected codes this should be ≈ 1.
Sourcepub fn deactivate(&mut self, k: usize)
pub fn deactivate(&mut self, k: usize)
Deactivate atom k and zero its stored weight.
Sourcepub fn effective_weights(&self) -> Array1<f64>
pub fn effective_weights(&self) -> Array1<f64>
Materialize the effective weight vector (zeros at inactive indices)
as an owned Array1. Useful for matmul-shaped downstream code.
Trait Implementations§
Source§impl Clone for SparseAtomCode
impl Clone for SparseAtomCode
Source§fn clone(&self) -> SparseAtomCode
fn clone(&self) -> SparseAtomCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SparseAtomCode
impl RefUnwindSafe for SparseAtomCode
impl Send for SparseAtomCode
impl Sync for SparseAtomCode
impl Unpin for SparseAtomCode
impl UnsafeUnpin for SparseAtomCode
impl UnwindSafe for SparseAtomCode
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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>
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>
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.