def test_Roll2D(par): """Dot-test and comparison with PyLops for Roll operator on 2d signal """ np.random.seed(10) x = {} x['0'] = da.outer(np.arange(par['ny']), da.ones(par['nx'])) + \ par['imag'] * np.outer(da.arange(par['ny']), da.ones(par['nx'])) x['1'] = da.outer(da.ones(par['ny']), da.arange(par['nx'])) + \ par['imag'] * np.outer(da.ones(par['ny']), da.arange(par['nx'])) for dir in [0, 1]: dRop = dRoll(par['ny'] * par['nx'], dims=(par['ny'], par['nx']), dir=dir, shift=-2, dtype=par['dtype']) Rop = Roll(par['ny'] * par['nx'], dims=(par['ny'], par['nx']), dir=dir, shift=-2, dtype=par['dtype']) assert dottest(dRop, par['ny'] * par['nx'], par['ny'] * par['nx'], chunks=(par['ny'] * par['nx'], par['ny'] * par['nx'])) dy = dRop * x[str(dir)].ravel() y = Rop * x[str(dir)].compute().ravel() assert_array_equal(dy, y)\
def test_Roll3D(par): """Dot-test, forward and adjoint for Roll operator on 3d signal """ np.random.seed(10) x = {} x['0'] = np.outer(np.arange(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) + \ par['imag'] * np.outer(np.arange(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) x['1'] = np.outer(np.ones(par['ny']), np.arange(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) + \ par['imag'] * np.outer(np.ones(par['ny']), np.arange(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) x['2'] = np.outer(np.ones(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.arange(par['nx']) + \ par['imag'] * np.outer(np.ones(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.arange(par['nx']) for dir in [0, 1, 2]: Rop = Roll(par['ny'] * par['nx'] * par['nx'], dims=(par['ny'], par['nx'], par['nx']), dir=dir, shift=3, dtype=par['dtype']) y = Rop * x[str(dir)].flatten() assert dottest(Rop, par['ny'] * par['nx'] * par['nx'], par['ny'] * par['nx'] * par['nx']) xinv = Rop.H * y assert_array_almost_equal(x[str(dir)].ravel(), xinv, decimal=3)
def test_Roll3D(par): """Dot-test, forward and adjoint for Roll operator on 3d signal""" np.random.seed(10) x = {} x["0"] = np.outer(np.arange(par["ny"]), np.ones( par["nx"]))[:, :, np.newaxis] * np.ones(par["nx"]) + par["imag"] * np.outer( np.arange(par["ny"]), np.ones( par["nx"]))[:, :, np.newaxis] * np.ones(par["nx"]) x["1"] = np.outer(np.ones(par["ny"]), np.arange( par["nx"]))[:, :, np.newaxis] * np.ones(par["nx"]) + par["imag"] * np.outer( np.ones(par["ny"]), np.arange( par["nx"]))[:, :, np.newaxis] * np.ones(par["nx"]) x["2"] = np.outer(np.ones(par["ny"]), np.ones( par["nx"]))[:, :, np.newaxis] * np.arange( par["nx"]) + par["imag"] * np.outer(np.ones( par["ny"]), np.ones(par["nx"]))[:, :, np.newaxis] * np.arange( par["nx"]) for dir in [0, 1, 2]: Rop = Roll( par["ny"] * par["nx"] * par["nx"], dims=(par["ny"], par["nx"], par["nx"]), dir=dir, shift=3, dtype=par["dtype"], ) y = Rop * x[str(dir)].ravel() assert dottest(Rop, par["ny"] * par["nx"] * par["nx"], par["ny"] * par["nx"] * par["nx"]) xinv = Rop.H * y assert_array_almost_equal(x[str(dir)].ravel(), xinv, decimal=3)
def test_Roll1D(par): """Dot-test, forward and adjoint for Roll operator on 1d signal""" np.random.seed(10) x = np.arange(par["ny"]) + par["imag"] * np.arange(par["ny"]) Rop = Roll(par["ny"], shift=2, dtype=par["dtype"]) assert dottest(Rop, par["ny"], par["ny"]) y = Rop * x xadj = Rop.H * y assert_array_almost_equal(x, xadj, decimal=3)
def test_Roll1D(par): """Dot-test, forward and adjoint for Roll operator on 1d signal """ np.random.seed(10) x = np.arange(par['ny']) + par['imag'] * np.arange(par['ny']) Rop = Roll(par['ny'], shift=2, dtype=par['dtype']) dottest(Rop, par['ny'], par['ny'], verb=True) y = Rop * x xadj = Rop.H * y assert_array_almost_equal(x, xadj, decimal=3)
def test_Roll1D(par): """Dot-test and comparison with PyLops for Roll operator on 1d signal """ np.random.seed(10) x = da.arange(par['ny']) + par['imag'] * np.arange(par['ny']) dRop = dRoll(par['ny'], shift=2, dtype=par['dtype']) Rop = Roll(par['ny'], shift=2, dtype=par['dtype']) assert dottest(dRop, par['ny'], par['ny'], chunks=(par['ny'], par['ny'])) dy = dRop * x y = Rop * x.compute() assert_array_equal(dy, y)
def test_Roll3D(par): """Dot-test and comparison with PyLops for Roll operator on 3d signal """ np.random.seed(10) x = {} x['0'] = np.outer(np.arange(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) + \ par['imag'] * np.outer(np.arange(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) x['1'] = np.outer(np.ones(par['ny']), np.arange(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) + \ par['imag'] * np.outer(np.ones(par['ny']), np.arange(par['nx']))[:, :, np.newaxis] * \ np.ones(par['nx']) x['2'] = np.outer(np.ones(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.arange(par['nx']) + \ par['imag'] * np.outer(np.ones(par['ny']), np.ones(par['nx']))[:, :, np.newaxis] * \ np.arange(par['nx']) for dir in [0, 1, 2]: dRop = dRoll(par['ny'] * par['nx'] * par['nx'], dims=(par['ny'], par['nx'], par['nx']), dir=dir, shift=3, dtype=par['dtype']) Rop = Roll(par['ny'] * par['nx'] * par['nx'], dims=(par['ny'], par['nx'], par['nx']), dir=dir, shift=3, dtype=par['dtype']) assert dottest(dRop, par['ny'] * par['nx'] * par['nx'], par['ny'] * par['nx'] * par['nx'], chunks=(par['ny'] * par['nx'] * par['nx'], par['ny'] * par['nx'] * par['nx'])) dx = da.from_array(x[str(dir)]) dy = dRop * dx.ravel() y = Rop * x[str(dir)].ravel() assert_array_equal(dy, y)
def test_Roll2D(par): """Dot-test, forward and inverse for Roll operator on 2d signal """ np.random.seed(10) x = {} x['0'] = np.outer(np.arange(par['ny']), np.ones(par['nx'])) + \ par['imag'] * np.outer(np.arange(par['ny']), np.ones(par['nx'])) x['1'] = np.outer(np.ones(par['ny']), np.arange(par['nx'])) + \ par['imag'] * np.outer(np.ones(par['ny']), np.arange(par['nx'])) for dir in [0, 1]: Rop = Roll(par['ny'] * par['nx'], dims=(par['ny'], par['nx']), dir=dir, shift=-2, dtype=par['dtype']) y = Rop * x[str(dir)].flatten() assert dottest(Rop, par['ny'] * par['nx'], par['ny'] * par['nx']) xadj = Rop.H * y assert_array_almost_equal(x[str(dir)].ravel(), xadj, decimal=3)
def test_Roll2D(par): """Dot-test, forward and inverse for Roll operator on 2d signal""" np.random.seed(10) x = {} x["0"] = np.outer(np.arange(par["ny"]), np.ones( par["nx"])) + par["imag"] * np.outer(np.arange(par["ny"]), np.ones(par["nx"])) x["1"] = np.outer(np.ones(par["ny"]), np.arange( par["nx"])) + par["imag"] * np.outer(np.ones(par["ny"]), np.arange(par["nx"])) for dir in [0, 1]: Rop = Roll( par["ny"] * par["nx"], dims=(par["ny"], par["nx"]), dir=dir, shift=-2, dtype=par["dtype"], ) y = Rop * x[str(dir)].ravel() assert dottest(Rop, par["ny"] * par["nx"], par["ny"] * par["nx"]) xadj = Rop.H * y assert_array_almost_equal(x[str(dir)].ravel(), xadj, decimal=3)