pub trait NmfInput<F: BixverseFloat> {
// Required methods
fn shape(&self) -> (usize, usize);
fn sq_frob(&self) -> F;
fn wt_v(&self, w: MatRef<'_, F>, out: &mut Mat<F>);
fn v_ht(&self, h: MatRef<'_, F>, out: &mut Mat<F>);
fn top_k_svd(&self, k: usize) -> Result<SvdResults<F>, MethodsErrors>;
}Expand description
Backend-agnostic view of V for HALS NMF. Implementations write the two data-touching products into caller-owned buffers.
Required Methods§
Sourcefn sq_frob(&self) -> F
fn sq_frob(&self) -> F
The squared Frobenius norm ||V||_F^2,
Computed once at construction.
§Returns
The squared Frobenius norm.
Sourcefn wt_v(&self, w: MatRef<'_, F>, out: &mut Mat<F>)
fn wt_v(&self, w: MatRef<'_, F>, out: &mut Mat<F>)
Compute W^T V.
Writes the product W^T V into a caller-owned buffer.
§Params
w- Left factor, shapem x k.out- Output bufferk x n. Overwritten on return.
Sourcefn v_ht(&self, h: MatRef<'_, F>, out: &mut Mat<F>)
fn v_ht(&self, h: MatRef<'_, F>, out: &mut Mat<F>)
Gram matrix W^T W.
Computes the symmetric Gram matrix using a triangular matmul, then mirrors the lower triangle into the upper half.
§Params
w- Left factor, shapem x k.out- Output bufferk x k. Overwritten on return.
Sourcefn top_k_svd(&self, k: usize) -> Result<SvdResults<F>, MethodsErrors>
fn top_k_svd(&self, k: usize) -> Result<SvdResults<F>, MethodsErrors>
Top-k truncated SVD of V.
Used to seed NNDSVD initialisation.
§Params
k- Number of singular triplets to compute.
§Returns
The top-k SvdResults, or a MethodsErrors if the decomposition
fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<F: BixverseFloat> NmfInput<F> for DenseInput<'_, F>
NmfInput trait implementation for DenseInput
impl<S, F> NmfInput<F> for SparseInput<S, F>where
S: BixverseNumeric + BixverseSimd + Into<F> + Float + Clone + Sync,
F: BixverseFloat + BixverseSimd + Send + Sync + Sum,
NmfInput trait implementation for SparseInput