# harold.haroldsvd¶

harold.haroldsvd(A, also_rank=False, rank_tol=None)

This is a wrapper/container function of both the SVD decomposition and the rank computation. Since the regular rank computation is implemented via SVD it doesn’t make too much sense to recompute the SVD if we already have the rank information. Thus instead of typing two commands back to back for both the SVD and rank, we return both. To reduce the clutter, the rank information is supressed by default.

numpy svd is a bit strange because it compresses and looses the S matrix structure. From the manual, it is advised to use u.dot(np.diag(s).dot(v)) for recovering the original matrix. But that won’t work for rectangular matrices. Hence it recreates the rectangular S matrix of U,S,V triplet.

Parameters: A ((m,n) array_like) – Matrix to be decomposed also_rank (bool, optional) – Whether the rank of the matrix should also be reported or not. The returned rank is computed via the definition taken from the official numpy.linalg.matrix_rank and appended here. rank_tol ({None,float} optional) – The tolerance used for deciding the numerical rank. The default is set to None and uses the default definition of matrix_rank() from numpy. U,S,V ({(m,m),(m,n),(n,n)} array_like) – Decomposed-form matrices r (integer) – If the boolean “also_rank” is true, this variable is the numerical rank of the matrix D