Skip to content

lazymatrix::WeightedGramKernel ​

LazyMatrix for Rust · 0.8.1

Source

rust
pub trait WeightedGramKernel<F: Scalar>: MatrixShape + MatrixErrorType

Backend kernel for a weighted Gram product with explicit normalization.

Computes the product for logical entries (X[i,j] - centers[j]) / scales[j], using zero centers and unit scales when the corresponding slice is absent. LazyMatrix forwards its parameters to this capability. Backends must center values before accumulating their products: correcting raw cross-products afterward can erase small centered variations.

The output, weight, and error contracts are those of WeightedGramInto. Negative scales and nonfinite parameters are preserved. No full normalized or weighted design matrix may be materialized.

Panics ​

In addition to product dimension checks, implementations must reject normalization slices of length other than ncols and exact zero scales (including negative zero), before writing output.

Methods ​

weighted_gram_normalized_into ​

rust
fn weighted_gram_normalized_into<W, O>(
    &self,
    weights: &W,
    centers: Option<&[F]>,
    scales: Option<&[F]>,
    out: &mut O
) -> Result<(), <Self as MatrixErrorType>::Error> where W: VectorView<F> + ?Sized, O: MatrixWrite<F> + ?Sized

Source

Implementation of WeightedGramKernel ​

Source

rust
impl<F, IP, IS, DS, Iptr> WeightedGramKernel<F> for lazymatrix::SprsCsc<sprs::CsMatBase<F, usize, IP, IS, DS, Iptr>> where F: Scalar, Iptr: SpIndex, IP: Deref<Target = [Iptr]>, IS: Deref<Target = [usize]>, DS: Deref<Target = [F]>

Implementation of WeightedGramKernel ​

Source

rust
impl<F, IP, IS, DS, Iptr> WeightedGramKernel<F> for lazymatrix::SprsCsr<sprs::CsMatBase<F, usize, IP, IS, DS, Iptr>> where F: Scalar, Iptr: SpIndex, IP: Deref<Target = [Iptr]>, IS: Deref<Target = [usize]>, DS: Deref<Target = [F]>

Implementation of WeightedGramKernel ​

Source

rust
impl<M, F, T> WeightedGramKernel<F> for EagerMatrix<M, T> where M: WeightedGramKernel<F>, F: Scalar

Released under the MIT and Apache 2.0 licenses.