Singular value decomposition
This task uses real numbers, not modular arithmetic. Given a real (n\times m)
matrix (A), output a thin singular value decomposition
Let (r=\min(n,m)). (U) has shape (n\times r), (V) has shape
(m\times r), and \(\Sigma=\operatorname{diag}(\sigma_1,\ldots,\sigma_r)).
The singular values must be non-negative and sorted in non-increasing order.
The checker accepts small floating-point error. Signs are not fixed: replacing
one column of (U) and the corresponding column of (V) by their negatives is
equivalent.
Input
The first line contains (n,m). The next (n) lines contain real entries of
(A).
Output
Print (U) as (n) rows of (r) values, then the (r) singular values, then
(V) as (m) rows of (r) values. Columns of (U) and (V) must be
orthonormal, and the reconstruction error must be at most (10^{-5}).
Constraints
- \(1\le n,m\le 10\)
- \(-10^4\le A_{i,j}\le 10^4\)