pub struct SparseRunningStatistics<T>where
T: Float,{ /* private fields */ }Expand description
Running statistics that accepts sparse column input but stores sufficient statistics in dense vectors.
This is more efficient than RunningStatistics<Ix1> when the input
data is sparse and has many rows, as it avoids materializing dense
matrices during reads.
Implementations§
Source§impl<T> SparseRunningStatistics<T>
impl<T> SparseRunningStatistics<T>
Sourcepub fn add_sparse_column(&mut self, row_indices: &[usize], values: &[T])
pub fn add_sparse_column(&mut self, row_indices: &[usize], values: &[T])
Add a sparse column (row indices + values) to the running
statistics. The column advances ncols_processed by one.
pub fn nrows(&self) -> usize
pub fn ncols_processed(&self) -> usize
Sourcepub fn to_vecs(&self) -> (Vec<T>, Vec<T>, Vec<T>, Vec<T>)
pub fn to_vecs(&self) -> (Vec<T>, Vec<T>, Vec<T>, Vec<T>)
Convert to owned vectors (npos, sum, mean, std)
Sourcepub fn add_dense_column(&mut self, values: &[T])
pub fn add_dense_column(&mut self, values: &[T])
Add a dense column directly. Skips zero / non-finite entries
so npos stays equivalent to what add_sparse_column would
produce — useful when an upstream coarsening step yields a dense
[D, n] intermediate we don’t want to re-sparsify.
Loop is structured for autovectorization: hoists the running-sum
and running-square accumulations through zip_eq over independent
&mut slices (no aliasing), and uses a branchless 1/0 mask
for the npos increment so the compiler can emit cmov /
vmaskmovps instead of a control-flow branch per element.
Sourcepub fn add_dense_column_scaled(&mut self, values: &[T], scale: T)
pub fn add_dense_column_scaled(&mut self, values: &[T], scale: T)
Self::add_dense_column with every value scaled by scale on the
way in. Folding the multiply into the accumulation loop touches each
element once, where scale-into-a-buffer-then-add would write and
re-read the whole column.
Sourcepub fn add_dense_columns(&mut self, dense: &DMatrix<T>)where
T: Scalar,
pub fn add_dense_columns(&mut self, dense: &DMatrix<T>)where
T: Scalar,
Add every column of a dense [D, n] matrix in column-major
order. Calls add_dense_column per column so the inner loop
stays vectorizable; the per-column overhead is negligible
(one += 1 for ncols_processed) compared to the per-element
accumulation work.
Source§impl<T> SparseRunningStatistics<T>
impl<T> SparseRunningStatistics<T>
Sourcepub fn save(&self, filename: &str, names: &[Box<str>], sep: &str) -> Result<()>
pub fn save(&self, filename: &str, names: &[Box<str>], sep: &str) -> Result<()>
Save the statistics to a file (parquet if filename ends with
.parquet, otherwise a separator-delimited text file).
Trait Implementations§
Source§impl<T> Clone for SparseRunningStatistics<T>
impl<T> Clone for SparseRunningStatistics<T>
Source§impl<T> RunningStatOps<T> for SparseRunningStatistics<T>
impl<T> RunningStatOps<T> for SparseRunningStatistics<T>
Auto Trait Implementations§
impl<T> Freeze for SparseRunningStatistics<T>
impl<T> RefUnwindSafe for SparseRunningStatistics<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for SparseRunningStatistics<T>
impl<T> Sync for SparseRunningStatistics<T>
impl<T> Unpin for SparseRunningStatistics<T>
impl<T> UnsafeUnpin for SparseRunningStatistics<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for SparseRunningStatistics<T>where
Vec<T>: UnwindSafe,
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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.