diff --git a/benchmarks/cuqi-ct/server.py b/benchmarks/cuqi-ct/server.py index aff69d3..1f0ff81 100644 --- a/benchmarks/cuqi-ct/server.py +++ b/benchmarks/cuqi-ct/server.py @@ -44,16 +44,21 @@ def __init__(self, name): Amat = dx*Amat - # Create the CUQIpy linear model - A = LinearModel(Amat) + # Create Image2D geometries of image and sinogram spaces + dg = Image2D(( N,N)) + rg = Image2D((nv,N)) + + # Define forward and adjoint operators (working on images) + def forward(x): + y = Amat @ x.ravel() + return y.reshape((nv, N)) - # Create the visual_only Image2D geometries of image and sinogram spaces - dg = Image2D(( N,N), visual_only=True) - rg = Image2D((nv,N), visual_only=True) + def adjoint(y): + x = Amat.T @ y.ravel() + return x.reshape((N, N)) - # Equip linear operator with geometries - A.domain_geometry = dg - A.range_geometry = rg + # Create the CUQIpy linear model + A = LinearModel(forward=forward, adjoint=adjoint, range_geometry=rg, domain_geometry=dg) # Create the CUQI data structure from vectorized image and geometry imC = CUQIarray(data["exact"], geometry=dg) @@ -127,7 +132,6 @@ def __init__(self): super().__init__(self.__class__.__name__) self.prior = GMRF(np.zeros(self.dim), lambda delta: 1 / delta, - physical_dim=2, geometry=self.likelihood.geometry, name="x") diff --git a/benchmarks/cuqi-ct/test_output.py b/benchmarks/cuqi-ct/test_output.py index 8898681..24a2981 100644 --- a/benchmarks/cuqi-ct/test_output.py +++ b/benchmarks/cuqi-ct/test_output.py @@ -41,12 +41,21 @@ Amat = dx*Amat -# Create the CUQIpy linear model -A = LinearModel(Amat) +# Create Image2D geometries of image and sinogram spaces +dg = Image2D(( N,N)) +rg = Image2D((nv,N)) + +# Define forward and adjoint operators (working on images) +def forward(x): + y = Amat @ x.ravel() + return y.reshape((nv, N)) -# Create the visual_only Image2D geometries of image and sinogram spaces -dg = Image2D(( N,N), visual_only=True) -rg = Image2D((nv,N), visual_only=True) +def adjoint(y): + x = Amat.T @ y.ravel() + return x.reshape((N, N)) + +# Create the CUQIpy linear model +A = LinearModel(forward=forward, adjoint=adjoint, range_geometry=rg, domain_geometry=dg) # Equip linear operator with geometries A.domain_geometry = dg @@ -132,7 +141,6 @@ assert output_Gaussian == pytest.approx(BP.posterior.logpdf(parameters)) BP.prior = cuqi.distribution.GMRF(np.zeros(256**2), 1/(0.01), - physical_dim=2, geometry=BP.likelihood.geometry) assert output_GMRF == pytest.approx(BP.posterior.logpdf(parameters))