svd

tenpy.linalg.np_conserved.svd(a, full_matrices=False, compute_uv=True, cutoff=None, qtotal_LR=[None, None], inner_labels=[None, None], inner_qconj=1)[source]

Singualar value decomposition of an Array a.

Factorizes U, S, VH = svd(a), such that a = U*diag(S)*VH (where * stands for a tensordot() and diag creates an correctly shaped Array with S on the diagonal). For a non-zero cutoff this holds only approximately.

There is a gauge freedom regarding the charges, see also Array.gauge_total_charge(). We ensure contractibility by setting U.legs[1] = VH.legs[0].conj(). Further, we gauge the LegCharge such that U and V have the desired qtotal_LR.

Parameters
aArray, shape (M, N)

The matrix to be decomposed.

full_matricesbool

If False (default), U and V have shapes (M, K) and (K, N), where K=len(S). If True, U and V are full square unitary matrices with shapes (M, M) and (N, N). Note that the arrays are not directly contractible in that case; diag(S) would need to be a rectangluar (M, N) matrix.

compute_uvbool

Whether to compute and return U and V.

cutoffNone | float

Keep only singular values which are (strictly) greater than cutoff. (Then the factorization holds only approximately). If None (default), ignored.

qtotal_LR[{charges|None}, {charges|None}]

The desired qtotal for U and VH, respectively. [None, None] (Default) is equivalent to [None, a.qtotal]. A single None entry is replaced the unique charge satisfying the requirement U.qtotal + VH.qtotal = a.qtotal (modulo qmod).

inner_labels_LR: [{str|None}, {str|None}]

The first label corresponds to U.legs[1], the second to VH.legs[0].

inner_qconj{+1, -1}

Direction of the charges for the new leg. Default +1. The new LegCharge is constructed such that VH.legs[0].qconj = qconj.

Returns
UArray

Matrix with left singular vectors as columns. Shape (M, M) or (M, K) depending on full_matrices.

S1D ndarray

The singluar values of the array. If no cutoff is given, it has lenght min(M, N).

VHArray

Matrix with right singular vectors as rows. Shape (N, N) or (K, N) depending on full_matrices.