예제 #1
0
 def matvec(v):
     v = v.reshape((chi, chi))
     Th_v = ct.XopL(A_L, X=v)
     vR = ct.proj(v, lR) * Id
     v = v - Th_v + vR
     v = v.flatten()
     return v
예제 #2
0
def is_left_isometric(A_L, rtol=1E-5, atol=1E-8, verbose=False):
    """
    Passes if A_L is left-isometric.
    """
    contracted = ct.XopL(A_L)
    eye = np.eye(contracted.shape[0], dtype=A_L.dtype)
    passed, err = check(verbose, contracted, eye, thresh=atol)
    return (passed, err)
예제 #3
0
def is_right_canonical(A_R, L, rtol=1E-5, atol=1E-8, verbose=False):
    """
    Passes if A_R is right-canonical.
    """
    if verbose:
        print("Testing if right isometric.")
    is_iso, iso_err = is_right_isometric(A_R, rtol=rtol, atol=atol,
                                         verbose=verbose)
    contracted = ct.XopL(A_R, X=L)
    if verbose:
        print("Testing if right canonical.")
    is_can, can_err = check(verbose, contracted, L, 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.XopL(A, B=B, X=xmat)
     xvec = xmat.flatten()
     return xvec