% Simulate continuous convolution
%
% Samuli Siltanen Jan 2015

% Choose PSF width parameter
a = .01;

% Construct evaluation points
Nx = 2048;
x  = linspace(0,1,Nx);

% Initialize the result
convres = zeros(size(x));

% Construct numerical integration points
Nt = 2048;
t  = linspace(-a,a,Nt);

% Normalization of the point spread function
psi = PSF(t,a);
Dt  = t(2)-t(1);
Ca  = Dt*sum(psi);
psi = psi/Ca;
save data/PSF a Ca

% Loop over evaluation points x
for iii = 1:Nx
    % Evaluate the integrand
    integrand = psi.*target1(x(iii)-t);
    
    % Integrate to get the result
    convres(iii) = Dt*sum(integrand);
end

% Save the results to file
save data/deconv1_cont Nt t psi Nx x convres a

% Plot the results
deconv1_cont_plot


