qr

tenpy.linalg.np_conserved.qr(a, mode='reduced', inner_labels=[None, None], cutoff=None, pos_diag_R=False, qtotal_Q=None, inner_qconj=1)[source]

Q-R decomposition of a matrix.

Decomposition such that A == npc.tensordot(Q, R, axes=1) up to numerical rounding errors.

Parameters:
  • a (Array) – The matrix to be decomposed, shape (M,N).

  • mode ('reduced', 'complete') – ‘reduced’: return q and r with shapes (M,K) and (K,N), where K=min(M,N) ‘complete’: return q with shape (M,M).

  • inner_labels ([{str|None}, {str|None}]) – The first label is used for Q.legs[1], the second for R.legs[0].

  • cutoff (None or float) – If not None, discard linearly dependent vectors to given precision, which might reduce K of the ‘reduced’ mode even further.

  • pos_diag_R (bool) – If True, ensure the uniqueness of the qr decomposition by imposing that the diagonal of R is positive.

  • qtotal_Q (None | charges) – Total charge for Q. None defaults to trivial charges. Use qtotal_Q=a.qtotal to get R with trivial charges, since a.qtotal = chinfo.make_valid(q.qtotal + r.qtotal).

  • inner_qconj ({+1, -1}) – Direction of the charges for the new leg. Default +1. The new LegCharge is constructed such that R.legs[0].qconj = inner_qconj.

Returns:

  • Q (Array) – If mode is ‘complete’, a unitary matrix. For mode ‘reduced’ an isometry such that \(q^{*}_{j,i} q_{j,k} = \delta_{i,k}\).

  • R (Array) – Upper triangular matrix if both legs of A are sorted by charges; Otherwise a simple transposition (performed when sorting by charges) brings it to upper triangular form.