Skip to main content

Module svd

Module svd 

Source
Expand description

Singular Value Decomposition (SVD)

The matrix A is decomposed as A = U * S * V^T where:

  • s contains the singular values (1D vector)
  • u contains the left singular vectors (matrix U)
  • vt contains the transposed right singular vectors (matrix V^T)

Singular values are mathematically real. Backends choose the scalar type used to represent them through SVD::SingularValue.

// ----- Singular Value Decomposition (SVD) -----
use mdarray_linalg::svd::SVDDecomp;
use mdarray_linalg::prelude::*; // Import traits anonymously
use mdarray_linalg_backend::Backend; // Use the real backend here, Lapack, Faer, ...

let bd = Backend::default();
let SVDDecomp { s, u, vt } = bd.svd(&mut a.clone()).expect("SVD failed");
// Or the shorter ...
let SVDDecomp { s, u, vt } = bd.svd(&mut a.clone()).expect("SVD failed");

Structs§

SVDDecomp
Holds the results of a singular value decomposition, including singular values and the left and right singular vectors.

Enums§

SVDError
Error types related to singular value decomposition

Traits§

SVD
Singular value decomposition for matrix factorization and analysis