예제 #1
0
 def test_10(self):
     dsz = ((8, 8, 16), (12, 12, 32))
     u = np.zeros((24, 24, 48))
     u[0:8, 0:8, 0:16] = 1.0
     u[0:12, 0:12, 16:] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0
예제 #2
0
    def test_13(self):
        N = 64
        M = 4
        Nd = 8
        D0 = cr.normalise(cr.zeromean(
            np.random.randn(Nd, Nd, M), (Nd, Nd, M), dimN=2), dimN=2)
        X = np.zeros((N, N, M))
        xr = np.random.randn(N, N, M)
        xp = np.abs(xr) > 3
        X[xp] = np.random.randn(X[xp].size)
        S = np.sum(sl.ifftn(sl.fftn(D0, (N, N), (0, 1)) *
                            sl.fftn(X, None, (0, 1)), None, (0, 1)).real,
                   axis=2)
        L = 0.5
        opt = ccmod.ConvCnstrMOD.Options(
            {'Verbose': False, 'MaxMainIter': 3000, 'ZeroMean': True,
             'RelStopTol': 0., 'L': L, 'BackTrack': {'Enabled': True}})
        Xr = X.reshape(X.shape[0:2] + (1, 1,) + X.shape[2:])
        Sr = S.reshape(S.shape + (1,))
        c = ccmod.ConvCnstrMOD(Xr, Sr, D0.shape, opt)
        c.solve()
        D1 = cr.bcrop(c.X, D0.shape).squeeze()

        assert sl.rrs(D0, D1) < 1e-4
        assert np.array(c.getitstat().Rsdl)[-1] < 1e-5
예제 #3
0
    def test_18(self):
        N = 64
        M = 4
        Nd = 8
        D0 = cr.normalise(cr.zeromean(np.random.randn(Nd, Nd, M), (Nd, Nd, M),
                                      dimN=2),
                          dimN=2)
        X = np.zeros((N, N, M))
        xr = np.random.randn(N, N, M)
        xp = np.abs(xr) > 3
        X[xp] = np.random.randn(X[xp].size)
        S = np.sum(ifftn(
            fftn(D0, (N, N), (0, 1)) * fftn(X, None, (0, 1)), None,
            (0, 1)).real,
                   axis=2)
        L = 50.0
        opt = ccmod.ConvCnstrMOD.Options({
            'Verbose': False,
            'MaxMainIter': 3000,
            'ZeroMean': True,
            'RelStopTol': 0.,
            'L': L,
            'Monotone': True
        })
        Xr = X.reshape(X.shape[0:2] + (
            1,
            1,
        ) + X.shape[2:])
        Sr = S.reshape(S.shape + (1, ))
        c = ccmod.ConvCnstrMOD(Xr, Sr, D0.shape, opt)
        c.solve()
        D1 = cr.bcrop(c.X, D0.shape).squeeze()

        assert rrs(D0, D1) < 1e-4
        assert np.array(c.getitstat().Rsdl)[-1] < 1e-5
예제 #4
0
 def test_10(self):
     dsz = ((8, 8, 16), (12, 12, 32))
     u = np.zeros((24, 24, 48))
     u[0:8, 0:8, 0:16] = 1.0
     u[0:12, 0:12, 16:] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0
예제 #5
0
 def test_02(self):
     N = 32
     M = 4
     Nd = 5
     D0 = cr.normalise(cr.zeromean(
         np.random.randn(Nd, Nd, M), (Nd, Nd, M), dimN=2), dimN=2)
     X = np.zeros((N, N, M))
     xr = np.random.randn(N, N, M)
     xp = np.abs(xr) > 3
     X[xp] = np.random.randn(X[xp].size)
     S = np.sum(sl.ifftn(sl.fftn(D0, (N, N), (0,1)) *
                sl.fftn(X, None, (0,1)), None, (0,1)).real, axis=2)
     rho = 1e-1
     opt = ccmod.ConvCnstrMOD_CG.Options({'Verbose': False,
                 'MaxMainIter': 500, 'LinSolveCheck': True,
                 'ZeroMean': True, 'RelStopTol': 1e-5, 'rho': rho,
                 'AutoRho': {'Enabled': False},
                 'CG': {'StopTol': 1e-5}})
     Xr = X.reshape(X.shape[0:2] + (1,1,) + X.shape[2:])
     Sr = S.reshape(S.shape + (1,))
     c = ccmod.ConvCnstrMOD_CG(Xr, Sr, D0.shape, opt)
     c.solve()
     D1 = cr.bcrop(c.Y, D0.shape).squeeze()
     assert(sl.rrs(D0, D1) < 1e-4)
     assert(np.array(c.getitstat().XSlvRelRes).max() < 1e-3)
