This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp5/Project_5_Maggioni_Claudio/code_template.asv

42 lines
724 B
Text
Raw Normal View History

2020-11-27 22:19:51 +00:00
close all;
clear; clc;
%% Load Default Img Data
load('blur_data/B.mat');
B=double(B);
load('blur_data/A.mat');
A=double(A);
ciao = A;
% Show Image
figure
im_l=min(min(B));
im_u=max(max(B));
imshow(B,[im_l,im_u])
title('Blured Image')
% Vectorize the image (row by row)
b=B';
b=b(:);
%IL = ichol(A, struct('type', 'nofill', 'diagcomp', 0));
y = IL \ b;
x0 = IL' \ y;
[x, rvec] = myCG(A, b, diag(IL), 200, 1e-6);
semilogy(rvec);
[X2,flag,~,~,rvec2] = pcg(A, b, 1e-6, 200);
%% Validate Test values
load('test_data/A_test.mat');
load('test_data/x_test_exact.mat');
load('test_data/b_test.mat');
%res=||x^*-A^{-1}b||
res=x_test_exact-inv(A_test)*b_test;
norm(res);
%(Now do it with your CG and Matlab's PCG routine!!!)