Skip to main content

NmfInput

Trait NmfInput 

Source
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§

Source

fn shape(&self) -> (usize, usize)

Returns the shape

§Returns

(m, n).

Source

fn sq_frob(&self) -> F

The squared Frobenius norm ||V||_F^2,

Computed once at construction.

§Returns

The squared Frobenius norm.

Source

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, shape m x k.
  • out - Output buffer k x n. Overwritten on return.
Source

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, shape m x k.
  • out - Output buffer k x k. Overwritten on return.
Source

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§

Source§

impl<F: BixverseFloat> NmfInput<F> for DenseInput<'_, F>

NmfInput trait implementation for DenseInput

Source§

impl<S, F> NmfInput<F> for SparseInput<S, F>

NmfInput trait implementation for SparseInput