% This routine is for computing the scattering transform at the k-grid
% created by routine kvec_comp.m.
%
% We use the Lippmann-Schwinger -type eqution approach for computing t(k).
% This involves knowing the conductivity, not starting from boundary 
% measurements as in the EIT problem.
%
% Samuli Siltanen April 2012

% Size of the computational grid is 2^M times 2^M. Larger values of |k|
% typically need only a coarser grid. Values of M less than 7 probably will
% not give reasonable results.
M = 9;
N = 2^M;

% Load the precomputed vector of k values
load data/kvec kvec

% Initialize the result
tLS = zeros(size(kvec));

% The potential is supported in a disc D(0,Rpot) with Rpot defined here
Rpot = 1;

% Size of the square giving the periodic structure on the plane.
% If the potential is supported in a disc D(0,Rpot), then s must be chosen so
% that s > 2*Rpot. In the case of the potential being support in the unit
% disc, a good choice is s=2.1.
s = 2.1;

% Loop over k values
for iii = 1:length(kvec)
    k = kvec(iii);
    
    % Compute complex geometric optics solution using the
    % Lippmann-Schwinger type equation
    [Nmu, x1, x2, h] = GVLS_solve('green_faddeev', k, 'poten', M, s, Rpot);
    
    % Integrate
    z = x1+i*x2;
    tLS(iii) = h^2*sum(sum(exp(i*(k*z+conj(k)*conj(z))).*poten(z).*Nmu));
    
    % Monitor the run
    if mod(iii,10)==0
        disp(['Done ', num2str(iii), ' out of ', num2str(length(kvec))])
    end
end

% Save the result to file.
save data/tLS tLS kvec

