%
% @file fourier_gs.m
%
% @brief
%
% @copyright
% Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
% SPC (Swiss Plasma Center)
%
% spclibs is free software: you can redistribute it and/or modify it under
% the terms of the GNU Lesser General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% spclibs is distributed in the hope that it will be useful, but WITHOUT ANY
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public License
% along with this program. If not, see .
%
% @authors
% (in alphabetical order)
% @author Trach-Minh Tran
%
clear all
tau=0;
alpha=0.5;
theta=-pi:0.02:pi;
[x,y] = meshgrid(theta,theta);
n1=length(theta);
n2=n1;
%%%%
%%%% Gauss-Seidel relaxations
%%%%
str_title=sprintf('tau = %.1f, alpha = %.2f',tau, alpha);
ee = exp(i.*theta);
eep= conj(ee);
csin= alpha.*complex(alpha, (tau/2).*imag(ee));
G=zeros(n1,n2);
for ii=1:n1
for jj=1:n2
num = ee(ii) + csin(ii)*ee(jj);
G(ii,jj) = num / (2*(1+alpha^2) - conj(num));
end
end
figure
hold off
G0=(ee+csin)./(2*(1+alpha^2)-(eep+conj(csin)));
plot(theta, abs(G(:,1)), 'r', 'LineWidth', 2)
hold on
plot(theta, abs(G0), 'g', 'LineWidth', 2)
for jj=1:20:n2
plot(theta, abs(G(:,jj)), 'b')
end
xlabel('\theta_1'); ylabel('Amplification Factor for Gauss-Seidel')
title(str_title)
% $$$ figure
% $$$ mesh(x,y,abs(G))
% $$$ xlabel('\theta_1'); ylabel('\theta_2')
% $$$ title(str_title);
% $$$ view(-120,25)
max(max(abs(G)))