svd#
- class saiunit.linalg.svd(x, *, full_matrices=True, compute_uv=True, hermitian=False, subset_by_index=None, algorithm=None, **kwargs)#
Singular value decomposition.
SaiUnit implementation of
numpy.linalg.svd().Decomposes a matrix A into
U @ diag(S) @ Vh. The singular values S carry the unit of A; U and Vh are dimensionless.- Parameters:
x (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Input of shape(..., M, N).full_matrices (
bool) – IfTrue(default), U and Vh have shapes(..., M, M)and(..., N, N). IfFalse, the shapes are(..., M, K)and(..., K, N)withK = min(M, N).compute_uv (
bool) – IfTrue(default), return(U, S, Vh). IfFalse, return only S.hermitian (
bool) – IfTrue, x is assumed to be Hermitian, enabling a more efficient algorithm.subset_by_index (
tuple[int,int] |None) – Two-element tuple(start, end)selecting a subset of singular values.algorithm (
SvdAlgorithm|None) – SVD backend algorithm.
- Return type:
saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex|tuple[Array, saiunit.Quantity |Array,Array]- Returns:
U (ndarray) – Left singular vectors (omitted when
compute_uv=False).S (ndarray or Quantity) – Singular values carrying the unit of x.
Vh (ndarray) – Right singular vectors (omitted when
compute_uv=False).
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> x = jnp.array([[1., 2., 3.], ... [4., 5., 6.]]) * u.meter >>> U, S, Vh = u.linalg.svd(x, full_matrices=False) >>> S ArrayImpl([9.50803089, 0.77286941], dtype=float32) * meter