carpet/utils.py
def v_to_u(v, x, A=None, D=None, inv_AtA=None, device='cpu'):
    """ Return primal variable from dual variable. """
    v = check_tensor(v, device=device)
    x = check_tensor(x, device=device)

    if inv_AtA is None:
        if A is not None and D is not None:
            A = check_tensor(A, device=device)
            AtA = A.matmul(A.t())
            inv_AtA = torch.pinverse(AtA)
        else:
            raise ValueError("If inv_AtA is None, "
                             "A and D should be given")

    A = check_tensor(A, device=device)
    D = check_tensor(D, device=device)
    inv_AtA = check_tensor(inv_AtA, device=device)

    return (x.matmul(A.t()) - v.matmul(D.t())).matmul(inv_AtA)
 Return primal variable from dual variable. 
Return primal variable from dual variable.
Return primal variable from dual variable .
def v_to_u(v, x, A=None, D=None, inv_AtA=None, device='cpu'):
    v = check_tensor(v, device=device)
    x = check_tensor(x, device=device)
    if inv_AtA is None:
        if A is not None and D is not None:
            A = check_tensor(A, device=device)
            AtA = A.matmul(A.t())
            inv_AtA = torch.pinverse(AtA)
        else:
            raise ValueError("If inv_AtA is None, "
                             "A and D should be given")
    A = check_tensor(A, device=device)
    D = check_tensor(D, device=device)
    inv_AtA = check_tensor(inv_AtA, device=device)
    return (x.matmul(A.t()) - v.matmul(D.t())).matmul(inv_AtA)
def v_to_u ( v , x , A = None , D = None , inv_AtA = None , device = 'cpu' ) : v = check_tensor ( v , device = device ) x = check_tensor ( x , device = device ) if inv_AtA is None : if A is not None and D is not None : A = check_tensor ( A , device = device ) AtA = A . matmul ( A . t ( ) ) inv_AtA = torch . pinverse ( AtA ) else : raise ValueError ( "If inv_AtA is None, " "A and D should be given" ) A = check_tensor ( A , device = device ) D = check_tensor ( D , device = device ) inv_AtA = check_tensor ( inv_AtA , device = device ) return ( x . matmul ( A . t ( ) ) - v . matmul ( D . t ( ) ) ) . matmul ( inv_AtA )
Return primal variable from dual variable.
Return primal variable from dual variable .
""" Return primal variable from dual variable. """
v
x
A
D
inv_AtA
device