%StartAprx
%This program checks how the number of matrix multiplications are altered
%by using 2 starting approximations.

load('h06_10')
A=h06_10;
tol=10^-3;
k=2;        %eigenpairs
sMax=200;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dist=10.^-(0:0.1:10); %stop tolerance for approximations
steps=length(dist);

Legend1=zeros(steps,1);
Legend2=zeros(steps,1);
Legend3=zeros(steps,1);
Legend4=zeros(steps,1);
Compare=zeros(steps,1);

L=length(A(:,1));
Dist=dist; %aproximations true residual norm
for i=1:steps
    [bla W]=BLKLAN(A,k,2,sMax,dist(i),1);           %Aquire approximations
    Dist(i)=norm(A*W(:,k)-norm(A*W(:,k))*W(:,k));   %Compute true approximation residual norm
    
    Block1=W;
    [bla ha Legend1(i)]=BLKLAN(A,k,2,sMax,tol,0,Block1);
    
    Block2=[(W(:,1)+W(:,2))/sqrt(2) (W(:,1)-W(:,2))/sqrt(2)];
    [bla ha Legend2(i)]=BLKLAN(A,k,2,sMax,tol,0,Block2);
    
    Block3=Block2(:,1);
    [bla ha Legend3(i)]=BLKLAN(A,k,1,sMax,tol,0,Block3);
    
    Block4=reort([(W(:,1)+W(:,2))/sqrt(2) rand(L,k-1)-0.5]);
    [bla ha Legend4(i)]=BLKLAN(A,k,2,sMax,tol,0,reort(Block4));
    
    [bla ha Compare(i)]=BLKLAN(A,k,2,sMax,tol,0);

    display([num2str(100*i/steps) '% done'])
end



semilogx(Dist,Legend1,Dist,Legend2,Dist,Legend3,Dist,Compare)

[Legend1 Legend2 Legend3 Compare]


