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§
Sourcefn mul_dense(
&self,
rhs: ArrayView2<'_, T>,
out: ArrayViewMut2<'_, T>,
trans: bool,
)
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§
Sourcefn col_means(&self) -> Array1<T>
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.
Sourcefn mul_dense_centered(
&self,
rhs: ArrayView2<'_, T>,
out: ArrayViewMut2<'_, T>,
trans: bool,
means: ArrayView1<'_, T>,
)
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".