예제 #6
0
 def test_02(self):
     N = 32
     M = 4
     Nd = 5
     D0 = cr.normalise(cr.zeromean(
         np.random.randn(Nd, Nd, M), (Nd, Nd, M), dimN=2), dimN=2)
     X = np.zeros((N, N, M))
     xr = np.random.randn(N, N, M)
     xp = np.abs(xr) > 3
     X[xp] = np.random.randn(X[xp].size)
     S = np.sum(sl.ifftn(sl.fftn(D0, (N, N), (0, 1)) *
                sl.fftn(X, None, (0, 1)), None, (0, 1)).real, axis=2)
     rho = 1e-1
     opt = ccmod.ConvCnstrMOD_CG.Options({'Verbose': False,
                 'MaxMainIter': 500, 'LinSolveCheck': True,
                 'ZeroMean': True, 'RelStopTol': 1e-5, 'rho': rho,
                 'AutoRho': {'Enabled': False},
                 'CG': {'StopTol': 1e-5}})
     Xr = X.reshape(X.shape[0:2] + (1, 1,) + X.shape[2:])
     Sr = S.reshape(S.shape + (1,))
     c = ccmod.ConvCnstrMOD_CG(Xr, Sr, D0.shape, opt)
     c.solve()
     D1 = cr.bcrop(c.Y, D0.shape).squeeze()
     assert sl.rrs(D0, D1) < 1e-4
     assert np.array(c.getitstat().XSlvRelRes).max() < 1e-3
예제 #7
0
 def test_11(self):
     dsz = (((5, 5, 2, 8), (7, 7, 1, 8)), ((9, 9, 2, 16), (10, 10, 1, 16)))
     u = np.zeros((16, 16, 3, 24))
     u[0:5, 0:5, 0:2, 0:8] = 1.0
     u[0:7, 0:7, 2, 0:8] = 1.0
     u[0:9, 0:9, 0:2, 8:] = 1.0
     u[0:10, 0:10, 2, 8:] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0
예제 #8
0
 def test_11(self):
     dsz = (((5, 5, 2, 8), (7, 7, 1, 8)),
            ((9, 9, 2, 16), (10, 10, 1, 16)))
     u = np.zeros((16, 16, 3, 24))
     u[0:5, 0:5, 0:2, 0:8] = 1.0
     u[0:7, 0:7, 2, 0:8] = 1.0
     u[0:9, 0:9, 0:2, 8:] = 1.0
     u[0:10, 0:10, 2, 8:] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0
예제 #9
0
 def setup_method(self, method):
     np.random.seed(12345)
     N = 32
     M = 4
     Nd = 5
     self.D0 = cr.normalise(cr.zeromean(np.random.randn(Nd, Nd, M),
                                        (Nd, Nd, M),
                                        dimN=2),
                            dimN=2)
     self.X = np.zeros((N, N, M))
     xr = np.random.randn(N, N, M)
     xp = np.abs(xr) > 3
     self.X[xp] = np.random.randn(self.X[xp].size)
     self.S = np.sum(fftconv(self.X, self.D0, axes=(0, 1)).real, axis=2)
     d0c = np.random.randn(Nd, Nd, M) + 1j * np.random.randn(Nd, Nd, M)
     self.D0c = cr.normalise(cr.zeromean(d0c, (Nd, Nd, M), dimN=2), dimN=2)
     self.Xc = np.zeros((N, N, M)) + 1j * np.zeros((N, N, M))
     self.Xc[xp] = (np.random.randn(self.Xc[xp].size) +
                    1j * np.random.randn(self.Xc[xp].size))
     self.Sc = np.sum(fftconv(self.Xc, self.D0c, axes=(0, 1)), axis=2)
예제 #10
0
 def test_02(self):
     N = 32
     M = 4
     Nd = 5
     D0 = cr.normalise(cr.zeromean(
         np.random.randn(Nd, Nd, M), (Nd, Nd, M), dimN=2), dimN=2)
     X = np.zeros((N, N, M))
     xr = np.random.randn(N, N, M)
     xp = np.abs(xr) > 3
     X[xp] = np.random.randn(X[xp].size)
     S = np.sum(sl.ifftn(sl.fftn(D0, (N, N), (0,1)) *
                sl.fftn(X, None, (0,1)), None, (0,1)).real, axis=2)
     L = 1e1
     opt = ccmod.ConvCnstrMOD.Options({'Verbose': False,
                 'MaxMainIter': 3000,
                 'ZeroMean': True, 'RelStopTol': 1e-6, 'L': L,
                 'BackTrack': {'Enabled': True}})
     Xr = X.reshape(X.shape[0:2] + (1,1,) + X.shape[2:])
     Sr = S.reshape(S.shape + (1,))
     c = ccmod.ConvCnstrMOD(Xr, Sr, D0.shape, opt)
     c.solve()
     D1 = cr.bcrop(c.X, D0.shape).squeeze()
     assert(sl.rrs(D0, D1) < 1e-4)
     assert(np.array(c.getitstat().Rsdl)[-1] < 1e-5)
예제 #11
0
 def test_09(self):
     dsz = (8, 8, 32)
     u = np.zeros((16, 16, 32))
     u[0:8, 0:8, 0:16] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0
예제 #12
0
 def test_09(self):
     dsz = (8, 8, 32)
     u = np.zeros((16, 16, 32))
     u[0:8, 0:8, 0:16] = 1.0
     v = cnvrep.zeromean(u, dsz)
     assert np.sum(np.abs(v)) == 0.0