Skip to main content

SparseMatDense

Trait SparseMatDense 

Source
pub trait SparseMatDense<T: SvdFloat>: SparseMat<T> {
    // Required method
    fn mul_dense(
        &self,
        rhs: ArrayView2<'_, T>,
        out: ArrayViewMut2<'_, T>,
        trans: bool,
    );

    // Provided methods
    fn col_means(&self) -> Array1<T> { ... }
    fn mul_dense_centered(
        &self,
        rhs: ArrayView2<'_, T>,
        out: ArrayViewMut2<'_, T>,
        trans: bool,
        means: ArrayView1<'_, T>,
    ) { ... }
}
Expand description

Blocked products, needed by the randomized solvers.

mul_dense has no default — an implementor must supply it — but col_means and mul_dense_centered do, so mean-centering comes for free once the plain product works.

Required Methods§

Source

fn mul_dense( &self, rhs: ArrayView2<'_, T>, out: ArrayViewMut2<'_, T>, trans: bool, )

out = A·rhs when trans is false, out = Aᵀ·rhs when true.

out is fully overwritten.

Provided Methods§

Source

fn col_means(&self) -> Array1<T>

Column means, length cols().

The default computes Aᵀ·1 / rows(), which routes through whichever mul_vec direction is cheapest for the storage order.

Source

fn mul_dense_centered( &self, rhs: ArrayView2<'_, T>, out: ArrayViewMut2<'_, T>, trans: bool, means: ArrayView1<'_, T>, )

The product against A - 1·meansᵀ, without ever forming it — centering a sparse matrix would destroy its sparsity, so it goes in as the rank-1 update it is:

  • trans == false: (A - 1·mᵀ)·D = A·D - 1·(mᵀ·D)
  • trans == true: (A - 1·mᵀ)ᵀ·D = Aᵀ·D - m·(1ᵀ·D)

The correction is one length-k vector either way, so it adds O(k·(rows + cols)) and allocates nothing else.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, I, Iptr> SparseMatDense<T> for CsMatI<T, I, Iptr>
where T: SvdFloat, I: SpIndex, Iptr: SpIndex,

Source§

fn mul_dense( &self, rhs: ArrayView2<'_, T>, out: ArrayViewMut2<'_, T>, trans: bool, )

Source§

impl<T: SvdFloat, M: SparseMatDense<T> + ?Sized> SparseMatDense<T> for &M

Source§

fn mul_dense( &self, rhs: ArrayView2<'_, T>, out: ArrayViewMut2<'_, T>, trans: bool, )

Source§

fn col_means(&self) -> Array1<T>

Source§

fn mul_dense_centered( &self, rhs: ArrayView2<'_, T>, out: ArrayViewMut2<'_, T>, trans: bool, means: ArrayView1<'_, T>, )

Implementors§

Source§

impl<T, I, Iptr> SparseMatDense<T> for MaskedCsMat<'_, T, I, Iptr>
where T: SvdFloat, I: SpIndex, Iptr: SpIndex,