Function SV_decomp (o2scl_linalg)¶
-
template<class mat_t, class mat2_t, class vec_t, class vec2_t>
void o2scl_linalg::SV_decomp(size_t M, size_t N, mat_t &A, mat2_t &V, vec_t &S, vec2_t &work)¶ Factorise a general matrix into its SV decomposition using the Golub-Reinsch algorithm.
This factors matrix
A
of size(M,N)
into\[ A = U~D~V^T \]whereU
is a column-orthogonal matrix of size(M,N)
(stored inA
),D
is a diagonal matrix of size(N,N)
(stored in the vectorS
of sizeN
), andV
is a orthogonal matrix of size(N,N)
. The vectorwork
is a workspace vector of sizeN
. The matricesU
andV
are constructed so that\[ U^T~U = I \qquad \mathrm{and} \qquad V^T~V = V~V^T = I \]This algorithm requres \( M \geq N \).
- Todo:
Test N=1 case, N=2 case, and non-square matrices.