% Evaluate multiple PWDM versions for a circular stadium.
%
% Conclusions:
% For a small time penalty, pwdm4 gives a very smooth, high dynamic range tension(k) plot.

k = 0.1:0.02:10;
tension4 = 0; %initialize to prevent confusion
tension3 = 0; %initialize to prevent confusion
tension2 = 0; %initialize to prevent confusion
tension1 = 0; %initialize to prevent confusion
Nk = numel(k);
foo=tic;
for ii = 1:Nk
   tension4(ii) = pwdm4(k(ii),0,12);
endfor
t4_elapsed_seconds=toc(foo)
foo=tic;
for ii = 1:Nk
   tension3(ii) = pwdm3(k(ii),0,12);
endfor
t3_elapsed_seconds=toc(foo)
foo=tic;
for ii = 1:Nk
   tension2(ii) = pwdm2(k(ii),0,12);
endfor
t2_elapsed_seconds=toc(foo)
foo=tic;
for ii = 1:Nk
   tension1(ii) = pwdm(k(ii),0,12);   
endfor
t1_elapsed_seconds=toc(foo)

figure(1)
hold off
plot(k,log10(tension1),'k')
hold on
plot(k,log10(tension2),'g')
plot(k,log10(tension3),'r')
plot(k,log10(tension4),'b')
legend('pwdm: randomized phases','pwdm2: deterministic phases','pwdm3: normalized wave function','pwdm4: SVD via pinv(M)' )
hold off