Example #1
0
def setTruncation(theta, chi):
    #print theta
    LA = uni10.UniTensor(theta.bond())
    GA = uni10.UniTensor(theta.bond())
    GB = uni10.UniTensor(theta.bond())

    bond_In_list, bond_OUT_list = bond_list_dist(theta)
    #print bond_In_list,bond_OUT_list
    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd = []
    for qnum in blk_qnums:
        M_tem = theta.getBlock(qnum)
        svds[qnum] = M_tem.svd()
        #print qnum, svds[qnum][1]
        dim_svd.append(int(svds[qnum][1].col()))
    svs = []
    bidxs = []
    for bidx in xrange(len(blk_qnums)):
        svs, bidxs = sv_merge(svs, bidxs, bidx, svds[blk_qnums[bidx]][1], chi,
                              len(blk_qnums))
        #print "lol", svs, bidxs
    dims = [0] * len(blk_qnums)
    for bidx in bidxs:
        dims[bidx] += 1
    qnums = []
    for bidx in xrange(len(blk_qnums)):
        qnums += [blk_qnums[bidx]] * dims[bidx]
    bdi_mid = uni10.Bond(uni10.BD_IN, qnums)
    #print "Hi", chi, svs, qnums, bdi_mid
    #print bdi_mid
    bdo_mid = uni10.Bond(uni10.BD_OUT, qnums)
    bond_In_list.append(bdo_mid)
    GA.assign(bond_In_list)
    bond_OUT_list.insert(0, bdi_mid)
    GB.assign(bond_OUT_list)
    LA.assign([bdi_mid, bdo_mid])
    degs = bdi_mid.degeneracy()
    for qnum, dim in degs.iteritems():
        if qnum not in svds:
            raise Exception("In setTruncaton(): Fatal error.")
        svd = svds[qnum]
        GA.putBlock(qnum, svd[0].resize(svd[0].row(), dim))
        GB.putBlock(qnum, svd[2].resize(dim, svd[2].col()))
        LA.putBlock(qnum, svd[1].resize(dim, dim))
    #print LA
    return GA, GB, LA
Example #2
0
def qr_parity(theta):

    #bd1=copy.copy(theta.bond(3))
    #bd1.change(uni10.BD_IN)
    bd1 = uni10.Bond(uni10.BD_IN, theta.bond(1).Qlist())

    GA = uni10.UniTensor(uni10.CTYPE, [theta.bond(0), theta.bond(1)])
    LA = uni10.UniTensor(uni10.CTYPE, [bd1, theta.bond(1)])

    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd = []
    for qnum in blk_qnums:
        svds[qnum] = theta.getBlock(qnum).qr()
        GA.putBlock(qnum, svds[qnum][0])
        LA.putBlock(qnum, svds[qnum][1])

    #    print LA
    return GA, LA
Example #3
0
def   svd_parity(theta):
    #print theta,theta.getBlock().svd()
    bdo=uni10.Bond(uni10.BD_OUT,theta.bond(1).Qlist())
    bdo1=uni10.Bond(uni10.BD_OUT,theta.bond(2).Qlist())

    #A_{m<n}=U_{mm}S_{mm}V_{mn}

    LA=uni10.UniTensor([theta.bond(1), bdo])
    GA=uni10.UniTensor([theta.bond(0), theta.bond(1),bdo])
    GB=uni10.UniTensor([theta.bond(1), bdo1])
    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd=[]
    for qnum in blk_qnums:
        svds[qnum] = theta.getBlock(qnum).svd()
    for qnum in blk_qnums:
        svd = svds[qnum]
        GA.putBlock(qnum, svd[0])
        GB.putBlock(qnum, svd[2])
        LA.putBlock(qnum, svd[1])
#    print LA
    return GA, LA,GB