Ejemplo n.º 1
0
def Wz_factory(mrow, mcol, alp_v, alp_h):
    Dy_mat = TV.DyMatRep(mrow, mcol)
    Dx_mat = TV.DxMatRep(mrow, mcol)

    def Wx_fun(z):
        """
        Wx operator for both Dx and Dv and dct2
        """
        m = mrow * mcol
        u0 = z[0:m]

        x = dct2.Mx_fun(u0, mrow, mcol).flatten()
        if alp_v > 0:
            u1 = z[m:2*m]
            x = x + alp_v * Dy_mat.dot(u1).flatten()
        if alp_h > 0:
            if alp_v > 0:
                u2 = z[2*m:3*m]
            else:
                u2 = z[m:2*m]
            x = x + alp_h * Dx_mat.dot(u2).flatten()

        return x

    return Wx_fun
Ejemplo n.º 2
0
def breg_hess_eval(n, m, mu, lam, x):
    DxMat = TV.DxMatRep(n, m)
    DyMat = TV.DyMatRep(n, m)

    dxx = DxMat.T.dot(DxMat).dot(x)
    dyy = DyMat.T.dot(DyMat).dot(x)

    return mu * x + lam * (dxx + dyy)
Ejemplo n.º 3
0
def breg_rhs(n, m, lam, mu, f, dx, bx, dy, by):
    DxMat = TV.DxMatRep(n, m)
    DyMat = TV.DyMatRep(n, m)

    dxx = lam * DxMat.T.dot(dx - bx)
    dyy = lam * DyMat.T.dot(dy - by)

    return mu * f + dxx + dyy
Ejemplo n.º 4
0
def breg_hess_solve(n, m, mu, lam, b):
    DxMat = TV.DxMatRep(n, m)
    DyMat = TV.DyMatRep(n, m)

    Dxx = DxMat.T.dot(DxMat)
    Dyy = DyMat.T.dot(DyMat)
    I = np.eye(n * m)

    H = mu * I + lam * (Dxx + Dyy)
    return np.linalg.solve(H, b)
Ejemplo n.º 5
0
def Hess_diag(N, M, mu, lam):
    import build_TV_data
    DyMat = build_TV_data.DyMatRep(N, M)
    DxMat = build_TV_data.DxMatRep(N, M)

    H = DyMat.T.dot(DyMat) + DxMat.T.dot(DxMat)
    I = np.eye(N * M)
    H = mu * I + lam * H
    H = np.diag(H)
    H = 1 / H
    return H
Ejemplo n.º 6
0
def Wtx_factory(mrow, mcol, alp_v, alp_h):
    Dy_mat = TV.DyMatRep(mrow, mcol)
    Dx_mat = TV.DxMatRep(mrow, mcol)

    def Wtx_fun(x):
        """
        Wx operator for both Dx and Dv and dct2
        """
        y1 = dct2.Mty_fun(x, mrow, mcol).flatten()
        y2 = alp_v * Dy_mat.T.dot(x).flatten()
        y3 = alp_h * Dx_mat.T.dot(x).flatten()

        if alp_v > 0 and alp_h > 0:
            return np.hstack((y1, y2, y3))

        if alp_v <= 0 and alp_h > 0:
            return np.hstack((y1, y3))

        if alp_v > 0 and alp_h <= 0:
            return np.hstack((y1, y2))

        return y1

    return Wtx_fun