extendr_api::prelude::modules::svd

Function compute_svd

pub fn compute_svd<E>(
    matrix: MatRef<'_, E>,
    s: ColMut<'_, E>,
    u: Option<MatMut<'_, E>>,
    v: Option<MatMut<'_, E>>,
    parallelism: Parallelism<'_>,
    stack: PodStack<'_>,
    params: SvdParams,
)
where E: ComplexField,
Expand description

Computes the singular value decomposition of matrix.

s represents the main diagonal of the matrix $S$, and must have size equal to the minimum of matrix.nrows() and matrix.ncols().

For each of u and v:

  • If the argument is None, then the corresponding singular vector matrix is not computed.
  • If it is Some(..), then it must have a number of rows equal to matrix.nrows() for u, and matrix.ncols() for v.
  • The number of columns may be either equal to the number of rows, or it may be equal to the minimum of matrix.nrows() and matrix.ncols(), in which case only the singular vectors corresponding to the provided column storage are computed.

ยงPanics

Panics if any of the conditions described above is violated, or if the type E does not have a fixed precision at compile time, e.g. a dynamic multiprecision floating point type.

This can also panic if the provided memory in stack is insufficient (see compute_svd_req).