def test_10(self): N = 64 M = 4 Nd = 8 D = cp.random.randn(Nd, Nd, M) X0 = cp.zeros((N, N, M)) xr = cp.random.randn(N, N, M) xp = cp.abs(xr) > 3 X0[xp] = cp.random.randn(X0[xp].size) S = cp.sum(fftconv(D, X0, axes=(0, 1)), axis=2) lmbda = 1e-4 rho = 1e-1 opt = cbpdn.ConvBPDN.Options({ 'Verbose': False, 'MaxMainIter': 500, 'RelStopTol': 1e-3, 'rho': rho, 'AutoRho': { 'Enabled': False } }) b = cbpdn.ConvBPDN(D, S, lmbda, opt) b.solve() X1 = b.Y.squeeze() assert rrs(X0, X1) < 5e-5 Sr = b.reconstruct().squeeze() assert rrs(S, Sr) < 1e-4
def test_11(self): N = 63 M = 4 Nd = 8 D = cp.random.randn(Nd, Nd, M) X0 = cp.zeros((N, N, M)) xr = cp.random.randn(N, N, M) xp = cp.abs(xr) > 3 X0[xp] = cp.random.randn(X0[xp].size) S = cp.sum(ifftn( fftn(D, (N, N), (0, 1)) * fftn(X0, None, (0, 1)), None, (0, 1)).real, axis=2) lmbda = 1e-2 L = 1e3 opt = cbpdn.ConvBPDN.Options({ 'Verbose': False, 'MaxMainIter': 2000, 'RelStopTol': 1e-9, 'L': L, 'BackTrack': { 'Enabled': False } }) b = cbpdn.ConvBPDN(D, S, lmbda, opt) b.solve() X1 = b.X.squeeze() assert rrs(X0, X1) < 5e-4 Sr = b.reconstruct().squeeze() assert rrs(S, Sr) < 2e-4
def test_10(self): N = 64 M = 4 Nd = 8 D = cp.random.randn(Nd, Nd, M) X0 = cp.zeros((N, N, M)) xr = cp.random.randn(N, N, M) xp = cp.abs(xr) > 3 X0[xp] = cp.random.randn(X0[xp].size) S = cp.sum(sl.fftconv(D, X0), axis=2) lmbda = 1e-4 rho = 1e-1 opt = cbpdn.ConvBPDN.Options({'Verbose': False, 'MaxMainIter': 500, 'RelStopTol': 1e-3, 'rho': rho, 'AutoRho': {'Enabled': False}}) b = cbpdn.ConvBPDN(D, S, lmbda, opt) b.solve() X1 = b.Y.squeeze() assert sl.rrs(X0, X1) < 5e-5 Sr = b.reconstruct().squeeze() assert sl.rrs(S, Sr) < 1e-4
def test_09(self): rho = 1e-1 N = 32 M = 16 K = 8 D = util.complex_randn(N, N, 1, 1, M) X = util.complex_randn(N, N, 1, K, M) S = cp.sum(D * X, axis=4, keepdims=True) Z = (D.conj()*cp.sum(D*X, axis=4, keepdims=True) + \ rho*X - D.conj()*S) / rho Xslv = linalg.solvedbi_sm(D, rho, D.conj() * S + rho * Z) assert (linalg.rrs( D.conj() * cp.sum(D * Xslv, axis=4, keepdims=True) + rho * Xslv, D.conj() * S + rho * Z) < 1e-11)
def test_08(self): rho = 1e-1 N = 128 M = 64 K = 32 D = cp.random.randn(N, M) X = cp.random.randn(M, K) S = D.dot(X) Z = (D.dot(X).dot(X.T) + rho * D - S.dot(X.T)) / rho c, lwr = linalg.cho_factor(X, rho) Dslv = linalg.cho_solve_AATI(X, rho, S.dot(X.T) + rho * Z, c, lwr) assert (linalg.rrs( Dslv.dot(X).dot(X.T) + rho * Dslv, S.dot(X.T) + rho * Z) < 1e-11)
def test_06(self): rho = 1e-1 N = 128 M = 64 K = 32 D = cp.random.randn(N, M) X = cp.random.randn(M, K) S = D.dot(X) Z = (D.T.dot(D).dot(X) + rho * X - D.T.dot(S)) / rho c, lwr = linalg.cho_factor(D, rho) Xslv = linalg.cho_solve_ATAI(D, rho, D.T.dot(S) + rho * Z, c, lwr) assert (linalg.rrs( D.T.dot(D).dot(Xslv) + rho * Xslv, D.T.dot(S) + rho * Z) < 1e-14)
def test_11(self): N = 63 M = 4 Nd = 8 D = cp.random.randn(Nd, Nd, M) X0 = cp.zeros((N, N, M)) xr = cp.random.randn(N, N, M) xp = cp.abs(xr) > 3 X0[xp] = cp.random.randn(X0[xp].size) S = cp.sum(sl.ifftn(sl.fftn(D, (N, N), (0, 1)) * sl.fftn(X0, None, (0, 1)), None, (0, 1)).real, axis=2) lmbda = 1e-2 L = 1e3 opt = cbpdn.ConvBPDN.Options({'Verbose': False, 'MaxMainIter': 2000, 'RelStopTol': 1e-9, 'L': L, 'BackTrack': {'Enabled': False}}) b = cbpdn.ConvBPDN(D, S, lmbda, opt) b.solve() X1 = b.X.squeeze() assert sl.rrs(X0, X1) < 5e-4 Sr = b.reconstruct().squeeze() assert sl.rrs(S, Sr) < 2e-4
def test_10(self): N = 32 M = 16 K = 8 D = util.complex_randn(N, N, 1, 1, M) X = util.complex_randn(N, N, 1, K, M) S = cp.sum(D * X, axis=4, keepdims=True) d = 1e-1 * (cp.random.randn(N, N, 1, 1, M).astype('complex') + cp.random.randn(N, N, 1, 1, M).astype('complex') * 1.0j) Z = (D.conj() * cp.sum(D * X, axis=4, keepdims=True) + d * X - D.conj() * S) / d Xslv = linalg.solvedbd_sm(D, d, D.conj() * S + d * Z) assert (linalg.rrs( D.conj() * cp.sum(D * Xslv, axis=4, keepdims=True) + d * Xslv, D.conj() * S + d * Z) < 1e-11)
def test_13(self): rho = 1e-1 N = 32 M = 16 K = 8 D = util.complex_randn(N, N, 1, 1, M) X = util.complex_randn(N, N, 1, K, M) S = cp.sum(D * X, axis=4, keepdims=True) Xop = lambda x: cp.sum(X * x, axis=4, keepdims=True) XHop = lambda x: cp.sum(cp.conj(X) * x, axis=3, keepdims=True) Z = (XHop(Xop(D)) + rho * D - XHop(S)) / rho Dslv = linalg.solvemdbi_rsm(X, rho, XHop(S) + rho * Z, 3) assert linalg.rrs(XHop(Xop(Dslv)) + rho * Dslv, XHop(S) + rho * Z) < 1e-11