% Try naive reconstruction
%
% Samuli Siltanen Jan 2015

% Choose noise amplitude
noiselevel = 0.02;

% Let's construct discrete approximation of the target
load data/deconv2 n 
xvec = [0:(n-1)]/n;
Dx   = xvec(2)-xvec(1);
f    = target1(xvec);

% Let's construct the discrete PSF
load data/PSF a Ca
nu   = floor(a/Dx);
tvec = [-nu:nu]*Dx; 
p    = PSF(tvec,a);
p    = p/Ca;

% Let us build the measurement matrix
A = Dx*DC_convmtx(p,n);

% Construct measurement with inverse crime
mIC  = A*f(:);
mICn = mIC + noiselevel*max(abs(mIC))*randn(n,1);

% Construct measurement without inverse crime
load data/deconv1_cont x convres
mCF  = interp1(x,convres,xvec,'spline');
mCF  = mCF(:);
mCFn = mCF + noiselevel*max(abs(mCF))*randn(n,1);

% Naive inversions
recIC  = inv(A)*mIC;
recICn = inv(A)*mICn;
rec    = inv(A)*mCF;
recn   = inv(A)*mCFn;

% Save results to disc
save data/deconv3 n xvec f tvec p A mIC recIC mICn recICn mCF rec mCFn recn

deconv3_naive_plot

