Skip to content

lazymatrix::LazyColumn ​

LazyMatrix for Rust · 0.8.1

Source

rust
pub struct LazyColumn<C, F>

A borrowed lazily normalized column over an arbitrary raw backend view.

Inherent implementation ​

Source

rust
impl<'a, F: Scalar> LazyColumn<SparseColumnRef<'a, F>, F>

implicit_value ​

rust
pub fn implicit_value(&self) -> F

Source

Logical value at a structurally absent row, -center / scale.

raw_sum ​

rust
pub fn raw_sum(&self) -> F

Source

Sum of the raw stored values.

row_indices ​

rust
pub fn row_indices(&self) -> &'a [usize]

Source

Row indices of the raw stored entries.

stored_corrections ​

rust
pub fn stored_corrections(&self) -> impl Iterator<Item = (usize, F)> + '_

Source

Stored corrections to the implicit value as (row, raw_value / scale).

values ​

rust
pub fn values(&self) -> &'a [F]

Source

Raw stored values corresponding to Self::row_indices.

Inherent implementation ​

Source

rust
impl<C, F> LazyColumn<C, F>

raw ​

rust
pub fn raw(&self) -> &C

Source

Borrow the backend's raw column view.

Inherent implementation ​

Source

rust
impl<C: RawColumn<F>, F: Scalar> LazyColumn<C, F>

center ​

rust
pub fn center(&self) -> F

Source

Effective column center.

This is zero when centering is inactive.

dot ​

rust
pub fn dot<V: VectorView<F> + ?Sized>(&self, vector: &V) -> F

Source

Dot 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 ​

rust
pub fn dot_with_sum<V: VectorView<F> + ?Sized>(
    &self,
    vector: &V,
    vector_sum: F
) -> F

Source

Dot 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 ​

rust
pub fn is_empty(&self) -> bool

Source

Whether the logical column has no rows.

len ​

rust
pub fn len(&self) -> usize

Source

Logical length of the column, including structurally absent entries.

norm_squared ​

rust
pub fn norm_squared(&self) -> F

Source

Squared 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 ​

rust
pub fn scale(&self) -> F

Source

Effective column scale.

This is one when scaling is inactive.

scaled_add_to ​

rust
pub fn scaled_add_to<V: VectorViewMut<F> + ?Sized>(
    &self,
    alpha: F,
    destination: &mut V
)

Source

Add alpha times this logical column to a dense destination.

sum ​

rust
pub fn sum(&self) -> F

Source

Sum of the logical normalized entries.

This takes O(nnz) time and does not materialize the column.

weighted_dot ​

