Ejemplo n.º 1
0
def gauge_match_SVD(A_C, C, thresh=1E-13):
    """
    Return approximately gauge-matched A_L and A_R from A_C and C
    using an SVD. If 
    """
    Ashape = A_C.shape
    Cdag = np.conj(C.T)

    AC_mat_l = ct.fuse_left(A_C)  #A_C.reshape(d*chi, chi)
    ACl_Cd = np.dot(AC_mat_l, Cdag)
    Ul, Sl, Vld = np.linalg.svd(ACl_Cd, full_matrices=False)
    AL_mat = np.dot(Ul, Vld)
    A_L = ct.unfuse_left(AL_mat, Ashape)

    AC_mat_r = ct.fuse_right(A_C)
    d, chi, chi = Ashape
    AC_mat_r = A_C.reshape(chi, d * chi)
    Cd_ACr = np.dot(Cdag, AC_mat_r)
    Ur, Sr, Vrd = np.linalg.svd(Cd_ACr, full_matrices=False)
    AR_mat = np.dot(Ur, Vrd)
    A_R = ct.unfuse_right(AR_mat, Ashape)

    smallest = min(min(Sl), min(Sr))
    SVD_ok = smallest > thresh
    if not SVD_ok:
        print("Singular values fell beneath threshold.")
    return (A_L, A_R, SVD_ok)
Ejemplo n.º 2
0
def gauge_match_polar(A_C, C):
    """
    Return approximately gauge-matched A_L and A_R from A_C and C
    using a polar decomposition.
    """
    Ashape = A_C.shape
    AC_mat_l = ct.fuse_left(A_C)
    AC_mat_r = ct.fuse_right(A_C)

    UAc_l, PAc_l = sp.linalg.polar(AC_mat_l, side="right")
    UAc_r, PAc_r = sp.linalg.polar(AC_mat_r, side="left")
    UC_l, PC_l = sp.linalg.polar(C, side="right")
    UC_r, PC_r = sp.linalg.polar(C, side="left")

    A_L = np.dot(UAc_l, np.conj(UC_l.T))
    A_L = ct.unfuse_left(A_L, Ashape)
    A_R = np.dot(np.conj(UC_r.T), UAc_r)
    A_R = ct.unfuse_right(A_R, Ashape)
    return (A_L, A_R)
Ejemplo n.º 3
0
def null_spaces(mpslist):
    """
    Return matrices spanning the null spaces of A_L and A_R, and
    the hermitian conjugates of these, reshaped into rank
    3 tensors.
    """
    AL, C, AR = mpslist
    d, chi, _ = AL.shape
    NLshp = (d, chi, (d-1)*chi)
    ALdag = ct.fuse_left(AL).T.conj()
    NLm = sp.linalg.null_space(ALdag)
    NL = NLm.reshape(NLshp)

    ARmat = ct.fuse_right(AR)
    NRm_dag = sp.linalg.null_space(ARmat)
    NRm = np.conj(NRm_dag)
    NR = NRm.reshape((d, chi, (d-1)*chi))
    NR = NR.transpose((0, 2, 1))
    return (NL, NR)
Ejemplo n.º 4
0
def rqpos(A):
    """
    RQ decomp. of A, with phase convention such that R has only positive
    elements on the main diagonal. 

    If A is an MPS tensor (d, chiL, chiR), it is reshaped and
    transposed appropriately
    before the throughput begins. In that case, Q will be a tensor
    of the same size, while R will be a chiL x chiL matrix.
    """
    Ashp = A.shape
    if len(Ashp) == 2:
        return rqmat(A)
    elif len(Ashp) != 3:
        print("A had invalid dimensions, ", A.shape)

    A = ct.fuse_right(A)  #chiL, d*chiR
    R, Q = qrmat(A, mode="economic")
    Q = ct.unfuse_right(Q, Ashp)
    return (Q, R)