예제 #1
0
 def matvec(v):
     v = v.reshape((chi, chi))
     Th_v = ct.XopR(A_R, X=v)
     Lv = ct.proj(rL, v) * Id
     v = v - Th_v + Lv
     v = v.flatten()
     return v
예제 #2
0
def is_right_isometric(A_R, rtol=1E-5, atol=1E-8, verbose=False):
    """
    Passes if A_R is right-isometric.
    """
    contracted = ct.XopR(A_R)
    eye = np.eye(contracted.shape[0], dtype=A_R.dtype)
    passed, err = check(verbose, contracted, eye, thresh=atol)
    return (passed, err)
예제 #3
0
def is_left_canonical(A_L, R, rtol=1E-5, atol=1E-8, verbose=False):
    """
    Passes if A_L is left-canonical.
    """
    if verbose:
        print("Testing if left isometric, ")
    is_iso, iso_err = is_left_isometric(A_L, rtol=rtol, atol=atol,
                                        verbose=verbose)
    contracted = ct.XopR(A_L, X=R)
    if verbose:
        print("Testing if left canonical, ")
    is_can, can_err = check(verbose, contracted, R, thresh=atol)
    passed = is_iso and is_can
    err = iso_err + can_err
    return (passed, err)
예제 #4
0
def B2_variance(oldlist, newlist):
    """
    Given two MPS tensors in mixed canonical form, estimate the gradient
    variance.

    PARAMETERS
    ----------
    oldlist, newlist: Both lists [A_L, C, A_R] representing two MPS in
                      mixed canonical form.

    RETURNS
    ------
    B2 (float) : The gradient variance.
    """
    NL, NR = mps_null_spaces(oldlist)
    AL, C, AR = newlist
    AC = ct.rightmult(AL, C)
    L = ct.XopL(AC, B=NL)
    R = ct.XopR(AR, B=NR)
    B2_tensor = L @ R.T
    B2 = norm(B2_tensor)
    return B2
예제 #5
0
 def tmmatvec(xvec):
     xmat = xvec.reshape(outshape)
     xmat = ct.XopR(A, B=B, X=xmat)
     xvec = xmat.flatten()
     return xvec