rust
pub fn weighted_dot<V, W>(
    &self,
    vector: &V,
    weights: &W
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?Sized

Source

Weighted 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 ​

rust
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> + ?Sized

Source

Weighted 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 ​

rust
pub fn weighted_norm_squared<W: VectorView<F> + ?Sized>(&self, weights: &W) -> F

Source

Weighted 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 ​

rust
pub fn weighted_norm_squared_with_sum<W: VectorView<F> + ?Sized>(
    &self,
    weights: &W,
    _weight_sum: F
) -> F

Source

Weighted 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 ​

Source

rust
impl<F: Scalar> LazyColumn<FilteredRawColumn<SparseColumnRef<'_, F>>, F>

implicit_value ​

rust
pub fn implicit_value(&self) -> F

Source

Logical value of an implicit zero.

stored_corrections ​

rust
pub fn stored_corrections(&self) -> impl Iterator<Item = (usize, F)> + '_

Source

Scaled stored corrections to the implicit value.

stored_entries ​

rust
pub fn stored_entries(&self) -> impl Iterator<Item = (usize, F)> + '_

Source

Raw stored entries, preserving storage order, duplicates, and zeros.

Implementation of Clone ​

Source

rust
impl<C: core::clone::Clone, F: core::clone::Clone> Clone for LazyColumn<C, F>

clone ​

rust
fn clone(&self) -> Self

Source

Implementation of Copy ​

Source

rust
impl<C: core::marker::Copy, F: core::marker::Copy> Copy for LazyColumn<C, F>

Implementation of Debug ​

Source

rust
impl<C: core::fmt::Debug, F: core::fmt::Debug> Debug for LazyColumn<C, F>

fmt ​

rust
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

Source

Implementation of LogicalColumn ​

Source

rust
impl<C: RawColumn<F>, F: Scalar> LogicalColumn<F> for LazyColumn<C, F>

center ​

rust
fn center(&self) -> F

Source

dot ​

rust
fn dot<V: VectorView<F> + ?Sized>(&self, vector: &V) -> F

Source

dot_with_sum ​

rust
fn dot_with_sum<V: VectorView<F> + ?Sized>(
    &self,
    vector: &V,
    vector_sum: F
) -> F

Source

len ​

rust
fn len(&self) -> usize

Source

norm_squared ​

rust
fn norm_squared(&self) -> F

Source

scale ​

rust
fn scale(&self) -> F

Source

scaled_add_to ​

rust
fn scaled_add_to<V: VectorViewMut<F> + ?Sized>(
    &self,
    alpha: F,
    destination: &mut V
)

Source

sum ​

rust
fn sum(&self) -> F

Source

weighted_dot ​

rust
fn weighted_dot<V, W>(
    &self,
    vector: &V,
    weights: &W
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?Sized

Source

weighted_dot_with_sum ​

rust
fn weighted_dot_with_sum<V, W>(
    &self,
    vector: &V,
    weights: &W,
    sum: F
) -> F where V: VectorView<F> + ?Sized, W: VectorView<F> + ?Sized

Source

weighted_norm_squared ​

rust
fn weighted_norm_squared<W: VectorView<F> + ?Sized>(&self, weights: &W) -> F

Source

weighted_norm_squared_with_sum ​

rust
fn weighted_norm_squared_with_sum<W: VectorView<F> + ?Sized>(
    &self,
    weights: &W,
    sum: F
) -> F

Source

Implementation of Freeze ​

rust
impl<C, F> Freeze for LazyColumn<C, F> where C: Freeze, F: Freeze + Freeze

Implementation of RefUnwindSafe ​

rust
impl<C, F> RefUnwindSafe for LazyColumn<C, F> where C: RefUnwindSafe, F: RefUnwindSafe + RefUnwindSafe

Implementation of Send ​

rust
impl<C, F> Send for LazyColumn<C, F> where C: Send, F: Send + Send

Implementation of Sync ​

rust
impl<C, F> Sync for LazyColumn<C, F> where C: Sync, F: Sync + Sync

Implementation of Unpin ​

rust
impl<C, F> Unpin for LazyColumn<C, F> where C: Unpin, F: Unpin + Unpin

Implementation of UnsafeUnpin ​

rust
impl<C, F> UnsafeUnpin for LazyColumn<C, F> where C: UnsafeUnpin, F: UnsafeUnpin + UnsafeUnpin

Implementation of UnwindSafe ​

rust
impl<C, F> UnwindSafe for LazyColumn<C, F> where C: UnwindSafe, F: UnwindSafe + UnwindSafe

Implementation of Any ​

rust
impl<T> Any for T where T: 'static + ?Sized

Implementation of Borrow ​

rust
impl<T> Borrow<T> for T where T: ?Sized

Implementation of BorrowMut ​

rust
impl<T> BorrowMut<T> for T where T: ?Sized

Implementation of ByRef ​

rust
impl<T> ByRef<T> for T

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized

Implementation of CloneToUninit ​

rust
impl<T> CloneToUninit for T where T: Clone

Implementation of From ​

rust
impl<T> From<T> for T

Implementation of Imply ​

rust
impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized

Implementation of Into ​

rust
impl<T, U> Into<U> for T where U: From<T>

Implementation of IntoEither ​

rust
impl<T> IntoEither for T

Implementation of Pointable ​

rust
impl<T> Pointable for T

Implementation of Read ​

rust
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized

Implementation of Same ​

rust
impl<T> Same for T

Implementation of SupersetOf ​

rust
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>

Implementation of ToOwned ​

rust
impl<T> ToOwned for T where T: Clone

Implementation of TryFrom ​

rust
impl<T, U> TryFrom<U> for T where U: Into<T>

Implementation of TryInto ​

rust
impl<T, U> TryInto<U> for T where U: TryFrom<T>

Released under the MIT and Apache 2.0 licenses.