Skip to content

lazymatrix::NormalizedColumn ​

LazyMatrix for Rust · 0.12.0

Source

rust
pub struct NormalizedColumn<'a, C, P>

A borrowed column with row or ordered normalization.

The view borrows raw storage and fitted parameters without copying, fitting, gathering, or decoding. Logical entries combine raw duplicates in storage order before applying each saved stage. Borrowing takes O(1) time.

Reductions and dense updates visit every logical row, including implicit zeros, in O(nrows * stages + stored entries) time. Dense slices and sorted, unique sparse columns use constant workspace. Other storage orders and duplicates use one O(nrows) working column to coalesce raw values. The view itself and individual reads allocate nothing.

Sparse views expose their generally dense, row-dependent background through Self::implicit_value and scaled raw corrections through Self::stored_corrections. Adding those parts may differ from direct normalization through rounding or nonfinite arithmetic. Use Self::get or Self::normalize_value for direct stage-by-stage evaluation.

A view cannot outlive the operator or its fitted parameters:

rust
use lazymatrix::{LazyMatrix, RawColumns};
fn escaped<M: RawColumns<f64>>(data: M) -> f64 {
    let column = {
        let op = LazyMatrix::from_row_parts(data, None, None);
        op.column(0)
    };
    column.get(0)
}

Inherent implementation ​

Source

rust
impl<'a, C, P> NormalizedColumn<'a, C, P>

normalization ​

rust
pub fn normalization(&self) -> &'a P

Source

Borrow the saved parameters for the complete matrix.

raw ​

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

Source

Borrow the backend's raw column view.

Inherent implementation ​

Source

rust
impl<'a, F: Scalar, P: NormalizationParams<Scalar = F>> NormalizedColumn<'a, lazymatrix::SparseColumnRef<'a, F>, P>

raw_sum ​

rust
pub fn raw_sum(&self) -> F

Source

Sum raw stored values without applying normalization.

row_indices ​

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

Source

Raw stored row indices in storage order, retaining duplicates.

stored_corrections ​

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

Source

Stored corrections as (row, scaled raw value), without allocating.

Preserves storage order, duplicates, and explicit zeros. Each correction applies scales in stage order, taking O(stages) time. See the type documentation for numerical limitations.

values ​

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

Source

Raw stored values, including explicitly stored zeros.

Inherent implementation ​

Source

rust
impl<C, P> NormalizedColumn<'_, C, P> where P: NormalizationParams, C: RawColumn<<P as NormalizationParams>::Scalar>

dot ​

rust
pub fn dot<V: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    vector: &V
) -> <P as NormalizationParams>::Scalar

Source

Dot product with a vector, including transformed implicit zeros.

See the type documentation for time and workspace bounds.

Panics ​

Panics if vector.len() != self.len().

dot_with_sum ​

rust
pub fn dot_with_sum<V: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    vector: &V,
    _vector_sum: <P as NormalizationParams>::Scalar
) -> <P as NormalizationParams>::Scalar

Source

Dot product accepting a cached vector sum for LogicalColumn parity.

The sum is ignored because a scalar total cannot account for row-dependent normalization. Complexity and panics match Self::dot.

get ​

rust
pub fn get(&self, row: usize) -> <P as NormalizationParams>::Scalar

Source

Read a logical entry, combining raw duplicates in storage order first.

Dense slices take O(stages) time; other raw columns take O(stored entries + stages) time. This allocates nothing and preserves stored signed zeros before normalization.

Panics ​

Panics if row >= self.len().

implicit_value ​

rust
pub fn implicit_value(&self, row: usize) -> <P as NormalizationParams>::Scalar

Source

Logical value at a structurally absent row, in O(stages) time.

Panics ​

Panics if row >= self.len().

is_empty ​

rust
pub fn is_empty(&self) -> bool

Source

Whether the column has no logical rows.

len ​

rust
pub fn len(&self) -> usize

Source

Logical length, including structurally absent entries.

norm_squared ​

rust
pub fn norm_squared(&self) -> <P as NormalizationParams>::Scalar

Source

Sum squared logical entries after applying every stage in order.

See the type documentation for time and workspace bounds.

normalize_value ​

rust
pub fn normalize_value(
    &self,
    row: usize,
    raw: <P as NormalizationParams>::Scalar
) -> <P as NormalizationParams>::Scalar

Source

Apply every saved stage to a coalesced raw value in row row.

This takes O(stages) time and allocates nothing. Sum raw duplicates before calling this method.

Panics ​

Panics if row >= self.len().

scaled_add_to ​

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

Source

Add alpha times each logical entry to a dense destination.

Normalizes each coalesced value before multiplying by alpha. See the type documentation for time and workspace bounds.

Panics ​

Panics if destination.len() != self.len().

sum ​

