def NormL1_project(x,weights,tau):

    if all(np.isreal(x)):
        return oneProjector(x,weights,tau)
    else:
        xa  = abs(x)
        idx = xa < np.spacing(1)
        xc  = oneProjector(xa,weights,tau)
        xc  = xc / xa
        xc[idx] = 0
        return x * xc
Beispiel #2
0
def NormL1_project(x, weights, tau):

    if all(np.isreal(x)):
        return oneProjector(x, weights, tau)
    else:
        xa = abs(x)
        idx = xa < np.spacing(1)
        xc = oneProjector(xa, weights, tau)
        xc = xc / xa
        xc[idx] = 0
        return x * xc
def NormGroupL2_project(groups,x,weights,tau):
    if all(np.isreal(x)):
        xa  = np.sqrt(np.sum(groups * x**2.,axis=1))
    else:
        xa  = np.sqrt(np.sum(groups * abs(x)**2.,axis=1))

    idx = xa < spacing(1)
    xc  = oneProjector(xa,weights,tau)

    xc  = xc / xa
    xc[idx] = 0
    return dot(np.conj(groups.T),xc)*x
Beispiel #4
0
def NormGroupL2_project(groups, x, weights, tau):
    if all(np.isreal(x)):
        xa = np.sqrt(np.sum(groups * x**2., axis=1))
    else:
        xa = np.sqrt(np.sum(groups * abs(x)**2., axis=1))

    idx = xa < spacing(1)
    xc = oneProjector(xa, weights, tau)

    xc = xc / xa
    xc[idx] = 0
    return dot(np.conj(groups.T), xc) * x
def NormL12_project(g,x,weights,tau):
    m = round(np.size(x) / g)
    n = g
    x = reshape(x,m,n)

    if all(np.isreal(x)):
        xa  = np.sqrt(np.sum(x**2,axis=1))
    else:
        xa  = np.sqrt(np.sum(abs(x)**2,axis=1))

    idx = xa < spacing(1)
    xc  = oneProjector(xa,weights,tau)

    xc  = xc / xa
    xc[idx] = 0
    x   = np.sparse.spdiags(xc,0,m,m)*x

    return x.flatten()
Beispiel #6
0
def NormL12_project(g, x, weights, tau):
    m = round(np.size(x) / g)
    n = g
    x = reshape(x, m, n)

    if all(np.isreal(x)):
        xa = np.sqrt(np.sum(x**2, axis=1))
    else:
        xa = np.sqrt(np.sum(abs(x)**2, axis=1))

    idx = xa < spacing(1)
    xc = oneProjector(xa, weights, tau)

    xc = xc / xa
    xc[idx] = 0
    x = np.sparse.spdiags(xc, 0, m, m) * x

    return x.flatten()