lazymatrix::LazyColumn
LazyMatrix for Rust · 0.8.1
pub struct LazyColumn<C, F>A borrowed lazily normalized column over an arbitrary raw backend view.
Inherent implementation
impl<'a, F: Scalar> LazyColumn<SparseColumnRef<'a, F>, F>implicit_value
pub fn implicit_value(&self) -> FLogical value at a structurally absent row, -center / scale.
raw_sum
pub fn raw_sum(&self) -> FSum of the raw stored values.
row_indices
pub fn row_indices(&self) -> &'a [usize]Row indices of the raw stored entries.
stored_corrections
pub fn stored_corrections(&self) -> impl Iterator<Item = (usize, F)> + '_Stored corrections to the implicit value as (row, raw_value / scale).
values
pub fn values(&self) -> &'a [F]Raw stored values corresponding to Self::row_indices.
Inherent implementation
impl<C, F> LazyColumn<C, F>raw
pub fn raw(&self) -> &CBorrow the backend's raw column view.
Inherent implementation
impl<C: RawColumn<F>, F: Scalar> LazyColumn<C, F>center
pub fn center(&self) -> FEffective column center.
This is zero when centering is inactive.
dot
pub fn dot<V: VectorView<F> + ?Sized>(&self, vector: &V) -> FDot product of the logical normalized column with a dense vector.
Computing the vector sum takes O(n) time, after which the stored-entry dot product takes O(nnz). Use Self::dot_with_sum when the vector sum is already available.
Panics
Panics if vector.len() != self.len().
dot_with_sum
pub fn dot_with_sum<V: VectorView<F> + ?Sized>(
&self,
vector: &V,
vector_sum: F
) -> FDot product using a precomputed sum of the dense vector.
vector_sum must equal vector.iter().sum(). Supplying the cached sum keeps this operation O(nnz), which is useful when repeatedly taking column products with the same vector.
Panics
Panics if vector.len() != self.len().
is_empty
pub fn is_empty(&self) -> boolWhether the logical column has no rows.
len
pub fn len(&self) -> usizeLogical length of the column, including structurally absent entries.
norm_squared
pub fn norm_squared(&self) -> FSquared Euclidean norm of the logical normalized column.
Structurally absent entries contribute center² / scale². Sorted, unique entries take O(nnz) time and constant scratch space. Unsorted or duplicate indices use O(n + nnz) time and one O(n) working column to combine raw duplicates before squaring.
scale
pub fn scale(&self) -> FEffective column scale.
This is one when scaling is inactive.
scaled_add_to
pub fn scaled_add_to<V: VectorViewMut<F> + ?Sized>(
&self,
alpha: F,
destination: &mut V
)Add alpha times this logical column to a dense destination.
sum
pub fn sum(&self) -> FSum of the logical normalized entries.
This takes O(nnz) time and does not materialize the column.
weighted_dot
pub fn weighted_dot<V, W>(
&self,
vector: &V,
weights: &W
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?SizedWeighted dot product of the logical normalized column with a dense vector, sum_i weights[i] * self[i] * vector[i].
Computing the weighted vector sum takes O(n) time, after which the stored-entry product takes O(nnz). Use Self::weighted_dot_with_sum when sum_i weights[i] * vector[i] is already available.
Panics
Panics unless vector.len() == weights.len() == self.len().
weighted_dot_with_sum
pub fn weighted_dot_with_sum<V, W>(
&self,
vector: &V,
weights: &W,
weighted_vector_sum: F
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?SizedWeighted dot product using a precomputed weighted vector sum.
weighted_vector_sum must equal sum_i weights[i] * vector[i]. Supplying it keeps this operation O(nnz), which is useful for repeatedly computing weighted correlations against different columns.
Panics
Panics unless vector.len() == weights.len() == self.len().
weighted_norm_squared
pub fn weighted_norm_squared<W: VectorView<F> + ?Sized>(&self, weights: &W) -> FWeighted squared Euclidean norm of the logical normalized column, sum_i weights[i] * self[i]^2.
Accumulates normalized entries directly, including implicit zeros, without subtracting stored weights from a rounded total. Signed weights and IEEE nonfinite arithmetic are preserved.
Takes O(n + nnz) time. Columns with sorted, unique row indices use constant scratch space. Unsorted or duplicate indices require one O(n) working column to combine raw entries before normalization.
Panics
Panics if weights.len() != self.len().
weighted_norm_squared_with_sum
pub fn weighted_norm_squared_with_sum<W: VectorView<F> + ?Sized>(
&self,
weights: &W,
_weight_sum: F
) -> FWeighted squared norm accepting a precomputed total for compatibility.
The total is ignored: subtracting stored weights from it can lose the entire contribution of implicit zeros. This uses the same O(n + nnz) calculation and scratch space as Self::weighted_norm_squared.
Panics
Panics if weights.len() != self.len().
Inherent implementation
impl<F: Scalar> LazyColumn<FilteredRawColumn<SparseColumnRef<'_, F>>, F>implicit_value
pub fn implicit_value(&self) -> FLogical value of an implicit zero.
stored_corrections
pub fn stored_corrections(&self) -> impl Iterator<Item = (usize, F)> + '_Scaled stored corrections to the implicit value.
stored_entries
pub fn stored_entries(&self) -> impl Iterator<Item = (usize, F)> + '_Raw stored entries, preserving storage order, duplicates, and zeros.
Implementation of Clone
impl<C: core::clone::Clone, F: core::clone::Clone> Clone for LazyColumn<C, F>clone
fn clone(&self) -> SelfImplementation of Copy
impl<C: core::marker::Copy, F: core::marker::Copy> Copy for LazyColumn<C, F>Implementation of Debug
impl<C: core::fmt::Debug, F: core::fmt::Debug> Debug for LazyColumn<C, F>fmt
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::ResultImplementation of LogicalColumn
impl<C: RawColumn<F>, F: Scalar> LogicalColumn<F> for LazyColumn<C, F>center
fn center(&self) -> Fdot
fn dot<V: VectorView<F> + ?Sized>(&self, vector: &V) -> Fdot_with_sum
fn dot_with_sum<V: VectorView<F> + ?Sized>(
&self,
vector: &V,
vector_sum: F
) -> Flen
fn len(&self) -> usizenorm_squared
fn norm_squared(&self) -> Fscale
fn scale(&self) -> Fscaled_add_to
fn scaled_add_to<V: VectorViewMut<F> + ?Sized>(
&self,
alpha: F,
destination: &mut V
)sum
fn sum(&self) -> Fweighted_dot
fn weighted_dot<V, W>(
&self,
vector: &V,
weights: &W
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?Sizedweighted_dot_with_sum
fn weighted_dot_with_sum<V, W>(
&self,
vector: &V,
weights: &W,
sum: F
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?Sizedweighted_norm_squared
fn weighted_norm_squared<W: VectorView<F> + ?Sized>(&self, weights: &W) -> Fweighted_norm_squared_with_sum
fn weighted_norm_squared_with_sum<W: VectorView<F> + ?Sized>(
&self,
weights: &W,
sum: F
) -> FImplementation of Freeze
impl<C, F> Freeze for LazyColumn<C, F> where C: Freeze, F: Freeze + FreezeImplementation of RefUnwindSafe
impl<C, F> RefUnwindSafe for LazyColumn<C, F> where C: RefUnwindSafe, F: RefUnwindSafe + RefUnwindSafeImplementation of Send
impl<C, F> Send for LazyColumn<C, F> where C: Send, F: Send + SendImplementation of Sync
impl<C, F> Sync for LazyColumn<C, F> where C: Sync, F: Sync + SyncImplementation of Unpin
impl<C, F> Unpin for LazyColumn<C, F> where C: Unpin, F: Unpin + UnpinImplementation of UnsafeUnpin
impl<C, F> UnsafeUnpin for LazyColumn<C, F> where C: UnsafeUnpin, F: UnsafeUnpin + UnsafeUnpinImplementation of UnwindSafe
impl<C, F> UnwindSafe for LazyColumn<C, F> where C: UnwindSafe, F: UnwindSafe + UnwindSafeImplementation of Any
impl<T> Any for T where T: 'static + ?SizedImplementation of Borrow
impl<T> Borrow<T> for T where T: ?SizedImplementation of BorrowMut
impl<T> BorrowMut<T> for T where T: ?SizedImplementation of ByRef
impl<T> ByRef<T> for TImplementation of CastableFrom
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?SizedImplementation of CastableFrom
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?SizedImplementation of CloneToUninit
impl<T> CloneToUninit for T where T: CloneImplementation of From
impl<T> From<T> for TImplementation of Imply
impl<T, U> Imply<T> for U where T: ?Sized, U: ?SizedImplementation of Into
impl<T, U> Into<U> for T where U: From<T>Implementation of IntoEither
impl<T> IntoEither for TImplementation of Pointable
impl<T> Pointable for TImplementation of Read
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?SizedImplementation of Same
impl<T> Same for TImplementation of SupersetOf
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>Implementation of ToOwned
impl<T> ToOwned for T where T: CloneImplementation of TryFrom
impl<T, U> TryFrom<U> for T where U: Into<T>Implementation of TryInto
impl<T, U> TryInto<U> for T where U: TryFrom<T>