rust
pub fn sum(&self) -> <P as NormalizationParams>::Scalar

Source

Sum logical entries, including transformed implicit zeros.

See the type documentation for time and workspace bounds.

weighted_dot ​

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

Source

Compute sum_i weights[i] * self[i] * vector[i] on logical entries.

See the type documentation for time and workspace bounds.

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: <P as NormalizationParams>::Scalar
) -> <P as NormalizationParams>::Scalar where V: VectorView<<P as NormalizationParams>::Scalar> + ?Sized, W: VectorView<<P as NormalizationParams>::Scalar> + ?Sized

Source

Weighted dot product accepting a cached sum for LogicalColumn parity.

The cached total is ignored. Complexity and panics match Self::weighted_dot.

weighted_norm_squared ​

rust
pub fn weighted_norm_squared<W: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    weights: &W
) -> <P as NormalizationParams>::Scalar

Source

Sum weights[i] * self[i]^2, including implicit zeros and signed weights.

Normalizes before squaring and visits implicit rows directly, preserving small contributions and IEEE nonfinite arithmetic. See the type documentation for time and workspace bounds.

Panics ​

Panics if weights.len() != self.len().

weighted_norm_squared_with_sum ​

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

Source

Weighted squared norm accepting a cached total for LogicalColumn parity.

The cached total is ignored to preserve implicit-row contributions. Complexity and panics match Self::weighted_norm_squared.

Implementation of Clone ​

Source

rust
impl<C: Clone, P> Clone for NormalizedColumn<'_, C, P>

clone ​

rust
fn clone(&self) -> Self

Source

Implementation of Copy ​

Source

rust
impl<C: Copy, P> Copy for NormalizedColumn<'_, C, P>

Implementation of Debug ​

Source

rust
impl<'a, C: core::fmt::Debug, P: core::fmt::Debug> Debug for NormalizedColumn<'a, C, P>

fmt ​

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

Source

Implementation of LogicalColumn ​

Source

rust
impl<C, P> LogicalColumn<<P as NormalizationParams>::Scalar> for NormalizedColumn<'_, C, P> where P: NormalizationParams, C: RawColumn<<P as NormalizationParams>::Scalar>

dot ​

rust
fn dot<V: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    vector: &V
) -> <P as NormalizationParams>::Scalar

Source

dot_with_sum ​

rust
fn dot_with_sum<V: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    vector: &V,
    sum: <P as NormalizationParams>::Scalar
) -> <P as NormalizationParams>::Scalar

Source

get ​

rust
fn get(&self, row: usize) -> <P as NormalizationParams>::Scalar

Source

len ​

rust
fn len(&self) -> usize

Source

norm_squared ​

rust
fn norm_squared(&self) -> <P as NormalizationParams>::Scalar

Source

scaled_add_to ​

rust
fn scaled_add_to<V: VectorViewMut<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    alpha: <P as NormalizationParams>::Scalar,
    destination: &mut V
)

Source

sum ​

rust
fn sum(&self) -> <P as NormalizationParams>::Scalar

Source

weighted_dot ​

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

Source

weighted_dot_with_sum ​

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

Source

weighted_norm_squared ​

rust
fn weighted_norm_squared<W: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    weights: &W
) -> <P as NormalizationParams>::Scalar

Source

weighted_norm_squared_with_sum ​

rust
fn weighted_norm_squared_with_sum<W: VectorView<<P as NormalizationParams>::Scalar> + ?Sized>(
    &self,
    weights: &W,
    sum: <P as NormalizationParams>::Scalar
) -> <P as NormalizationParams>::Scalar

Source

Implementation of Freeze ​

rust
impl<'a, C, P> Freeze for NormalizedColumn<'a, C, P> where C: Freeze, &'a P: Freeze

Implementation of RefUnwindSafe ​

rust
impl<'a, C, P> RefUnwindSafe for NormalizedColumn<'a, C, P> where C: RefUnwindSafe, &'a P: RefUnwindSafe

Implementation of Send ​

rust
impl<'a, C, P> Send for NormalizedColumn<'a, C, P> where C: Send, &'a P: Send

Implementation of Sync ​

rust
impl<'a, C, P> Sync for NormalizedColumn<'a, C, P> where C: Sync, &'a P: Sync

Implementation of Unpin ​

rust
impl<'a, C, P> Unpin for NormalizedColumn<'a, C, P> where C: Unpin, &'a P: Unpin

Implementation of UnsafeUnpin ​

rust
impl<'a, C, P> UnsafeUnpin for NormalizedColumn<'a, C, P> where C: UnsafeUnpin, &'a P: UnsafeUnpin

Implementation of UnwindSafe ​

rust
impl<'a, C, P> UnwindSafe for NormalizedColumn<'a, C, P> where C: UnwindSafe, &'a P: 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.