Coverage for src / cvx / linalg / svd.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-19 05:40 +0000

1"""Raw singular value decomposition utilities.""" 

2 

3from __future__ import annotations 

4 

5import numpy as np 

6 

7from .types import Matrix 

8 

9 

10def svd(matrix: Matrix) -> tuple[Matrix, Matrix, Matrix]: 

11 """Compute the compact singular value decomposition of a matrix. 

12 

13 This is a thin wrapper around ``numpy.linalg.svd`` with 

14 ``full_matrices=False``. 

15 

16 Args: 

17 matrix: Input matrix of shape ``(m, n)``. 

18 

19 Returns: 

20 Tuple ``(u, s, vt)`` such that ``matrix == u @ np.diag(s) @ vt``. 

21 """ 

22 return np.linalg.svd(matrix, full_matrices=False)