Skip to main content

compute_objective

Function compute_objective 

Source
pub fn compute_objective<F: BixverseFloat + Send + Sync>(
    sq_frob_v: F,
    h: MatRef<'_, F>,
    a: MatRef<'_, F>,
    b: MatRef<'_, F>,
    d: MatRef<'_, F>,
) -> F
Expand description

Frobenius squared reconstruction error.

Evaluates ||V - WH||_F^2 via the expansion ||V||_F^2 - 2<W^T V, H> + <W^T W, H H^T>, avoiding materialising W H. Always in f64 to avoid issues with catastrophic cancellation.

§Params

  • sq_frob_v - Precomputed ||V||_F^2.
  • h - Right factor k x n.
  • a - Product W^T V, shape k x n.
  • b - Gram matrix W^T W, shape k x k.
  • d - Gram matrix H H^T, shape k x k.

§Returns

The scalar reconstruction error.